nylas 6.2.3 → 6.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb37db614a1d3567334d0d7217d50e81a94a3d31bc758c916fa752953fc7369e
4
- data.tar.gz: 123be60d4794edb9ea702ae62c2768d39fda98afa7b53157d3e7b53def4b3b98
3
+ metadata.gz: 275a09b48ad361ba1f441efa8b32a026fa547c0296ea3b681da440e6c7652516
4
+ data.tar.gz: 813293f38fabeb6cbfae1a9974a6e27622c68352442982a49890c176c354a2d5
5
5
  SHA512:
6
- metadata.gz: 4d26327e107d0a911397a30a8f2f2d2fc7836dcf8d9c4f9448b4ec8ab58aa2cd37595fa7cdcea8c5ade7643d6d9ec8b33451dbf297237501ce0834494946f331
7
- data.tar.gz: 9340849392790c37b9c86334a97afe8b5b991c6d681313dee3158f26371953d698114bd38796e02f28c49e6de028594bfee4adae9b9e11d62d7e29cf10ccdb22
6
+ metadata.gz: 3453ab99f8e2ab3bec6abd2f2cad0c8ea0d43e26a328eb3ff318b2c250f3cc4d699396c7638648118f4b2af47d37aca767f4106ad04dc5a0858b2c99f6814d5e
7
+ data.tar.gz: 236711014f51f24b29c64fbe578cf0eea851cb44bb486dec3ec39c73a9311cb84a42d1f78d5c29e5eeae8025aef154e9e2ae74789fc50c9b5ebfe39eb9226a93
data/lib/nylas/client.rb CHANGED
@@ -8,6 +8,7 @@ require_relative "resources/auth"
8
8
  require_relative "resources/webhooks"
9
9
  require_relative "resources/applications"
10
10
  require_relative "resources/folders"
11
+ require_relative "resources/notetakers"
11
12
  require_relative "resources/scheduler"
12
13
 
13
14
  module Nylas
@@ -124,5 +125,11 @@ module Nylas
124
125
  def scheduler
125
126
  Scheduler.new(self)
126
127
  end
128
+
129
+ # The Notetaker resources for your Nylas application.
130
+ # @return [Nylas::Notetakers] Notetaker resources for your Nylas application.
131
+ def notetakers
132
+ Notetakers.new(self)
133
+ end
127
134
  end
128
135
  end
data/lib/nylas/errors.rb CHANGED
@@ -14,7 +14,7 @@ module Nylas
14
14
 
15
15
  # Error class representing a failed response from the Nylas API.
16
16
  class NylasApiError < AbstractNylasApiError
17
- attr_accessor :type, :request_id, :provider_error, :status_code
17
+ attr_accessor :type, :request_id, :provider_error, :status_code, :headers
18
18
 
19
19
  # Initializes an error and assigns the given attributes to it.
20
20
  #
@@ -23,24 +23,26 @@ module Nylas
23
23
  # @param status_code [Integer] Error status code.
24
24
  # @param provider_error [Hash, nil] The error from the provider.
25
25
  # @param request_id [Hash, nil] The ID of the request.
26
- def initialize(type, message, status_code, provider_error = nil, request_id = nil)
26
+ def initialize(type, message, status_code, provider_error = nil, request_id = nil, headers = nil)
27
27
  super(message)
28
28
  self.type = type
29
29
  self.status_code = status_code
30
30
  self.provider_error = provider_error
31
31
  self.request_id = request_id
32
+ self.headers = headers
32
33
  end
33
34
 
34
35
  # Parses the error response.
35
36
  #
36
37
  # @param response [Hash] Response from the Nylas API.
37
38
  # @param status_code [Integer] Error status code.
38
- def self.parse_error_response(response, status_code)
39
+ def self.parse_error_response(response, status_code, headers = nil)
39
40
  new(
40
41
  response["type"],
41
42
  response["message"],
42
43
  status_code,
43
- response["provider_error"]
44
+ response["provider_error"],
45
+ headers
44
46
  )
45
47
  end
46
48
  end
@@ -15,22 +15,23 @@ module Nylas
15
15
  #
16
16
  # @param path [String] Destination path for the call.
17
17
  # @param query_params [Hash, {}] Query params to pass to the call.
18
- # @return [Array([Hash, Array], String)] Nylas data object and API Request ID.
18
+ # @return [Array([Hash, Array], String, Hash)] Nylas data object, API Request ID, and response headers.
19
19
  def get(path:, query_params: {})
20
20
  response = get_raw(path: path, query_params: query_params)
21
21
 
22
- [response[:data], response[:request_id]]
22
+ [response[:data], response[:request_id], response[:headers]]
23
23
  end
24
24
 
25
25
  # Performs a GET call to the Nylas API for a list response.
26
26
  #
27
27
  # @param path [String] Destination path for the call.
28
28
  # @param query_params [Hash, {}] Query params to pass to the call.
29
- # @return [Array(Array(Hash), String, String)] Nylas data array, API Request ID, and next cursor.
29
+ # @return [Array<Array<Hash>, String, String, Hash>]
30
+ # Nylas data array, API Request ID, next cursor, and response headers.response headers.
30
31
  def get_list(path:, query_params: {})
31
32
  response = get_raw(path: path, query_params: query_params)
32
33
 
33
- [response[:data], response[:request_id], response[:next_cursor]]
34
+ [response[:data], response[:request_id], response[:next_cursor], response[:headers]]
34
35
  end
35
36
 
36
37
  private
@@ -63,7 +64,7 @@ module Nylas
63
64
  # @param query_params [Hash, {}] Query params to pass to the call.
64
65
  # @param request_body [Hash, nil] Request body to pass to the call.
65
66
  # @param headers [Hash, {}] Additional HTTP headers to include in the payload.
66
- # @return Nylas data object and API Request ID.
67
+ # @return [Array(Hash, String, Hash)] Nylas data object, API Request ID, and response headers.
67
68
  def post(path:, query_params: {}, request_body: nil, headers: {})
68
69
  response = execute(
69
70
  method: :post,
@@ -75,7 +76,7 @@ module Nylas
75
76
  timeout: timeout
76
77
  )
77
78
 
78
- [response[:data], response[:request_id]]
79
+ [response[:data], response[:request_id], response[:headers]]
79
80
  end
80
81
  end
81
82
 
@@ -40,7 +40,10 @@ module Nylas
40
40
  content_type = response.headers[:content_type].downcase
41
41
  end
42
42
 
43
- parse_json_evaluate_error(result.code.to_i, response, path, content_type)
43
+ parsed_response = parse_json_evaluate_error(result.code.to_i, response, path, content_type)
44
+ # Include headers in the response
45
+ parsed_response[:headers] = response.headers unless parsed_response.nil?
46
+ parsed_response
44
47
  end
45
48
  rescue RestClient::Exceptions::OpenTimeout, RestClient::Exceptions::ReadTimeout
46
49
  raise Nylas::NylasSdkTimeoutError.new(request[:path], timeout)
@@ -116,7 +119,7 @@ module Nylas
116
119
  def parse_response(response)
117
120
  return response if response.is_a?(Enumerable)
118
121
 
119
- Yajl::Parser.new(symbolize_names: true).parse(response)
122
+ Yajl::Parser.new(symbolize_names: true).parse(response) || raise(Nylas::JsonParseError)
120
123
  rescue Yajl::ParseError
121
124
  raise Nylas::JsonParseError
122
125
  end
@@ -188,22 +191,26 @@ module Nylas
188
191
  def error_hash_to_exception(response, status_code, path)
189
192
  return if !response || !response.key?(:error)
190
193
 
194
+ # Safely get headers without risking KeyError
195
+ headers = response.key?(:headers) ? response[:headers] : nil
196
+
191
197
  if %W[#{api_uri}/v3/connect/token #{api_uri}/v3/connect/revoke].include?(path)
192
198
  NylasOAuthError.new(response[:error], response[:error_description], response[:error_uri],
193
199
  response[:error_code], status_code)
194
200
  else
195
- throw_error(response, status_code)
201
+ throw_error(response, status_code, headers)
196
202
  end
197
203
  end
198
204
 
199
- def throw_error(response, status_code)
205
+ def throw_error(response, status_code, headers = nil)
200
206
  error_obj = response[:error]
201
207
 
202
208
  # If `error_obj` is just a string, turn it into a hash with default keys.
203
209
  if error_obj.is_a?(String)
204
210
  error_obj = {
205
211
  type: "NylasApiError",
206
- message: error_obj
212
+ message: error_obj,
213
+ headers: headers
207
214
  }
208
215
  end
209
216
 
@@ -214,7 +221,8 @@ module Nylas
214
221
  error_obj[:message],
215
222
  status_code,
216
223
  provider_error,
217
- response[:request_id]
224
+ response[:request_id],
225
+ headers
218
226
  )
219
227
  end
220
228
 
@@ -39,6 +39,7 @@ module Nylas
39
39
  #
40
40
  # @param identifier [String] Grant ID or email account in which to create the object.
41
41
  # @param request_body [Hash] The values to create the calendar with.
42
+ # This can include a `notetaker` object with settings and calendar sync rules for the Notetaker bot.
42
43
  # @return [Array(Hash, String)] The created calendar and API Request ID.
43
44
  def create(identifier:, request_body:)
44
45
  post(
@@ -52,7 +53,8 @@ module Nylas
52
53
  # @param identifier [String] Grant ID or email account in which to update an object.
53
54
  # @param calendar_id [String] The id of the calendar to update.
54
55
  # Use "primary" to refer to the primary calendar associated with grant.
55
- # @param request_body [Hash] The values to update the calendar with
56
+ # @param request_body [Hash] The values to update the calendar with.
57
+ # This can include a `notetaker` object with settings and calendar sync rules for the Notetaker bot.
56
58
  # @return [Array(Hash, String)] The updated calendar and API Request ID.
57
59
  def update(identifier:, calendar_id:, request_body:)
58
60
  put(
@@ -40,6 +40,7 @@ module Nylas
40
40
  #
41
41
  # @param identifier [String] Grant ID or email account in which to create the object.
42
42
  # @param request_body [Hash] The values to create the event with.
43
+ # This can include a `notetaker` object with settings for the Notetaker bot.
43
44
  # @param query_params [Hash] The query parameters to include in the request.
44
45
  # @return [Array(Hash, String)] The created event and API Request ID.
45
46
  def create(identifier:, request_body:, query_params:)
@@ -54,7 +55,8 @@ module Nylas
54
55
  #
55
56
  # @param identifier [String] Grant ID or email account in which to update an object.
56
57
  # @param event_id [String] The id of the event to update.
57
- # @param request_body [Hash] The values to update the event with
58
+ # @param request_body [Hash] The values to update the event with.
59
+ # This can include a `notetaker` object with settings for the Notetaker bot.
58
60
  # @param query_params [Hash] The query parameters to include in the request
59
61
  # @return [Array(Hash, String)] The updated event and API Request ID.
60
62
  def update(identifier:, event_id:, request_body:, query_params:)
@@ -94,5 +96,19 @@ module Nylas
94
96
  request_body: request_body
95
97
  )
96
98
  end
99
+
100
+ # Returns a list of recurring events, recurring event exceptions, and single events
101
+ # from the specified calendar within a given time frame. This is useful when you
102
+ # want to import, store, and synchronize events from the time frame to your application
103
+ #
104
+ # @param identifier [String] Grant ID or email account to import events from.
105
+ # @param query_params [Hash] The query parameters to include in the request
106
+ # @return [(Array(Hash), String, String)] The list of events, API Request ID, and next cursor.
107
+ def list_import_events(identifier:, query_params:)
108
+ get_list(
109
+ path: "#{api_uri}/v3/grants/#{identifier}/events/import",
110
+ query_params: query_params
111
+ )
112
+ end
97
113
  end
98
114
  end
@@ -0,0 +1,142 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "resource"
4
+ require_relative "../handler/api_operations"
5
+
6
+ module Nylas
7
+ # Nylas Notetaker API
8
+ class Notetakers < Resource
9
+ include ApiOperations::Get
10
+ include ApiOperations::Post
11
+ include ApiOperations::Put
12
+ include ApiOperations::Delete
13
+ include ApiOperations::Patch
14
+
15
+ # Return all notetakers.
16
+ #
17
+ # @param identifier [String, nil] Grant ID or email account to query.
18
+ # @param query_params [Hash, nil] Query params to pass to the request.
19
+ # @return [Array(Array(Hash), String, String)] The list of notetakers, API Request ID, and next cursor.
20
+ def list(identifier: nil, query_params: nil)
21
+ path = identifier ? "#{api_uri}/v3/grants/#{identifier}/notetakers" : "#{api_uri}/v3/notetakers"
22
+
23
+ get_list(
24
+ path: path,
25
+ query_params: query_params
26
+ )
27
+ end
28
+
29
+ # Return a notetaker.
30
+ #
31
+ # @param notetaker_id [String] The id of the notetaker to return.
32
+ # @param identifier [String, nil] Grant ID or email account to query.
33
+ # @param query_params [Hash, nil] Query params to pass to the request.
34
+ # @return [Array(Hash, String)] The notetaker and API request ID.
35
+ def find(notetaker_id:, identifier: nil, query_params: nil)
36
+ base_path = "#{api_uri}/v3"
37
+ path = if identifier
38
+ "#{base_path}/grants/#{identifier}/notetakers/#{notetaker_id}"
39
+ else
40
+ "#{base_path}/notetakers/#{notetaker_id}"
41
+ end
42
+
43
+ get(
44
+ path: path,
45
+ query_params: query_params
46
+ )
47
+ end
48
+
49
+ # Invite a notetaker to a meeting.
50
+ #
51
+ # @param request_body [Hash] The values to create the notetaker with.
52
+ # @param identifier [String, nil] Grant ID or email account in which to create the object.
53
+ # @return [Array(Hash, String)] The created notetaker and API Request ID.
54
+ def create(request_body:, identifier: nil)
55
+ path = identifier ? "#{api_uri}/v3/grants/#{identifier}/notetakers" : "#{api_uri}/v3/notetakers"
56
+
57
+ post(
58
+ path: path,
59
+ request_body: request_body
60
+ )
61
+ end
62
+
63
+ # Update a scheduled notetaker.
64
+ #
65
+ # @param notetaker_id [String] The id of the notetaker to update.
66
+ # @param request_body [Hash] The values to update the notetaker with
67
+ # @param identifier [String, nil] Grant ID or email account in which to update an object.
68
+ # @return [Array(Hash, String)] The updated notetaker and API Request ID.
69
+ def update(notetaker_id:, request_body:, identifier: nil)
70
+ base_path = "#{api_uri}/v3"
71
+ path = if identifier
72
+ "#{base_path}/grants/#{identifier}/notetakers/#{notetaker_id}"
73
+ else
74
+ "#{base_path}/notetakers/#{notetaker_id}"
75
+ end
76
+
77
+ patch(
78
+ path: path,
79
+ request_body: request_body
80
+ )
81
+ end
82
+
83
+ # Download notetaker media.
84
+ #
85
+ # @param notetaker_id [String] The id of the notetaker to download media from.
86
+ # @param identifier [String, nil] Grant ID or email account to query.
87
+ # @param query_params [Hash, nil] Query params to pass to the request.
88
+ # @return [Array(Hash, String)] The media data and API request ID.
89
+ def download_media(notetaker_id:, identifier: nil, query_params: nil)
90
+ base_path = "#{api_uri}/v3"
91
+ path = if identifier
92
+ "#{base_path}/grants/#{identifier}/notetakers/#{notetaker_id}/media"
93
+ else
94
+ "#{base_path}/notetakers/#{notetaker_id}/media"
95
+ end
96
+
97
+ get(
98
+ path: path,
99
+ query_params: query_params
100
+ )
101
+ end
102
+
103
+ # Remove a notetaker from a meeting.
104
+ #
105
+ # @param notetaker_id [String] The id of the notetaker to remove.
106
+ # @param identifier [String, nil] Grant ID or email account to query.
107
+ # @return [Array(Hash, String)] The response data and API request ID.
108
+ def leave(notetaker_id:, identifier: nil)
109
+ base_path = "#{api_uri}/v3"
110
+ path = if identifier
111
+ "#{base_path}/grants/#{identifier}/notetakers/#{notetaker_id}/leave"
112
+ else
113
+ "#{base_path}/notetakers/#{notetaker_id}/leave"
114
+ end
115
+
116
+ post(
117
+ path: path,
118
+ request_body: {}
119
+ )
120
+ end
121
+
122
+ # Cancel a scheduled notetaker.
123
+ #
124
+ # @param notetaker_id [String] The id of the notetaker to cancel.
125
+ # @param identifier [String, nil] Grant ID or email account from which to delete an object.
126
+ # @return [Array(TrueClass, String)] True and the API Request ID for the cancel operation.
127
+ def cancel(notetaker_id:, identifier: nil)
128
+ base_path = "#{api_uri}/v3"
129
+ path = if identifier
130
+ "#{base_path}/grants/#{identifier}/notetakers/#{notetaker_id}/cancel"
131
+ else
132
+ "#{base_path}/notetakers/#{notetaker_id}/cancel"
133
+ end
134
+
135
+ _, request_id = delete(
136
+ path: path
137
+ )
138
+
139
+ [true, request_id]
140
+ end
141
+ end
142
+ end
@@ -22,6 +22,7 @@ module Nylas
22
22
  MESSAGE_CREATED = "message.created"
23
23
  MESSAGE_UPDATED = "message.updated"
24
24
  MESSAGE_OPENED = "message.opened"
25
+ MESSAGE_BOUNCE_DETECTED = "message.bounce_detected"
25
26
  MESSAGE_LINK_CLICKED = "message.link_clicked"
26
27
  THREAD_REPLIED = "thread.replied"
27
28
  FOLDER_CREATED = "folder.created"
@@ -62,6 +62,7 @@ module Nylas
62
62
  opened_files = []
63
63
 
64
64
  attachments.each_with_index do |attachment, _index|
65
+ attachment.delete(:file_path)
65
66
  current_attachment = attachment[:content]
66
67
  next unless current_attachment
67
68
 
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.3"
4
+ VERSION = "6.4.0"
5
5
  end
data/lib/nylas.rb CHANGED
@@ -39,6 +39,7 @@ require_relative "nylas/resources/events"
39
39
  require_relative "nylas/resources/folders"
40
40
  require_relative "nylas/resources/grants"
41
41
  require_relative "nylas/resources/messages"
42
+ require_relative "nylas/resources/notetakers"
42
43
  require_relative "nylas/resources/smart_compose"
43
44
  require_relative "nylas/resources/threads"
44
45
  require_relative "nylas/resources/redirect_uris"
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.2.3
4
+ version: 6.4.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: 2025-01-23 00:00:00.000000000 Z
11
+ date: 2025-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -154,6 +154,20 @@ dependencies:
154
154
  - - "~>"
155
155
  - !ruby/object:Gem::Version
156
156
  version: '2.22'
157
+ - !ruby/object:Gem::Dependency
158
+ name: rubocop-capybara
159
+ requirement: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - "~>"
162
+ - !ruby/object:Gem::Version
163
+ version: '2.20'
164
+ type: :development
165
+ prerelease: false
166
+ version_requirements: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - "~>"
169
+ - !ruby/object:Gem::Version
170
+ version: '2.20'
157
171
  - !ruby/object:Gem::Dependency
158
172
  name: rspec
159
173
  requirement: !ruby/object:Gem::Requirement
@@ -277,6 +291,7 @@ files:
277
291
  - lib/nylas/resources/folders.rb
278
292
  - lib/nylas/resources/grants.rb
279
293
  - lib/nylas/resources/messages.rb
294
+ - lib/nylas/resources/notetakers.rb
280
295
  - lib/nylas/resources/redirect_uris.rb
281
296
  - lib/nylas/resources/resource.rb
282
297
  - lib/nylas/resources/scheduler.rb