nylas 6.1.1 → 6.2.1

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: a2876cab1f609fb357369d692fa8ed5b0fa04754d8b95b30b9d483856bbcff2e
4
- data.tar.gz: 94db4b8a8c253c4737348dcdb2fbdddf0fbdf021ac626ef0318ade71da4bf247
3
+ metadata.gz: d91ae3ccc20cfd009bfd1d7faf5e2d67488b1eee292823b0e0ec35cf56f56b58
4
+ data.tar.gz: 22f379f3e2d40936efbab14391e21ec92a26551917286e6451ed99047e258bb7
5
5
  SHA512:
6
- metadata.gz: bade836048e4f19c3a1aebcf03a792bb73d38d850473fe9e60ff116fe6e7ca613f5e48c7f4d4f959f36cf0b361f3b2e7414cc96d5347c60bd7d306961da13e55
7
- data.tar.gz: 76d8048ed9eb92a1a660e3edc4d04cda08d7a676898c40092739f60c87250b99afefb19cf04ceef79b08a8cc7bf5425b87178d02e019f74c9937694a86d953e7
6
+ metadata.gz: aa88cd03b9163346a7b944203ab6882c337d74a7c034987f378eedd80d2b97d3b22c066d651ec6ffa220895d999df6b343c66e30a6914a10fe47ddd46d8584c0
7
+ data.tar.gz: 6dc249dbc302dcbe07f93fa582c16fd93d4f3c0e33dc2bdf40dfcbcf5c29aca4b1e254f254b58658dd13cada5b5dcaf2ed5ced0a24b2a9b4e9983707da582463
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/scheduler"
11
12
 
12
13
  module Nylas
13
14
  # Methods to retrieve data from the Nylas API as Ruby objects.
@@ -117,5 +118,11 @@ module Nylas
117
118
  def webhooks
118
119
  Webhooks.new(self)
119
120
  end
121
+
122
+ # The Scheduler resources for your Nylas application.
123
+ # @return [Nylas::Scheduler] Scheduler resources for your Nylas application.
124
+ def scheduler
125
+ Scheduler.new(self)
126
+ end
120
127
  end
121
128
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "resource"
4
+ require_relative "../handler/api_operations"
5
+
6
+ module Nylas
7
+ # Nylas Messages API
8
+ class Availability < Resource
9
+ include ApiOperations::Get
10
+
11
+ # Return availabilities for a configuration.
12
+ # @param query_params [Hash, nil] Query params to pass to the request.
13
+ # @return [Array(Array(Hash), String, String)] The list of configurations, API Request ID,
14
+ # and next cursor.
15
+ def list(query_params: nil)
16
+ get_list(
17
+ path: "#{api_uri}/v3/scheduling/availability",
18
+ query_params: query_params
19
+ )
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "resource"
4
+ require_relative "../handler/api_operations"
5
+
6
+ module Nylas
7
+ # Nylas Messages API
8
+ class Bookings < Resource
9
+ include ApiOperations::Get
10
+ include ApiOperations::Post
11
+ include ApiOperations::Put
12
+ include ApiOperations::Delete
13
+ include ApiOperations::Patch
14
+
15
+ # Return a booking.
16
+ # @param booking_id [String] The id of the booking to return.
17
+ # @param query_params [Hash, nil] Query params to pass to the request.
18
+ # @return [Array(Hash, String)] The booking and API request ID.
19
+ def find(booking_id:, query_params:)
20
+ get(
21
+ path: "#{api_uri}/v3/scheduling/bookings/#{booking_id}",
22
+ query_params: query_params
23
+ )
24
+ end
25
+
26
+ # Create a booking.
27
+ # @param request_body [Hash] The values to create the booking with.
28
+ # @param query_params [Hash, nil] Query params to pass to the request.
29
+ # @return [Array(Hash, String)] The created booking and API Request ID.
30
+ def create(request_body:, query_params:)
31
+ post(
32
+ path: "#{api_uri}/v3/scheduling/bookings",
33
+ request_body: request_body,
34
+ query_params: query_params
35
+ )
36
+ end
37
+
38
+ # Create a booking.
39
+ # @param request_body [Hash] The values to update the booking with.
40
+ # @param booking_id [String] The id of the booking to update.
41
+ # @param query_params [Hash, nil] Query params to pass to the request.
42
+ # @return [Array(Hash, String)] The created booking and API Request ID.
43
+ def update(request_body:, booking_id:, query_params:)
44
+ patch(
45
+ path: "#{api_uri}/v3/scheduling/bookings/#{booking_id}",
46
+ request_body: request_body,
47
+ query_params: query_params
48
+ )
49
+ end
50
+
51
+ # Confirm a booking.
52
+ # @param booking_id [String] The id of the booking to confirm.
53
+ # @param request_body [Hash] The values to update the booking with
54
+ # @param query_params [Hash, nil] Query params to pass to the request.
55
+ # @return [Array(Hash, String)] The updated booking and API Request ID.
56
+ def confirm_booking(booking_id:, request_body:, query_params:)
57
+ put(
58
+ path: "#{api_uri}/v3/scheduling/bookings/#{booking_id}",
59
+ request_body: request_body,
60
+ query_params: query_params
61
+ )
62
+ end
63
+
64
+ # Delete a booking.
65
+ # @param booking_id [String] The id of the booking to delete.
66
+ # @param query_params [Hash, nil] Query params to pass to the request.
67
+ # @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
68
+ def destroy(booking_id:, query_params:)
69
+ _, request_id = delete(
70
+ path: "#{api_uri}/v3/scheduling/bookings/#{booking_id}",
71
+ query_params: query_params
72
+ )
73
+
74
+ [true, request_id]
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "resource"
4
+ require_relative "../handler/api_operations"
5
+
6
+ module Nylas
7
+ # Nylas Scheduler Configurations API
8
+ class Configurations < Resource
9
+ include ApiOperations::Get
10
+ include ApiOperations::Post
11
+ include ApiOperations::Put
12
+ include ApiOperations::Delete
13
+
14
+ # Return all Scheduler Configurations.
15
+ #
16
+ # @param identifier [String] Grant ID or email account to query.
17
+ # @param query_params [Hash, nil] Query params to pass to the request.
18
+ # @return [Array(Array(Hash), String, String)] The list of configurations, API Request ID,
19
+ # and next cursor.
20
+ def list(identifier:, query_params: nil)
21
+ get_list(
22
+ path: "#{api_uri}/v3/grants/#{identifier}/scheduling/configurations",
23
+ query_params: query_params
24
+ )
25
+ end
26
+
27
+ # Return a Configuration.
28
+ #
29
+ # @param identifier [String] Grant ID or email account to query.
30
+ # @param configuration_id [String] The id of the configuration to return.
31
+ # @return [Array(Hash, String)] The configuration and API request ID.
32
+ def find(identifier:, configuration_id:)
33
+ get(
34
+ path: "#{api_uri}/v3/grants/#{identifier}/scheduling/configurations/#{configuration_id}"
35
+ )
36
+ end
37
+
38
+ # Create a configuration.
39
+ #
40
+ # @param identifier [String] Grant ID or email account in which to create the object.
41
+ # @param request_body [Hash] The values to create the configuration with.
42
+ # @return [Array(Hash, String)] The created configuration and API Request ID.
43
+ def create(identifier:, request_body:)
44
+ post(
45
+ path: "#{api_uri}/v3/grants/#{identifier}/scheduling/configurations",
46
+ request_body: request_body
47
+ )
48
+ end
49
+
50
+ # Update a configuration.
51
+ #
52
+ # @param identifier [String] Grant ID or email account in which to update an object.
53
+ # @param configuration_id [String] The id of the configuration to update.
54
+ # @param request_body [Hash] The values to update the configuration with
55
+ # @return [Array(Hash, String)] The updated configuration and API Request ID.
56
+ def update(identifier:, configuration_id:, request_body:)
57
+ put(
58
+ path: "#{api_uri}/v3/grants/#{identifier}/scheduling/configurations/#{configuration_id}",
59
+ request_body: request_body
60
+ )
61
+ end
62
+
63
+ # Delete a configuration.
64
+ #
65
+ # @param identifier [String] Grant ID or email account from which to delete an object.
66
+ # @param configuration_id [String] The id of the configuration to delete.
67
+ # @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
68
+ def destroy(identifier:, configuration_id:)
69
+ _, request_id = delete(
70
+ path: "#{api_uri}/v3/grants/#{identifier}/scheduling/configurations/#{configuration_id}"
71
+ )
72
+
73
+ [true, request_id]
74
+ end
75
+ end
76
+ end
@@ -14,10 +14,12 @@ module Nylas
14
14
  # Return all folders.
15
15
  #
16
16
  # @param identifier [String] Grant ID or email account to query.
17
+ # @param query_params [Hash, nil] Query params to pass to the request.
17
18
  # @return [Array(Array(Hash), String, String)] The list of folders, API Request ID, and next cursor.
18
- def list(identifier:)
19
+ def list(identifier:, query_params: nil)
19
20
  get_list(
20
- path: "#{api_uri}/v3/grants/#{identifier}/folders"
21
+ path: "#{api_uri}/v3/grants/#{identifier}/folders",
22
+ query_params: query_params
21
23
  )
22
24
  end
23
25
 
@@ -25,10 +27,12 @@ module Nylas
25
27
  #
26
28
  # @param identifier [String] Grant ID or email account to query.
27
29
  # @param folder_id [String] The id of the folder to return.
30
+ # @param query_params [Hash, nil] Query params to pass to the request.
28
31
  # @return [Array(Hash, String)] The folder and API request ID.
29
- def find(identifier:, folder_id:)
32
+ def find(identifier:, folder_id:, query_params: nil)
30
33
  get(
31
- path: "#{api_uri}/v3/grants/#{identifier}/folders/#{folder_id}"
34
+ path: "#{api_uri}/v3/grants/#{identifier}/folders/#{folder_id}",
35
+ query_params: query_params
32
36
  )
33
37
  end
34
38
 
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "./configurations"
4
+ require_relative "./sessions"
5
+ require_relative "./bookings"
6
+ require_relative "./availability"
7
+
8
+ module Nylas
9
+ # Nylas Scheduler API
10
+ # This class provides access to the Scheduler resources, including
11
+ # configurations, bookings, sessions, and availability.
12
+ #
13
+ # @attr_reader [Nylas::Configurations] configurations The Scheduler configurations resource for your
14
+ # Nylas application.
15
+ # @attr_reader [Nylas::Bookings] bookings The Scheduler bookings resource for your
16
+ # Nylas application.
17
+ # @attr_reader [Nylas::Sessions] sessions The Scheduler sessions resource for your
18
+ # Nylas application.
19
+ # @attr_reader [Nylas::Availability] availability The Scheduler availability resource for your
20
+ # Nylas application.
21
+ class Scheduler
22
+ attr_reader :configurations, :sessions, :bookings, :availability
23
+
24
+ # Initializes the Scheduler class.
25
+ #
26
+ # @param api_client [APIClient] The Nylas API client instance for making requests.
27
+ def initialize(api_client)
28
+ @api_client = api_client
29
+ @configurations = Configurations.new(@api_client)
30
+ @bookings = Bookings.new(@api_client)
31
+ @sessions = Sessions.new(@api_client)
32
+ @availability = Availability.new(@api_client)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "resource"
4
+ require_relative "../handler/api_operations"
5
+
6
+ module Nylas
7
+ # Nylas Messages API
8
+ class Sessions < Resource
9
+ include ApiOperations::Post
10
+ include ApiOperations::Delete
11
+
12
+ # Create a session for a configuration.
13
+ # @param request_body [Hash] The values to create a configuration sessions.
14
+ # @return [Array(Hash, String)] The created configuration and API Request ID.
15
+ def create(request_body:)
16
+ post(
17
+ path: "#{api_uri}/v3/scheduling/sessions",
18
+ request_body: request_body
19
+ )
20
+ end
21
+
22
+ # Delete a session for a configuration.
23
+ # @param session_id [String] The id of the session to delete.
24
+ # @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
25
+ def destroy(session_id:)
26
+ _, request_id = delete(
27
+ path: "#{api_uri}/v3/scheduling/sessions/#{session_id}"
28
+ )
29
+
30
+ [true, request_id]
31
+ end
32
+ end
33
+ end
@@ -26,10 +26,12 @@ module Nylas
26
26
  #
27
27
  # @param identifier [String] Grant ID or email account to query.
28
28
  # @param thread_id [String] The id of the thread to return.
29
+ # @param query_params [Hash, nil] Query params to pass to the request.
29
30
  # @return [Array(Hash, String)] The thread and API request ID.
30
- def find(identifier:, thread_id:)
31
+ def find(identifier:, thread_id:, query_params: nil)
31
32
  get(
32
- path: "#{api_uri}/v3/grants/#{identifier}/threads/#{thread_id}"
33
+ path: "#{api_uri}/v3/grants/#{identifier}/threads/#{thread_id}",
34
+ query_params: query_params
33
35
  )
34
36
  end
35
37
 
@@ -13,20 +13,29 @@ module Nylas
13
13
  # @return The form data to send to the API and the opened files.
14
14
  # @!visibility private
15
15
  def self.build_form_request(request_body)
16
- attachments = request_body.delete(:attachments) || request_body.delete("attachments") || []
16
+ attachments = request_body[:attachments] || request_body["attachments"] || []
17
+ serializable_body = request_body.reject { |key, _| [:attachments, "attachments"].include?(key) }
18
+ request_body_copy = Marshal.load(Marshal.dump(serializable_body))
17
19
 
18
20
  # RestClient will not send a multipart request if there are no attachments
19
- # so we need to return the message payload to be used as a json payload
20
- return [request_body, []] if attachments.empty?
21
+ return [request_body_copy, []] if attachments.empty?
21
22
 
22
23
  # Prepare the data to return
23
- message_payload = request_body.to_json
24
+ message_payload = request_body_copy.to_json
24
25
 
25
26
  form_data = {}
26
27
  opened_files = []
27
28
 
28
29
  attachments.each_with_index do |attachment, index|
29
30
  file = attachment[:content] || attachment["content"]
31
+ if file.respond_to?(:closed?) && file.closed?
32
+ unless attachment[:file_path]
33
+ raise ArgumentError, "The file at index #{index} is closed and no file_path was provided."
34
+ end
35
+
36
+ file = File.open(attachment[:file_path], "rb")
37
+ end
38
+
30
39
  form_data.merge!({ "file#{index}" => file })
31
40
  opened_files << file
32
41
  end
@@ -82,9 +91,10 @@ module Nylas
82
91
 
83
92
  # Build the request to attach a file to a message/draft object.
84
93
  # @param file_path [String] The path to the file to attach.
94
+ # @param filename [String] The name of the attached file. Optional, derived from file_path by default.
85
95
  # @return [Hash] The request that will attach the file to the message/draft
86
- def self.attach_file_request_builder(file_path)
87
- filename = File.basename(file_path)
96
+ def self.attach_file_request_builder(file_path, filename = nil)
97
+ filename ||= File.basename(file_path)
88
98
  content_type = MIME::Types.type_for(file_path)
89
99
  content_type = if !content_type.nil? && !content_type.empty?
90
100
  content_type.first.to_s
@@ -98,7 +108,8 @@ module Nylas
98
108
  filename: filename,
99
109
  content_type: content_type,
100
110
  size: size,
101
- content: content
111
+ content: content,
112
+ file_path: file_path
102
113
  }
103
114
  end
104
115
  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.1.1"
4
+ VERSION = "6.2.1"
5
5
  end
data/lib/nylas.rb CHANGED
@@ -43,5 +43,6 @@ require_relative "nylas/resources/smart_compose"
43
43
  require_relative "nylas/resources/threads"
44
44
  require_relative "nylas/resources/redirect_uris"
45
45
  require_relative "nylas/resources/webhooks"
46
+ require_relative "nylas/resources/scheduler"
46
47
 
47
48
  require_relative "nylas/utils/file_utils"
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.1.1
4
+ version: 6.2.1
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-08-20 00:00:00.000000000 Z
11
+ date: 2024-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types
@@ -31,12 +31,26 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: 3.5.1
33
33
  - !ruby/object:Gem::Dependency
34
- name: rest-client
34
+ name: ostruct
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '2.1'
39
+ version: '0.6'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.6'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rest-client
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 2.0.0
40
54
  - - "<"
41
55
  - !ruby/object:Gem::Version
42
56
  version: '3.0'
@@ -44,9 +58,9 @@ dependencies:
44
58
  prerelease: false
45
59
  version_requirements: !ruby/object:Gem::Requirement
46
60
  requirements:
47
- - - "~>"
61
+ - - ">="
48
62
  - !ruby/object:Gem::Version
49
- version: '2.1'
63
+ version: 2.0.0
50
64
  - - "<"
51
65
  - !ruby/object:Gem::Version
52
66
  version: '3.0'
@@ -237,7 +251,10 @@ files:
237
251
  - lib/nylas/resources/applications.rb
238
252
  - lib/nylas/resources/attachments.rb
239
253
  - lib/nylas/resources/auth.rb
254
+ - lib/nylas/resources/availability.rb
255
+ - lib/nylas/resources/bookings.rb
240
256
  - lib/nylas/resources/calendars.rb
257
+ - lib/nylas/resources/configurations.rb
241
258
  - lib/nylas/resources/connectors.rb
242
259
  - lib/nylas/resources/contacts.rb
243
260
  - lib/nylas/resources/credentials.rb
@@ -248,6 +265,8 @@ files:
248
265
  - lib/nylas/resources/messages.rb
249
266
  - lib/nylas/resources/redirect_uris.rb
250
267
  - lib/nylas/resources/resource.rb
268
+ - lib/nylas/resources/scheduler.rb
269
+ - lib/nylas/resources/sessions.rb
251
270
  - lib/nylas/resources/smart_compose.rb
252
271
  - lib/nylas/resources/threads.rb
253
272
  - lib/nylas/resources/webhooks.rb
@@ -278,7 +297,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
278
297
  - !ruby/object:Gem::Version
279
298
  version: '0'
280
299
  requirements: []
281
- rubygems_version: 3.4.10
300
+ rubygems_version: 3.5.22
282
301
  signing_key:
283
302
  specification_version: 4
284
303
  summary: Gem for interacting with the Nylas API