nylas 6.0.1 → 6.0.3
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 +4 -4
- data/lib/nylas/resources/drafts.rb +23 -4
- data/lib/nylas/resources/grants.rb +2 -1
- data/lib/nylas/resources/messages.rb +11 -2
- data/lib/nylas/resources/webhooks.rb +2 -2
- 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: 3bd6fdcadf69439f1f8a8549e26e3b43f4df3cfeb8ae0c5a2aef5aca8fb3acce
|
4
|
+
data.tar.gz: b1f939a98c16ec5bf390791df31bb0f76feb45af07e4e6bcfc32c52e79e3b53f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 591735adfae3cfefdbc513762eff603390779f14321a543bf0a2115f3a368f1b674175c6e5cbea9052b4e10db157d74a3cda80b74773b212bbda2e38fc25aea0
|
7
|
+
data.tar.gz: 17dc68c13af649f533d206a546a72cf45b508864f71d2daae1eb020f686ce5b79c39829d841dd919cc944cd038042f4075116a7a941c2f782b6ae127c35d63a8
|
data/lib/nylas/client.rb
CHANGED
data/lib/nylas/resources/auth.rb
CHANGED
@@ -118,7 +118,7 @@ module Nylas
|
|
118
118
|
# @return [String] Updated list of parameters, including those specific to admin
|
119
119
|
# consent.
|
120
120
|
def build_query_with_admin_consent(config)
|
121
|
-
params =
|
121
|
+
params = build_http_query(config)
|
122
122
|
|
123
123
|
# Appends new params specific for admin consent.
|
124
124
|
params[:provider] = "microsoft"
|
@@ -135,7 +135,7 @@ module Nylas
|
|
135
135
|
# @return [String] Updated list of encoded parameters, including those specific
|
136
136
|
# to PKCE.
|
137
137
|
def build_query_with_pkce(config, secret_hash)
|
138
|
-
params =
|
138
|
+
params = build_http_query(config)
|
139
139
|
|
140
140
|
# Appends new PKCE specific params.
|
141
141
|
params[:code_challenge_method] = "s256"
|
@@ -151,7 +151,7 @@ module Nylas
|
|
151
151
|
def url_auth_builder(config)
|
152
152
|
builder = URI.parse(api_uri)
|
153
153
|
builder.path = "/v3/connect/auth"
|
154
|
-
builder.query = URI.encode_www_form(
|
154
|
+
builder.query = URI.encode_www_form(build_http_query(config)).gsub(/\+/, "%20")
|
155
155
|
|
156
156
|
builder
|
157
157
|
end
|
@@ -160,7 +160,7 @@ module Nylas
|
|
160
160
|
#
|
161
161
|
# @param config [Hash] Configuration for the query.
|
162
162
|
# @return [Hash] List of parameters to encode in the query.
|
163
|
-
def
|
163
|
+
def build_http_query(config)
|
164
164
|
params = {
|
165
165
|
client_id: config[:client_id],
|
166
166
|
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)
|
@@ -9,6 +9,7 @@ module Nylas
|
|
9
9
|
include ApiOperations::Get
|
10
10
|
include ApiOperations::Put
|
11
11
|
include ApiOperations::Delete
|
12
|
+
include ApiOperations::Patch
|
12
13
|
|
13
14
|
# Return all grants.
|
14
15
|
#
|
@@ -37,7 +38,7 @@ module Nylas
|
|
37
38
|
# @param request_body [Hash] The values to update the grant with
|
38
39
|
# @return [Array(Hash, String)] The updated grant and API Request ID.
|
39
40
|
def update(grant_id:, request_body:)
|
40
|
-
|
41
|
+
patch(
|
41
42
|
path: "#{api_uri}/v3/grants/#{grant_id}",
|
42
43
|
request_body: request_body
|
43
44
|
)
|
@@ -79,11 +79,20 @@ module Nylas
|
|
79
79
|
# you can use {FileUtils::attach_file_request_builder} to build each object attach.
|
80
80
|
# @return [Array(Hash, String)] The sent message and the API Request ID.
|
81
81
|
def send(identifier:, request_body:)
|
82
|
-
|
82
|
+
payload = request_body
|
83
|
+
opened_files = []
|
84
|
+
|
85
|
+
# Use form data only if the attachment size is greater than 3mb
|
86
|
+
attachments = request_body[:attachments] || request_body["attachments"] || []
|
87
|
+
attachment_size = attachments&.sum { |attachment| attachment[:size] || 0 } || 0
|
88
|
+
|
89
|
+
if attachment_size >= FileUtils::FORM_DATA_ATTACHMENT_SIZE
|
90
|
+
payload, opened_files = FileUtils.build_form_request(request_body)
|
91
|
+
end
|
83
92
|
|
84
93
|
response = post(
|
85
94
|
path: "#{api_uri}/v3/grants/#{identifier}/messages/send",
|
86
|
-
request_body:
|
95
|
+
request_body: payload
|
87
96
|
)
|
88
97
|
|
89
98
|
opened_files.each(&:close)
|
@@ -89,8 +89,8 @@ module Nylas
|
|
89
89
|
# @param webhook_id [String] The ID of the webhook destination to update.
|
90
90
|
# @return [Array(Hash, String)] The updated webhook destination and API Request ID.
|
91
91
|
def rotate_secret(webhook_id:)
|
92
|
-
|
93
|
-
path: "#{api_uri}/v3/webhooks/#{webhook_id}
|
92
|
+
post(
|
93
|
+
path: "#{api_uri}/v3/webhooks/rotate-secret/#{webhook_id}",
|
94
94
|
request_body: {}
|
95
95
|
)
|
96
96
|
end
|
@@ -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.0.3
|
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-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime-types
|