nylas 5.8.0 → 5.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/nylas/account.rb +2 -0
- data/lib/nylas/api.rb +15 -5
- data/lib/nylas/calendar_collection.rb +27 -4
- data/lib/nylas/collection.rb +1 -1
- data/lib/nylas/component.rb +1 -0
- data/lib/nylas/http_client.rb +65 -14
- data/lib/nylas/job_status.rb +1 -1
- data/lib/nylas/job_status_collection.rb +21 -0
- data/lib/nylas/model.rb +11 -3
- data/lib/nylas/new_message.rb +7 -1
- data/lib/nylas/outbox.rb +116 -0
- data/lib/nylas/outbox_job_status.rb +19 -0
- data/lib/nylas/outbox_message.rb +17 -0
- data/lib/nylas/participant.rb +1 -0
- data/lib/nylas/send_grid_verified_status.rb +12 -0
- data/lib/nylas/version.rb +1 -1
- data/lib/nylas/webhook.rb +1 -0
- data/lib/nylas.rb +8 -3
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6eb43d4c1633ea80b1fb094c41339f36a164bafa47ee840865c14a93dfcd3aa1
|
4
|
+
data.tar.gz: 159cc82b30a79b827586ce6502ad6eee7fdc9054306c20b81f7b57c4e068cbc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 285d94938a1914d46852c98b898428a99a7ab62270e4516bc17ba53cedb93e7f270da82d7468cae4bf0b6ec177ce29cacb9af2ab5a98d9400ad1ea28f85081b8
|
7
|
+
data.tar.gz: 2ef74619299884087395ee7cfadcbaf329b57f5d3e0aa9d5819bf2f03a3031879febe2a77d0d8657d8b8aeecb780e1a22922e2701a9284417d03c0328277f156
|
data/lib/nylas/account.rb
CHANGED
@@ -9,12 +9,14 @@ module Nylas
|
|
9
9
|
self.showable = true
|
10
10
|
self.updatable = true
|
11
11
|
self.destroyable = true
|
12
|
+
self.auth_method = HttpClient::AuthMethod::BASIC
|
12
13
|
|
13
14
|
attribute :id, :string, read_only: true
|
14
15
|
attribute :account_id, :string, read_only: true
|
15
16
|
attribute :billing_state, :string, read_only: true
|
16
17
|
attribute :sync_state, :string, read_only: true
|
17
18
|
attribute :provider, :string, read_only: true
|
19
|
+
attribute :authentication_type, :string, read_only: true
|
18
20
|
|
19
21
|
attribute :email, :string, read_only: true
|
20
22
|
attribute :trial, :boolean, read_only: true
|
data/lib/nylas/api.rb
CHANGED
@@ -132,7 +132,12 @@ module Nylas
|
|
132
132
|
|
133
133
|
# @return[Collection<JobStatus>] A queryable collection of {JobStatus} objects
|
134
134
|
def job_statuses
|
135
|
-
@job_statuses ||=
|
135
|
+
@job_statuses ||= JobStatusCollection.new(model: JobStatus, api: self)
|
136
|
+
end
|
137
|
+
|
138
|
+
# @return[OutboxCollection] A collection of Outbox operations
|
139
|
+
def outbox
|
140
|
+
@outbox ||= Outbox.new(api: self)
|
136
141
|
end
|
137
142
|
|
138
143
|
# @return[SchedulerCollection<Scheduler>] A queryable collection of {Scheduler} objects
|
@@ -143,7 +148,7 @@ module Nylas
|
|
143
148
|
@scheduler ||= SchedulerCollection.new(model: Scheduler, api: scheduler_api)
|
144
149
|
end
|
145
150
|
|
146
|
-
# @return[Neural] A
|
151
|
+
# @return[Neural] A collection of Neural operations
|
147
152
|
def neural
|
148
153
|
@neural ||= Neural.new(api: self)
|
149
154
|
end
|
@@ -163,7 +168,11 @@ module Nylas
|
|
163
168
|
# Returns the application details
|
164
169
|
# @return [ApplicationDetail] The application details
|
165
170
|
def application_details
|
166
|
-
response = client.as(client.app_secret).execute(
|
171
|
+
response = client.as(client.app_secret).execute(
|
172
|
+
method: :get,
|
173
|
+
path: "/a/#{app_id}",
|
174
|
+
auth_method: HttpClient::AuthMethod::BASIC
|
175
|
+
)
|
167
176
|
ApplicationDetail.new(**response)
|
168
177
|
end
|
169
178
|
|
@@ -174,7 +183,8 @@ module Nylas
|
|
174
183
|
response = client.as(client.app_secret).execute(
|
175
184
|
method: :put,
|
176
185
|
path: "/a/#{app_id}",
|
177
|
-
payload: JSON.dump(application_details.to_h)
|
186
|
+
payload: JSON.dump(application_details.to_h),
|
187
|
+
auth_method: HttpClient::AuthMethod::BASIC
|
178
188
|
)
|
179
189
|
ApplicationDetail.new(**response)
|
180
190
|
end
|
@@ -184,7 +194,7 @@ module Nylas
|
|
184
194
|
# hash has keys of :updated_at (unix timestamp) and :ip_addresses (array of strings)
|
185
195
|
def ip_addresses
|
186
196
|
path = "/a/#{app_id}/ip_addresses"
|
187
|
-
client.as(client.app_secret).get(path: path)
|
197
|
+
client.as(client.app_secret).get(path: path, auth_method: HttpClient::AuthMethod::BASIC)
|
188
198
|
end
|
189
199
|
|
190
200
|
# @param message [Hash, String, #send!]
|
@@ -4,6 +4,18 @@ module Nylas
|
|
4
4
|
# Additional methods for some of Calendar's other functionality
|
5
5
|
# @see https://developer.nylas.com/docs/connectivity/calendar
|
6
6
|
class CalendarCollection < Collection
|
7
|
+
# Check multiple calendars to find available time slots for a single meeting
|
8
|
+
# @param duration_minutes [Integer] The total number of minutes the event should last
|
9
|
+
# @param interval_minutes [Integer] How many minutes it should check for availability
|
10
|
+
# @param start_time [Integer] The timestamp for the beginning of the event
|
11
|
+
# @param end_time [Integer] The timestamp for the end of the event
|
12
|
+
# @param emails [Array<String>] Emails on the same domain to check
|
13
|
+
# @param buffer [Integer] The amount of buffer time in minutes that you want around existing meetings
|
14
|
+
# @param round_robin [String] Finds available meeting times in a round-robin style
|
15
|
+
# @param free_busy [Array<Nylas::FreeBusy>] A list of free-busy data for users not in your organization
|
16
|
+
# @param open_hours [Array<Nylas::OpenHours>] Additional times email accounts are available
|
17
|
+
# @param calendars [Array] Check account and calendar IDs for free/busy status
|
18
|
+
# @return [Hash] The availability information; a list of time slots where all participants are available
|
7
19
|
def availability(duration_minutes:,
|
8
20
|
interval_minutes:,
|
9
21
|
start_time:,
|
@@ -25,11 +37,22 @@ module Nylas
|
|
25
37
|
emails: emails,
|
26
38
|
buffer: buffer,
|
27
39
|
round_robin: round_robin,
|
28
|
-
free_busy: free_busy,
|
29
|
-
open_hours: open_hours,
|
40
|
+
free_busy: free_busy.map(&:to_h),
|
41
|
+
open_hours: open_hours.map(&:to_h),
|
30
42
|
calendars: calendars)
|
31
43
|
end
|
32
44
|
|
45
|
+
# Check multiple calendars to find availability for multiple meetings with several participants
|
46
|
+
# @param duration_minutes [Integer] The total number of minutes the event should last
|
47
|
+
# @param interval_minutes [Integer] How many minutes it should check for availability
|
48
|
+
# @param start_time [Integer] The timestamp for the beginning of the event
|
49
|
+
# @param end_time [Integer] The timestamp for the end of the event
|
50
|
+
# @param emails [Array<Array<String>>] Emails on the same domain to check
|
51
|
+
# @param buffer [Integer] The amount of buffer time in minutes that you want around existing meetings
|
52
|
+
# @param free_busy [Array<Nylas::FreeBusy>] A list of free-busy data for users not in your organization
|
53
|
+
# @param open_hours [Array<Nylas::OpenHours>] Additional times email accounts are available
|
54
|
+
# @param calendars [Array] Check account and calendar IDs for free/busy status
|
55
|
+
# @return [Hash] The availability information; a list of all possible groupings that share time slots
|
33
56
|
def consecutive_availability(duration_minutes:,
|
34
57
|
interval_minutes:,
|
35
58
|
start_time:,
|
@@ -49,8 +72,8 @@ module Nylas
|
|
49
72
|
end_time: end_time,
|
50
73
|
emails: emails,
|
51
74
|
buffer: buffer,
|
52
|
-
free_busy: free_busy,
|
53
|
-
open_hours: open_hours,
|
75
|
+
free_busy: free_busy.map(&:to_h),
|
76
|
+
open_hours: open_hours.map(&:to_h),
|
54
77
|
calendars: calendars)
|
55
78
|
end
|
56
79
|
|
data/lib/nylas/collection.rb
CHANGED
@@ -139,7 +139,7 @@ module Nylas
|
|
139
139
|
# @return [Hash] Specification for request to be passed to {API#execute}
|
140
140
|
def to_be_executed
|
141
141
|
{ method: :get, path: resources_path, query: constraints.to_query,
|
142
|
-
headers: constraints.to_headers }
|
142
|
+
headers: constraints.to_headers, auth_method: model.auth_method }
|
143
143
|
end
|
144
144
|
|
145
145
|
# Retrieves the data from the API for the particular constraints
|
data/lib/nylas/component.rb
CHANGED
@@ -6,6 +6,7 @@ module Nylas
|
|
6
6
|
include Model
|
7
7
|
allows_operations(creatable: true, listable: true, filterable: true, showable: true, updatable: true,
|
8
8
|
destroyable: true)
|
9
|
+
self.auth_method = HttpClient::AuthMethod::BASIC
|
9
10
|
|
10
11
|
attribute :id, :string, read_only: true
|
11
12
|
attribute :account_id, :string
|
data/lib/nylas/http_client.rb
CHANGED
@@ -2,10 +2,16 @@
|
|
2
2
|
|
3
3
|
module Nylas
|
4
4
|
require "yajl"
|
5
|
+
require "base64"
|
5
6
|
|
6
7
|
# Plain HTTP client that can be used to interact with the Nylas API sans any type casting.
|
7
8
|
class HttpClient # rubocop:disable Metrics/ClassLength
|
8
|
-
|
9
|
+
module AuthMethod
|
10
|
+
BEARER = 1
|
11
|
+
BASIC = 2
|
12
|
+
end
|
13
|
+
|
14
|
+
HTTP_SUCCESS_CODES = [200, 201, 202, 302].freeze
|
9
15
|
|
10
16
|
HTTP_CODE_TO_EXCEPTIONS = {
|
11
17
|
400 => InvalidRequest,
|
@@ -33,7 +39,8 @@ module Nylas
|
|
33
39
|
"/delta/longpoll" => 3650,
|
34
40
|
"/delta/streaming" => 3650
|
35
41
|
}.freeze
|
36
|
-
|
42
|
+
|
43
|
+
SUPPORTED_API_VERSION = "2.5"
|
37
44
|
|
38
45
|
include Logging
|
39
46
|
attr_accessor :api_server
|
@@ -73,9 +80,10 @@ module Nylas
|
|
73
80
|
# @param query [Hash] (Optional, defaults to {}) - Hash of names and values to include in the query
|
74
81
|
# section of the URI fragment
|
75
82
|
# @param payload [String,Hash] (Optional, defaults to nil) - Body to send with the request.
|
83
|
+
# @param auth_method [AuthMethod] (Optional, defaults to BEARER) - The authentication method.
|
76
84
|
# @return [Array Hash Stringn]
|
77
85
|
# rubocop:disable Metrics/MethodLength
|
78
|
-
def execute(method:, path: nil, headers: {}, query: {}, payload: nil)
|
86
|
+
def execute(method:, path: nil, headers: {}, query: {}, payload: nil, auth_method: nil)
|
79
87
|
timeout = ENDPOINT_TIMEOUTS.fetch(path, 230)
|
80
88
|
request = build_request(
|
81
89
|
method: method,
|
@@ -83,7 +91,8 @@ module Nylas
|
|
83
91
|
headers: headers,
|
84
92
|
query: query,
|
85
93
|
payload: payload,
|
86
|
-
timeout: timeout
|
94
|
+
timeout: timeout,
|
95
|
+
auth_method: auth_method || AuthMethod::BEARER
|
87
96
|
)
|
88
97
|
rest_client_execute(**request) do |response, _request, result|
|
89
98
|
content_type = nil
|
@@ -107,35 +116,64 @@ module Nylas
|
|
107
116
|
inform_on :execute, level: :debug,
|
108
117
|
also_log: { result: true, values: %i[method url path headers query payload] }
|
109
118
|
|
110
|
-
def build_request(
|
119
|
+
def build_request(
|
120
|
+
method:,
|
121
|
+
path: nil,
|
122
|
+
headers: {},
|
123
|
+
query: {},
|
124
|
+
payload: nil,
|
125
|
+
timeout: nil,
|
126
|
+
auth_method: nil
|
127
|
+
)
|
111
128
|
url ||= url_for_path(path)
|
112
129
|
url = add_query_params_to_url(url, query)
|
113
|
-
resulting_headers = default_headers.merge(headers)
|
130
|
+
resulting_headers = default_headers.merge(headers).merge(auth_header(auth_method))
|
114
131
|
{ method: method, url: url, payload: payload, headers: resulting_headers, timeout: timeout }
|
115
132
|
end
|
116
133
|
|
117
134
|
# Syntactical sugar for making GET requests via the API.
|
118
135
|
# @see #execute
|
119
|
-
def get(path: nil, headers: {}, query: {})
|
120
|
-
execute(method: :get, path: path, query: query, headers: headers)
|
136
|
+
def get(path: nil, headers: {}, query: {}, auth_method: nil)
|
137
|
+
execute(method: :get, path: path, query: query, headers: headers, auth_method: auth_method)
|
121
138
|
end
|
122
139
|
|
123
140
|
# Syntactical sugar for making POST requests via the API.
|
124
141
|
# @see #execute
|
125
|
-
def post(path: nil, payload: nil, headers: {}, query: {})
|
126
|
-
execute(
|
142
|
+
def post(path: nil, payload: nil, headers: {}, query: {}, auth_method: nil)
|
143
|
+
execute(
|
144
|
+
method: :post,
|
145
|
+
path: path,
|
146
|
+
headers: headers,
|
147
|
+
query: query,
|
148
|
+
payload: payload,
|
149
|
+
auth_method: auth_method
|
150
|
+
)
|
127
151
|
end
|
128
152
|
|
129
153
|
# Syntactical sugar for making PUT requests via the API.
|
130
154
|
# @see #execute
|
131
|
-
def put(path: nil, payload:, headers: {}, query: {})
|
132
|
-
execute(
|
155
|
+
def put(path: nil, payload:, headers: {}, query: {}, auth_method: nil)
|
156
|
+
execute(
|
157
|
+
method: :put,
|
158
|
+
path: path,
|
159
|
+
headers: headers,
|
160
|
+
query: query,
|
161
|
+
payload: payload,
|
162
|
+
auth_method: auth_method
|
163
|
+
)
|
133
164
|
end
|
134
165
|
|
135
166
|
# Syntactical sugar for making DELETE requests via the API.
|
136
167
|
# @see #execute
|
137
|
-
def delete(path: nil, payload: nil, headers: {}, query: {})
|
138
|
-
execute(
|
168
|
+
def delete(path: nil, payload: nil, headers: {}, query: {}, auth_method: nil)
|
169
|
+
execute(
|
170
|
+
method: :delete,
|
171
|
+
path: path,
|
172
|
+
headers: headers,
|
173
|
+
query: query,
|
174
|
+
payload: payload,
|
175
|
+
auth_method: auth_method
|
176
|
+
)
|
139
177
|
end
|
140
178
|
|
141
179
|
def default_headers
|
@@ -216,5 +254,18 @@ module Nylas
|
|
216
254
|
|
217
255
|
query
|
218
256
|
end
|
257
|
+
|
258
|
+
def auth_header(auth_method)
|
259
|
+
authorization_string = case auth_method
|
260
|
+
when AuthMethod::BEARER
|
261
|
+
"Bearer #{access_token}"
|
262
|
+
when AuthMethod::BASIC
|
263
|
+
"Basic #{Base64.encode64("#{access_token}:")}"
|
264
|
+
else
|
265
|
+
"Bearer #{access_token}"
|
266
|
+
end
|
267
|
+
|
268
|
+
{ "Authorization" => authorization_string }
|
269
|
+
end
|
219
270
|
end
|
220
271
|
end
|
data/lib/nylas/job_status.rb
CHANGED
@@ -15,7 +15,7 @@ module Nylas
|
|
15
15
|
attribute :object, :string, read_only: true
|
16
16
|
attribute :status, :string, read_only: true
|
17
17
|
attribute :created_at, :unix_timestamp, read_only: true
|
18
|
-
attribute :
|
18
|
+
attribute :reason, :string, read_only: true
|
19
19
|
|
20
20
|
# Returns the status of a job as a boolean
|
21
21
|
# @return [Boolean] If the job was successful
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nylas
|
4
|
+
# Additional methods for some of Calendar's other functionality
|
5
|
+
# @see https://developer.nylas.com/docs/connectivity/calendar
|
6
|
+
class JobStatusCollection < Collection
|
7
|
+
def find_model(id)
|
8
|
+
response = api.execute(
|
9
|
+
**to_be_executed.merge(
|
10
|
+
path: "#{resources_path}/#{id}",
|
11
|
+
query: view_query
|
12
|
+
)
|
13
|
+
)
|
14
|
+
|
15
|
+
object_type = response[:object]
|
16
|
+
return OutboxJobStatus.from_hash(response, api: api) if object_type == "message"
|
17
|
+
|
18
|
+
model.from_hash(response, api: api)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/nylas/model.rb
CHANGED
@@ -39,8 +39,8 @@ module Nylas
|
|
39
39
|
!id.nil?
|
40
40
|
end
|
41
41
|
|
42
|
-
def execute(method:, payload: nil, path:, query: {})
|
43
|
-
api.execute(method: method, payload: payload, path: path, query: query)
|
42
|
+
def execute(method:, payload: nil, path:, query: {}, auth_method: self.auth_method)
|
43
|
+
api.execute(method: method, payload: payload, path: path, query: query, auth_method: auth_method)
|
44
44
|
end
|
45
45
|
|
46
46
|
def create
|
@@ -107,6 +107,10 @@ module Nylas
|
|
107
107
|
self.class.resources_path(api: api)
|
108
108
|
end
|
109
109
|
|
110
|
+
def auth_method
|
111
|
+
self.class.auth_method(api: api)
|
112
|
+
end
|
113
|
+
|
110
114
|
def destroy
|
111
115
|
raise ModelNotDestroyableError, self unless destroyable?
|
112
116
|
|
@@ -138,7 +142,7 @@ module Nylas
|
|
138
142
|
module ClassMethods
|
139
143
|
attr_accessor :raw_mime_type, :creatable, :showable, :filterable, :searchable, :listable, :updatable,
|
140
144
|
:destroyable
|
141
|
-
attr_writer :resources_path
|
145
|
+
attr_writer :resources_path, :auth_method
|
142
146
|
|
143
147
|
def allows_operations(creatable: false, showable: false, listable: false, filterable: false,
|
144
148
|
searchable: false, updatable: false, destroyable: false)
|
@@ -184,6 +188,10 @@ module Nylas
|
|
184
188
|
@resources_path
|
185
189
|
end
|
186
190
|
|
191
|
+
def auth_method(*)
|
192
|
+
@auth_method || HttpClient::AuthMethod::BEARER
|
193
|
+
end
|
194
|
+
|
187
195
|
def exposable_as_raw?
|
188
196
|
!raw_mime_type.nil?
|
189
197
|
end
|
data/lib/nylas/new_message.rb
CHANGED
@@ -26,8 +26,14 @@ module Nylas
|
|
26
26
|
|
27
27
|
attribute :tracking, :message_tracking
|
28
28
|
|
29
|
+
# Sends the new message
|
30
|
+
# @return [Message] The sent message
|
31
|
+
# @raise [RuntimeError] if the API response data was not a hash
|
29
32
|
def send!
|
30
|
-
|
33
|
+
message_data = api.execute(method: :post, path: "/send", payload: to_json)
|
34
|
+
raise "Unexpected response from the server, data received not a Message" unless message_data.is_a?(Hash)
|
35
|
+
|
36
|
+
Message.from_hash(message_data, api: api)
|
31
37
|
end
|
32
38
|
end
|
33
39
|
end
|
data/lib/nylas/outbox.rb
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nylas
|
4
|
+
# Methods for Outbox functionality
|
5
|
+
# @see https://developer.nylas.com/docs/api/#tag--Outbox
|
6
|
+
class Outbox
|
7
|
+
attr_accessor :api
|
8
|
+
|
9
|
+
def initialize(api:)
|
10
|
+
self.api = api
|
11
|
+
end
|
12
|
+
|
13
|
+
def outbox_path
|
14
|
+
@outbox_path ||= "/v2/outbox"
|
15
|
+
end
|
16
|
+
|
17
|
+
# rubocop:disable Layout/LineLength
|
18
|
+
# Send a message via Outbox
|
19
|
+
# @param draft [Draft, OutboxMessage] The message to send
|
20
|
+
# @param send_at [Numeric] The date and time to send the message. If not set, Outbox will send this message immediately.
|
21
|
+
# @param retry_limit_datetime [Numeric] The date and time to stop retry attempts for a message. If not set, it defaults to 24 hours after send_at.
|
22
|
+
# @return [OutboxJobStatus] The outbox job status status and message data
|
23
|
+
# rubocop:enable Layout/LineLength
|
24
|
+
def send(draft, send_at: nil, retry_limit_datetime: nil)
|
25
|
+
message = draft.to_h(enforce_read_only: true)
|
26
|
+
message.merge!(validate_set_date_time(send_at, retry_limit_datetime))
|
27
|
+
outbox_response = api.execute(
|
28
|
+
method: :post,
|
29
|
+
path: outbox_path,
|
30
|
+
payload: JSON.dump(message)
|
31
|
+
)
|
32
|
+
|
33
|
+
OutboxJobStatus.new(**outbox_response)
|
34
|
+
end
|
35
|
+
|
36
|
+
# rubocop:disable Layout/LineLength
|
37
|
+
# Update a scheduled Outbox message
|
38
|
+
# @param job_status_id [String] The ID of the outbox job status
|
39
|
+
# @param message [Draft, OutboxMessage] The message object with updated values
|
40
|
+
# @param send_at [Numeric] The date and time to send the message. If not set, Outbox will send this message immediately.
|
41
|
+
# @param retry_limit_datetime [Numeric] The date and time to stop retry attempts for a message. If not set, it defaults to 24 hours after send_at.
|
42
|
+
# @return [OutboxJobStatus] The updated outbox job status status and message data
|
43
|
+
# rubocop:enable Layout/LineLength
|
44
|
+
def update(job_status_id, message: nil, send_at: nil, retry_limit_datetime: nil)
|
45
|
+
payload = {}
|
46
|
+
payload.merge!(message.to_h(enforce_read_only: true)) if message
|
47
|
+
payload.merge!(validate_set_date_time(send_at, retry_limit_datetime))
|
48
|
+
outbox_response = api.execute(
|
49
|
+
method: :patch,
|
50
|
+
path: "#{outbox_path}/#{job_status_id}",
|
51
|
+
payload: JSON.dump(payload)
|
52
|
+
)
|
53
|
+
|
54
|
+
OutboxJobStatus.new(**outbox_response)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Delete a scheduled Outbox message
|
58
|
+
# @param job_status_id [String] The ID of the outbox job status to delete
|
59
|
+
# @return [void]
|
60
|
+
def delete(job_status_id)
|
61
|
+
api.execute(
|
62
|
+
method: :delete,
|
63
|
+
path: "#{outbox_path}/#{job_status_id}"
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
# SendGrid - Check Authentication and Verification Status
|
68
|
+
# @return [SendGridVerifiedStatus] The SendGrid Authentication and Verification Status
|
69
|
+
def send_grid_verification_status
|
70
|
+
response = api.execute(
|
71
|
+
method: :get,
|
72
|
+
path: "#{outbox_path}/onboard/verified_status"
|
73
|
+
)
|
74
|
+
|
75
|
+
raise "Verification status not present in response" if response.key?("results")
|
76
|
+
|
77
|
+
SendGridVerifiedStatus.new(**response[:results])
|
78
|
+
end
|
79
|
+
|
80
|
+
# SendGrid - Delete SendGrid Subuser and UAS Grant
|
81
|
+
# @param email [String] Email address for SendGrid subuser to delete
|
82
|
+
# @return [void]
|
83
|
+
def delete_send_grid_sub_user(email)
|
84
|
+
api.execute(
|
85
|
+
method: :delete,
|
86
|
+
path: "#{outbox_path}/onboard/subuser",
|
87
|
+
payload: JSON.dump({ email: email })
|
88
|
+
)
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
def validate_set_date_time(send_at, retry_limit_datetime)
|
94
|
+
hash = {}
|
95
|
+
hash[:send_at] = validate_send_at(send_at) if send_at
|
96
|
+
if retry_limit_datetime
|
97
|
+
hash[:retry_limit_datetime] = validate_retry_limit_datetime(send_at, retry_limit_datetime)
|
98
|
+
end
|
99
|
+
|
100
|
+
hash
|
101
|
+
end
|
102
|
+
|
103
|
+
def validate_send_at(send_at)
|
104
|
+
return send_at unless send_at != 0 && (send_at < Time.now.to_i)
|
105
|
+
|
106
|
+
raise ArgumentError, "Cannot set message to be sent at a time before the current time."
|
107
|
+
end
|
108
|
+
|
109
|
+
def validate_retry_limit_datetime(send_at, retry_limit_datetime)
|
110
|
+
valid_send_at = send_at && send_at != 0 ? send_at : Time.now.to_i
|
111
|
+
return retry_limit_datetime unless retry_limit_datetime != 0 && (retry_limit_datetime < valid_send_at)
|
112
|
+
|
113
|
+
raise ArgumentError, "Cannot set message to stop retrying before time to send at."
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nylas
|
4
|
+
# Ruby representation of a Nylas Outbox Job Status object
|
5
|
+
# @see https://developer.nylas.com/docs/api/#post/v2/outbox
|
6
|
+
class OutboxJobStatus < JobStatus
|
7
|
+
include Model
|
8
|
+
|
9
|
+
attribute :send_at, :unix_timestamp
|
10
|
+
attribute :original_send_at, :unix_timestamp
|
11
|
+
attribute :message_id, :string
|
12
|
+
attribute :thread_id, :string
|
13
|
+
attribute :original_data, :outbox_message
|
14
|
+
|
15
|
+
transfer :api, to: %i[original_data]
|
16
|
+
|
17
|
+
inherit_attributes
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nylas
|
4
|
+
# Ruby representation of a Nylas Outbox Message object
|
5
|
+
# @see https://developer.nylas.com/docs/api/#post/v2/outbox
|
6
|
+
class OutboxMessage < Draft
|
7
|
+
include Model
|
8
|
+
|
9
|
+
attribute :send_at, :unix_timestamp
|
10
|
+
attribute :retry_limit_datetime, :unix_timestamp
|
11
|
+
attribute :original_send_at, :unix_timestamp, read_only: true
|
12
|
+
|
13
|
+
transfer :api, to: %i[events files folder labels]
|
14
|
+
|
15
|
+
inherit_attributes
|
16
|
+
end
|
17
|
+
end
|
data/lib/nylas/participant.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nylas
|
4
|
+
# Ruby representation of a Nylas Send Grid verified status object
|
5
|
+
# @see https://docs.nylas.com/reference#drafts
|
6
|
+
class SendGridVerifiedStatus
|
7
|
+
include Model::Attributable
|
8
|
+
|
9
|
+
attribute :domain_verified, :boolean
|
10
|
+
attribute :sender_verified, :boolean
|
11
|
+
end
|
12
|
+
end
|
data/lib/nylas/version.rb
CHANGED
data/lib/nylas/webhook.rb
CHANGED
@@ -43,6 +43,7 @@ module Nylas
|
|
43
43
|
include Model
|
44
44
|
allows_operations(creatable: true, listable: true, showable: true, updatable: true,
|
45
45
|
destroyable: true)
|
46
|
+
self.auth_method = HttpClient::AuthMethod::BASIC
|
46
47
|
attribute :id, :string, read_only: true
|
47
48
|
attribute :application_id, :string, read_only: true
|
48
49
|
|
data/lib/nylas.rb
CHANGED
@@ -29,6 +29,8 @@ require_relative "nylas/registry"
|
|
29
29
|
require_relative "nylas/types"
|
30
30
|
require_relative "nylas/constraints"
|
31
31
|
|
32
|
+
require_relative "nylas/http_client"
|
33
|
+
require_relative "nylas/api"
|
32
34
|
require_relative "nylas/collection"
|
33
35
|
require_relative "nylas/model"
|
34
36
|
|
@@ -67,6 +69,8 @@ require_relative "nylas/free_busy_collection"
|
|
67
69
|
require_relative "nylas/calendar_collection"
|
68
70
|
require_relative "nylas/component_collection"
|
69
71
|
require_relative "nylas/scheduler_collection"
|
72
|
+
require_relative "nylas/job_status_collection"
|
73
|
+
require_relative "nylas/outbox"
|
70
74
|
|
71
75
|
# Models supported by the API
|
72
76
|
require_relative "nylas/account"
|
@@ -87,6 +91,9 @@ require_relative "nylas/scheduler"
|
|
87
91
|
require_relative "nylas/job_status"
|
88
92
|
require_relative "nylas/token_info"
|
89
93
|
require_relative "nylas/application_details"
|
94
|
+
require_relative "nylas/outbox_message"
|
95
|
+
require_relative "nylas/outbox_job_status"
|
96
|
+
require_relative "nylas/send_grid_verified_status"
|
90
97
|
|
91
98
|
# Neural specific types
|
92
99
|
require_relative "nylas/neural"
|
@@ -107,9 +114,6 @@ require_relative "nylas/scheduler_booking_confirmation"
|
|
107
114
|
|
108
115
|
require_relative "nylas/native_authentication"
|
109
116
|
|
110
|
-
require_relative "nylas/http_client"
|
111
|
-
require_relative "nylas/api"
|
112
|
-
|
113
117
|
require_relative "nylas/filter_attributes"
|
114
118
|
# an SDK for interacting with the Nylas API
|
115
119
|
# @see https://docs.nylas.com/reference
|
@@ -152,4 +156,5 @@ module Nylas
|
|
152
156
|
Types.registry[:scheduler_config] = Types::ModelType.new(model: SchedulerConfig)
|
153
157
|
Types.registry[:scheduler_time_slot] = Types::ModelType.new(model: SchedulerTimeSlot)
|
154
158
|
Types.registry[:job_status] = Types::ModelType.new(model: JobStatus)
|
159
|
+
Types.registry[:outbox_message] = Types::ModelType.new(model: OutboxMessage)
|
155
160
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nylas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nylas, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -300,6 +300,7 @@ files:
|
|
300
300
|
- lib/nylas/http_client.rb
|
301
301
|
- lib/nylas/im_address.rb
|
302
302
|
- lib/nylas/job_status.rb
|
303
|
+
- lib/nylas/job_status_collection.rb
|
303
304
|
- lib/nylas/label.rb
|
304
305
|
- lib/nylas/logging.rb
|
305
306
|
- lib/nylas/message.rb
|
@@ -325,6 +326,9 @@ files:
|
|
325
326
|
- lib/nylas/new_message.rb
|
326
327
|
- lib/nylas/nylas_date.rb
|
327
328
|
- lib/nylas/open_hours.rb
|
329
|
+
- lib/nylas/outbox.rb
|
330
|
+
- lib/nylas/outbox_job_status.rb
|
331
|
+
- lib/nylas/outbox_message.rb
|
328
332
|
- lib/nylas/participant.rb
|
329
333
|
- lib/nylas/phone_number.rb
|
330
334
|
- lib/nylas/physical_address.rb
|
@@ -340,6 +344,7 @@ files:
|
|
340
344
|
- lib/nylas/scheduler_config.rb
|
341
345
|
- lib/nylas/scheduler_time_slot.rb
|
342
346
|
- lib/nylas/search_collection.rb
|
347
|
+
- lib/nylas/send_grid_verified_status.rb
|
343
348
|
- lib/nylas/thread.rb
|
344
349
|
- lib/nylas/time_slot.rb
|
345
350
|
- lib/nylas/timespan.rb
|