nylas 5.17.0 → 6.0.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 +121 -0
- data/lib/nylas/config.rb +19 -0
- data/lib/nylas/errors.rb +63 -89
- data/lib/nylas/handler/api_operations.rb +162 -0
- data/lib/nylas/handler/http_client.rb +252 -0
- data/lib/nylas/resources/applications.rb +27 -0
- data/lib/nylas/resources/attachments.rb +65 -0
- data/lib/nylas/resources/auth.rb +209 -0
- data/lib/nylas/resources/calendars.rb +101 -0
- 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 +121 -0
- data/lib/nylas/resources/events.rb +98 -0
- data/lib/nylas/resources/folders.rb +73 -0
- data/lib/nylas/resources/grants.rb +59 -0
- data/lib/nylas/resources/messages.rb +135 -0
- data/lib/nylas/resources/redirect_uris.rb +68 -0
- data/lib/nylas/resources/resource.rb +18 -0
- data/lib/nylas/resources/smart_compose.rb +36 -0
- data/lib/nylas/resources/threads.rb +62 -0
- data/lib/nylas/resources/webhooks.rb +121 -0
- data/lib/nylas/utils/file_utils.rb +61 -0
- data/lib/nylas/version.rb +1 -1
- data/lib/nylas.rb +31 -148
- metadata +88 -247
- data/lib/nylas/account.rb +0 -56
- data/lib/nylas/api.rb +0 -246
- 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 -144
- 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 -111
- 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: 3bd6fdcadf69439f1f8a8549e26e3b43f4df3cfeb8ae0c5a2aef5aca8fb3acce
|
4
|
+
data.tar.gz: b1f939a98c16ec5bf390791df31bb0f76feb45af07e4e6bcfc32c52e79e3b53f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 591735adfae3cfefdbc513762eff603390779f14321a543bf0a2115f3a368f1b674175c6e5cbea9052b4e10db157d74a3cda80b74773b212bbda2e38fc25aea0
|
7
|
+
data.tar.gz: 17dc68c13af649f533d206a546a72cf45b508864f71d2daae1eb020f686ce5b79c39829d841dd919cc944cd038042f4075116a7a941c2f782b6ae127c35d63a8
|
data/lib/nylas/client.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "resources/calendars"
|
4
|
+
require_relative "resources/connectors"
|
5
|
+
require_relative "resources/messages"
|
6
|
+
require_relative "resources/events"
|
7
|
+
require_relative "resources/auth"
|
8
|
+
require_relative "resources/webhooks"
|
9
|
+
require_relative "resources/applications"
|
10
|
+
require_relative "resources/folders"
|
11
|
+
|
12
|
+
module Nylas
|
13
|
+
# Methods to retrieve data from the Nylas API as Ruby objects.
|
14
|
+
class Client
|
15
|
+
attr_reader :api_key, :api_uri, :timeout
|
16
|
+
|
17
|
+
# Initializes a client session.
|
18
|
+
#
|
19
|
+
# @param api_key [String, nil] API key to use for the client session.
|
20
|
+
# @param api_uri [String] Client session's host.
|
21
|
+
# @param timeout [Integer, nil] Timeout value to use for the client session.
|
22
|
+
def initialize(api_key:,
|
23
|
+
api_uri: Config::DEFAULT_REGION_URL,
|
24
|
+
timeout: nil)
|
25
|
+
@api_key = api_key
|
26
|
+
@api_uri = api_uri
|
27
|
+
@timeout = timeout || 90
|
28
|
+
end
|
29
|
+
|
30
|
+
# The application resources for your Nylas application.
|
31
|
+
#
|
32
|
+
# @return [Nylas::Applications] Application resources for your Nylas application.
|
33
|
+
def applications
|
34
|
+
Applications.new(self)
|
35
|
+
end
|
36
|
+
|
37
|
+
# The attachments resources for your Nylas application.
|
38
|
+
#
|
39
|
+
# @return [Nylas::Attachments] Attachment resources for your Nylas application.
|
40
|
+
def attachments
|
41
|
+
Attachments.new(self)
|
42
|
+
end
|
43
|
+
|
44
|
+
# The auth resources for your Nylas application.
|
45
|
+
#
|
46
|
+
# @return [Nylas::Auth] Auth resources for your Nylas application.
|
47
|
+
def auth
|
48
|
+
Auth.new(self)
|
49
|
+
end
|
50
|
+
|
51
|
+
# The calendar resources for your Nylas application.
|
52
|
+
#
|
53
|
+
# @return [Nylas::Calendars] Calendar resources for your Nylas application.
|
54
|
+
def calendars
|
55
|
+
Calendars.new(self)
|
56
|
+
end
|
57
|
+
|
58
|
+
# The connector resources for your Nylas application.
|
59
|
+
#
|
60
|
+
# @return [Nylas::Connectors] Connector resources for your Nylas application.
|
61
|
+
def connectors
|
62
|
+
Connectors.new(self)
|
63
|
+
end
|
64
|
+
|
65
|
+
# The contact resources for your Nylas application.
|
66
|
+
#
|
67
|
+
# @return [Nylas::Contacts] Contact resources for your Nylas application.
|
68
|
+
def contacts
|
69
|
+
Contacts.new(self)
|
70
|
+
end
|
71
|
+
|
72
|
+
# The draft resources for your Nylas application.
|
73
|
+
#
|
74
|
+
# @return [Nylas::Drafts] Draft resources for your Nylas application.
|
75
|
+
def drafts
|
76
|
+
Drafts.new(self)
|
77
|
+
end
|
78
|
+
|
79
|
+
# The event resources for your Nylas application.
|
80
|
+
#
|
81
|
+
# @return [Nylas::Events] Event resources for your Nylas application
|
82
|
+
def events
|
83
|
+
Events.new(self)
|
84
|
+
end
|
85
|
+
|
86
|
+
# The folder resources for your Nylas application.
|
87
|
+
#
|
88
|
+
# @return [Nylas::Folder] Folder resources for your Nylas application
|
89
|
+
def folders
|
90
|
+
Folders.new(self)
|
91
|
+
end
|
92
|
+
|
93
|
+
# The grants resources for your Nylas application.
|
94
|
+
#
|
95
|
+
# @return [Nylas::Grants] Grant resources for your Nylas application
|
96
|
+
def grants
|
97
|
+
Grants.new(self)
|
98
|
+
end
|
99
|
+
|
100
|
+
# The message resources for your Nylas application.
|
101
|
+
#
|
102
|
+
# @return [Nylas::Messages] Message resources for your Nylas application
|
103
|
+
def messages
|
104
|
+
Messages.new(self)
|
105
|
+
end
|
106
|
+
|
107
|
+
# The thread resources for your Nylas application.
|
108
|
+
#
|
109
|
+
# @return [Nylas::Threads] Thread resources for your Nylas application.
|
110
|
+
def threads
|
111
|
+
Threads.new(self)
|
112
|
+
end
|
113
|
+
|
114
|
+
# The webhook resources for your Nylas application.
|
115
|
+
#
|
116
|
+
# @return [Nylas::Webhooks] Webhook resources for your Nylas application.
|
117
|
+
def webhooks
|
118
|
+
Webhooks.new(self)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
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,83 @@
|
|
3
3
|
module Nylas
|
4
4
|
Error = Class.new(::StandardError)
|
5
5
|
|
6
|
-
class
|
7
|
-
class
|
8
|
-
|
9
|
-
class
|
10
|
-
class
|
11
|
-
|
12
|
-
class
|
13
|
-
class
|
14
|
-
|
15
|
-
class
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
class NoAuthToken < Error
|
28
|
-
def initialize(method_name)
|
29
|
-
super "No access token was provided and the #{method_name} method requires one"
|
30
|
-
end
|
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)
|
6
|
+
# Base error class for API-related errors.
|
7
|
+
class AbstractNylasApiError < Error; end
|
8
|
+
|
9
|
+
# Base error class for SDK-related errors.
|
10
|
+
class AbstractNylasSdkError < Error; end
|
11
|
+
|
12
|
+
# Error class representing a failed parse of a JSON response from the Nylas API.
|
13
|
+
class JsonParseError < AbstractNylasSdkError; end
|
14
|
+
|
15
|
+
# Error class representing a failed response from the Nylas API.
|
16
|
+
class NylasApiError < AbstractNylasApiError
|
17
|
+
attr_accessor :type, :request_id, :provider_error, :status_code
|
18
|
+
|
19
|
+
# Initializes an error and assigns the given attributes to it.
|
20
|
+
#
|
21
|
+
# @param type [Hash] Error type.
|
22
|
+
# @param message [String] Error message.
|
23
|
+
# @param status_code [Integer] Error status code.
|
24
|
+
# @param provider_error [String, nil] Provider error.
|
25
|
+
# @param request_id [Hash, nil] The ID of the request.
|
26
|
+
def initialize(type, message, status_code, provider_error = nil, request_id = nil)
|
43
27
|
super(message)
|
44
28
|
self.type = type
|
45
|
-
self.
|
46
|
-
self.
|
29
|
+
self.status_code = status_code
|
30
|
+
self.provider_error = provider_error
|
31
|
+
self.request_id = request_id
|
47
32
|
end
|
48
33
|
|
49
|
-
|
34
|
+
# Parses the error response.
|
35
|
+
#
|
36
|
+
# @param response [Hash] Response from the Nylas API.
|
37
|
+
# @param status_code [Integer] Error status code.
|
38
|
+
def self.parse_error_response(response, status_code)
|
50
39
|
new(
|
51
40
|
response["type"],
|
52
41
|
response["message"],
|
53
|
-
|
42
|
+
status_code,
|
43
|
+
response["provider_error"]
|
54
44
|
)
|
55
45
|
end
|
56
46
|
end
|
57
47
|
|
58
|
-
# Error class representing a
|
59
|
-
class
|
60
|
-
attr_accessor :
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
48
|
+
# Error class representing a failed response from the Nylas OAuth integration.
|
49
|
+
class NylasOAuthError < AbstractNylasApiError
|
50
|
+
attr_accessor :error, :error_description, :error_uri, :error_code, :status_code
|
51
|
+
|
52
|
+
# Initializes an error and assigns the given attributes to it.
|
53
|
+
#
|
54
|
+
# @param error [String] Error type.
|
55
|
+
# @param error_description [String] Description of the error.
|
56
|
+
# @param error_uri [String] Error URI.
|
57
|
+
# @param error_code [String] Error code.
|
58
|
+
# @param status_code [String] Error status code.
|
59
|
+
def initialize(error, error_description, error_uri, error_code, status_code)
|
60
|
+
super(error_description)
|
61
|
+
self.error = error
|
62
|
+
self.error_description = error_description
|
63
|
+
self.error_uri = error_uri
|
64
|
+
self.error_code = error_code
|
65
|
+
self.status_code = status_code
|
70
66
|
end
|
67
|
+
end
|
71
68
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
)
|
82
|
-
|
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]
|
69
|
+
# Error class representing a timeout from the Nylas SDK.
|
70
|
+
class NylasSdkTimeoutError < AbstractNylasSdkError
|
71
|
+
attr_accessor :url, :timeout
|
72
|
+
|
73
|
+
# Initializes an error and assigns the given attributes to it.
|
74
|
+
# @param url [String] URL that timed out.
|
75
|
+
# @param timeout [Integer] Timeout in seconds.
|
76
|
+
# @return [NylasSdkTimeoutError] The error object.
|
77
|
+
def initialize(url, timeout)
|
78
|
+
super("Nylas SDK timed out before receiving a response from the server.")
|
79
|
+
self.url = url
|
80
|
+
self.timeout = timeout
|
91
81
|
end
|
92
|
-
|
93
|
-
private_class_method :extract_rate_limit_details
|
94
82
|
end
|
95
83
|
|
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)
|
84
|
+
HTTP_SUCCESS_CODES = [200, 201, 202, 302].freeze
|
111
85
|
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "http_client"
|
4
|
+
|
5
|
+
module Nylas
|
6
|
+
# Allows resources to perform API operations on the Nylas API endpoints without exposing the HTTP
|
7
|
+
# client to the end user.
|
8
|
+
module ApiOperations
|
9
|
+
# Performs a GET call to the Nylas API.
|
10
|
+
module Get
|
11
|
+
protected
|
12
|
+
|
13
|
+
include HttpClient
|
14
|
+
# Performs a GET call to the Nylas API for a single item response.
|
15
|
+
#
|
16
|
+
# @param path [String] Destination path for the call.
|
17
|
+
# @param query_params [Hash, {}] Query params to pass to the call.
|
18
|
+
# @return [Array([Hash, Array], String)] Nylas data object and API Request ID.
|
19
|
+
def get(path:, query_params: {})
|
20
|
+
response = get_raw(path: path, query_params: query_params)
|
21
|
+
|
22
|
+
[response[:data], response[:request_id]]
|
23
|
+
end
|
24
|
+
|
25
|
+
# Performs a GET call to the Nylas API for a list response.
|
26
|
+
#
|
27
|
+
# @param path [String] Destination path for the call.
|
28
|
+
# @param query_params [Hash, {}] Query params to pass to the call.
|
29
|
+
# @return [Array(Array(Hash), String, String)] Nylas data array, API Request ID, and next cursor.
|
30
|
+
def get_list(path:, query_params: {})
|
31
|
+
response = get_raw(path: path, query_params: query_params)
|
32
|
+
|
33
|
+
[response[:data], response[:request_id], response[:next_cursor]]
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
# Performs a GET call to the Nylas API.
|
39
|
+
#
|
40
|
+
# @param path [String] Destination path for the call.
|
41
|
+
# @param query_params [Hash, {}] Query params to pass to the call.
|
42
|
+
# @return [Hash] The JSON response from the Nylas API.
|
43
|
+
def get_raw(path:, query_params: {})
|
44
|
+
execute(
|
45
|
+
method: :get,
|
46
|
+
path: path,
|
47
|
+
query: query_params,
|
48
|
+
payload: nil,
|
49
|
+
api_key: api_key,
|
50
|
+
timeout: timeout
|
51
|
+
)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Performs a POST call to the Nylas API.
|
56
|
+
module Post
|
57
|
+
protected
|
58
|
+
|
59
|
+
include HttpClient
|
60
|
+
# Performs a POST call to the Nylas API.
|
61
|
+
#
|
62
|
+
# @param path [String] Destination path for the call.
|
63
|
+
# @param query_params [Hash, {}] Query params to pass to the call.
|
64
|
+
# @param request_body [Hash, nil] Request body to pass to the call.
|
65
|
+
# @param headers [Hash, {}] Additional HTTP headers to include in the payload.
|
66
|
+
# @return Nylas data object and API Request ID.
|
67
|
+
def post(path:, query_params: {}, request_body: nil, headers: {})
|
68
|
+
response = execute(
|
69
|
+
method: :post,
|
70
|
+
path: path,
|
71
|
+
query: query_params,
|
72
|
+
payload: request_body,
|
73
|
+
headers: headers,
|
74
|
+
api_key: api_key,
|
75
|
+
timeout: timeout
|
76
|
+
)
|
77
|
+
|
78
|
+
[response[:data], response[:request_id]]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Performs a PUT call to the Nylas API.
|
83
|
+
module Put
|
84
|
+
protected
|
85
|
+
|
86
|
+
include HttpClient
|
87
|
+
# Performs a PUT call to the Nylas API.
|
88
|
+
#
|
89
|
+
# @param path [String] Destination path for the call.
|
90
|
+
# @param query_params [Hash, {}] Query params to pass to the call.
|
91
|
+
# @param request_body [Hash, nil] Request body to pass to the call.
|
92
|
+
# @param headers [Hash, {}] Additional HTTP headers to include in the payload.
|
93
|
+
# @return Nylas data object and API Request ID.
|
94
|
+
def put(path:, query_params: {}, request_body: nil, headers: {})
|
95
|
+
response = execute(
|
96
|
+
method: :put,
|
97
|
+
path: path,
|
98
|
+
query: query_params,
|
99
|
+
payload: request_body,
|
100
|
+
headers: headers,
|
101
|
+
api_key: api_key,
|
102
|
+
timeout: timeout
|
103
|
+
)
|
104
|
+
|
105
|
+
[response[:data], response[:request_id]]
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# Performs a PATCH call to the Nylas API.
|
110
|
+
module Patch
|
111
|
+
protected
|
112
|
+
|
113
|
+
include HttpClient
|
114
|
+
# Performs a PATCH call to the Nylas API.
|
115
|
+
#
|
116
|
+
# @param path [String] Destination path for the call.
|
117
|
+
# @param query_params [Hash, {}] Query params to pass to the call.
|
118
|
+
# @param request_body [Hash, nil] Request body to pass to the call.
|
119
|
+
# @param headers [Hash, {}] Additional HTTP headers to include in the payload.
|
120
|
+
# @return Nylas data object and API Request ID.
|
121
|
+
def patch(path:, query_params: {}, request_body: nil, headers: {})
|
122
|
+
response = execute(
|
123
|
+
method: :patch,
|
124
|
+
path: path,
|
125
|
+
query: query_params,
|
126
|
+
payload: request_body,
|
127
|
+
headers: headers,
|
128
|
+
api_key: api_key,
|
129
|
+
timeout: timeout
|
130
|
+
)
|
131
|
+
|
132
|
+
[response[:data], response[:request_id]]
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
# Performs a DELETE call to the Nylas API.
|
137
|
+
module Delete
|
138
|
+
protected
|
139
|
+
|
140
|
+
include HttpClient
|
141
|
+
# Performs a DELETE call to the Nylas API.
|
142
|
+
#
|
143
|
+
# @param path [String] Destination path for the call.
|
144
|
+
# @param query_params [Hash, {}] Query params to pass to the call.
|
145
|
+
# @param headers [Hash, {}] Additional HTTP headers to include in the payload.
|
146
|
+
# @return Nylas data object and API Request ID.
|
147
|
+
def delete(path:, query_params: {}, headers: {})
|
148
|
+
response = execute(
|
149
|
+
method: :delete,
|
150
|
+
path: path,
|
151
|
+
query: query_params,
|
152
|
+
headers: headers,
|
153
|
+
payload: nil,
|
154
|
+
api_key: api_key,
|
155
|
+
timeout: timeout
|
156
|
+
)
|
157
|
+
|
158
|
+
[response[:data], response[:request_id]]
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|