nylas 6.2.1 → 6.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d91ae3ccc20cfd009bfd1d7faf5e2d67488b1eee292823b0e0ec35cf56f56b58
4
- data.tar.gz: 22f379f3e2d40936efbab14391e21ec92a26551917286e6451ed99047e258bb7
3
+ metadata.gz: cb37db614a1d3567334d0d7217d50e81a94a3d31bc758c916fa752953fc7369e
4
+ data.tar.gz: 123be60d4794edb9ea702ae62c2768d39fda98afa7b53157d3e7b53def4b3b98
5
5
  SHA512:
6
- metadata.gz: aa88cd03b9163346a7b944203ab6882c337d74a7c034987f378eedd80d2b97d3b22c066d651ec6ffa220895d999df6b343c66e30a6914a10fe47ddd46d8584c0
7
- data.tar.gz: 6dc249dbc302dcbe07f93fa582c16fd93d4f3c0e33dc2bdf40dfcbcf5c29aca4b1e254f254b58658dd13cada5b5dcaf2ed5ced0a24b2a9b4e9983707da582463
6
+ metadata.gz: 4d26327e107d0a911397a30a8f2f2d2fc7836dcf8d9c4f9448b4ec8ab58aa2cd37595fa7cdcea8c5ade7643d6d9ec8b33451dbf297237501ce0834494946f331
7
+ data.tar.gz: 9340849392790c37b9c86334a97afe8b5b991c6d681313dee3158f26371953d698114bd38796e02f28c49e6de028594bfee4adae9b9e11d62d7e29cf10ccdb22
data/lib/nylas/errors.rb CHANGED
@@ -21,7 +21,7 @@ module Nylas
21
21
  # @param type [Hash] Error type.
22
22
  # @param message [String] Error message.
23
23
  # @param status_code [Integer] Error status code.
24
- # @param provider_error [String, nil] Provider error.
24
+ # @param provider_error [Hash, nil] The error from the provider.
25
25
  # @param request_id [Hash, nil] The ID of the request.
26
26
  def initialize(type, message, status_code, provider_error = nil, request_id = nil)
27
27
  super(message)
@@ -198,10 +198,24 @@ module Nylas
198
198
 
199
199
  def throw_error(response, status_code)
200
200
  error_obj = response[:error]
201
- provider_error = error_obj.fetch(:provider_error, nil)
202
201
 
203
- NylasApiError.new(error_obj[:type], error_obj[:message], status_code, provider_error,
204
- response[:request_id])
202
+ # If `error_obj` is just a string, turn it into a hash with default keys.
203
+ if error_obj.is_a?(String)
204
+ error_obj = {
205
+ type: "NylasApiError",
206
+ message: error_obj
207
+ }
208
+ end
209
+
210
+ provider_error = error_obj.fetch(:provider_error, nil) if error_obj.is_a?(Hash)
211
+
212
+ NylasApiError.new(
213
+ error_obj[:type],
214
+ error_obj[:message],
215
+ status_code,
216
+ provider_error,
217
+ response[:request_id]
218
+ )
205
219
  end
206
220
 
207
221
  # Adds query parameters to a URL.
@@ -16,7 +16,7 @@ module Nylas
16
16
  # @param booking_id [String] The id of the booking to return.
17
17
  # @param query_params [Hash, nil] Query params to pass to the request.
18
18
  # @return [Array(Hash, String)] The booking and API request ID.
19
- def find(booking_id:, query_params:)
19
+ def find(booking_id:, query_params: nil)
20
20
  get(
21
21
  path: "#{api_uri}/v3/scheduling/bookings/#{booking_id}",
22
22
  query_params: query_params
@@ -27,7 +27,7 @@ module Nylas
27
27
  # @param request_body [Hash] The values to create the booking with.
28
28
  # @param query_params [Hash, nil] Query params to pass to the request.
29
29
  # @return [Array(Hash, String)] The created booking and API Request ID.
30
- def create(request_body:, query_params:)
30
+ def create(request_body:, query_params: nil)
31
31
  post(
32
32
  path: "#{api_uri}/v3/scheduling/bookings",
33
33
  request_body: request_body,
@@ -40,7 +40,7 @@ module Nylas
40
40
  # @param booking_id [String] The id of the booking to update.
41
41
  # @param query_params [Hash, nil] Query params to pass to the request.
42
42
  # @return [Array(Hash, String)] The created booking and API Request ID.
43
- def update(request_body:, booking_id:, query_params:)
43
+ def update(request_body:, booking_id:, query_params: nil)
44
44
  patch(
45
45
  path: "#{api_uri}/v3/scheduling/bookings/#{booking_id}",
46
46
  request_body: request_body,
@@ -53,7 +53,7 @@ module Nylas
53
53
  # @param request_body [Hash] The values to update the booking with
54
54
  # @param query_params [Hash, nil] Query params to pass to the request.
55
55
  # @return [Array(Hash, String)] The updated booking and API Request ID.
56
- def confirm_booking(booking_id:, request_body:, query_params:)
56
+ def confirm(booking_id:, request_body:, query_params: nil)
57
57
  put(
58
58
  path: "#{api_uri}/v3/scheduling/bookings/#{booking_id}",
59
59
  request_body: request_body,
@@ -65,7 +65,7 @@ module Nylas
65
65
  # @param booking_id [String] The id of the booking to delete.
66
66
  # @param query_params [Hash, nil] Query params to pass to the request.
67
67
  # @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
68
- def destroy(booking_id:, query_params:)
68
+ def destroy(booking_id:, query_params: nil)
69
69
  _, request_id = delete(
70
70
  path: "#{api_uri}/v3/scheduling/bookings/#{booking_id}",
71
71
  query_params: query_params
@@ -36,7 +36,16 @@ module Nylas
36
36
  file = File.open(attachment[:file_path], "rb")
37
37
  end
38
38
 
39
- form_data.merge!({ "file#{index}" => file })
39
+ # Setting original filename and content type if available. See rest-client#lib/restclient/payload.rb
40
+ filename = attachment[:filename] || attachment["filename"]
41
+ file.define_singleton_method(:original_filename) { filename } if filename
42
+
43
+ content_type = attachment[:content_type] || attachment["content_type"]
44
+ file.define_singleton_method(:content_type) { content_type } if content_type
45
+
46
+ content_id = attachment[:content_id] || attachment["content_id"] || "file#{index}"
47
+
48
+ form_data.merge!({ content_id => file })
40
49
  opened_files << file
41
50
  end
42
51
 
@@ -93,7 +102,7 @@ module Nylas
93
102
  # @param file_path [String] The path to the file to attach.
94
103
  # @param filename [String] The name of the attached file. Optional, derived from file_path by default.
95
104
  # @return [Hash] The request that will attach the file to the message/draft
96
- def self.attach_file_request_builder(file_path, filename = nil)
105
+ def self.attach_file_request_builder(file_path, filename = nil, content_id = nil)
97
106
  filename ||= File.basename(file_path)
98
107
  content_type = MIME::Types.type_for(file_path)
99
108
  content_type = if !content_type.nil? && !content_type.empty?
@@ -103,12 +112,12 @@ module Nylas
103
112
  end
104
113
  size = File.size(file_path)
105
114
  content = File.new(file_path, "rb")
106
-
107
115
  {
108
116
  filename: filename,
109
117
  content_type: content_type,
110
118
  size: size,
111
119
  content: content,
120
+ content_id: content_id,
112
121
  file_path: file_path
113
122
  }
114
123
  end
data/lib/nylas/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nylas
4
- VERSION = "6.2.1"
4
+ VERSION = "6.2.3"
5
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nylas
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.1
4
+ version: 6.2.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-12 00:00:00.000000000 Z
11
+ date: 2025-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: base64
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: mime-types
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -297,7 +311,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
297
311
  - !ruby/object:Gem::Version
298
312
  version: '0'
299
313
  requirements: []
300
- rubygems_version: 3.5.22
314
+ rubygems_version: 3.4.18
301
315
  signing_key:
302
316
  specification_version: 4
303
317
  summary: Gem for interacting with the Nylas API