nylas 6.0.0.beta.1 → 6.0.0.beta.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nylas/client.rb +68 -9
- data/lib/nylas/errors.rb +33 -11
- data/lib/nylas/handler/api_operations.rb +7 -5
- data/lib/nylas/handler/http_client.rb +98 -34
- data/lib/nylas/resources/applications.rb +1 -1
- data/lib/nylas/resources/attachments.rb +65 -0
- data/lib/nylas/resources/auth.rb +15 -14
- data/lib/nylas/resources/calendars.rb +83 -13
- data/lib/nylas/resources/connectors.rb +80 -0
- data/lib/nylas/resources/contacts.rb +89 -0
- data/lib/nylas/resources/credentials.rb +75 -0
- data/lib/nylas/resources/drafts.rb +102 -0
- data/lib/nylas/resources/events.rb +89 -11
- data/lib/nylas/resources/folders.rb +73 -0
- data/lib/nylas/resources/grants.rb +47 -9
- data/lib/nylas/resources/messages.rb +126 -0
- data/lib/nylas/resources/redirect_uris.rb +59 -11
- data/lib/nylas/resources/resource.rb +2 -2
- data/lib/nylas/resources/smart_compose.rb +36 -0
- data/lib/nylas/resources/threads.rb +62 -0
- data/lib/nylas/resources/webhooks.rb +62 -11
- data/lib/nylas/utils/file_utils.rb +54 -0
- data/lib/nylas/version.rb +1 -1
- data/lib/nylas.rb +12 -1
- metadata +32 -4
- data/lib/nylas/handler/admin_api_operations.rb +0 -95
- data/lib/nylas/handler/grants_api_operations.rb +0 -99
@@ -1,20 +1,58 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "resource"
|
4
|
-
require_relative "../handler/
|
4
|
+
require_relative "../handler/api_operations"
|
5
5
|
|
6
6
|
module Nylas
|
7
7
|
# Grants
|
8
8
|
class Grants < Resource
|
9
|
-
include
|
10
|
-
include
|
11
|
-
include
|
12
|
-
include AdminApiOperations::Destroy
|
13
|
-
include AdminApiOperations::Find
|
9
|
+
include ApiOperations::Get
|
10
|
+
include ApiOperations::Put
|
11
|
+
include ApiOperations::Delete
|
14
12
|
|
15
|
-
#
|
16
|
-
|
17
|
-
|
13
|
+
# Return all grants.
|
14
|
+
#
|
15
|
+
# @param query_params [Hash, nil] Query params to pass to the request.
|
16
|
+
# @return [Array(Array(Hash), String)] The list of grants and API Request ID.
|
17
|
+
def list(query_params: nil)
|
18
|
+
get(
|
19
|
+
path: "#{api_uri}/v3/grant",
|
20
|
+
query_params: query_params
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Return a grant.
|
25
|
+
#
|
26
|
+
# @param grant_id [String] The id of the grant to return.
|
27
|
+
# @return [Array(Hash, String)] The grant and API request ID.
|
28
|
+
def find(grant_id:)
|
29
|
+
get(
|
30
|
+
path: "#{api_uri}/v3/grant/#{grant_id}"
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Update a grant.
|
35
|
+
#
|
36
|
+
# @param grant_id [String] The id of the grant to update.
|
37
|
+
# @param request_body [Hash] The values to update the grant with
|
38
|
+
# @return [Array(Hash, String)] The updated grant and API Request ID.
|
39
|
+
def update(grant_id:, request_body:)
|
40
|
+
put(
|
41
|
+
path: "#{api_uri}/v3/grant/#{grant_id}",
|
42
|
+
request_body: request_body
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Delete a grant.
|
47
|
+
#
|
48
|
+
# @param grant_id [String] The id of the grant to delete.
|
49
|
+
# @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
|
50
|
+
def destroy(grant_id:)
|
51
|
+
_, request_id = delete(
|
52
|
+
path: "#{api_uri}/v3/grant/#{grant_id}"
|
53
|
+
)
|
54
|
+
|
55
|
+
[true, request_id]
|
18
56
|
end
|
19
57
|
end
|
20
58
|
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "resource"
|
4
|
+
require_relative "smart_compose"
|
5
|
+
require_relative "../handler/api_operations"
|
6
|
+
require_relative "../utils/file_utils"
|
7
|
+
|
8
|
+
module Nylas
|
9
|
+
# Nylas Messages API
|
10
|
+
class Messages < Resource
|
11
|
+
include ApiOperations::Get
|
12
|
+
include ApiOperations::Post
|
13
|
+
include ApiOperations::Put
|
14
|
+
include ApiOperations::Delete
|
15
|
+
|
16
|
+
attr_reader :smart_compose
|
17
|
+
|
18
|
+
# Initializes the messages resource.
|
19
|
+
# @param sdk_instance [Nylas::API] The API instance to which the resource is bound.
|
20
|
+
def initialize(sdk_instance)
|
21
|
+
super(sdk_instance)
|
22
|
+
@smart_compose = SmartCompose.new(sdk_instance)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Return all messages.
|
26
|
+
#
|
27
|
+
# @param identifier [String] Grant ID or email account to query.
|
28
|
+
# @param query_params [Hash, nil] Query params to pass to the request.
|
29
|
+
# @return [Array(Array(Hash), String)] The list of messages and API Request ID.
|
30
|
+
def list(identifier:, query_params: nil)
|
31
|
+
get(
|
32
|
+
path: "#{api_uri}/v3/grants/#{identifier}/messages",
|
33
|
+
query_params: query_params
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Return a message.
|
38
|
+
#
|
39
|
+
# @param identifier [String] Grant ID or email account to query.
|
40
|
+
# @param message_id [String] The id of the message to return.
|
41
|
+
# @return [Array(Hash, String)] The message and API request ID.
|
42
|
+
def find(identifier:, message_id:)
|
43
|
+
get(
|
44
|
+
path: "#{api_uri}/v3/grants/#{identifier}/messages/#{message_id}"
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Update a message.
|
49
|
+
#
|
50
|
+
# @param identifier [String] Grant ID or email account in which to update an object.
|
51
|
+
# @param message_id [String] The id of the message to update.
|
52
|
+
# @param request_body [Hash] The values to update the message with
|
53
|
+
# @return [Array(Hash, String)] The updated message and API Request ID.
|
54
|
+
def update(identifier:, message_id:, request_body:)
|
55
|
+
put(
|
56
|
+
path: "#{api_uri}/v3/grants/#{identifier}/messages/#{message_id}",
|
57
|
+
request_body: request_body
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Delete a message.
|
62
|
+
#
|
63
|
+
# @param identifier [String] Grant ID or email account from which to delete an object.
|
64
|
+
# @param message_id [String] The id of the message to delete.
|
65
|
+
# @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
|
66
|
+
def destroy(identifier:, message_id:)
|
67
|
+
_, request_id = delete(
|
68
|
+
path: "#{api_uri}/v3/grants/#{identifier}/messages/#{message_id}"
|
69
|
+
)
|
70
|
+
|
71
|
+
[true, request_id]
|
72
|
+
end
|
73
|
+
|
74
|
+
# Send a message.
|
75
|
+
#
|
76
|
+
# @param identifier [String] Grant ID or email account from which to delete an object.
|
77
|
+
# @param request_body [Hash] The values to create the message with.
|
78
|
+
# If you're attaching files, you must pass an array of [File] objects, or
|
79
|
+
# you can use {FileUtils::attach_file_request_builder} to build each object attach.
|
80
|
+
# @return [Array(Hash, String)] The sent message and the API Request ID.
|
81
|
+
def send(identifier:, request_body:)
|
82
|
+
form_body, opened_files = FileUtils.build_form_request(request_body)
|
83
|
+
|
84
|
+
response = post(
|
85
|
+
path: "#{api_uri}/v3/grants/#{identifier}/messages/send",
|
86
|
+
request_body: form_body
|
87
|
+
)
|
88
|
+
|
89
|
+
opened_files.each(&:close)
|
90
|
+
|
91
|
+
response
|
92
|
+
end
|
93
|
+
|
94
|
+
# Retrieve your scheduled messages.
|
95
|
+
#
|
96
|
+
# @param identifier [String] Grant ID or email account from which to find the scheduled message from.
|
97
|
+
# @param schedule_id [String] The id of the scheduled message to stop.
|
98
|
+
# @return [Array(Hash, String)] The list of scheduled messages and the API Request ID.
|
99
|
+
def list_scheduled_messages(identifier:, schedule_id:)
|
100
|
+
get(
|
101
|
+
path: "#{api_uri}/v3/grants/#{identifier}/messages/schedules/#{schedule_id}"
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Retrieve your scheduled messages.
|
106
|
+
#
|
107
|
+
# @param identifier [String] Grant ID or email account from which to list the scheduled messages from.
|
108
|
+
# @return [Array(Hash, String)] The scheduled message and the API Request ID.
|
109
|
+
def find_scheduled_messages(identifier:)
|
110
|
+
get(
|
111
|
+
path: "#{api_uri}/v3/grants/#{identifier}/messages/schedules"
|
112
|
+
)
|
113
|
+
end
|
114
|
+
|
115
|
+
# Stop a scheduled message.
|
116
|
+
#
|
117
|
+
# @param identifier [String] Grant ID or email account from which to list the scheduled messages from.
|
118
|
+
# @param schedule_id [String] The id of the scheduled message to stop..
|
119
|
+
# @return [Array(Hash, String)] The scheduled message and the API Request ID.
|
120
|
+
def stop_scheduled_messages(identifier:, schedule_id:)
|
121
|
+
delete(
|
122
|
+
path: "#{api_uri}/v3/grants/#{identifier}/messages/schedules/#{schedule_id}"
|
123
|
+
)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -1,20 +1,68 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "resource"
|
4
|
-
require_relative "../handler/
|
4
|
+
require_relative "../handler/api_operations"
|
5
5
|
|
6
6
|
module Nylas
|
7
|
-
#
|
7
|
+
# A collection of redirect URI related API endpoints.
|
8
8
|
class RedirectUris < Resource
|
9
|
-
include
|
10
|
-
include
|
11
|
-
include
|
12
|
-
include
|
13
|
-
|
14
|
-
|
15
|
-
#
|
16
|
-
|
17
|
-
|
9
|
+
include ApiOperations::Get
|
10
|
+
include ApiOperations::Post
|
11
|
+
include ApiOperations::Put
|
12
|
+
include ApiOperations::Delete
|
13
|
+
|
14
|
+
# Return all redirect uris.
|
15
|
+
#
|
16
|
+
# @return [Array(Array(Hash), String)] The list of redirect uris and API Request ID.
|
17
|
+
def list
|
18
|
+
get(
|
19
|
+
path: "#{api_uri}/v3/applications/redirect-uris"
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Return a redirect uri.
|
24
|
+
#
|
25
|
+
# @param redirect_uri_id [String] The id of the redirect uri to return.
|
26
|
+
# @return [Array(Hash, String)] The redirect uri and API request ID.
|
27
|
+
def find(redirect_uri_id:)
|
28
|
+
get(
|
29
|
+
path: "#{api_uri}/v3/applications/redirect-uris/#{redirect_uri_id}"
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Create a redirect uri.
|
34
|
+
#
|
35
|
+
# @param request_body [Hash] The values to create the redirect uri with.
|
36
|
+
# @return [Array(Hash, String)] The created redirect uri and API Request ID.
|
37
|
+
def create(request_body:)
|
38
|
+
post(
|
39
|
+
path: "#{api_uri}/v3/applications/redirect-uris",
|
40
|
+
request_body: request_body
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Update a redirect uri.
|
45
|
+
#
|
46
|
+
# @param redirect_uri_id [String] The id of the redirect uri to update.
|
47
|
+
# @param request_body [Hash] The values to update the redirect uri with
|
48
|
+
# @return [Array(Hash, String)] The updated redirect uri and API Request ID.
|
49
|
+
def update(redirect_uri_id:, request_body:)
|
50
|
+
put(
|
51
|
+
path: "#{api_uri}/v3/applications/redirect-uris/#{redirect_uri_id}",
|
52
|
+
request_body: request_body
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Delete a redirect uri.
|
57
|
+
#
|
58
|
+
# @param redirect_uri_id [String] The id of the redirect uri to delete.
|
59
|
+
# @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
|
60
|
+
def destroy(redirect_uri_id:)
|
61
|
+
_, request_id = delete(
|
62
|
+
path: "#{api_uri}/v3/applications/redirect-uris/#{redirect_uri_id}"
|
63
|
+
)
|
64
|
+
|
65
|
+
[true, request_id]
|
18
66
|
end
|
19
67
|
end
|
20
68
|
end
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module Nylas
|
4
4
|
# NOTE: BaseResource is the base class for all Nylas API resources.
|
5
|
+
# Used by all Nylas API resources
|
5
6
|
class Resource
|
6
7
|
# Initializes a resource.
|
7
|
-
def initialize(
|
8
|
-
@resource_name = resource_name
|
8
|
+
def initialize(sdk_instance)
|
9
9
|
@api_key = sdk_instance.api_key
|
10
10
|
@api_uri = sdk_instance.api_uri
|
11
11
|
@timeout = sdk_instance.timeout
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "resource"
|
4
|
+
require_relative "../handler/api_operations"
|
5
|
+
|
6
|
+
module Nylas
|
7
|
+
# Nylas Smart Compose API
|
8
|
+
class SmartCompose < Resource
|
9
|
+
include ApiOperations::Post
|
10
|
+
|
11
|
+
# Compose a message.
|
12
|
+
#
|
13
|
+
# @param identifier [String] Grant ID or email account to generate a message suggestion for.
|
14
|
+
# @param request_body [Hash] The prompt that smart compose will use to generate a message suggestion.
|
15
|
+
# @return [Array(Hash, String)] The generated message and API Request ID.
|
16
|
+
def compose_message(identifier:, request_body:)
|
17
|
+
post(
|
18
|
+
path: "#{api_uri}/v3/grants/#{identifier}/messages/smart-compose",
|
19
|
+
request_body: request_body
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Compose a message reply.
|
24
|
+
#
|
25
|
+
# @param identifier [String] Grant ID or email account to generate a message suggestion for.
|
26
|
+
# @param message_id [String] The id of the message to reply to.
|
27
|
+
# @param request_body [Hash] The prompt that smart compose will use to generate a message reply.
|
28
|
+
# @return [Array(Hash, String)] The generated message reply and API Request ID.
|
29
|
+
def compose_message_reply(identifier:, message_id:, request_body:)
|
30
|
+
post(
|
31
|
+
path: "#{api_uri}/v3/grants/#{identifier}/messages/#{message_id}/smart-compose",
|
32
|
+
request_body: request_body
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "resource"
|
4
|
+
require_relative "../handler/api_operations"
|
5
|
+
|
6
|
+
module Nylas
|
7
|
+
# Nylas Threads API
|
8
|
+
class Threads < Resource
|
9
|
+
include ApiOperations::Get
|
10
|
+
include ApiOperations::Put
|
11
|
+
include ApiOperations::Delete
|
12
|
+
|
13
|
+
# Return all threads.
|
14
|
+
#
|
15
|
+
# @param identifier [String] Grant ID or email account to query.
|
16
|
+
# @param query_params [Hash] Query params to pass to the request.
|
17
|
+
# @return [Array(Array(Hash), String)] The list of threads and API Request ID.
|
18
|
+
def list(identifier:, query_params: nil)
|
19
|
+
get(
|
20
|
+
path: "#{api_uri}/v3/grants/#{identifier}/threads",
|
21
|
+
query_params: query_params
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Return an thread.
|
26
|
+
#
|
27
|
+
# @param identifier [String] Grant ID or email account to query.
|
28
|
+
# @param thread_id [String] The id of the thread to return.
|
29
|
+
# @return [Array(Hash, String)] The thread and API request ID.
|
30
|
+
def find(identifier:, thread_id:)
|
31
|
+
get(
|
32
|
+
path: "#{api_uri}/v3/grants/#{identifier}/threads/#{thread_id}"
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Update an thread.
|
37
|
+
#
|
38
|
+
# @param identifier [String] Grant ID or email account in which to update the thread.
|
39
|
+
# @param thread_id [String] The id of the thread to update.
|
40
|
+
# @param request_body [Hash] The values to update the thread with
|
41
|
+
# @return [Array(Hash, String)] The updated thread and API Request ID.
|
42
|
+
def update(identifier:, thread_id:, request_body:)
|
43
|
+
put(
|
44
|
+
path: "#{api_uri}/v3/grants/#{identifier}/threads/#{thread_id}",
|
45
|
+
request_body: request_body
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Delete an thread.
|
50
|
+
#
|
51
|
+
# @param identifier [String] Grant ID or email account from which to delete the thread.
|
52
|
+
# @param thread_id [String] The id of the thread to delete.
|
53
|
+
# @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
|
54
|
+
def destroy(identifier:, thread_id:)
|
55
|
+
_, request_id = delete(
|
56
|
+
path: "#{api_uri}/v3/grants/#{identifier}/threads/#{thread_id}"
|
57
|
+
)
|
58
|
+
|
59
|
+
[true, request_id]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "resource"
|
4
|
-
require_relative "../handler/
|
4
|
+
require_relative "../handler/api_operations"
|
5
5
|
|
6
6
|
module Nylas
|
7
7
|
# Module representing the possible 'trigger' values in a Webhook.
|
@@ -19,19 +19,70 @@ module Nylas
|
|
19
19
|
GRANT_EXPIRED = "grant.expired"
|
20
20
|
MESSAGE_SEND_SUCCESS = "message.send_success"
|
21
21
|
MESSAGE_SEND_FAILED = "message.send_failed"
|
22
|
+
MESSAGE_OPENED = "message.opened"
|
23
|
+
MESSAGE_LINK_CLICKED = "message.link_clicked"
|
24
|
+
THREAD_REPLIED = "thread.replied"
|
22
25
|
end
|
23
26
|
|
24
|
-
# Webhooks
|
27
|
+
# Nylas Webhooks API
|
25
28
|
class Webhooks < Resource
|
26
|
-
include
|
27
|
-
include
|
28
|
-
include
|
29
|
-
include
|
30
|
-
|
31
|
-
|
32
|
-
#
|
33
|
-
|
34
|
-
|
29
|
+
include ApiOperations::Get
|
30
|
+
include ApiOperations::Post
|
31
|
+
include ApiOperations::Put
|
32
|
+
include ApiOperations::Delete
|
33
|
+
|
34
|
+
# Return all webhooks.
|
35
|
+
#
|
36
|
+
# @return [Array(Array(Hash), String)] The list of webhooks and API Request ID.
|
37
|
+
def list
|
38
|
+
get(
|
39
|
+
path: "#{api_uri}/v3/webhooks"
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Return a webhook.
|
44
|
+
#
|
45
|
+
# @param webhook_id [String] The id of the webhook to return.
|
46
|
+
# @return [Array(Hash, String)] The webhook and API request ID.
|
47
|
+
def find(webhook_id:)
|
48
|
+
get(
|
49
|
+
path: "#{api_uri}/v3/webhooks/#{webhook_id}"
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Create a webhook.
|
54
|
+
#
|
55
|
+
# @param request_body [Hash] The values to create the webhook with.
|
56
|
+
# @return [Array(Hash, String)] The created webhook and API Request ID.
|
57
|
+
def create(request_body:)
|
58
|
+
post(
|
59
|
+
path: "#{api_uri}/v3/webhooks",
|
60
|
+
request_body: request_body
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Update a webhook.
|
65
|
+
#
|
66
|
+
# @param webhook_id [String] The id of the webhook to update.
|
67
|
+
# @param request_body [Hash] The values to update the webhook with
|
68
|
+
# @return [Array(Hash, String)] The updated webhook and API Request ID.
|
69
|
+
def update(webhook_id:, request_body:)
|
70
|
+
put(
|
71
|
+
path: "#{api_uri}/v3/webhooks/#{webhook_id}",
|
72
|
+
request_body: request_body
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Delete a webhook.
|
77
|
+
#
|
78
|
+
# @param webhook_id [String] The id of the webhook to delete.
|
79
|
+
# @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
|
80
|
+
def destroy(webhook_id:)
|
81
|
+
_, request_id = delete(
|
82
|
+
path: "#{api_uri}/v3/webhooks/#{webhook_id}"
|
83
|
+
)
|
84
|
+
|
85
|
+
[true, request_id]
|
35
86
|
end
|
36
87
|
end
|
37
88
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mime/types"
|
4
|
+
|
5
|
+
module Nylas
|
6
|
+
# A collection of file-related utilities.
|
7
|
+
module FileUtils
|
8
|
+
# Build a form request for the API.
|
9
|
+
# @param request_body The values to create the message with.
|
10
|
+
# @return The form data to send to the API and the opened files.
|
11
|
+
# @!visibility private
|
12
|
+
def self.build_form_request(request_body)
|
13
|
+
attachments = request_body.delete(:attachments) || request_body.delete("attachments") || []
|
14
|
+
|
15
|
+
# RestClient will not send a multipart request if there are no attachments
|
16
|
+
# so we need to return the message payload to be used as a json payload
|
17
|
+
return [request_body, []] if attachments.empty?
|
18
|
+
|
19
|
+
# Prepare the data to return
|
20
|
+
message_payload = request_body.to_json
|
21
|
+
|
22
|
+
form_data = {}
|
23
|
+
opened_files = []
|
24
|
+
|
25
|
+
attachments.each_with_index do |attachment, index|
|
26
|
+
file = attachment[:content] || attachment["content"]
|
27
|
+
form_data.merge!({ "file#{index}" => file })
|
28
|
+
opened_files << file
|
29
|
+
end
|
30
|
+
|
31
|
+
form_data.merge!({ "multipart" => true, "message" => message_payload })
|
32
|
+
|
33
|
+
[form_data, opened_files]
|
34
|
+
end
|
35
|
+
|
36
|
+
# Build the request to attach a file to a message/draft object.
|
37
|
+
# @param file_path [String] The path to the file to attach.
|
38
|
+
# @return [Hash] The request that will attach the file to the message/draft
|
39
|
+
def self.attach_file_request_builder(file_path)
|
40
|
+
filename = File.basename(file_path)
|
41
|
+
content_type = MIME::Types.type_for(file_path).first.to_s
|
42
|
+
content_type = "application/octet-stream" if content_type.empty?
|
43
|
+
size = File.size(file_path)
|
44
|
+
content = File.new(file_path, "rb")
|
45
|
+
|
46
|
+
{
|
47
|
+
filename: filename,
|
48
|
+
content_type: content_type,
|
49
|
+
size: size,
|
50
|
+
content: content
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/nylas/version.rb
CHANGED
data/lib/nylas.rb
CHANGED
@@ -7,7 +7,7 @@ require "rest-client"
|
|
7
7
|
# See https://github.com/sparklemotion/http-cookie/issues/27
|
8
8
|
# and https://github.com/sparklemotion/http-cookie/issues/6
|
9
9
|
#
|
10
|
-
# CookieJar uses unsafe class caching for dynamically loading cookie jars.
|
10
|
+
# CookieJar uses unsafe class caching for dynamically loading cookie jars.
|
11
11
|
# If two rest-client instances are instantiated at the same time (in threads), non-deterministic
|
12
12
|
# behaviour can occur whereby the Hash cookie jar isn't properly loaded and cached.
|
13
13
|
# Forcing an instantiation of the jar onload will force the CookieJar to load before the system has
|
@@ -28,9 +28,20 @@ require_relative "nylas/config"
|
|
28
28
|
require_relative "nylas/handler/http_client"
|
29
29
|
|
30
30
|
require_relative "nylas/resources/applications"
|
31
|
+
require_relative "nylas/resources/attachments"
|
31
32
|
require_relative "nylas/resources/auth"
|
32
33
|
require_relative "nylas/resources/calendars"
|
34
|
+
require_relative "nylas/resources/connectors"
|
35
|
+
require_relative "nylas/resources/contacts"
|
36
|
+
require_relative "nylas/resources/credentials"
|
37
|
+
require_relative "nylas/resources/drafts"
|
33
38
|
require_relative "nylas/resources/events"
|
39
|
+
require_relative "nylas/resources/folders"
|
34
40
|
require_relative "nylas/resources/grants"
|
41
|
+
require_relative "nylas/resources/messages"
|
42
|
+
require_relative "nylas/resources/smart_compose"
|
43
|
+
require_relative "nylas/resources/threads"
|
35
44
|
require_relative "nylas/resources/redirect_uris"
|
36
45
|
require_relative "nylas/resources/webhooks"
|
46
|
+
|
47
|
+
require_relative "nylas/utils/file_utils"
|
metadata
CHANGED
@@ -1,15 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nylas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.0.beta.
|
4
|
+
version: 6.0.0.beta.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:
|
11
|
+
date: 2024-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mime-types
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.5'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.5.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.5'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.5.1
|
13
33
|
- !ruby/object:Gem::Dependency
|
14
34
|
name: rest-client
|
15
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,18 +232,26 @@ files:
|
|
212
232
|
- lib/nylas/client.rb
|
213
233
|
- lib/nylas/config.rb
|
214
234
|
- lib/nylas/errors.rb
|
215
|
-
- lib/nylas/handler/admin_api_operations.rb
|
216
235
|
- lib/nylas/handler/api_operations.rb
|
217
|
-
- lib/nylas/handler/grants_api_operations.rb
|
218
236
|
- lib/nylas/handler/http_client.rb
|
219
237
|
- lib/nylas/resources/applications.rb
|
238
|
+
- lib/nylas/resources/attachments.rb
|
220
239
|
- lib/nylas/resources/auth.rb
|
221
240
|
- lib/nylas/resources/calendars.rb
|
241
|
+
- lib/nylas/resources/connectors.rb
|
242
|
+
- lib/nylas/resources/contacts.rb
|
243
|
+
- lib/nylas/resources/credentials.rb
|
244
|
+
- lib/nylas/resources/drafts.rb
|
222
245
|
- lib/nylas/resources/events.rb
|
246
|
+
- lib/nylas/resources/folders.rb
|
223
247
|
- lib/nylas/resources/grants.rb
|
248
|
+
- lib/nylas/resources/messages.rb
|
224
249
|
- lib/nylas/resources/redirect_uris.rb
|
225
250
|
- lib/nylas/resources/resource.rb
|
251
|
+
- lib/nylas/resources/smart_compose.rb
|
252
|
+
- lib/nylas/resources/threads.rb
|
226
253
|
- lib/nylas/resources/webhooks.rb
|
254
|
+
- lib/nylas/utils/file_utils.rb
|
227
255
|
- lib/nylas/version.rb
|
228
256
|
homepage:
|
229
257
|
licenses:
|