nylas 6.2.0 → 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 +4 -4
- data/lib/nylas/client.rb +7 -0
- data/lib/nylas/resources/availability.rb +22 -0
- data/lib/nylas/resources/bookings.rb +77 -0
- data/lib/nylas/resources/configurations.rb +76 -0
- data/lib/nylas/resources/folders.rb +4 -2
- data/lib/nylas/resources/scheduler.rb +35 -0
- data/lib/nylas/resources/sessions.rb +33 -0
- data/lib/nylas/resources/threads.rb +4 -2
- data/lib/nylas/utils/file_utils.rb +3 -2
- data/lib/nylas/version.rb +1 -1
- data/lib/nylas.rb +1 -0
- metadata +8 -4
- data/lib/nylas/test.rb +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d91ae3ccc20cfd009bfd1d7faf5e2d67488b1eee292823b0e0ec35cf56f56b58
|
4
|
+
data.tar.gz: 22f379f3e2d40936efbab14391e21ec92a26551917286e6451ed99047e258bb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -27,10 +27,12 @@ module Nylas
|
|
27
27
|
#
|
28
28
|
# @param identifier [String] Grant ID or email account to query.
|
29
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.
|
30
31
|
# @return [Array(Hash, String)] The folder and API request ID.
|
31
|
-
def find(identifier:, folder_id:)
|
32
|
+
def find(identifier:, folder_id:, query_params: nil)
|
32
33
|
get(
|
33
|
-
path: "#{api_uri}/v3/grants/#{identifier}/folders/#{folder_id}"
|
34
|
+
path: "#{api_uri}/v3/grants/#{identifier}/folders/#{folder_id}",
|
35
|
+
query_params: query_params
|
34
36
|
)
|
35
37
|
end
|
36
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
|
|
@@ -91,9 +91,10 @@ module Nylas
|
|
91
91
|
|
92
92
|
# Build the request to attach a file to a message/draft object.
|
93
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.
|
94
95
|
# @return [Hash] The request that will attach the file to the message/draft
|
95
|
-
def self.attach_file_request_builder(file_path)
|
96
|
-
filename
|
96
|
+
def self.attach_file_request_builder(file_path, filename = nil)
|
97
|
+
filename ||= File.basename(file_path)
|
97
98
|
content_type = MIME::Types.type_for(file_path)
|
98
99
|
content_type = if !content_type.nil? && !content_type.empty?
|
99
100
|
content_type.first.to_s
|
data/lib/nylas/version.rb
CHANGED
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.2.
|
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-
|
11
|
+
date: 2024-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime-types
|
@@ -251,7 +251,10 @@ files:
|
|
251
251
|
- lib/nylas/resources/applications.rb
|
252
252
|
- lib/nylas/resources/attachments.rb
|
253
253
|
- lib/nylas/resources/auth.rb
|
254
|
+
- lib/nylas/resources/availability.rb
|
255
|
+
- lib/nylas/resources/bookings.rb
|
254
256
|
- lib/nylas/resources/calendars.rb
|
257
|
+
- lib/nylas/resources/configurations.rb
|
255
258
|
- lib/nylas/resources/connectors.rb
|
256
259
|
- lib/nylas/resources/contacts.rb
|
257
260
|
- lib/nylas/resources/credentials.rb
|
@@ -262,10 +265,11 @@ files:
|
|
262
265
|
- lib/nylas/resources/messages.rb
|
263
266
|
- lib/nylas/resources/redirect_uris.rb
|
264
267
|
- lib/nylas/resources/resource.rb
|
268
|
+
- lib/nylas/resources/scheduler.rb
|
269
|
+
- lib/nylas/resources/sessions.rb
|
265
270
|
- lib/nylas/resources/smart_compose.rb
|
266
271
|
- lib/nylas/resources/threads.rb
|
267
272
|
- lib/nylas/resources/webhooks.rb
|
268
|
-
- lib/nylas/test.rb
|
269
273
|
- lib/nylas/utils/file_utils.rb
|
270
274
|
- lib/nylas/version.rb
|
271
275
|
homepage:
|
@@ -293,7 +297,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
293
297
|
- !ruby/object:Gem::Version
|
294
298
|
version: '0'
|
295
299
|
requirements: []
|
296
|
-
rubygems_version: 3.
|
300
|
+
rubygems_version: 3.5.22
|
297
301
|
signing_key:
|
298
302
|
specification_version: 4
|
299
303
|
summary: Gem for interacting with the Nylas API
|
data/lib/nylas/test.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'nylas'
|
4
|
-
|
5
|
-
nylas = Nylas::Client.new(
|
6
|
-
api_key: "nyk_v0_tRgvnXpqESPGVaaf5QTDzoSYet94natpftScKTT8auH6Www49RJUQ1WJ5VAWplqu"
|
7
|
-
)
|
8
|
-
|
9
|
-
# file = Nylas::FileUtils.attach_file_request_builder("/Users/mostafa.r@nylas.com/Downloads/05i7gc9wvgv51.jpg")
|
10
|
-
file = Nylas::FileUtils.attach_file_request_builder("/Users/mostafa.r@nylas.com/Downloads/zara_reciept.pdf")
|
11
|
-
|
12
|
-
request_body = {
|
13
|
-
subject: "Ruby SDK attachment test - 8.30.24 x1",
|
14
|
-
to: [{email: "mostafa.r@nylas.com"}],
|
15
|
-
attachments: [file],
|
16
|
-
}
|
17
|
-
|
18
|
-
puts "Before request"
|
19
|
-
puts request_body
|
20
|
-
|
21
|
-
begin
|
22
|
-
email, _ = nylas.messages.send(identifier: "mostafa.r@nylas.com", request_body: request_body)
|
23
|
-
puts "Email sent successfully: #{email}"
|
24
|
-
rescue StandardError => e
|
25
|
-
puts "An error occurred: #{e.message}"
|
26
|
-
end
|
27
|
-
|
28
|
-
puts "After request"
|
29
|
-
puts request_body
|
30
|
-
|
31
|
-
# begin
|
32
|
-
# email, _ = nylas.messages.send(identifier: "mostafa.r@nylas.com", request_body: request_body)
|
33
|
-
# puts "Email sent successfully: #{email}"
|
34
|
-
# rescue StandardError => e1
|
35
|
-
# puts "An error occurred: #{e1.message}"
|
36
|
-
# end
|