nylas 6.0.0.beta.1 → 6.0.0.beta.2
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 +54 -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 +17 -3
- data/lib/nylas/resources/calendars.rb +83 -13
- data/lib/nylas/resources/connectors.rb +80 -0
- data/lib/nylas/resources/credentials.rb +75 -0
- data/lib/nylas/resources/drafts.rb +91 -0
- data/lib/nylas/resources/events.rb +74 -11
- data/lib/nylas/resources/folders.rb +73 -0
- data/lib/nylas/resources/grants.rb +60 -10
- 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 +59 -11
- data/lib/nylas/utils/file_utils.rb +49 -0
- data/lib/nylas/version.rb +1 -1
- data/lib/nylas.rb +11 -1
- metadata +31 -4
- data/lib/nylas/handler/admin_api_operations.rb +0 -95
- data/lib/nylas/handler/grants_api_operations.rb +0 -99
@@ -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.
|
@@ -21,17 +21,65 @@ module Nylas
|
|
21
21
|
MESSAGE_SEND_FAILED = "message.send_failed"
|
22
22
|
end
|
23
23
|
|
24
|
-
# Webhooks
|
24
|
+
# Nylas Webhooks API
|
25
25
|
class Webhooks < Resource
|
26
|
-
include
|
27
|
-
include
|
28
|
-
include
|
29
|
-
include
|
30
|
-
|
31
|
-
|
32
|
-
#
|
33
|
-
|
34
|
-
|
26
|
+
include ApiOperations::Get
|
27
|
+
include ApiOperations::Post
|
28
|
+
include ApiOperations::Put
|
29
|
+
include ApiOperations::Delete
|
30
|
+
|
31
|
+
# Return all webhooks.
|
32
|
+
#
|
33
|
+
# @return [Array(Array(Hash), String)] The list of webhooks and API Request ID.
|
34
|
+
def list
|
35
|
+
get(
|
36
|
+
path: "#{api_uri}/v3/webhooks"
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Return a webhook.
|
41
|
+
#
|
42
|
+
# @param webhook_id [String] The id of the webhook to return.
|
43
|
+
# @return [Array(Hash, String)] The webhook and API request ID.
|
44
|
+
def find(webhook_id:)
|
45
|
+
get(
|
46
|
+
path: "#{api_uri}/v3/webhooks/#{webhook_id}"
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Create a webhook.
|
51
|
+
#
|
52
|
+
# @param request_body [Hash] The values to create the webhook with.
|
53
|
+
# @return [Array(Hash, String)] The created webhook and API Request ID.
|
54
|
+
def create(request_body:)
|
55
|
+
post(
|
56
|
+
path: "#{api_uri}/v3/webhooks",
|
57
|
+
request_body: request_body
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Update a webhook.
|
62
|
+
#
|
63
|
+
# @param webhook_id [String] The id of the webhook to update.
|
64
|
+
# @param request_body [Hash] The values to update the webhook with
|
65
|
+
# @return [Array(Hash, String)] The updated webhook and API Request ID.
|
66
|
+
def update(webhook_id:, request_body:)
|
67
|
+
put(
|
68
|
+
path: "#{api_uri}/v3/webhooks/#{webhook_id}",
|
69
|
+
request_body: request_body
|
70
|
+
)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Delete a webhook.
|
74
|
+
#
|
75
|
+
# @param webhook_id [String] The id of the webhook to delete.
|
76
|
+
# @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
|
77
|
+
def destroy(webhook_id:)
|
78
|
+
_, request_id = delete(
|
79
|
+
path: "#{api_uri}/v3/webhooks/#{webhook_id}"
|
80
|
+
)
|
81
|
+
|
82
|
+
[true, request_id]
|
35
83
|
end
|
36
84
|
end
|
37
85
|
end
|
@@ -0,0 +1,49 @@
|
|
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
|
+
message_payload = request_body.to_json
|
15
|
+
|
16
|
+
# Prepare the data to return
|
17
|
+
form_data = {}
|
18
|
+
opened_files = []
|
19
|
+
|
20
|
+
attachments.each_with_index do |attachment, index|
|
21
|
+
file = attachment[:content] || attachment["content"]
|
22
|
+
form_data.merge!({ "file#{index}" => file })
|
23
|
+
opened_files << file
|
24
|
+
end
|
25
|
+
|
26
|
+
form_data.merge!({ "multipart" => true, "message" => message_payload })
|
27
|
+
|
28
|
+
[form_data, opened_files]
|
29
|
+
end
|
30
|
+
|
31
|
+
# Build the request to attach a file to a message/draft object.
|
32
|
+
# @param file_path [String] The path to the file to attach.
|
33
|
+
# @return [Hash] The request that will attach the file to the message/draft
|
34
|
+
def self.attach_file_request_builder(file_path)
|
35
|
+
filename = File.basename(file_path)
|
36
|
+
content_type = MIME::Types.type_for(file_path).first.to_s
|
37
|
+
content_type = "application/octet-stream" if content_type.empty?
|
38
|
+
size = File.size(file_path)
|
39
|
+
content = File.new(file_path, "rb")
|
40
|
+
|
41
|
+
{
|
42
|
+
filename: filename,
|
43
|
+
content_type: content_type,
|
44
|
+
size: size,
|
45
|
+
content: content
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
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,19 @@ 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/credentials"
|
36
|
+
require_relative "nylas/resources/drafts"
|
33
37
|
require_relative "nylas/resources/events"
|
38
|
+
require_relative "nylas/resources/folders"
|
34
39
|
require_relative "nylas/resources/grants"
|
40
|
+
require_relative "nylas/resources/messages"
|
41
|
+
require_relative "nylas/resources/smart_compose"
|
42
|
+
require_relative "nylas/resources/threads"
|
35
43
|
require_relative "nylas/resources/redirect_uris"
|
36
44
|
require_relative "nylas/resources/webhooks"
|
45
|
+
|
46
|
+
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nylas, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-21 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,25 @@ 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/credentials.rb
|
243
|
+
- lib/nylas/resources/drafts.rb
|
222
244
|
- lib/nylas/resources/events.rb
|
245
|
+
- lib/nylas/resources/folders.rb
|
223
246
|
- lib/nylas/resources/grants.rb
|
247
|
+
- lib/nylas/resources/messages.rb
|
224
248
|
- lib/nylas/resources/redirect_uris.rb
|
225
249
|
- lib/nylas/resources/resource.rb
|
250
|
+
- lib/nylas/resources/smart_compose.rb
|
251
|
+
- lib/nylas/resources/threads.rb
|
226
252
|
- lib/nylas/resources/webhooks.rb
|
253
|
+
- lib/nylas/utils/file_utils.rb
|
227
254
|
- lib/nylas/version.rb
|
228
255
|
homepage:
|
229
256
|
licenses:
|
@@ -1,95 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "http_client"
|
4
|
-
require_relative "api_operations"
|
5
|
-
|
6
|
-
module Nylas
|
7
|
-
# Allows resources to perform CRUD operations on the Admin API endpoints without exposing the
|
8
|
-
# HTTP client to the end user.
|
9
|
-
module AdminApiOperations
|
10
|
-
include HttpClient
|
11
|
-
# Creates a Nylas object.
|
12
|
-
module Create
|
13
|
-
include ApiOperations::Post
|
14
|
-
# Creates a Nylas object.
|
15
|
-
#
|
16
|
-
# @param query_params [Hash, {}] Query params to pass to the request.
|
17
|
-
# @param request_body [Hash, nil] Request body to pass to the request.
|
18
|
-
# @return [Array(Hash, String)] Created Nylas object and API Request ID.
|
19
|
-
def create(query_params: {}, request_body: nil)
|
20
|
-
post(
|
21
|
-
path: "#{api_uri}/v3/#{resource_name}",
|
22
|
-
query_params: query_params,
|
23
|
-
request_body: request_body
|
24
|
-
)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# Lists Nylas objects.
|
29
|
-
module List
|
30
|
-
include ApiOperations::Get
|
31
|
-
# Lists Nylas objects.
|
32
|
-
#
|
33
|
-
# @param query_params [Hash, {}] Query params to pass to the request.
|
34
|
-
# @return [Array(Hash, String)] List of Nylas objects and API Request ID.
|
35
|
-
def list(query_params: {})
|
36
|
-
get(
|
37
|
-
path: "#{api_uri}/v3/#{resource_name}",
|
38
|
-
query_params: query_params
|
39
|
-
)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# Finds a Nylas object.
|
44
|
-
module Find
|
45
|
-
include ApiOperations::Get
|
46
|
-
# Finds a Nylas object.
|
47
|
-
#
|
48
|
-
# @param object_id [String] Object ID.
|
49
|
-
# @param query_params [Hash, {}] Query params to pass to the request.
|
50
|
-
# @return [Array(Hash, String)] Nylas object and API Request ID.
|
51
|
-
def find(object_id:, query_params: {})
|
52
|
-
get(
|
53
|
-
path: "#{api_uri}/v3/#{resource_name}/#{object_id}",
|
54
|
-
query_params: query_params
|
55
|
-
)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
# Updates a Nylas object.
|
60
|
-
module Update
|
61
|
-
include ApiOperations::Put
|
62
|
-
# Updates a Nylas object.
|
63
|
-
#
|
64
|
-
# @param object_id [String] Object ID.
|
65
|
-
# @param query_params [Hash, {}] Query params to pass to the request.
|
66
|
-
# @param request_body [Hash, nil] Request body to pass to the request.
|
67
|
-
# @return [Array(Hash, String)] Updated Nylas object and API Request ID.
|
68
|
-
def update(object_id:, query_params: {}, request_body: nil)
|
69
|
-
put(
|
70
|
-
path: "#{api_uri}/v3/#{resource_name}/#{object_id}",
|
71
|
-
query_params: query_params,
|
72
|
-
request_body: request_body
|
73
|
-
)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
# Deletes a Nylas object.
|
78
|
-
module Destroy
|
79
|
-
include ApiOperations::Delete
|
80
|
-
# Deletes a Nylas object.
|
81
|
-
#
|
82
|
-
# @param object_id [String] Object ID.
|
83
|
-
# @param query_params [Hash, {}] Query params to pass to the request.
|
84
|
-
# @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
|
85
|
-
def destroy(object_id:, query_params: {})
|
86
|
-
_, request_id = delete(
|
87
|
-
path: "#{api_uri}/v3/#{resource_name}/#{object_id}",
|
88
|
-
query_params: query_params
|
89
|
-
)
|
90
|
-
|
91
|
-
[true, request_id]
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|