nylas 5.17.0 → 6.0.0.beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nylas/client.rb +62 -0
  3. data/lib/nylas/config.rb +19 -0
  4. data/lib/nylas/errors.rb +41 -89
  5. data/lib/nylas/handler/admin_api_operations.rb +95 -0
  6. data/lib/nylas/handler/api_operations.rb +138 -0
  7. data/lib/nylas/handler/grants_api_operations.rb +99 -0
  8. data/lib/nylas/handler/http_client.rb +179 -0
  9. data/lib/nylas/resources/applications.rb +27 -0
  10. data/lib/nylas/resources/auth.rb +197 -0
  11. data/lib/nylas/resources/calendars.rb +31 -0
  12. data/lib/nylas/resources/events.rb +20 -0
  13. data/lib/nylas/resources/grants.rb +20 -0
  14. data/lib/nylas/resources/redirect_uris.rb +20 -0
  15. data/lib/nylas/resources/resource.rb +18 -0
  16. data/lib/nylas/resources/webhooks.rb +37 -0
  17. data/lib/nylas/version.rb +1 -1
  18. data/lib/nylas.rb +20 -148
  19. metadata +70 -257
  20. data/lib/nylas/account.rb +0 -56
  21. data/lib/nylas/api.rb +0 -246
  22. data/lib/nylas/application_details.rb +0 -13
  23. data/lib/nylas/calendar.rb +0 -46
  24. data/lib/nylas/calendar_collection.rb +0 -144
  25. data/lib/nylas/categorize.rb +0 -14
  26. data/lib/nylas/collection.rb +0 -175
  27. data/lib/nylas/component.rb +0 -35
  28. data/lib/nylas/component_collection.rb +0 -10
  29. data/lib/nylas/constraints.rb +0 -56
  30. data/lib/nylas/contact.rb +0 -53
  31. data/lib/nylas/contact_group.rb +0 -23
  32. data/lib/nylas/current_account.rb +0 -23
  33. data/lib/nylas/delta.rb +0 -56
  34. data/lib/nylas/deltas.rb +0 -19
  35. data/lib/nylas/deltas_collection.rb +0 -40
  36. data/lib/nylas/draft.rb +0 -100
  37. data/lib/nylas/email_address.rb +0 -12
  38. data/lib/nylas/event.rb +0 -144
  39. data/lib/nylas/event_collection.rb +0 -15
  40. data/lib/nylas/event_conferencing.rb +0 -12
  41. data/lib/nylas/event_conferencing_autocreate.rb +0 -10
  42. data/lib/nylas/event_conferencing_details.rb +0 -14
  43. data/lib/nylas/event_notification.rb +0 -17
  44. data/lib/nylas/file.rb +0 -75
  45. data/lib/nylas/filter_attributes.rb +0 -25
  46. data/lib/nylas/folder.rb +0 -26
  47. data/lib/nylas/free_busy.rb +0 -13
  48. data/lib/nylas/free_busy_collection.rb +0 -48
  49. data/lib/nylas/http_client.rb +0 -279
  50. data/lib/nylas/im_address.rb +0 -11
  51. data/lib/nylas/job_status.rb +0 -27
  52. data/lib/nylas/job_status_collection.rb +0 -21
  53. data/lib/nylas/label.rb +0 -27
  54. data/lib/nylas/logging.rb +0 -41
  55. data/lib/nylas/message.rb +0 -98
  56. data/lib/nylas/message_headers.rb +0 -27
  57. data/lib/nylas/message_tracking.rb +0 -13
  58. data/lib/nylas/model/attributable.rb +0 -89
  59. data/lib/nylas/model/attribute_definition.rb +0 -24
  60. data/lib/nylas/model/attributes.rb +0 -97
  61. data/lib/nylas/model/list_attribute_definition.rb +0 -39
  62. data/lib/nylas/model/transferable.rb +0 -53
  63. data/lib/nylas/model.rb +0 -217
  64. data/lib/nylas/native_authentication.rb +0 -39
  65. data/lib/nylas/neural.rb +0 -87
  66. data/lib/nylas/neural_categorizer.rb +0 -29
  67. data/lib/nylas/neural_clean_conversation.rb +0 -33
  68. data/lib/nylas/neural_contact_link.rb +0 -11
  69. data/lib/nylas/neural_contact_name.rb +0 -11
  70. data/lib/nylas/neural_message_options.rb +0 -35
  71. data/lib/nylas/neural_ocr.rb +0 -16
  72. data/lib/nylas/neural_sentiment_analysis.rb +0 -17
  73. data/lib/nylas/neural_signature_contact.rb +0 -81
  74. data/lib/nylas/neural_signature_extraction.rb +0 -18
  75. data/lib/nylas/new_message.rb +0 -39
  76. data/lib/nylas/nylas_date.rb +0 -25
  77. data/lib/nylas/open_hours.rb +0 -15
  78. data/lib/nylas/outbox.rb +0 -116
  79. data/lib/nylas/outbox_job_status.rb +0 -19
  80. data/lib/nylas/outbox_message.rb +0 -17
  81. data/lib/nylas/participant.rb +0 -13
  82. data/lib/nylas/phone_number.rb +0 -11
  83. data/lib/nylas/physical_address.rb +0 -17
  84. data/lib/nylas/raw_message.rb +0 -25
  85. data/lib/nylas/recurrence.rb +0 -11
  86. data/lib/nylas/registry.rb +0 -42
  87. data/lib/nylas/room_resource.rb +0 -19
  88. data/lib/nylas/rsvp.rb +0 -24
  89. data/lib/nylas/scheduler.rb +0 -51
  90. data/lib/nylas/scheduler_booking_confirmation.rb +0 -24
  91. data/lib/nylas/scheduler_booking_request.rb +0 -17
  92. data/lib/nylas/scheduler_collection.rb +0 -104
  93. data/lib/nylas/scheduler_config.rb +0 -20
  94. data/lib/nylas/scheduler_time_slot.rb +0 -14
  95. data/lib/nylas/search_collection.rb +0 -10
  96. data/lib/nylas/send_grid_verified_status.rb +0 -12
  97. data/lib/nylas/services/tunnel.rb +0 -128
  98. data/lib/nylas/thread.rb +0 -66
  99. data/lib/nylas/time_slot.rb +0 -16
  100. data/lib/nylas/time_slot_capacity.rb +0 -13
  101. data/lib/nylas/timespan.rb +0 -20
  102. data/lib/nylas/token_info.rb +0 -20
  103. data/lib/nylas/types.rb +0 -168
  104. data/lib/nylas/web_page.rb +0 -11
  105. data/lib/nylas/webhook.rb +0 -111
  106. data/lib/nylas/when.rb +0 -75
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0660c04f6656d846a55819153819877b599ed5342d8f2ea9c18a7b19e0799ec3
4
- data.tar.gz: bf1bd6d4382a6705a5146ff86202436512cf0fc5c68817c77a932e846c3150cf
3
+ metadata.gz: 8695c7d105dd1621576a1cc5dfa3bd2d7ff482d171763bf9273a3797cc320675
4
+ data.tar.gz: 88bda22c310af6c54061db72b6c19a5c4f8abed1e8e6a8518f4a4585d1ea6c38
5
5
  SHA512:
6
- metadata.gz: 076702b69e4ea6a7ef882f3ac65490d54c90bae69cdc8f940aab62a4d29997627d7936b3426158e10935f1aecfad517e17b2d3c5502aa26a636e48319c492fcd
7
- data.tar.gz: 1d7fd956e5676c2b418ed2d0d79ecfd9cf3b6a961f8768ee0dd97952f0ea043810e90499063b1940efc055506a79187f78d4daf04fe386dfbdf64141bd1d9262
6
+ metadata.gz: cc213a177a26c78864c48e678f6ff2d01cf9a3f29305cb2169b192018a531f3b5d106dab1fdfd350b323e1bbb69c4069ed13ec8ff5319742805c559077d52ac5
7
+ data.tar.gz: 2d51f8063938e335b00d9331f1beb9fb7c317c0af0954544c8ed40e3e4e14341452cdcf9be98a61ac4f9aae24d98eb0661434aea622a495fbd7f531d1293ec5c
@@ -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
@@ -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
- # Raised when attempting to set a field that is not on a model with mass assignment
20
- class ModelMissingFieldError < ModelActionError
21
- def initialize(field, model)
22
- super("#{field} is not a valid attribute for #{model.class.name}")
23
- end
24
- end
25
-
26
- # Indicates that a given method needs an access token to work.
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)
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.message = message
46
- self.server_error = server_error
22
+ self.status_code = status_code
23
+ self.provider_error = provider_error
24
+ self.request_id = request_id
47
25
  end
48
26
 
49
- def self.parse_error_response(response)
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
- response["server_error"]
35
+ status_code,
36
+ response["provider_error"]
54
37
  )
55
38
  end
56
39
  end
57
40
 
58
- # Error class representing a 429 error response, with details on the rate limit
59
- class RateLimitError < APIError
60
- attr_accessor :rate_limit
61
- attr_accessor :rate_limit_reset
62
-
63
- RATE_LIMIT_LIMIT_HEADER = "x_ratelimit_limit"
64
- RATE_LIMIT_RESET_HEADER = "x_ratelimit_reset"
65
-
66
- def initialize(type, message, server_error = nil, rate_limit = nil, rate_limit_reset = nil)
67
- super(type, message, server_error)
68
- self.rate_limit = rate_limit
69
- self.rate_limit_reset = rate_limit_reset
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
- AccessDenied = Class.new(APIError)
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