nylas 6.0.2 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nylas/client.rb +1 -1
- data/lib/nylas/resources/auth.rb +16 -4
- data/lib/nylas/resources/drafts.rb +23 -4
- data/lib/nylas/resources/messages.rb +31 -6
- data/lib/nylas/resources/webhooks.rb +5 -0
- data/lib/nylas/utils/file_utils.rb +3 -0
- data/lib/nylas/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02d4ddf22b4a6d57beca4b1f0d9fe0628c3d118e62dcee6e7c8ec38695035b5b
|
4
|
+
data.tar.gz: 6393d443a2c9d4f45ffff8d8094929ba767bec0f27414aa5f47eb3914dab16f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d815d22e5bf051d16465ea4985ac231ac99f61f8de9e728cb73750ca7ed325e2bbebf7d03ac3e7465d2a0abf42be31925df52f48db2a5fff2a4572d4c537498f
|
7
|
+
data.tar.gz: 6cb20979b66c86fad147bba710cd10cb1a1323712eb8986863f603c98f5c9fe11f11b3cc85384733fcd5193bce0c622e2df1ac41a2388bb7b7bf59bb4baa7d4e
|
data/lib/nylas/client.rb
CHANGED
data/lib/nylas/resources/auth.rb
CHANGED
@@ -16,6 +16,18 @@ module Nylas
|
|
16
16
|
include ApiOperations::Post
|
17
17
|
include ApiOperations::Get
|
18
18
|
|
19
|
+
# Get info about a specific token based on the identifier you include.
|
20
|
+
# Use either the ID Token or Access Token.
|
21
|
+
#
|
22
|
+
# @param ID of the request.
|
23
|
+
# @return [Hash] Token Info.
|
24
|
+
def access_token_info(query_params: nil)
|
25
|
+
get(
|
26
|
+
path: "#{api_uri}/v3/connect/tokeninfo",
|
27
|
+
query_params: query_params
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
19
31
|
# Builds the URL for authenticating users to your application with OAuth 2.0.
|
20
32
|
#
|
21
33
|
# @param config [Hash] Configuration for building the URL.
|
@@ -118,7 +130,7 @@ module Nylas
|
|
118
130
|
# @return [String] Updated list of parameters, including those specific to admin
|
119
131
|
# consent.
|
120
132
|
def build_query_with_admin_consent(config)
|
121
|
-
params =
|
133
|
+
params = build_http_query(config)
|
122
134
|
|
123
135
|
# Appends new params specific for admin consent.
|
124
136
|
params[:provider] = "microsoft"
|
@@ -135,7 +147,7 @@ module Nylas
|
|
135
147
|
# @return [String] Updated list of encoded parameters, including those specific
|
136
148
|
# to PKCE.
|
137
149
|
def build_query_with_pkce(config, secret_hash)
|
138
|
-
params =
|
150
|
+
params = build_http_query(config)
|
139
151
|
|
140
152
|
# Appends new PKCE specific params.
|
141
153
|
params[:code_challenge_method] = "s256"
|
@@ -151,7 +163,7 @@ module Nylas
|
|
151
163
|
def url_auth_builder(config)
|
152
164
|
builder = URI.parse(api_uri)
|
153
165
|
builder.path = "/v3/connect/auth"
|
154
|
-
builder.query = URI.encode_www_form(
|
166
|
+
builder.query = URI.encode_www_form(build_http_query(config)).gsub(/\+/, "%20")
|
155
167
|
|
156
168
|
builder
|
157
169
|
end
|
@@ -160,7 +172,7 @@ module Nylas
|
|
160
172
|
#
|
161
173
|
# @param config [Hash] Configuration for the query.
|
162
174
|
# @return [Hash] List of parameters to encode in the query.
|
163
|
-
def
|
175
|
+
def build_http_query(config)
|
164
176
|
params = {
|
165
177
|
client_id: config[:client_id],
|
166
178
|
redirect_uri: config[:redirect_uri],
|
@@ -43,10 +43,20 @@ module Nylas
|
|
43
43
|
# you can use {FileUtils::attach_file_request_builder} to build each object attach.
|
44
44
|
# @return [Array(Hash, String)] The created draft and API Request ID.
|
45
45
|
def create(identifier:, request_body:)
|
46
|
-
|
46
|
+
payload = request_body
|
47
|
+
opened_files = []
|
48
|
+
|
49
|
+
# Use form data only if the attachment size is greater than 3mb
|
50
|
+
attachments = request_body[:attachments] || request_body["attachments"] || []
|
51
|
+
attachment_size = attachments&.sum { |attachment| attachment[:size] || 0 } || 0
|
52
|
+
|
53
|
+
if attachment_size >= FileUtils::FORM_DATA_ATTACHMENT_SIZE
|
54
|
+
payload, opened_files = FileUtils.build_form_request(request_body)
|
55
|
+
end
|
56
|
+
|
47
57
|
response = post(
|
48
58
|
path: "#{api_uri}/v3/grants/#{identifier}/drafts",
|
49
|
-
request_body:
|
59
|
+
request_body: payload
|
50
60
|
)
|
51
61
|
|
52
62
|
opened_files.each(&:close)
|
@@ -63,11 +73,20 @@ module Nylas
|
|
63
73
|
# you can use {FileUtils::attach_file_request_builder} to build each object attach.
|
64
74
|
# @return [Array(Hash, String)] The updated draft and API Request ID.
|
65
75
|
def update(identifier:, draft_id:, request_body:)
|
66
|
-
|
76
|
+
payload = request_body
|
77
|
+
opened_files = []
|
78
|
+
|
79
|
+
# Use form data only if the attachment size is greater than 3mb
|
80
|
+
attachments = request_body[:attachments] || request_body["attachments"] || []
|
81
|
+
attachment_size = attachments&.sum { |attachment| attachment[:size] || 0 } || 0
|
82
|
+
|
83
|
+
if attachment_size >= FileUtils::FORM_DATA_ATTACHMENT_SIZE
|
84
|
+
payload, opened_files = FileUtils.build_form_request(request_body)
|
85
|
+
end
|
67
86
|
|
68
87
|
response = put(
|
69
88
|
path: "#{api_uri}/v3/grants/#{identifier}/drafts/#{draft_id}",
|
70
|
-
request_body:
|
89
|
+
request_body: payload
|
71
90
|
)
|
72
91
|
|
73
92
|
opened_files.each(&:close)
|
@@ -38,10 +38,12 @@ module Nylas
|
|
38
38
|
#
|
39
39
|
# @param identifier [String] Grant ID or email account to query.
|
40
40
|
# @param message_id [String] The id of the message to return.
|
41
|
+
# @param query_params [Hash, nil] Query params to pass to the request.
|
41
42
|
# @return [Array(Hash, String)] The message and API request ID.
|
42
|
-
def find(identifier:, message_id:)
|
43
|
+
def find(identifier:, message_id:, query_params: nil)
|
43
44
|
get(
|
44
|
-
path: "#{api_uri}/v3/grants/#{identifier}/messages/#{message_id}"
|
45
|
+
path: "#{api_uri}/v3/grants/#{identifier}/messages/#{message_id}",
|
46
|
+
query_params: query_params
|
45
47
|
)
|
46
48
|
end
|
47
49
|
|
@@ -50,11 +52,13 @@ module Nylas
|
|
50
52
|
# @param identifier [String] Grant ID or email account in which to update an object.
|
51
53
|
# @param message_id [String] The id of the message to update.
|
52
54
|
# @param request_body [Hash] The values to update the message with
|
55
|
+
# @param query_params [Hash, nil] Query params to pass to the request.
|
53
56
|
# @return [Array(Hash, String)] The updated message and API Request ID.
|
54
|
-
def update(identifier:, message_id:, request_body:)
|
57
|
+
def update(identifier:, message_id:, request_body:, query_params: nil)
|
55
58
|
put(
|
56
59
|
path: "#{api_uri}/v3/grants/#{identifier}/messages/#{message_id}",
|
57
|
-
request_body: request_body
|
60
|
+
request_body: request_body,
|
61
|
+
query_params: query_params
|
58
62
|
)
|
59
63
|
end
|
60
64
|
|
@@ -71,6 +75,18 @@ module Nylas
|
|
71
75
|
[true, request_id]
|
72
76
|
end
|
73
77
|
|
78
|
+
# Clean a message.
|
79
|
+
#
|
80
|
+
# @param identifier [String] Grant ID or email account from which to clean a message.
|
81
|
+
# @param request_body [Hash] The options to clean a message with
|
82
|
+
# @return [Array(Hash)] The list of clean messages.
|
83
|
+
def clean_messages(identifier:, request_body:)
|
84
|
+
put(
|
85
|
+
path: "#{api_uri}/v3/grants/#{identifier}/messages/clean",
|
86
|
+
request_body: request_body
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
74
90
|
# Send a message.
|
75
91
|
#
|
76
92
|
# @param identifier [String] Grant ID or email account from which to delete an object.
|
@@ -79,11 +95,20 @@ module Nylas
|
|
79
95
|
# you can use {FileUtils::attach_file_request_builder} to build each object attach.
|
80
96
|
# @return [Array(Hash, String)] The sent message and the API Request ID.
|
81
97
|
def send(identifier:, request_body:)
|
82
|
-
|
98
|
+
payload = request_body
|
99
|
+
opened_files = []
|
100
|
+
|
101
|
+
# Use form data only if the attachment size is greater than 3mb
|
102
|
+
attachments = request_body[:attachments] || request_body["attachments"] || []
|
103
|
+
attachment_size = attachments&.sum { |attachment| attachment[:size] || 0 } || 0
|
104
|
+
|
105
|
+
if attachment_size >= FileUtils::FORM_DATA_ATTACHMENT_SIZE
|
106
|
+
payload, opened_files = FileUtils.build_form_request(request_body)
|
107
|
+
end
|
83
108
|
|
84
109
|
response = post(
|
85
110
|
path: "#{api_uri}/v3/grants/#{identifier}/messages/send",
|
86
|
-
request_body:
|
111
|
+
request_body: payload
|
87
112
|
)
|
88
113
|
|
89
114
|
opened_files.each(&:close)
|
@@ -19,9 +19,14 @@ module Nylas
|
|
19
19
|
GRANT_EXPIRED = "grant.expired"
|
20
20
|
MESSAGE_SEND_SUCCESS = "message.send_success"
|
21
21
|
MESSAGE_SEND_FAILED = "message.send_failed"
|
22
|
+
MESSAGE_CREATED = "message.created"
|
23
|
+
MESSAGE_UPDATED = "message.updated"
|
22
24
|
MESSAGE_OPENED = "message.opened"
|
23
25
|
MESSAGE_LINK_CLICKED = "message.link_clicked"
|
24
26
|
THREAD_REPLIED = "thread.replied"
|
27
|
+
FOLDER_CREATED = "folder.created"
|
28
|
+
FOLDER_UPDATE = "folder.updated"
|
29
|
+
FOLDER_DELETED = "folder.deleted"
|
25
30
|
end
|
26
31
|
|
27
32
|
# Nylas Webhooks API
|
@@ -5,6 +5,9 @@ require "mime/types"
|
|
5
5
|
module Nylas
|
6
6
|
# A collection of file-related utilities.
|
7
7
|
module FileUtils
|
8
|
+
# The maximum size of an attachment that can be sent using json
|
9
|
+
FORM_DATA_ATTACHMENT_SIZE = 3 * 1024 * 1024
|
10
|
+
|
8
11
|
# Build a form request for the API.
|
9
12
|
# @param request_body The values to create the message with.
|
10
13
|
# @return The form data to send to the API and the opened files.
|
data/lib/nylas/version.rb
CHANGED
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: 6.0
|
4
|
+
version: 6.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nylas, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime-types
|