nylas 4.6.3 → 4.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nylas/draft.rb +4 -0
- data/lib/nylas/errors.rb +6 -0
- data/lib/nylas/file.rb +3 -1
- data/lib/nylas/http_client.rb +15 -2
- data/lib/nylas/new_message.rb +2 -1
- data/lib/nylas/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eac1943c9596d6042676b8c5eb3356e6986a5f41088b419fd6dcd8295ef41fd7
|
4
|
+
data.tar.gz: a6207a0b0004fcfcaf251675fe6ad9d70c0c3cd57bcb9b7ca6e83d95decdb8e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '018f5931707cc9bbb8ab43908619fd7fabb9eea0992cbcc486bc35c2d67ff9ae8ffb52a49a9bfa0beecf4eca4897849e4e2bcd1c33878a89f06756de24f60c59'
|
7
|
+
data.tar.gz: 0a215f1bcc5e9b19bbd5229ed350fefe07bfb415f7e1118f451f2e31998604fa1b730d325d68083cfe09fb9a9efc84a18a247f8a85ad41b48231732f37c57c81
|
data/lib/nylas/draft.rb
CHANGED
@@ -33,9 +33,13 @@ module Nylas
|
|
33
33
|
attribute :folder, :folder
|
34
34
|
has_n_of_attribute :labels, :label
|
35
35
|
|
36
|
+
attribute :tracking, :message_tracking
|
37
|
+
|
36
38
|
transfer :api, to: %i[events files folder labels]
|
37
39
|
|
38
40
|
def send!
|
41
|
+
return execute(method: :post, path: "/send", payload: to_json) if tracking
|
42
|
+
|
39
43
|
save
|
40
44
|
execute(method: :post, path: "/send", payload: JSON.dump(draft_id: id, version: version))
|
41
45
|
end
|
data/lib/nylas/errors.rb
CHANGED
@@ -14,6 +14,8 @@ module Nylas
|
|
14
14
|
class ModelNotUpdatableError < ModelActionError; end
|
15
15
|
class ModelNotDestroyableError < ModelActionError; end
|
16
16
|
|
17
|
+
class JsonParseError < Error; end
|
18
|
+
|
17
19
|
# Raised when attempting to set a field that is not on a model with mass assignment
|
18
20
|
class ModelMissingFieldError < ModelActionError
|
19
21
|
def initialize(field, model)
|
@@ -48,6 +50,10 @@ module Nylas
|
|
48
50
|
ResourceNotFound = Class.new(APIError)
|
49
51
|
MethodNotAllowed = Class.new(APIError)
|
50
52
|
InvalidRequest = Class.new(APIError)
|
53
|
+
UnauthorizedRequest = Class.new(APIError)
|
54
|
+
ResourceRemoved = Class.new(APIError)
|
55
|
+
TeapotError = Class.new(APIError)
|
56
|
+
RequestTimedOut = Class.new(APIError)
|
51
57
|
MessageRejected = Class.new(APIError)
|
52
58
|
SendingQuotaExceeded = Class.new(APIError)
|
53
59
|
ServiceUnavailable = Class.new(APIError)
|
data/lib/nylas/file.rb
CHANGED
@@ -56,7 +56,9 @@ module Nylas
|
|
56
56
|
def retrieve_file
|
57
57
|
response = api.get(path: "#{resource_path}/download")
|
58
58
|
filename = response.headers.fetch(:content_disposition, "").gsub("attachment; filename=", "")
|
59
|
-
|
59
|
+
# The returned filename can be longer than 256 chars which isn't supported by rb_sysopen.
|
60
|
+
# 128 chars here is more than enough given that TempFile ensure the filename will be unique.
|
61
|
+
temp_file = Tempfile.new(filename[0..127], encoding: "ascii-8bit")
|
60
62
|
temp_file.write(response.body)
|
61
63
|
temp_file.seek(0)
|
62
64
|
temp_file
|
data/lib/nylas/http_client.rb
CHANGED
@@ -7,16 +7,20 @@ module Nylas
|
|
7
7
|
class HttpClient # rubocop:disable Metrics/ClassLength
|
8
8
|
HTTP_CODE_TO_EXCEPTIONS = {
|
9
9
|
400 => InvalidRequest,
|
10
|
+
401 => UnauthorizedRequest,
|
10
11
|
402 => MessageRejected,
|
11
12
|
403 => AccessDenied,
|
12
13
|
404 => ResourceNotFound,
|
13
14
|
405 => MethodNotAllowed,
|
15
|
+
410 => ResourceRemoved,
|
16
|
+
418 => TeapotError,
|
14
17
|
422 => MailProviderError,
|
15
18
|
429 => SendingQuotaExceeded,
|
16
19
|
500 => InternalError,
|
17
20
|
501 => EndpointNotYetImplemented,
|
18
21
|
502 => BadGateway,
|
19
|
-
503 => ServiceUnavailable
|
22
|
+
503 => ServiceUnavailable,
|
23
|
+
504 => RequestTimedOut
|
20
24
|
}.freeze
|
21
25
|
|
22
26
|
ENDPOINT_TIMEOUTS = {
|
@@ -82,7 +86,14 @@ module Nylas
|
|
82
86
|
timeout: timeout
|
83
87
|
)
|
84
88
|
rest_client_execute(**request) do |response, _request, result|
|
85
|
-
|
89
|
+
content_type = nil
|
90
|
+
|
91
|
+
if response.headers && response.headers[:content_type]
|
92
|
+
content_type = response.headers[:content_type].downcase
|
93
|
+
end
|
94
|
+
|
95
|
+
response = parse_response(response) if content_type == "application/json"
|
96
|
+
|
86
97
|
handle_failed_response(result: result, response: response)
|
87
98
|
response
|
88
99
|
end
|
@@ -136,6 +147,8 @@ module Nylas
|
|
136
147
|
|
137
148
|
json = StringIO.new(response)
|
138
149
|
Yajl::Parser.new(symbolize_names: true).parse(json)
|
150
|
+
rescue Yajl::ParseError
|
151
|
+
raise Nylas::JsonParseError
|
139
152
|
end
|
140
153
|
inform_on :parse_response, level: :debug, also_log: { result: true }
|
141
154
|
|
data/lib/nylas/new_message.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Nylas
|
4
|
-
# Data structure for
|
4
|
+
# Data structure for sending a message via the Nylas API
|
5
5
|
class NewMessage
|
6
6
|
include Model
|
7
7
|
self.creatable = false
|
@@ -15,6 +15,7 @@ module Nylas
|
|
15
15
|
has_n_of_attribute :from, :email_address
|
16
16
|
has_n_of_attribute :cc, :email_address
|
17
17
|
has_n_of_attribute :bcc, :email_address
|
18
|
+
has_n_of_attribute :reply_to, :email_address
|
18
19
|
|
19
20
|
attribute :subject, :string
|
20
21
|
attribute :body, :string
|
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: 4.6.
|
4
|
+
version: 4.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nylas, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -240,7 +240,7 @@ dependencies:
|
|
240
240
|
requirements:
|
241
241
|
- - ">="
|
242
242
|
- !ruby/object:Gem::Version
|
243
|
-
version: '
|
243
|
+
version: '2.0'
|
244
244
|
- - "<"
|
245
245
|
- !ruby/object:Gem::Version
|
246
246
|
version: '3.0'
|
@@ -250,7 +250,7 @@ dependencies:
|
|
250
250
|
requirements:
|
251
251
|
- - ">="
|
252
252
|
- !ruby/object:Gem::Version
|
253
|
-
version: '
|
253
|
+
version: '2.0'
|
254
254
|
- - "<"
|
255
255
|
- !ruby/object:Gem::Version
|
256
256
|
version: '3.0'
|
@@ -356,7 +356,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
356
356
|
- !ruby/object:Gem::Version
|
357
357
|
version: '0'
|
358
358
|
requirements: []
|
359
|
-
rubygems_version: 3.
|
359
|
+
rubygems_version: 3.2.5
|
360
360
|
signing_key:
|
361
361
|
specification_version: 4
|
362
362
|
summary: Gem for interacting with the Nylas API
|