nylas 5.17.0 → 6.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nylas/client.rb +121 -0
  3. data/lib/nylas/config.rb +19 -0
  4. data/lib/nylas/errors.rb +63 -89
  5. data/lib/nylas/handler/api_operations.rb +162 -0
  6. data/lib/nylas/handler/http_client.rb +252 -0
  7. data/lib/nylas/resources/applications.rb +27 -0
  8. data/lib/nylas/resources/attachments.rb +65 -0
  9. data/lib/nylas/resources/auth.rb +209 -0
  10. data/lib/nylas/resources/calendars.rb +101 -0
  11. data/lib/nylas/resources/connectors.rb +80 -0
  12. data/lib/nylas/resources/contacts.rb +89 -0
  13. data/lib/nylas/resources/credentials.rb +75 -0
  14. data/lib/nylas/resources/drafts.rb +121 -0
  15. data/lib/nylas/resources/events.rb +98 -0
  16. data/lib/nylas/resources/folders.rb +73 -0
  17. data/lib/nylas/resources/grants.rb +59 -0
  18. data/lib/nylas/resources/messages.rb +135 -0
  19. data/lib/nylas/resources/redirect_uris.rb +68 -0
  20. data/lib/nylas/resources/resource.rb +18 -0
  21. data/lib/nylas/resources/smart_compose.rb +36 -0
  22. data/lib/nylas/resources/threads.rb +62 -0
  23. data/lib/nylas/resources/webhooks.rb +121 -0
  24. data/lib/nylas/utils/file_utils.rb +61 -0
  25. data/lib/nylas/version.rb +1 -1
  26. data/lib/nylas.rb +31 -148
  27. metadata +88 -247
  28. data/lib/nylas/account.rb +0 -56
  29. data/lib/nylas/api.rb +0 -246
  30. data/lib/nylas/application_details.rb +0 -13
  31. data/lib/nylas/calendar.rb +0 -46
  32. data/lib/nylas/calendar_collection.rb +0 -144
  33. data/lib/nylas/categorize.rb +0 -14
  34. data/lib/nylas/collection.rb +0 -175
  35. data/lib/nylas/component.rb +0 -35
  36. data/lib/nylas/component_collection.rb +0 -10
  37. data/lib/nylas/constraints.rb +0 -56
  38. data/lib/nylas/contact.rb +0 -53
  39. data/lib/nylas/contact_group.rb +0 -23
  40. data/lib/nylas/current_account.rb +0 -23
  41. data/lib/nylas/delta.rb +0 -56
  42. data/lib/nylas/deltas.rb +0 -19
  43. data/lib/nylas/deltas_collection.rb +0 -40
  44. data/lib/nylas/draft.rb +0 -100
  45. data/lib/nylas/email_address.rb +0 -12
  46. data/lib/nylas/event.rb +0 -144
  47. data/lib/nylas/event_collection.rb +0 -15
  48. data/lib/nylas/event_conferencing.rb +0 -12
  49. data/lib/nylas/event_conferencing_autocreate.rb +0 -10
  50. data/lib/nylas/event_conferencing_details.rb +0 -14
  51. data/lib/nylas/event_notification.rb +0 -17
  52. data/lib/nylas/file.rb +0 -75
  53. data/lib/nylas/filter_attributes.rb +0 -25
  54. data/lib/nylas/folder.rb +0 -26
  55. data/lib/nylas/free_busy.rb +0 -13
  56. data/lib/nylas/free_busy_collection.rb +0 -48
  57. data/lib/nylas/http_client.rb +0 -279
  58. data/lib/nylas/im_address.rb +0 -11
  59. data/lib/nylas/job_status.rb +0 -27
  60. data/lib/nylas/job_status_collection.rb +0 -21
  61. data/lib/nylas/label.rb +0 -27
  62. data/lib/nylas/logging.rb +0 -41
  63. data/lib/nylas/message.rb +0 -98
  64. data/lib/nylas/message_headers.rb +0 -27
  65. data/lib/nylas/message_tracking.rb +0 -13
  66. data/lib/nylas/model/attributable.rb +0 -89
  67. data/lib/nylas/model/attribute_definition.rb +0 -24
  68. data/lib/nylas/model/attributes.rb +0 -97
  69. data/lib/nylas/model/list_attribute_definition.rb +0 -39
  70. data/lib/nylas/model/transferable.rb +0 -53
  71. data/lib/nylas/model.rb +0 -217
  72. data/lib/nylas/native_authentication.rb +0 -39
  73. data/lib/nylas/neural.rb +0 -87
  74. data/lib/nylas/neural_categorizer.rb +0 -29
  75. data/lib/nylas/neural_clean_conversation.rb +0 -33
  76. data/lib/nylas/neural_contact_link.rb +0 -11
  77. data/lib/nylas/neural_contact_name.rb +0 -11
  78. data/lib/nylas/neural_message_options.rb +0 -35
  79. data/lib/nylas/neural_ocr.rb +0 -16
  80. data/lib/nylas/neural_sentiment_analysis.rb +0 -17
  81. data/lib/nylas/neural_signature_contact.rb +0 -81
  82. data/lib/nylas/neural_signature_extraction.rb +0 -18
  83. data/lib/nylas/new_message.rb +0 -39
  84. data/lib/nylas/nylas_date.rb +0 -25
  85. data/lib/nylas/open_hours.rb +0 -15
  86. data/lib/nylas/outbox.rb +0 -116
  87. data/lib/nylas/outbox_job_status.rb +0 -19
  88. data/lib/nylas/outbox_message.rb +0 -17
  89. data/lib/nylas/participant.rb +0 -13
  90. data/lib/nylas/phone_number.rb +0 -11
  91. data/lib/nylas/physical_address.rb +0 -17
  92. data/lib/nylas/raw_message.rb +0 -25
  93. data/lib/nylas/recurrence.rb +0 -11
  94. data/lib/nylas/registry.rb +0 -42
  95. data/lib/nylas/room_resource.rb +0 -19
  96. data/lib/nylas/rsvp.rb +0 -24
  97. data/lib/nylas/scheduler.rb +0 -51
  98. data/lib/nylas/scheduler_booking_confirmation.rb +0 -24
  99. data/lib/nylas/scheduler_booking_request.rb +0 -17
  100. data/lib/nylas/scheduler_collection.rb +0 -104
  101. data/lib/nylas/scheduler_config.rb +0 -20
  102. data/lib/nylas/scheduler_time_slot.rb +0 -14
  103. data/lib/nylas/search_collection.rb +0 -10
  104. data/lib/nylas/send_grid_verified_status.rb +0 -12
  105. data/lib/nylas/services/tunnel.rb +0 -128
  106. data/lib/nylas/thread.rb +0 -66
  107. data/lib/nylas/time_slot.rb +0 -16
  108. data/lib/nylas/time_slot_capacity.rb +0 -13
  109. data/lib/nylas/timespan.rb +0 -20
  110. data/lib/nylas/token_info.rb +0 -20
  111. data/lib/nylas/types.rb +0 -168
  112. data/lib/nylas/web_page.rb +0 -11
  113. data/lib/nylas/webhook.rb +0 -111
  114. data/lib/nylas/when.rb +0 -75
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "resource"
4
+ require_relative "../handler/api_operations"
5
+
6
+ module Nylas
7
+ # Nylas Connectors API
8
+ class Connectors < Resource
9
+ include ApiOperations::Get
10
+ include ApiOperations::Post
11
+ include ApiOperations::Patch
12
+ include ApiOperations::Delete
13
+
14
+ # Access the Credentials API
15
+ attr_reader :credentials
16
+
17
+ # Initializes Connectors.
18
+ def initialize(sdk_instance)
19
+ super(sdk_instance)
20
+
21
+ @credentials = Credentials.new(sdk_instance)
22
+ end
23
+
24
+ # Return all connectors.
25
+ #
26
+ # @param query_params [Hash, nil] Query params to pass to the request.
27
+ # @return [Array(Array(Hash), String)] The list of connectors and API Request ID.
28
+ def list(query_params: nil)
29
+ get(
30
+ path: "#{api_uri}/v3/connectors",
31
+ query_params: query_params
32
+ )
33
+ end
34
+
35
+ # Return a connector.
36
+ #
37
+ # @param provider [String] The provider associated to the connector to retrieve.
38
+ # @return [Array(Hash, String)] The connector and API request ID.
39
+ def find(provider:)
40
+ get(
41
+ path: "#{api_uri}/v3/connectors/#{provider}"
42
+ )
43
+ end
44
+
45
+ # Create a connector.
46
+ #
47
+ # @param request_body [Hash] The values to create the connector with.
48
+ # @return [Array(Hash, String)] The created connector and API Request ID.
49
+ def create(request_body:)
50
+ post(
51
+ path: "#{api_uri}/v3/connectors",
52
+ request_body: request_body
53
+ )
54
+ end
55
+
56
+ # Update a connector.
57
+ #
58
+ # @param provider [String] The provider associated to the connector to update.
59
+ # @param request_body [Hash] The values to update the connector with
60
+ # @return [Array(Hash, String)] The updated connector and API Request ID.
61
+ def update(provider:, request_body:)
62
+ patch(
63
+ path: "#{api_uri}/v3/connectors/#{provider}",
64
+ request_body: request_body
65
+ )
66
+ end
67
+
68
+ # Delete a connector.
69
+ #
70
+ # @param provider [String] The provider associated to the connector to delete.
71
+ # @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
72
+ def destroy(provider:)
73
+ _, request_id = delete(
74
+ path: "#{api_uri}/v3/connectors/#{provider}"
75
+ )
76
+
77
+ [true, request_id]
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "resource"
4
+ require_relative "../handler/api_operations"
5
+
6
+ module Nylas
7
+ # Nylas Contact API
8
+ class Contacts < Resource
9
+ include ApiOperations::Get
10
+ include ApiOperations::Post
11
+ include ApiOperations::Put
12
+ include ApiOperations::Delete
13
+
14
+ # Return all contacts.
15
+ #
16
+ # @param identifier [String] Grant ID or email account to query.
17
+ # @param query_params [Hash, nil] Query params to pass to the request.
18
+ # @return [Array(Array(Hash), String, String)] The list of contacts, API Request ID, and next cursor.
19
+ def list(identifier:, query_params: nil)
20
+ get_list(
21
+ path: "#{api_uri}/v3/grants/#{identifier}/contacts",
22
+ query_params: query_params
23
+ )
24
+ end
25
+
26
+ # Return a contact.
27
+ #
28
+ # @param identifier [String] Grant ID or email account to query.
29
+ # @param contact_id [String] The id of the contact to return.
30
+ # @param query_params [Hash, nil] Query params to pass to the request.
31
+ # @return [Array(Hash, String)] The contact and API request ID.
32
+ def find(identifier:, contact_id:, query_params: nil)
33
+ get(
34
+ path: "#{api_uri}/v3/grants/#{identifier}/contacts/#{contact_id}",
35
+ query_params: query_params
36
+ )
37
+ end
38
+
39
+ # Create a contact.
40
+ #
41
+ # @param identifier [String] Grant ID or email account in which to create the object.
42
+ # @param request_body [Hash] The values to create the contact with.
43
+ # @return [Array(Hash, String)] The created contact and API Request ID.
44
+ def create(identifier:, request_body:)
45
+ post(
46
+ path: "#{api_uri}/v3/grants/#{identifier}/contacts",
47
+ request_body: request_body
48
+ )
49
+ end
50
+
51
+ # Update a contact.
52
+ #
53
+ # @param identifier [String] Grant ID or email account in which to update an object.
54
+ # @param contact_id [String] The id of the contact to update.
55
+ # @param request_body [Hash] The values to update the contact with
56
+ # @return [Array(Hash, String)] The updated contact and API Request ID.
57
+ def update(identifier:, contact_id:, request_body:)
58
+ put(
59
+ path: "#{api_uri}/v3/grants/#{identifier}/contacts/#{contact_id}",
60
+ request_body: request_body
61
+ )
62
+ end
63
+
64
+ # Delete a contact.
65
+ #
66
+ # @param identifier [String] Grant ID or email account from which to delete an object.
67
+ # @param contact_id [String] The id of the contact to delete.
68
+ # @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
69
+ def destroy(identifier:, contact_id:)
70
+ _, request_id = delete(
71
+ path: "#{api_uri}/v3/grants/#{identifier}/contacts/#{contact_id}"
72
+ )
73
+
74
+ [true, request_id]
75
+ end
76
+
77
+ # Return all contact groups.
78
+ #
79
+ # @param identifier [String] Grant ID or email account to query.
80
+ # @param query_params [Hash, nil] Query params to pass to the request.
81
+ # @return [Array(Array(Hash), String, String)] The list of contact groups and API Request ID.
82
+ def list_groups(identifier:, query_params: nil)
83
+ get_list(
84
+ path: "#{api_uri}/v3/grants/#{identifier}/contacts/groups",
85
+ query_params: query_params
86
+ )
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "resource"
4
+ require_relative "../handler/api_operations"
5
+
6
+ module Nylas
7
+ # Nylas Connectors API
8
+ class Credentials < Resource
9
+ include ApiOperations::Get
10
+ include ApiOperations::Post
11
+ include ApiOperations::Patch
12
+ include ApiOperations::Delete
13
+
14
+ # Return all credentials.
15
+ #
16
+ # @param provider [String] The provider associated to the credential to list from
17
+ # @param query_params [Hash, nil] Query params to pass to the request.
18
+ # @return [Array(Array(Hash), String)] The list of credentials and API Request ID.
19
+ def list(provider:, query_params: nil)
20
+ get(
21
+ path: "#{api_uri}/v3/connectors/#{provider}/creds",
22
+ query_params: query_params
23
+ )
24
+ end
25
+
26
+ # Return a connector.
27
+ #
28
+ # @param provider [String] The provider associated to the connector to retrieve.
29
+ # @param credential_id [String] The id of the credentials to retrieve.
30
+ # @return [Array(Hash, String)] The connector and API request ID.
31
+ def find(provider:, credential_id:)
32
+ get(
33
+ path: "#{api_uri}/v3/connectors/#{provider}/creds/#{credential_id}"
34
+ )
35
+ end
36
+
37
+ # Create a connector.
38
+ #
39
+ # @param provider [String] The provider associated to the credential being created
40
+ # @param request_body [Hash] The values to create the connector with.
41
+ # @return [Array(Hash, String)] The created connector and API Request ID.
42
+ def create(provider:, request_body:)
43
+ post(
44
+ path: "#{api_uri}/v3/connectors/#{provider}/creds",
45
+ request_body: request_body
46
+ )
47
+ end
48
+
49
+ # Update a connector.
50
+ #
51
+ # @param provider [String] The provider associated to the connector to update from.
52
+ # @param credential_id [String] The id of the credentials to update.
53
+ # @param request_body [Hash] The values to update the connector with
54
+ # @return [Array(Hash, String)] The updated connector and API Request ID.
55
+ def update(provider:, credential_id:, request_body:)
56
+ patch(
57
+ path: "#{api_uri}/v3/connectors/#{provider}/creds/#{credential_id}",
58
+ request_body: request_body
59
+ )
60
+ end
61
+
62
+ # Delete a connector.
63
+ #
64
+ # @param provider [String] The provider associated to the connector to delete.
65
+ # @param credential_id [String] The id of the credentials to delete.
66
+ # @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
67
+ def destroy(provider:, credential_id:)
68
+ _, request_id = delete(
69
+ path: "#{api_uri}/v3/connectors/#{provider}/creds/#{credential_id}"
70
+ )
71
+
72
+ [true, request_id]
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,121 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "resource"
4
+ require_relative "../handler/api_operations"
5
+ require_relative "../utils/file_utils"
6
+
7
+ module Nylas
8
+ # Nylas Drafts API
9
+ class Drafts < Resource
10
+ include ApiOperations::Get
11
+ include ApiOperations::Post
12
+ include ApiOperations::Put
13
+ include ApiOperations::Delete
14
+
15
+ # Return all drafts.
16
+ #
17
+ # @param identifier [String] Grant ID or email account to query.
18
+ # @param query_params [Hash, nil] Query params to pass to the request.
19
+ # @return [Array(Array(Hash), String, String)] The list of drafts, API Request ID, and next cursor.
20
+ def list(identifier:, query_params: nil)
21
+ get_list(
22
+ path: "#{api_uri}/v3/grants/#{identifier}/drafts",
23
+ query_params: query_params
24
+ )
25
+ end
26
+
27
+ # Return an draft.
28
+ #
29
+ # @param identifier [String] Grant ID or email account to query.
30
+ # @param draft_id [String] The id of the draft to return.
31
+ # @return [Array(Hash, String)] The draft and API request ID.
32
+ def find(identifier:, draft_id:)
33
+ get(
34
+ path: "#{api_uri}/v3/grants/#{identifier}/drafts/#{draft_id}"
35
+ )
36
+ end
37
+
38
+ # Create an draft.
39
+ #
40
+ # @param identifier [String] Grant ID or email account in which to create the draft.
41
+ # @param request_body [Hash] The values to create the message with.
42
+ # If you're attaching files, you must pass an array of [File] objects, or
43
+ # you can use {FileUtils::attach_file_request_builder} to build each object attach.
44
+ # @return [Array(Hash, String)] The created draft and API Request ID.
45
+ def create(identifier:, request_body:)
46
+ payload = request_body
47
+ opened_files = []
48
+
49
+ # Use form data only if the attachment size is greater than 3mb
50
+ attachments = request_body[:attachments] || request_body["attachments"] || []
51
+ attachment_size = attachments&.sum { |attachment| attachment[:size] || 0 } || 0
52
+
53
+ if attachment_size >= FileUtils::FORM_DATA_ATTACHMENT_SIZE
54
+ payload, opened_files = FileUtils.build_form_request(request_body)
55
+ end
56
+
57
+ response = post(
58
+ path: "#{api_uri}/v3/grants/#{identifier}/drafts",
59
+ request_body: payload
60
+ )
61
+
62
+ opened_files.each(&:close)
63
+
64
+ response
65
+ end
66
+
67
+ # Update an draft.
68
+ #
69
+ # @param identifier [String] Grant ID or email account in which to update the draft.
70
+ # @param draft_id [String] The id of the draft to update.
71
+ # @param request_body [Hash] The values to create the message with.
72
+ # If you're attaching files, you must pass an array of [File] objects, or
73
+ # you can use {FileUtils::attach_file_request_builder} to build each object attach.
74
+ # @return [Array(Hash, String)] The updated draft and API Request ID.
75
+ def update(identifier:, draft_id:, request_body:)
76
+ payload = request_body
77
+ opened_files = []
78
+
79
+ # Use form data only if the attachment size is greater than 3mb
80
+ attachments = request_body[:attachments] || request_body["attachments"] || []
81
+ attachment_size = attachments&.sum { |attachment| attachment[:size] || 0 } || 0
82
+
83
+ if attachment_size >= FileUtils::FORM_DATA_ATTACHMENT_SIZE
84
+ payload, opened_files = FileUtils.build_form_request(request_body)
85
+ end
86
+
87
+ response = put(
88
+ path: "#{api_uri}/v3/grants/#{identifier}/drafts/#{draft_id}",
89
+ request_body: payload
90
+ )
91
+
92
+ opened_files.each(&:close)
93
+
94
+ response
95
+ end
96
+
97
+ # Delete an draft.
98
+ #
99
+ # @param identifier [String] Grant ID or email account from which to delete an object.
100
+ # @param draft_id [String] The id of the draft to delete.
101
+ # @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
102
+ def destroy(identifier:, draft_id:)
103
+ _, request_id = delete(
104
+ path: "#{api_uri}/v3/grants/#{identifier}/drafts/#{draft_id}"
105
+ )
106
+
107
+ [true, request_id]
108
+ end
109
+
110
+ # Send an draft.
111
+ #
112
+ # @param identifier [String] Grant ID or email account from which to send the draft.
113
+ # @param draft_id [String] The id of the draft to send.
114
+ # @return [Array(Hash, String)] The sent message draft and the API Request ID.
115
+ def send(identifier:, draft_id:)
116
+ post(
117
+ path: "#{api_uri}/v3/grants/#{identifier}/drafts/#{draft_id}"
118
+ )
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "resource"
4
+ require_relative "../handler/api_operations"
5
+
6
+ module Nylas
7
+ # Nylas Events API
8
+ class Events < Resource
9
+ include ApiOperations::Get
10
+ include ApiOperations::Post
11
+ include ApiOperations::Put
12
+ include ApiOperations::Delete
13
+
14
+ # Return all events.
15
+ #
16
+ # @param identifier [String] Grant ID or email account to query.
17
+ # @param query_params [Hash] Query params to pass to the request.
18
+ # @return [Array(Array(Hash), String, String)] The list of events, API Request ID, and next cursor.
19
+ def list(identifier:, query_params:)
20
+ get_list(
21
+ path: "#{api_uri}/v3/grants/#{identifier}/events",
22
+ query_params: query_params
23
+ )
24
+ end
25
+
26
+ # Return an event.
27
+ #
28
+ # @param identifier [String] Grant ID or email account to query.
29
+ # @param event_id [String] The id of the event to return.
30
+ # @param query_params [Hash] The query parameters to include in the request
31
+ # @return [Array(Hash, String)] The event and API request ID.
32
+ def find(identifier:, event_id:, query_params:)
33
+ get(
34
+ path: "#{api_uri}/v3/grants/#{identifier}/events/#{event_id}",
35
+ query_params: query_params
36
+ )
37
+ end
38
+
39
+ # Create an event.
40
+ #
41
+ # @param identifier [String] Grant ID or email account in which to create the object.
42
+ # @param request_body [Hash] The values to create the event with.
43
+ # @param query_params [Hash] The query parameters to include in the request.
44
+ # @return [Array(Hash, String)] The created event and API Request ID.
45
+ def create(identifier:, request_body:, query_params:)
46
+ post(
47
+ path: "#{api_uri}/v3/grants/#{identifier}/events",
48
+ query_params: query_params,
49
+ request_body: request_body
50
+ )
51
+ end
52
+
53
+ # Update an event.
54
+ #
55
+ # @param identifier [String] Grant ID or email account in which to update an object.
56
+ # @param event_id [String] The id of the event to update.
57
+ # @param request_body [Hash] The values to update the event with
58
+ # @param query_params [Hash] The query parameters to include in the request
59
+ # @return [Array(Hash, String)] The updated event and API Request ID.
60
+ def update(identifier:, event_id:, request_body:, query_params:)
61
+ put(
62
+ path: "#{api_uri}/v3/grants/#{identifier}/events/#{event_id}",
63
+ query_params: query_params,
64
+ request_body: request_body
65
+ )
66
+ end
67
+
68
+ # Delete an event.
69
+ #
70
+ # @param identifier [String] Grant ID or email account from which to delete an object.
71
+ # @param event_id [String] The id of the event to delete.
72
+ # @param query_params [Hash] The query parameters to include in the request
73
+ # @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
74
+ def destroy(identifier:, event_id:, query_params:)
75
+ _, request_id = delete(
76
+ path: "#{api_uri}/v3/grants/#{identifier}/events/#{event_id}",
77
+ query_params: query_params
78
+ )
79
+
80
+ [true, request_id]
81
+ end
82
+
83
+ # Send RSVP. Allows users to respond to events they have been added to as an attendee.
84
+ #
85
+ # @param identifier [String] Grant ID or email account from which to send RSVP with.
86
+ # @param event_id [String] The id of the event to respond to.
87
+ # @param request_body [Hash] The status values to send the RSVP with.
88
+ # @param query_params [Hash] The query parameters to include in the request
89
+ # @return [(Hash, String)] Response object with the API Request ID.
90
+ def send_rsvp(identifier:, event_id:, request_body:, query_params:)
91
+ post(
92
+ path: "#{api_uri}/v3/grants/#{identifier}/events/#{event_id}/send-rsvp",
93
+ query_params: query_params,
94
+ request_body: request_body
95
+ )
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "resource"
4
+ require_relative "../handler/api_operations"
5
+
6
+ module Nylas
7
+ # Nylas Folder API
8
+ class Folders < Resource
9
+ include ApiOperations::Get
10
+ include ApiOperations::Post
11
+ include ApiOperations::Put
12
+ include ApiOperations::Delete
13
+
14
+ # Return all folders.
15
+ #
16
+ # @param identifier [String] Grant ID or email account to query.
17
+ # @return [Array(Array(Hash), String, String)] The list of folders, API Request ID, and next cursor.
18
+ def list(identifier:)
19
+ get_list(
20
+ path: "#{api_uri}/v3/grants/#{identifier}/folders"
21
+ )
22
+ end
23
+
24
+ # Return a folder.
25
+ #
26
+ # @param identifier [String] Grant ID or email account to query.
27
+ # @param folder_id [String] The id of the folder to return.
28
+ # @return [Array(Hash, String)] The folder and API request ID.
29
+ def find(identifier:, folder_id:)
30
+ get(
31
+ path: "#{api_uri}/v3/grants/#{identifier}/folders/#{folder_id}"
32
+ )
33
+ end
34
+
35
+ # Create a folder.
36
+ #
37
+ # @param identifier [String] Grant ID or email account in which to create the object.
38
+ # @param request_body [Hash] The values to create the folder with.
39
+ # @return [Array(Hash, String)] The created folder and API Request ID.
40
+ def create(identifier:, request_body:)
41
+ post(
42
+ path: "#{api_uri}/v3/grants/#{identifier}/folders",
43
+ request_body: request_body
44
+ )
45
+ end
46
+
47
+ # Update a folder.
48
+ #
49
+ # @param identifier [String] Grant ID or email account in which to update an object.
50
+ # @param folder_id [String] The id of the folder to update.
51
+ # @param request_body [Hash] The values to update the folder with
52
+ # @return [Array(Hash, String)] The updated folder and API Request ID.
53
+ def update(identifier:, folder_id:, request_body:)
54
+ put(
55
+ path: "#{api_uri}/v3/grants/#{identifier}/folders/#{folder_id}",
56
+ request_body: request_body
57
+ )
58
+ end
59
+
60
+ # Delete a folder.
61
+ #
62
+ # @param identifier [String] Grant ID or email account from which to delete an object.
63
+ # @param folder_id [String] The id of the folder to delete.
64
+ # @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
65
+ def destroy(identifier:, folder_id:)
66
+ _, request_id = delete(
67
+ path: "#{api_uri}/v3/grants/#{identifier}/folders/#{folder_id}"
68
+ )
69
+
70
+ [true, request_id]
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "resource"
4
+ require_relative "../handler/api_operations"
5
+
6
+ module Nylas
7
+ # Grants
8
+ class Grants < Resource
9
+ include ApiOperations::Get
10
+ include ApiOperations::Put
11
+ include ApiOperations::Delete
12
+ include ApiOperations::Patch
13
+
14
+ # Return all grants.
15
+ #
16
+ # @param query_params [Hash, nil] Query params to pass to the request.
17
+ # @return [Array(Array(Hash), String)] The list of grants and API Request ID.
18
+ def list(query_params: nil)
19
+ get(
20
+ path: "#{api_uri}/v3/grants",
21
+ query_params: query_params
22
+ )
23
+ end
24
+
25
+ # Return a grant.
26
+ #
27
+ # @param grant_id [String] The id of the grant to return.
28
+ # @return [Array(Hash, String)] The grant and API request ID.
29
+ def find(grant_id:)
30
+ get(
31
+ path: "#{api_uri}/v3/grants/#{grant_id}"
32
+ )
33
+ end
34
+
35
+ # Update a grant.
36
+ #
37
+ # @param grant_id [String] The id of the grant to update.
38
+ # @param request_body [Hash] The values to update the grant with
39
+ # @return [Array(Hash, String)] The updated grant and API Request ID.
40
+ def update(grant_id:, request_body:)
41
+ patch(
42
+ path: "#{api_uri}/v3/grants/#{grant_id}",
43
+ request_body: request_body
44
+ )
45
+ end
46
+
47
+ # Delete a grant.
48
+ #
49
+ # @param grant_id [String] The id of the grant to delete.
50
+ # @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
51
+ def destroy(grant_id:)
52
+ _, request_id = delete(
53
+ path: "#{api_uri}/v3/grants/#{grant_id}"
54
+ )
55
+
56
+ [true, request_id]
57
+ end
58
+ end
59
+ end