nylas 5.16.0 → 6.0.0.beta.1
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 +62 -0
- data/lib/nylas/config.rb +19 -0
- data/lib/nylas/errors.rb +41 -89
- data/lib/nylas/handler/admin_api_operations.rb +95 -0
- data/lib/nylas/handler/api_operations.rb +138 -0
- data/lib/nylas/handler/grants_api_operations.rb +99 -0
- data/lib/nylas/handler/http_client.rb +179 -0
- data/lib/nylas/resources/applications.rb +27 -0
- data/lib/nylas/resources/auth.rb +197 -0
- data/lib/nylas/resources/calendars.rb +31 -0
- data/lib/nylas/resources/events.rb +20 -0
- data/lib/nylas/resources/grants.rb +20 -0
- data/lib/nylas/resources/redirect_uris.rb +20 -0
- data/lib/nylas/resources/resource.rb +18 -0
- data/lib/nylas/resources/webhooks.rb +37 -0
- data/lib/nylas/version.rb +1 -1
- data/lib/nylas.rb +20 -148
- metadata +70 -257
- data/lib/nylas/account.rb +0 -56
- data/lib/nylas/api.rb +0 -244
- data/lib/nylas/application_details.rb +0 -13
- data/lib/nylas/calendar.rb +0 -46
- data/lib/nylas/calendar_collection.rb +0 -144
- data/lib/nylas/categorize.rb +0 -14
- data/lib/nylas/collection.rb +0 -175
- data/lib/nylas/component.rb +0 -35
- data/lib/nylas/component_collection.rb +0 -10
- data/lib/nylas/constraints.rb +0 -56
- data/lib/nylas/contact.rb +0 -53
- data/lib/nylas/contact_group.rb +0 -23
- data/lib/nylas/current_account.rb +0 -23
- data/lib/nylas/delta.rb +0 -56
- data/lib/nylas/deltas.rb +0 -19
- data/lib/nylas/deltas_collection.rb +0 -40
- data/lib/nylas/draft.rb +0 -100
- data/lib/nylas/email_address.rb +0 -12
- data/lib/nylas/event.rb +0 -143
- data/lib/nylas/event_collection.rb +0 -15
- data/lib/nylas/event_conferencing.rb +0 -12
- data/lib/nylas/event_conferencing_autocreate.rb +0 -10
- data/lib/nylas/event_conferencing_details.rb +0 -14
- data/lib/nylas/event_notification.rb +0 -17
- data/lib/nylas/file.rb +0 -75
- data/lib/nylas/filter_attributes.rb +0 -25
- data/lib/nylas/folder.rb +0 -26
- data/lib/nylas/free_busy.rb +0 -13
- data/lib/nylas/free_busy_collection.rb +0 -48
- data/lib/nylas/http_client.rb +0 -279
- data/lib/nylas/im_address.rb +0 -11
- data/lib/nylas/job_status.rb +0 -27
- data/lib/nylas/job_status_collection.rb +0 -21
- data/lib/nylas/label.rb +0 -27
- data/lib/nylas/logging.rb +0 -41
- data/lib/nylas/message.rb +0 -98
- data/lib/nylas/message_headers.rb +0 -27
- data/lib/nylas/message_tracking.rb +0 -13
- data/lib/nylas/model/attributable.rb +0 -89
- data/lib/nylas/model/attribute_definition.rb +0 -24
- data/lib/nylas/model/attributes.rb +0 -97
- data/lib/nylas/model/list_attribute_definition.rb +0 -39
- data/lib/nylas/model/transferable.rb +0 -53
- data/lib/nylas/model.rb +0 -217
- data/lib/nylas/native_authentication.rb +0 -39
- data/lib/nylas/neural.rb +0 -87
- data/lib/nylas/neural_categorizer.rb +0 -29
- data/lib/nylas/neural_clean_conversation.rb +0 -33
- data/lib/nylas/neural_contact_link.rb +0 -11
- data/lib/nylas/neural_contact_name.rb +0 -11
- data/lib/nylas/neural_message_options.rb +0 -35
- data/lib/nylas/neural_ocr.rb +0 -16
- data/lib/nylas/neural_sentiment_analysis.rb +0 -17
- data/lib/nylas/neural_signature_contact.rb +0 -81
- data/lib/nylas/neural_signature_extraction.rb +0 -18
- data/lib/nylas/new_message.rb +0 -39
- data/lib/nylas/nylas_date.rb +0 -25
- data/lib/nylas/open_hours.rb +0 -15
- data/lib/nylas/outbox.rb +0 -116
- data/lib/nylas/outbox_job_status.rb +0 -19
- data/lib/nylas/outbox_message.rb +0 -17
- data/lib/nylas/participant.rb +0 -13
- data/lib/nylas/phone_number.rb +0 -11
- data/lib/nylas/physical_address.rb +0 -17
- data/lib/nylas/raw_message.rb +0 -25
- data/lib/nylas/recurrence.rb +0 -11
- data/lib/nylas/registry.rb +0 -42
- data/lib/nylas/room_resource.rb +0 -19
- data/lib/nylas/rsvp.rb +0 -24
- data/lib/nylas/scheduler.rb +0 -51
- data/lib/nylas/scheduler_booking_confirmation.rb +0 -24
- data/lib/nylas/scheduler_booking_request.rb +0 -17
- data/lib/nylas/scheduler_collection.rb +0 -104
- data/lib/nylas/scheduler_config.rb +0 -20
- data/lib/nylas/scheduler_time_slot.rb +0 -14
- data/lib/nylas/search_collection.rb +0 -10
- data/lib/nylas/send_grid_verified_status.rb +0 -12
- data/lib/nylas/services/tunnel.rb +0 -128
- data/lib/nylas/thread.rb +0 -66
- data/lib/nylas/time_slot.rb +0 -16
- data/lib/nylas/time_slot_capacity.rb +0 -13
- data/lib/nylas/timespan.rb +0 -20
- data/lib/nylas/token_info.rb +0 -20
- data/lib/nylas/types.rb +0 -168
- data/lib/nylas/web_page.rb +0 -11
- data/lib/nylas/webhook.rb +0 -100
- data/lib/nylas/when.rb +0 -75
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8695c7d105dd1621576a1cc5dfa3bd2d7ff482d171763bf9273a3797cc320675
|
4
|
+
data.tar.gz: 88bda22c310af6c54061db72b6c19a5c4f8abed1e8e6a8518f4a4585d1ea6c38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc213a177a26c78864c48e678f6ff2d01cf9a3f29305cb2169b192018a531f3b5d106dab1fdfd350b323e1bbb69c4069ed13ec8ff5319742805c559077d52ac5
|
7
|
+
data.tar.gz: 2d51f8063938e335b00d9331f1beb9fb7c317c0af0954544c8ed40e3e4e14341452cdcf9be98a61ac4f9aae24d98eb0661434aea622a495fbd7f531d1293ec5c
|
data/lib/nylas/client.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "resources/calendars"
|
4
|
+
require_relative "resources/events"
|
5
|
+
require_relative "resources/auth"
|
6
|
+
require_relative "resources/webhooks"
|
7
|
+
require_relative "resources/applications"
|
8
|
+
|
9
|
+
module Nylas
|
10
|
+
# Methods to retrieve data from the Nylas API as Ruby objects.
|
11
|
+
class Client
|
12
|
+
attr_reader :api_key, :api_uri, :timeout
|
13
|
+
|
14
|
+
# Initializes a client session.
|
15
|
+
#
|
16
|
+
# @param api_key [Hash, nil] API key to use for the client session.
|
17
|
+
# @param api_uri [Hash] Client session's host.
|
18
|
+
# @param timeout [Hash, nil] Timeout value to use for the client session.
|
19
|
+
def initialize(api_key: nil,
|
20
|
+
api_uri: Config::DEFAULT_REGION_URL,
|
21
|
+
timeout: nil)
|
22
|
+
@api_key = api_key
|
23
|
+
@api_uri = api_uri
|
24
|
+
@timeout = timeout
|
25
|
+
end
|
26
|
+
|
27
|
+
# The application resources for your Nylas application.
|
28
|
+
#
|
29
|
+
# @return [Nylas::Applications] Application resources for your Nylas application.
|
30
|
+
def applications
|
31
|
+
Applications.new(self)
|
32
|
+
end
|
33
|
+
|
34
|
+
# The calendar resources for your Nylas application.
|
35
|
+
#
|
36
|
+
# @return [Nylas::Calendars] Calendar resources for your Nylas application.
|
37
|
+
def calendars
|
38
|
+
Calendars.new(self)
|
39
|
+
end
|
40
|
+
|
41
|
+
# The event resources for your Nylas application.
|
42
|
+
#
|
43
|
+
# @return [Nylas::Events] Event resources for your Nylas application
|
44
|
+
def events
|
45
|
+
Events.new(self)
|
46
|
+
end
|
47
|
+
|
48
|
+
# The auth resources for your Nylas application.
|
49
|
+
#
|
50
|
+
# @return [Nylas::Auth] Auth resources for your Nylas application.
|
51
|
+
def auth
|
52
|
+
Auth.new(self)
|
53
|
+
end
|
54
|
+
|
55
|
+
# The webhook resources for your Nylas application.
|
56
|
+
#
|
57
|
+
# @return [Nylas::Webhooks] Webhook resources for your Nylas application.
|
58
|
+
def webhooks
|
59
|
+
Webhooks.new(self)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/nylas/config.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nylas
|
4
|
+
# Configuration options for the Nylas Ruby SDK.
|
5
|
+
module Config
|
6
|
+
# The configuration options for supported regions.
|
7
|
+
REGION_CONFIG = {
|
8
|
+
us: {
|
9
|
+
nylas_api_url: "https://api.us.nylas.com"
|
10
|
+
},
|
11
|
+
eu: {
|
12
|
+
nylas_api_url: "https://api.eu.nylas.com"
|
13
|
+
}
|
14
|
+
}.freeze
|
15
|
+
|
16
|
+
# The default API endpoint for the Nylas API.
|
17
|
+
DEFAULT_REGION_URL = REGION_CONFIG[:us][:nylas_api_url]
|
18
|
+
end
|
19
|
+
end
|
data/lib/nylas/errors.rb
CHANGED
@@ -3,109 +3,61 @@
|
|
3
3
|
module Nylas
|
4
4
|
Error = Class.new(::StandardError)
|
5
5
|
|
6
|
-
class ModelActionError < Error; end
|
7
|
-
class ModelNotFilterableError < ModelActionError; end
|
8
|
-
class ModelNotCreatableError < ModelActionError; end
|
9
|
-
class ModelNotShowableError < ModelActionError; end
|
10
|
-
class ModelNotAvailableAsRawError < ModelActionError; end
|
11
|
-
class ModelNotListableError < ModelActionError; end
|
12
|
-
class ModelNotFilterableError < ModelActionError; end
|
13
|
-
class ModelNotSearchableError < ModelActionError; end
|
14
|
-
class ModelNotUpdatableError < ModelActionError; end
|
15
|
-
class ModelNotDestroyableError < ModelActionError; end
|
16
|
-
|
17
6
|
class JsonParseError < Error; end
|
18
7
|
|
19
|
-
#
|
20
|
-
class
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
UnexpectedAccountAction = Class.new(Error)
|
34
|
-
UnexpectedResponse = Class.new(Error)
|
35
|
-
|
36
|
-
# Base class to inflate the standard errors returned from the Nylas API
|
37
|
-
class APIError < Error
|
38
|
-
attr_accessor :type
|
39
|
-
attr_accessor :message
|
40
|
-
attr_accessor :server_error
|
41
|
-
|
42
|
-
def initialize(type, message, server_error = nil)
|
8
|
+
# Base class to inflate the standard errors returned from the Nylas API.
|
9
|
+
class NylasApiError < Error
|
10
|
+
attr_accessor :type, :request_id, :provider_error, :status_code
|
11
|
+
|
12
|
+
# Initializes an error and assigns the given attributes to it.
|
13
|
+
#
|
14
|
+
# @param type [Hash] Error type.
|
15
|
+
# @param message [String] Error message.
|
16
|
+
# @param status_code [Hash] Error status code.
|
17
|
+
# @param provider_error [String, nil] Provider error.
|
18
|
+
# @param request_id [Hash, nil] The ID of the request.
|
19
|
+
def initialize(type, message, status_code, provider_error = nil, request_id = nil)
|
43
20
|
super(message)
|
44
21
|
self.type = type
|
45
|
-
self.
|
46
|
-
self.
|
22
|
+
self.status_code = status_code
|
23
|
+
self.provider_error = provider_error
|
24
|
+
self.request_id = request_id
|
47
25
|
end
|
48
26
|
|
49
|
-
|
27
|
+
# Parses the error response.
|
28
|
+
#
|
29
|
+
# @param response [Hash] Response from the Nylas API.
|
30
|
+
# @param status_code [String] Error status code.
|
31
|
+
def self.parse_error_response(response, status_code)
|
50
32
|
new(
|
51
33
|
response["type"],
|
52
34
|
response["message"],
|
53
|
-
|
35
|
+
status_code,
|
36
|
+
response["provider_error"]
|
54
37
|
)
|
55
38
|
end
|
56
39
|
end
|
57
40
|
|
58
|
-
#
|
59
|
-
class
|
60
|
-
attr_accessor :
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
41
|
+
# Base class to inflate the standard errors returned from the Nylas OAuth integration.
|
42
|
+
class NylasOAuthError < Error
|
43
|
+
attr_accessor :error, :error_description, :error_uri, :error_code, :status_code
|
44
|
+
|
45
|
+
# Initializes an error and assigns the given attributes to it.
|
46
|
+
#
|
47
|
+
# @param error [Hash] Error type.
|
48
|
+
# @param error_description [String] Description of the error.
|
49
|
+
# @param error_uri [Hash] Error URI.
|
50
|
+
# @param error_code [Hash] Error code.
|
51
|
+
# @param status_code [Hash] Error status code.
|
52
|
+
def initialize(error, error_description, error_uri, error_code, status_code)
|
53
|
+
super(error_description)
|
54
|
+
self.error = error
|
55
|
+
self.error_description = error_description
|
56
|
+
self.error_uri = error_uri
|
57
|
+
self.error_code = error_code
|
58
|
+
self.status_code = status_code
|
70
59
|
end
|
71
|
-
|
72
|
-
def self.parse_error_response(response)
|
73
|
-
rate_limit, rate_limit_rest = extract_rate_limit_details(response)
|
74
|
-
|
75
|
-
new(
|
76
|
-
response["type"],
|
77
|
-
response["message"],
|
78
|
-
response["server_error"],
|
79
|
-
rate_limit,
|
80
|
-
rate_limit_rest
|
81
|
-
)
|
82
|
-
end
|
83
|
-
|
84
|
-
def self.extract_rate_limit_details(response)
|
85
|
-
return nil, nil unless response.respond_to?(:headers)
|
86
|
-
|
87
|
-
rate_limit = response.headers[RATE_LIMIT_LIMIT_HEADER.to_sym].to_i
|
88
|
-
rate_limit_rest = response.headers[RATE_LIMIT_RESET_HEADER.to_sym].to_i
|
89
|
-
|
90
|
-
[rate_limit, rate_limit_rest]
|
91
|
-
end
|
92
|
-
|
93
|
-
private_class_method :extract_rate_limit_details
|
94
60
|
end
|
95
61
|
|
96
|
-
|
97
|
-
ResourceNotFound = Class.new(APIError)
|
98
|
-
MethodNotAllowed = Class.new(APIError)
|
99
|
-
InvalidRequest = Class.new(APIError)
|
100
|
-
UnauthorizedRequest = Class.new(APIError)
|
101
|
-
ResourceRemoved = Class.new(APIError)
|
102
|
-
TeapotError = Class.new(APIError)
|
103
|
-
RequestTimedOut = Class.new(APIError)
|
104
|
-
MessageRejected = Class.new(APIError)
|
105
|
-
SendingQuotaExceeded = Class.new(RateLimitError)
|
106
|
-
ServiceUnavailable = Class.new(APIError)
|
107
|
-
BadGateway = Class.new(APIError)
|
108
|
-
InternalError = Class.new(APIError)
|
109
|
-
EndpointNotYetImplemented = Class.new(APIError)
|
110
|
-
MailProviderError = Class.new(APIError)
|
62
|
+
HTTP_SUCCESS_CODES = [200, 201, 202, 302].freeze
|
111
63
|
end
|
@@ -0,0 +1,95 @@
|
|
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
|
@@ -0,0 +1,138 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nylas
|
4
|
+
# Allows resources to perform API operations on the Nylas API endpoints without exposing the HTTP
|
5
|
+
# client to the end user.
|
6
|
+
module ApiOperations
|
7
|
+
# Performs a GET call to the Nylas API.
|
8
|
+
module Get
|
9
|
+
protected
|
10
|
+
|
11
|
+
include HttpClient
|
12
|
+
# Performs a GET call to the Nylas API.
|
13
|
+
#
|
14
|
+
# @param path [String] Destination path for the call.
|
15
|
+
# @param query_params [Hash, {}] Query params to pass to the call.
|
16
|
+
# @return [Array(Hash, String)] List of Nylas objects and API Request ID.
|
17
|
+
def get(path:, query_params: {})
|
18
|
+
response = execute(
|
19
|
+
method: :get,
|
20
|
+
path: path,
|
21
|
+
query: query_params,
|
22
|
+
payload: nil,
|
23
|
+
api_key: api_key,
|
24
|
+
timeout: timeout
|
25
|
+
)
|
26
|
+
|
27
|
+
[response[:data], response[:request_id]]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Performs a POST call to the Nylas API.
|
32
|
+
module Post
|
33
|
+
protected
|
34
|
+
|
35
|
+
include HttpClient
|
36
|
+
# Performs a POST call to the Nylas API.
|
37
|
+
#
|
38
|
+
# @param path [String] Destination path for the call.
|
39
|
+
# @param query_params [Hash, {}] Query params to pass to the call.
|
40
|
+
# @param request_body [String, Hash, nil] Request body to pass to the call.
|
41
|
+
# @param headers [Hash, {}] Additional HTTP headers to include in the payload.
|
42
|
+
# @return [Array(Hash, String)] List of Nylas objects and API Request ID.
|
43
|
+
def post(path:, query_params: {}, request_body: nil, headers: {})
|
44
|
+
response = execute(
|
45
|
+
method: :post,
|
46
|
+
path: path,
|
47
|
+
query: query_params,
|
48
|
+
payload: request_body,
|
49
|
+
headers: headers,
|
50
|
+
api_key: api_key,
|
51
|
+
timeout: timeout
|
52
|
+
)
|
53
|
+
|
54
|
+
[response[:data], response[:request_id]]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Performs a PUT call to the Nylas API.
|
59
|
+
module Put
|
60
|
+
protected
|
61
|
+
|
62
|
+
include HttpClient
|
63
|
+
# Performs a PUT call to the Nylas API.
|
64
|
+
#
|
65
|
+
# @param path [String] Destination path for the call.
|
66
|
+
# @param query_params [Hash, {}] Query params to pass to the call.
|
67
|
+
# @param request_body [String, Hash, nil] Request body to pass to the call.
|
68
|
+
# @param headers [Hash, {}] Additional HTTP headers to include in the payload.
|
69
|
+
# @return [Array(Hash, String)] List of Nylas objects and API Request ID.
|
70
|
+
def put(path:, query_params: {}, request_body: nil, headers: {})
|
71
|
+
response = execute(
|
72
|
+
method: :put,
|
73
|
+
path: path,
|
74
|
+
query: query_params,
|
75
|
+
payload: request_body,
|
76
|
+
headers: headers,
|
77
|
+
api_key: api_key,
|
78
|
+
timeout: timeout
|
79
|
+
)
|
80
|
+
|
81
|
+
[response[:data], response[:request_id]]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Performs a PATCH call to the Nylas API.
|
86
|
+
module Patch
|
87
|
+
protected
|
88
|
+
|
89
|
+
include HttpClient
|
90
|
+
# Performs a PATCH call to the Nylas API.
|
91
|
+
#
|
92
|
+
# @param path [String] Destination path for the call.
|
93
|
+
# @param query_params [Hash, {}] Query params to pass to the call.
|
94
|
+
# @param request_body [String, Hash, nil] Request body to pass to the call.
|
95
|
+
# @param headers [Hash, {}] Additional HTTP headers to include in the payload.
|
96
|
+
# @return [Array(Hash, String)] List of Nylas objects and API Request ID.
|
97
|
+
def patch(path:, query_params: {}, request_body: nil, headers: {})
|
98
|
+
response = execute(
|
99
|
+
method: :patch,
|
100
|
+
path: path,
|
101
|
+
query: query_params,
|
102
|
+
payload: request_body,
|
103
|
+
headers: headers,
|
104
|
+
api_key: api_key,
|
105
|
+
timeout: timeout
|
106
|
+
)
|
107
|
+
|
108
|
+
[response[:data], response[:request_id]]
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# Performs a DELETE call to the Nylas API.
|
113
|
+
module Delete
|
114
|
+
protected
|
115
|
+
|
116
|
+
include HttpClient
|
117
|
+
# Performs a DELETE call to the Nylas API.
|
118
|
+
#
|
119
|
+
# @param path [String] Destination path for the call.
|
120
|
+
# @param query_params [Hash, {}] Query params to pass to the call.
|
121
|
+
# @param headers [Hash, {}] Additional HTTP headers to include in the payload.
|
122
|
+
# @return [Array(Hash, String)] List of Nylas objects and API Request ID.
|
123
|
+
def delete(path:, query_params: {}, headers: {})
|
124
|
+
response = execute(
|
125
|
+
method: :delete,
|
126
|
+
path: path,
|
127
|
+
query: query_params,
|
128
|
+
headers: headers,
|
129
|
+
payload: nil,
|
130
|
+
api_key: api_key,
|
131
|
+
timeout: timeout
|
132
|
+
)
|
133
|
+
|
134
|
+
[response[:data], response[:request_id]]
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,99 @@
|
|
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 Grants API endpoints without exposing the
|
8
|
+
# HTTP client to the end user.
|
9
|
+
module GrantsApiOperations
|
10
|
+
# Creates a Nylas object.
|
11
|
+
module Create
|
12
|
+
include ApiOperations::Post
|
13
|
+
# Creates a Nylas object.
|
14
|
+
#
|
15
|
+
# @param identifier [String] Grant ID or email account in which to create the object.
|
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(identifier:, query_params: {}, request_body: nil)
|
20
|
+
post(
|
21
|
+
path: "#{api_uri}/v3/grants/#{identifier}/#{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 identifier [String] Grant ID or email account to query.
|
34
|
+
# @param query_params [Hash, {}] Query params to pass to the request.
|
35
|
+
# @return [Array(Hash, String)] List of Nylas objects and API Request ID.
|
36
|
+
def list(identifier:, query_params: {})
|
37
|
+
get(
|
38
|
+
path: "#{api_uri}/v3/grants/#{identifier}/#{resource_name}",
|
39
|
+
query_params: query_params
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Finds a Nylas object.
|
45
|
+
module Find
|
46
|
+
include ApiOperations::Get
|
47
|
+
# Finds a Nylas object.
|
48
|
+
#
|
49
|
+
# @param identifier [String] Grant ID or email account to query.
|
50
|
+
# @param object_id [String] Object ID.
|
51
|
+
# @param query_params [Hash, {}] Query params to pass to the request.
|
52
|
+
# @return [Array(Hash, String)] Nylas object and API request ID.
|
53
|
+
def find(identifier:, object_id:, query_params: {})
|
54
|
+
get(
|
55
|
+
path: "#{api_uri}/v3/grants/#{identifier}/#{resource_name}/#{object_id}",
|
56
|
+
query_params: query_params
|
57
|
+
)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Updates a Nylas object.
|
62
|
+
module Update
|
63
|
+
include ApiOperations::Put
|
64
|
+
# Updates a Nylas object.
|
65
|
+
#
|
66
|
+
# @param identifier [String] Grant ID or email account in which to update an object.
|
67
|
+
# @param object_id [String] Object ID.
|
68
|
+
# @param query_params [Hash, {}] Query params to pass to the request.
|
69
|
+
# @param request_body [Hash, nil] Request body to pass to the request.
|
70
|
+
# @return [Array(Hash, String)] Updated Nylas object and API Request ID.
|
71
|
+
def update(identifier:, object_id:, query_params: {}, request_body: nil)
|
72
|
+
put(
|
73
|
+
path: "#{api_uri}/v3/grants/#{identifier}/#{resource_name}/#{object_id}",
|
74
|
+
query_params: query_params,
|
75
|
+
request_body: request_body
|
76
|
+
)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# Deletes a Nylas object.
|
81
|
+
module Destroy
|
82
|
+
include ApiOperations::Delete
|
83
|
+
# Deletes a Nylas object.
|
84
|
+
#
|
85
|
+
# @param identifier [String] Grant ID or email account from which to delete an object.
|
86
|
+
# @param object_id [String] Object ID.
|
87
|
+
# @param query_params [Hash, {}] Query params to pass to the request.
|
88
|
+
# @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
|
89
|
+
def destroy(identifier:, object_id:, query_params: {})
|
90
|
+
_, request_id = delete(
|
91
|
+
path: "#{api_uri}/v3/grants/#{identifier}/#{resource_name}/#{object_id}",
|
92
|
+
query_params: query_params
|
93
|
+
)
|
94
|
+
|
95
|
+
[true, request_id]
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|