nylas 5.17.0 → 6.0.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nylas/client.rb +107 -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 +140 -0
  6. data/lib/nylas/handler/http_client.rb +243 -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 +211 -0
  10. data/lib/nylas/resources/calendars.rb +101 -0
  11. data/lib/nylas/resources/connectors.rb +80 -0
  12. data/lib/nylas/resources/credentials.rb +75 -0
  13. data/lib/nylas/resources/drafts.rb +91 -0
  14. data/lib/nylas/resources/events.rb +83 -0
  15. data/lib/nylas/resources/folders.rb +73 -0
  16. data/lib/nylas/resources/grants.rb +70 -0
  17. data/lib/nylas/resources/messages.rb +126 -0
  18. data/lib/nylas/resources/redirect_uris.rb +68 -0
  19. data/lib/nylas/resources/resource.rb +18 -0
  20. data/lib/nylas/resources/smart_compose.rb +36 -0
  21. data/lib/nylas/resources/threads.rb +62 -0
  22. data/lib/nylas/resources/webhooks.rb +85 -0
  23. data/lib/nylas/utils/file_utils.rb +49 -0
  24. data/lib/nylas/version.rb +1 -1
  25. data/lib/nylas.rb +30 -148
  26. metadata +87 -247
  27. data/lib/nylas/account.rb +0 -56
  28. data/lib/nylas/api.rb +0 -246
  29. data/lib/nylas/application_details.rb +0 -13
  30. data/lib/nylas/calendar.rb +0 -46
  31. data/lib/nylas/calendar_collection.rb +0 -144
  32. data/lib/nylas/categorize.rb +0 -14
  33. data/lib/nylas/collection.rb +0 -175
  34. data/lib/nylas/component.rb +0 -35
  35. data/lib/nylas/component_collection.rb +0 -10
  36. data/lib/nylas/constraints.rb +0 -56
  37. data/lib/nylas/contact.rb +0 -53
  38. data/lib/nylas/contact_group.rb +0 -23
  39. data/lib/nylas/current_account.rb +0 -23
  40. data/lib/nylas/delta.rb +0 -56
  41. data/lib/nylas/deltas.rb +0 -19
  42. data/lib/nylas/deltas_collection.rb +0 -40
  43. data/lib/nylas/draft.rb +0 -100
  44. data/lib/nylas/email_address.rb +0 -12
  45. data/lib/nylas/event.rb +0 -144
  46. data/lib/nylas/event_collection.rb +0 -15
  47. data/lib/nylas/event_conferencing.rb +0 -12
  48. data/lib/nylas/event_conferencing_autocreate.rb +0 -10
  49. data/lib/nylas/event_conferencing_details.rb +0 -14
  50. data/lib/nylas/event_notification.rb +0 -17
  51. data/lib/nylas/file.rb +0 -75
  52. data/lib/nylas/filter_attributes.rb +0 -25
  53. data/lib/nylas/folder.rb +0 -26
  54. data/lib/nylas/free_busy.rb +0 -13
  55. data/lib/nylas/free_busy_collection.rb +0 -48
  56. data/lib/nylas/http_client.rb +0 -279
  57. data/lib/nylas/im_address.rb +0 -11
  58. data/lib/nylas/job_status.rb +0 -27
  59. data/lib/nylas/job_status_collection.rb +0 -21
  60. data/lib/nylas/label.rb +0 -27
  61. data/lib/nylas/logging.rb +0 -41
  62. data/lib/nylas/message.rb +0 -98
  63. data/lib/nylas/message_headers.rb +0 -27
  64. data/lib/nylas/message_tracking.rb +0 -13
  65. data/lib/nylas/model/attributable.rb +0 -89
  66. data/lib/nylas/model/attribute_definition.rb +0 -24
  67. data/lib/nylas/model/attributes.rb +0 -97
  68. data/lib/nylas/model/list_attribute_definition.rb +0 -39
  69. data/lib/nylas/model/transferable.rb +0 -53
  70. data/lib/nylas/model.rb +0 -217
  71. data/lib/nylas/native_authentication.rb +0 -39
  72. data/lib/nylas/neural.rb +0 -87
  73. data/lib/nylas/neural_categorizer.rb +0 -29
  74. data/lib/nylas/neural_clean_conversation.rb +0 -33
  75. data/lib/nylas/neural_contact_link.rb +0 -11
  76. data/lib/nylas/neural_contact_name.rb +0 -11
  77. data/lib/nylas/neural_message_options.rb +0 -35
  78. data/lib/nylas/neural_ocr.rb +0 -16
  79. data/lib/nylas/neural_sentiment_analysis.rb +0 -17
  80. data/lib/nylas/neural_signature_contact.rb +0 -81
  81. data/lib/nylas/neural_signature_extraction.rb +0 -18
  82. data/lib/nylas/new_message.rb +0 -39
  83. data/lib/nylas/nylas_date.rb +0 -25
  84. data/lib/nylas/open_hours.rb +0 -15
  85. data/lib/nylas/outbox.rb +0 -116
  86. data/lib/nylas/outbox_job_status.rb +0 -19
  87. data/lib/nylas/outbox_message.rb +0 -17
  88. data/lib/nylas/participant.rb +0 -13
  89. data/lib/nylas/phone_number.rb +0 -11
  90. data/lib/nylas/physical_address.rb +0 -17
  91. data/lib/nylas/raw_message.rb +0 -25
  92. data/lib/nylas/recurrence.rb +0 -11
  93. data/lib/nylas/registry.rb +0 -42
  94. data/lib/nylas/room_resource.rb +0 -19
  95. data/lib/nylas/rsvp.rb +0 -24
  96. data/lib/nylas/scheduler.rb +0 -51
  97. data/lib/nylas/scheduler_booking_confirmation.rb +0 -24
  98. data/lib/nylas/scheduler_booking_request.rb +0 -17
  99. data/lib/nylas/scheduler_collection.rb +0 -104
  100. data/lib/nylas/scheduler_config.rb +0 -20
  101. data/lib/nylas/scheduler_time_slot.rb +0 -14
  102. data/lib/nylas/search_collection.rb +0 -10
  103. data/lib/nylas/send_grid_verified_status.rb +0 -12
  104. data/lib/nylas/services/tunnel.rb +0 -128
  105. data/lib/nylas/thread.rb +0 -66
  106. data/lib/nylas/time_slot.rb +0 -16
  107. data/lib/nylas/time_slot_capacity.rb +0 -13
  108. data/lib/nylas/timespan.rb +0 -20
  109. data/lib/nylas/token_info.rb +0 -20
  110. data/lib/nylas/types.rb +0 -168
  111. data/lib/nylas/web_page.rb +0 -11
  112. data/lib/nylas/webhook.rb +0 -111
  113. 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::Put
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
+ put(
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,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::Put
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
+ put(
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,91 @@
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)] The list of drafts and API Request ID.
20
+ def list(identifier:, query_params: nil)
21
+ get(
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
+ form_body, opened_files = FileUtils.build_form_request(request_body)
47
+ response = post(
48
+ path: "#{api_uri}/v3/grants/#{identifier}/drafts",
49
+ request_body: form_body
50
+ )
51
+
52
+ opened_files.each(&:close)
53
+
54
+ response
55
+ end
56
+
57
+ # Update an draft.
58
+ #
59
+ # @param identifier [String] Grant ID or email account in which to update the draft.
60
+ # @param draft_id [String] The id of the draft to update.
61
+ # @param request_body [Hash] The values to create the message with.
62
+ # If you're attaching files, you must pass an array of [File] objects, or
63
+ # you can use {FileUtils::attach_file_request_builder} to build each object attach.
64
+ # @return [Array(Hash, String)] The updated draft and API Request ID.
65
+ def update(identifier:, draft_id:, request_body:)
66
+ form_body, opened_files = FileUtils.build_form_request(request_body)
67
+
68
+ response = put(
69
+ path: "#{api_uri}/v3/grants/#{identifier}/drafts/#{draft_id}",
70
+ request_body: form_body
71
+ )
72
+
73
+ opened_files.each(&:close)
74
+
75
+ response
76
+ end
77
+
78
+ # Delete an draft.
79
+ #
80
+ # @param identifier [String] Grant ID or email account from which to delete an object.
81
+ # @param draft_id [String] The id of the draft to delete.
82
+ # @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
83
+ def destroy(identifier:, draft_id:)
84
+ _, request_id = delete(
85
+ path: "#{api_uri}/v3/grants/#{identifier}/drafts/#{draft_id}"
86
+ )
87
+
88
+ [true, request_id]
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,83 @@
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)] The list of events and API Request ID.
19
+ def list(identifier:, query_params:)
20
+ get(
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
+ end
83
+ 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)] The list of folders and API Request ID.
18
+ def list(identifier:)
19
+ get(
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,70 @@
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::Post
11
+ include ApiOperations::Put
12
+ include ApiOperations::Delete
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/grant",
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/grant/#{grant_id}"
32
+ )
33
+ end
34
+
35
+ # Create a Grant via Custom Authentication.
36
+ #
37
+ # @param request_body [Hash] The values to create the Grant with.
38
+ # @return [Array(Hash, String)] Created grant and API Request ID.
39
+ def create(request_body)
40
+ post(
41
+ path: "#{api_uri}/v3/#{resource_name}/custom",
42
+ request_body: request_body
43
+ )
44
+ end
45
+
46
+ # Update a grant.
47
+ #
48
+ # @param grant_id [String] The id of the grant to update.
49
+ # @param request_body [Hash] The values to update the grant with
50
+ # @return [Array(Hash, String)] The updated grant and API Request ID.
51
+ def update(grant_id:, request_body:)
52
+ put(
53
+ path: "#{api_uri}/v3/grant/#{grant_id}",
54
+ request_body: request_body
55
+ )
56
+ end
57
+
58
+ # Delete a grant.
59
+ #
60
+ # @param grant_id [String] The id of the grant to delete.
61
+ # @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
62
+ def destroy(grant_id:)
63
+ _, request_id = delete(
64
+ path: "#{api_uri}/v3/grant/#{grant_id}"
65
+ )
66
+
67
+ [true, request_id]
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,126 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "resource"
4
+ require_relative "smart_compose"
5
+ require_relative "../handler/api_operations"
6
+ require_relative "../utils/file_utils"
7
+
8
+ module Nylas
9
+ # Nylas Messages API
10
+ class Messages < Resource
11
+ include ApiOperations::Get
12
+ include ApiOperations::Post
13
+ include ApiOperations::Put
14
+ include ApiOperations::Delete
15
+
16
+ attr_reader :smart_compose
17
+
18
+ # Initializes the messages resource.
19
+ # @param sdk_instance [Nylas::API] The API instance to which the resource is bound.
20
+ def initialize(sdk_instance)
21
+ super(sdk_instance)
22
+ @smart_compose = SmartCompose.new(sdk_instance)
23
+ end
24
+
25
+ # Return all messages.
26
+ #
27
+ # @param identifier [String] Grant ID or email account to query.
28
+ # @param query_params [Hash, nil] Query params to pass to the request.
29
+ # @return [Array(Array(Hash), String)] The list of messages and API Request ID.
30
+ def list(identifier:, query_params: nil)
31
+ get(
32
+ path: "#{api_uri}/v3/grants/#{identifier}/messages",
33
+ query_params: query_params
34
+ )
35
+ end
36
+
37
+ # Return a message.
38
+ #
39
+ # @param identifier [String] Grant ID or email account to query.
40
+ # @param message_id [String] The id of the message to return.
41
+ # @return [Array(Hash, String)] The message and API request ID.
42
+ def find(identifier:, message_id:)
43
+ get(
44
+ path: "#{api_uri}/v3/grants/#{identifier}/messages/#{message_id}"
45
+ )
46
+ end
47
+
48
+ # Update a message.
49
+ #
50
+ # @param identifier [String] Grant ID or email account in which to update an object.
51
+ # @param message_id [String] The id of the message to update.
52
+ # @param request_body [Hash] The values to update the message with
53
+ # @return [Array(Hash, String)] The updated message and API Request ID.
54
+ def update(identifier:, message_id:, request_body:)
55
+ put(
56
+ path: "#{api_uri}/v3/grants/#{identifier}/messages/#{message_id}",
57
+ request_body: request_body
58
+ )
59
+ end
60
+
61
+ # Delete a message.
62
+ #
63
+ # @param identifier [String] Grant ID or email account from which to delete an object.
64
+ # @param message_id [String] The id of the message to delete.
65
+ # @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
66
+ def destroy(identifier:, message_id:)
67
+ _, request_id = delete(
68
+ path: "#{api_uri}/v3/grants/#{identifier}/messages/#{message_id}"
69
+ )
70
+
71
+ [true, request_id]
72
+ end
73
+
74
+ # Send a message.
75
+ #
76
+ # @param identifier [String] Grant ID or email account from which to delete an object.
77
+ # @param request_body [Hash] The values to create the message with.
78
+ # If you're attaching files, you must pass an array of [File] objects, or
79
+ # you can use {FileUtils::attach_file_request_builder} to build each object attach.
80
+ # @return [Array(Hash, String)] The sent message and the API Request ID.
81
+ def send(identifier:, request_body:)
82
+ form_body, opened_files = FileUtils.build_form_request(request_body)
83
+
84
+ response = post(
85
+ path: "#{api_uri}/v3/grants/#{identifier}/messages/send",
86
+ request_body: form_body
87
+ )
88
+
89
+ opened_files.each(&:close)
90
+
91
+ response
92
+ end
93
+
94
+ # Retrieve your scheduled messages.
95
+ #
96
+ # @param identifier [String] Grant ID or email account from which to find the scheduled message from.
97
+ # @param schedule_id [String] The id of the scheduled message to stop.
98
+ # @return [Array(Hash, String)] The list of scheduled messages and the API Request ID.
99
+ def list_scheduled_messages(identifier:, schedule_id:)
100
+ get(
101
+ path: "#{api_uri}/v3/grants/#{identifier}/messages/schedules/#{schedule_id}"
102
+ )
103
+ end
104
+
105
+ # Retrieve your scheduled messages.
106
+ #
107
+ # @param identifier [String] Grant ID or email account from which to list the scheduled messages from.
108
+ # @return [Array(Hash, String)] The scheduled message and the API Request ID.
109
+ def find_scheduled_messages(identifier:)
110
+ get(
111
+ path: "#{api_uri}/v3/grants/#{identifier}/messages/schedules"
112
+ )
113
+ end
114
+
115
+ # Stop a scheduled message.
116
+ #
117
+ # @param identifier [String] Grant ID or email account from which to list the scheduled messages from.
118
+ # @param schedule_id [String] The id of the scheduled message to stop..
119
+ # @return [Array(Hash, String)] The scheduled message and the API Request ID.
120
+ def stop_scheduled_messages(identifier:, schedule_id:)
121
+ delete(
122
+ path: "#{api_uri}/v3/grants/#{identifier}/messages/schedules/#{schedule_id}"
123
+ )
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "resource"
4
+ require_relative "../handler/api_operations"
5
+
6
+ module Nylas
7
+ # A collection of redirect URI related API endpoints.
8
+ class RedirectUris < Resource
9
+ include ApiOperations::Get
10
+ include ApiOperations::Post
11
+ include ApiOperations::Put
12
+ include ApiOperations::Delete
13
+
14
+ # Return all redirect uris.
15
+ #
16
+ # @return [Array(Array(Hash), String)] The list of redirect uris and API Request ID.
17
+ def list
18
+ get(
19
+ path: "#{api_uri}/v3/applications/redirect-uris"
20
+ )
21
+ end
22
+
23
+ # Return a redirect uri.
24
+ #
25
+ # @param redirect_uri_id [String] The id of the redirect uri to return.
26
+ # @return [Array(Hash, String)] The redirect uri and API request ID.
27
+ def find(redirect_uri_id:)
28
+ get(
29
+ path: "#{api_uri}/v3/applications/redirect-uris/#{redirect_uri_id}"
30
+ )
31
+ end
32
+
33
+ # Create a redirect uri.
34
+ #
35
+ # @param request_body [Hash] The values to create the redirect uri with.
36
+ # @return [Array(Hash, String)] The created redirect uri and API Request ID.
37
+ def create(request_body:)
38
+ post(
39
+ path: "#{api_uri}/v3/applications/redirect-uris",
40
+ request_body: request_body
41
+ )
42
+ end
43
+
44
+ # Update a redirect uri.
45
+ #
46
+ # @param redirect_uri_id [String] The id of the redirect uri to update.
47
+ # @param request_body [Hash] The values to update the redirect uri with
48
+ # @return [Array(Hash, String)] The updated redirect uri and API Request ID.
49
+ def update(redirect_uri_id:, request_body:)
50
+ put(
51
+ path: "#{api_uri}/v3/applications/redirect-uris/#{redirect_uri_id}",
52
+ request_body: request_body
53
+ )
54
+ end
55
+
56
+ # Delete a redirect uri.
57
+ #
58
+ # @param redirect_uri_id [String] The id of the redirect uri to delete.
59
+ # @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
60
+ def destroy(redirect_uri_id:)
61
+ _, request_id = delete(
62
+ path: "#{api_uri}/v3/applications/redirect-uris/#{redirect_uri_id}"
63
+ )
64
+
65
+ [true, request_id]
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nylas
4
+ # NOTE: BaseResource is the base class for all Nylas API resources.
5
+ # Used by all Nylas API resources
6
+ class Resource
7
+ # Initializes a resource.
8
+ def initialize(sdk_instance)
9
+ @api_key = sdk_instance.api_key
10
+ @api_uri = sdk_instance.api_uri
11
+ @timeout = sdk_instance.timeout
12
+ end
13
+
14
+ private
15
+
16
+ attr_reader :resource_name, :api_key, :api_uri, :timeout
17
+ end
18
+ end