nextmail 0.0.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 (79) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +183 -0
  3. data/lib/nextmail/api_paths.rb +447 -0
  4. data/lib/nextmail/client.rb +81 -0
  5. data/lib/nextmail/constants.rb +1621 -0
  6. data/lib/nextmail/credentials.rb +53 -0
  7. data/lib/nextmail/decode.rb +34 -0
  8. data/lib/nextmail/defaults.rb +114 -0
  9. data/lib/nextmail/endpoint.rb +144 -0
  10. data/lib/nextmail/errors.rb +121 -0
  11. data/lib/nextmail/http.rb +172 -0
  12. data/lib/nextmail/image_crop.rb +38 -0
  13. data/lib/nextmail/languages.rb +42 -0
  14. data/lib/nextmail/pagination.rb +63 -0
  15. data/lib/nextmail/protocol.rb +221 -0
  16. data/lib/nextmail/raw_body.rb +83 -0
  17. data/lib/nextmail/request_path.rb +50 -0
  18. data/lib/nextmail/resource.rb +109 -0
  19. data/lib/nextmail/resources/account.rb +155 -0
  20. data/lib/nextmail/resources/addresses.rb +38 -0
  21. data/lib/nextmail/resources/analytics.rb +19 -0
  22. data/lib/nextmail/resources/app_host.rb +23 -0
  23. data/lib/nextmail/resources/audiences.rb +95 -0
  24. data/lib/nextmail/resources/automations.rb +125 -0
  25. data/lib/nextmail/resources/billing.rb +76 -0
  26. data/lib/nextmail/resources/bookings.rb +100 -0
  27. data/lib/nextmail/resources/branding.rb +24 -0
  28. data/lib/nextmail/resources/broadcasts.rb +102 -0
  29. data/lib/nextmail/resources/calendar.rb +153 -0
  30. data/lib/nextmail/resources/chats.rb +62 -0
  31. data/lib/nextmail/resources/connected_mailboxes.rb +35 -0
  32. data/lib/nextmail/resources/connectors.rb +75 -0
  33. data/lib/nextmail/resources/contacts.rb +197 -0
  34. data/lib/nextmail/resources/dns_connections.rb +23 -0
  35. data/lib/nextmail/resources/domains.rb +264 -0
  36. data/lib/nextmail/resources/drafts.rb +36 -0
  37. data/lib/nextmail/resources/emails.rb +120 -0
  38. data/lib/nextmail/resources/encryption.rb +19 -0
  39. data/lib/nextmail/resources/events.rb +22 -0
  40. data/lib/nextmail/resources/exports.rb +27 -0
  41. data/lib/nextmail/resources/files.rb +82 -0
  42. data/lib/nextmail/resources/follow_ups.rb +21 -0
  43. data/lib/nextmail/resources/forms.rb +112 -0
  44. data/lib/nextmail/resources/imports.rb +106 -0
  45. data/lib/nextmail/resources/keys.rb +126 -0
  46. data/lib/nextmail/resources/knowledge.rb +137 -0
  47. data/lib/nextmail/resources/labels.rb +43 -0
  48. data/lib/nextmail/resources/languages.rb +11 -0
  49. data/lib/nextmail/resources/me.rb +57 -0
  50. data/lib/nextmail/resources/members.rb +100 -0
  51. data/lib/nextmail/resources/out_of_office.rb +28 -0
  52. data/lib/nextmail/resources/provider_imports.rb +48 -0
  53. data/lib/nextmail/resources/roles.rb +39 -0
  54. data/lib/nextmail/resources/rules.rb +73 -0
  55. data/lib/nextmail/resources/security.rb +39 -0
  56. data/lib/nextmail/resources/segments.rb +31 -0
  57. data/lib/nextmail/resources/senders.rb +19 -0
  58. data/lib/nextmail/resources/sending.rb +23 -0
  59. data/lib/nextmail/resources/settings.rb +16 -0
  60. data/lib/nextmail/resources/signatures.rb +41 -0
  61. data/lib/nextmail/resources/subscriptions.rb +55 -0
  62. data/lib/nextmail/resources/support.rb +11 -0
  63. data/lib/nextmail/resources/suppressions.rb +43 -0
  64. data/lib/nextmail/resources/tasks.rb +95 -0
  65. data/lib/nextmail/resources/temp_mail.rb +67 -0
  66. data/lib/nextmail/resources/templates.rb +153 -0
  67. data/lib/nextmail/resources/threads.rb +218 -0
  68. data/lib/nextmail/resources/tools.rb +35 -0
  69. data/lib/nextmail/resources/tracking.rb +72 -0
  70. data/lib/nextmail/resources/webhooks.rb +170 -0
  71. data/lib/nextmail/resources/workspaces.rb +40 -0
  72. data/lib/nextmail/results.rb +33 -0
  73. data/lib/nextmail/transport.rb +272 -0
  74. data/lib/nextmail/update_notice.rb +69 -0
  75. data/lib/nextmail/version.rb +5 -0
  76. data/lib/nextmail/webhook.rb +82 -0
  77. data/lib/nextmail/wire.rb +102 -0
  78. data/lib/nextmail.rb +126 -0
  79. metadata +122 -0
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nextmail
4
+ module Resources
5
+ class TempMail < Resource
6
+ def list_domains(inbox_token: nil)
7
+ envelope = request(ApiPaths::TEMP_MAIL_DOMAINS, anonymous: true)
8
+ Pagination.items_of(envelope.is_a?(Hash) ? envelope : {})
9
+ end
10
+
11
+ def create(body = nil, inbox_token: nil, **fields)
12
+ request(ApiPaths::TEMP_MAIL_INBOXES, method: :post, body: payload(body, fields), anonymous: true)
13
+ end
14
+
15
+ def get(inbox_id, inbox_token: nil)
16
+ request(fill(ApiPaths::TEMP_MAIL_INBOX, id: inbox_id), inbox_token:)
17
+ end
18
+
19
+ def extend(inbox_id, *modules, inbox_token: nil)
20
+ return super(inbox_id, *modules) if inbox_id.is_a?(Module)
21
+
22
+ request(fill(ApiPaths::TEMP_MAIL_INBOX_EXTEND, id: inbox_id), method: :post, inbox_token:)
23
+ end
24
+
25
+ def delete(inbox_id, inbox_token: nil)
26
+ request(fill(ApiPaths::TEMP_MAIL_INBOX, id: inbox_id), method: :delete, inbox_token:)
27
+ end
28
+
29
+ def list_messages(inbox_id, limit: nil, cursor: nil, inbox_token: nil)
30
+ envelope = request(fill(ApiPaths::TEMP_MAIL_MESSAGES, id: inbox_id), query: query_params(limit:, cursor:),
31
+ inbox_token:)
32
+ envelope = {} unless envelope.is_a?(Hash)
33
+ next_cursor = Pagination.cursor_of(envelope[:nextCursor])
34
+
35
+ TempMessagesPage.new(
36
+ items: Pagination.items_of(envelope),
37
+ has_more: Pagination.more?(envelope, next_cursor),
38
+ next_cursor:,
39
+ expires_at: envelope[:expiresAt]
40
+ )
41
+ end
42
+
43
+ def list_all_messages(inbox_id, limit: nil, cursor: nil, inbox_token: nil)
44
+ iterate_messages(inbox_id, limit:, cursor:, inbox_token:).to_a
45
+ end
46
+
47
+ def iterate_messages(inbox_id, limit: nil, cursor: nil, inbox_token: nil, &)
48
+ pages = Pagination.walk(cursor) { |current| list_messages(inbox_id, limit:, cursor: current, inbox_token:) }
49
+ each_or_enumerator(pages, &)
50
+ end
51
+
52
+ def get_message(inbox_id, message_id, inbox_token: nil)
53
+ request(fill(ApiPaths::TEMP_MAIL_MESSAGE, id: inbox_id, messageId: message_id), inbox_token:)
54
+ end
55
+
56
+ def delete_message(inbox_id, message_id, inbox_token: nil)
57
+ request(fill(ApiPaths::TEMP_MAIL_MESSAGE, id: inbox_id, messageId: message_id), method: :delete, inbox_token:)
58
+ end
59
+
60
+ def list_attachments(inbox_id, message_id, inbox_token: nil)
61
+ envelope = request(fill(ApiPaths::TEMP_MAIL_MESSAGE_ATTACHMENTS, id: inbox_id, messageId: message_id),
62
+ inbox_token:)
63
+ Pagination.items_of(envelope.is_a?(Hash) ? envelope : {})
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,153 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nextmail
4
+ module Resources
5
+ class Templates < Resource
6
+ def list(status: nil, search: nil, sort: nil, limit: nil, cursor: nil, api_key: nil)
7
+ fetch_page(ApiPaths::TEMPLATES, query_params(status:, search:, sort:), limit:, cursor:, api_key:)
8
+ end
9
+
10
+ def list_all(status: nil, search: nil, sort: nil, limit: nil, cursor: nil, api_key: nil)
11
+ collect_all(ApiPaths::TEMPLATES, query_params(status:, search:, sort:), limit:, cursor:, api_key:)
12
+ end
13
+
14
+ def iterate(status: nil, search: nil, sort: nil, limit: nil, cursor: nil, api_key: nil, &)
15
+ iterate_pages(ApiPaths::TEMPLATES, query_params(status:, search:, sort:), limit:, cursor:, api_key:, &)
16
+ end
17
+
18
+ def list_starters(api_key: nil)
19
+ fetch_list(ApiPaths::TEMPLATE_STARTERS, api_key:)
20
+ end
21
+
22
+ def list_fonts(api_key: nil)
23
+ fetch_list(ApiPaths::TEMPLATE_FONTS, api_key:)
24
+ end
25
+
26
+ def get_starter(slug, api_key: nil)
27
+ request(fill(ApiPaths::TEMPLATE_STARTER, slug:), api_key:)
28
+ end
29
+
30
+ def render(body = nil, api_key: nil, **fields)
31
+ request(ApiPaths::TEMPLATE_RENDER, method: :post, body: payload(body, fields), repeatable: true, api_key:)
32
+ end
33
+
34
+ def get(id_or_slug, api_key: nil)
35
+ request(fill(ApiPaths::TEMPLATE, id: id_or_slug), api_key:)
36
+ end
37
+
38
+ def create(body = nil, api_key: nil, **fields)
39
+ request(ApiPaths::TEMPLATES, method: :post, body: payload(body, fields), api_key:)
40
+ end
41
+
42
+ def update(id_or_slug, patch = nil, api_key: nil, **fields)
43
+ request(fill(ApiPaths::TEMPLATE, id: id_or_slug), method: :patch, body: payload(patch, fields), api_key:)
44
+ end
45
+
46
+ def delete(id_or_slug, api_key: nil)
47
+ request(fill(ApiPaths::TEMPLATE, id: id_or_slug), method: :delete, api_key:)
48
+ end
49
+
50
+ def duplicate(id_or_slug, body = nil, api_key: nil, **fields)
51
+ request(fill(ApiPaths::TEMPLATE_DUPLICATE, id: id_or_slug), method: :post, body: payload(body, fields),
52
+ api_key:)
53
+ end
54
+
55
+ def replace_content(id_or_slug, body = nil, api_key: nil, **fields)
56
+ request(fill(ApiPaths::TEMPLATE_CONTENT, id: id_or_slug), method: :post, body: payload(body, fields), api_key:)
57
+ end
58
+
59
+ def list_versions(id_or_slug, limit: nil, cursor: nil, api_key: nil)
60
+ fetch_page(fill(ApiPaths::TEMPLATE_VERSIONS, id: id_or_slug), limit:, cursor:, api_key:)
61
+ end
62
+
63
+ def list_all_versions(id_or_slug, limit: nil, cursor: nil, api_key: nil)
64
+ collect_all(fill(ApiPaths::TEMPLATE_VERSIONS, id: id_or_slug), limit:, cursor:, api_key:)
65
+ end
66
+
67
+ def iterate_versions(id_or_slug, limit: nil, cursor: nil, api_key: nil, &)
68
+ iterate_pages(fill(ApiPaths::TEMPLATE_VERSIONS, id: id_or_slug), limit:, cursor:, api_key:, &)
69
+ end
70
+
71
+ def get_version(id_or_slug, version, api_key: nil)
72
+ request(fill(ApiPaths::TEMPLATE_VERSION, id: id_or_slug, version:), api_key:)
73
+ end
74
+
75
+ def delete_version(id_or_slug, version, api_key: nil)
76
+ request(fill(ApiPaths::TEMPLATE_VERSION, id: id_or_slug, version:), method: :delete, api_key:)
77
+ end
78
+
79
+ def restore_version(id_or_slug, version, body = nil, api_key: nil, **fields)
80
+ request(fill(ApiPaths::TEMPLATE_VERSION_RESTORE, id: id_or_slug, version:), method: :post,
81
+ body: payload(body, fields), api_key:)
82
+ end
83
+
84
+ def publish(id_or_slug, expected_version: nil, expected_updated_at: nil, api_key: nil)
85
+ expected = {"expectedVersion" => expected_version, "expectedUpdatedAt" => expected_updated_at}.compact
86
+ request(fill(ApiPaths::TEMPLATE_VERSIONS, id: id_or_slug), method: :post, body: expected.empty? ? nil : expected,
87
+ repeatable: true, api_key:)
88
+ end
89
+
90
+ def preview(id_or_slug, body = nil, api_key: nil, **fields)
91
+ request(fill(ApiPaths::TEMPLATE_PREVIEW, id: id_or_slug), method: :post, body: payload(body, fields),
92
+ repeatable: true, api_key:)
93
+ end
94
+
95
+ def get_analytics(id_or_slug, days: nil, minutes: nil, grain: nil, offset_minutes: nil, api_key: nil)
96
+ request(fill(ApiPaths::TEMPLATE_ANALYTICS, id: id_or_slug), query: window_query(days, minutes, grain,
97
+ offset_minutes), api_key:)
98
+ end
99
+
100
+ def list_sends(id_or_slug, page: nil, page_size: nil, search: nil, source: nil, version: nil, opened: nil,
101
+ clicked: nil, tracked: nil, days: nil, minutes: nil, grain: nil, offset_minutes: nil, api_key: nil)
102
+ query = window_query(days, minutes, grain, offset_minutes).merge(query_params(page:, page_size:, search:,
103
+ source:, version:, opened: flag(opened), clicked: flag(clicked), tracked: flag(tracked)))
104
+ envelope = request(fill(ApiPaths::TEMPLATE_SENDS, id: id_or_slug), query:, api_key:)
105
+ envelope = {} unless envelope.is_a?(Hash)
106
+
107
+ TemplateSends.new(
108
+ items: Pagination.items_of(envelope),
109
+ total: envelope[:total] || 0,
110
+ page: envelope[:page] || 1,
111
+ page_size: envelope[:pageSize] || 0
112
+ )
113
+ end
114
+
115
+ def send(id_or_slug, body = nil, idempotency_key: nil, api_key: nil, **fields)
116
+ request(fill(ApiPaths::TEMPLATE_SEND, id: id_or_slug), method: :post, body: Wire.recipients(payload(body, fields)),
117
+ idempotent: true, idempotency_key:, repeatable: true, api_key:)
118
+ end
119
+
120
+ def list_images(limit: nil, cursor: nil, api_key: nil)
121
+ fetch_page(ApiPaths::TEMPLATE_IMAGES, limit:, cursor:, api_key:)
122
+ end
123
+
124
+ def list_all_images(limit: nil, cursor: nil, api_key: nil)
125
+ collect_all(ApiPaths::TEMPLATE_IMAGES, limit:, cursor:, api_key:)
126
+ end
127
+
128
+ def iterate_images(limit: nil, cursor: nil, api_key: nil, &)
129
+ iterate_pages(ApiPaths::TEMPLATE_IMAGES, limit:, cursor:, api_key:, &)
130
+ end
131
+
132
+ def upload_image(data, content_type: nil, crop: nil, api_key: nil)
133
+ request(ApiPaths::TEMPLATE_IMAGES, method: :post, query: crop_query(crop), raw: data,
134
+ content_type: raw_content_type(data, content_type), timeout: upload_timeout, api_key:)
135
+ end
136
+
137
+ def design(body = nil, api_key: nil, **fields)
138
+ request(ApiPaths::TEMPLATES_DESIGN, method: :post, body: payload(body, fields), api_key:)
139
+ end
140
+
141
+ def redesign(id_or_slug, body = nil, api_key: nil, **fields)
142
+ request(fill(ApiPaths::TEMPLATE_REDESIGN, id: id_or_slug), method: :post, body: payload(body, fields),
143
+ api_key:)
144
+ end
145
+
146
+ private
147
+
148
+ def window_query(days, minutes, grain, offset_minutes)
149
+ query_params(days:, minutes:, grain:, offset_minutes:)
150
+ end
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,218 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nextmail
4
+ module Resources
5
+ class Threads < Resource
6
+ def list(folder: nil, query: nil, label_ids: nil, sort: nil, date_from: nil, date_to: nil, from_contacts: nil,
7
+ semantic: nil, category: nil, address: nil, limit: nil, cursor: nil, api_key: nil)
8
+ fetch_page(ApiPaths::THREADS,
9
+ list_query(folder, query, label_ids, sort, date_from, date_to, from_contacts, semantic, category, address),
10
+ style: PAGE_TOKEN, limit:, cursor:, api_key:)
11
+ end
12
+
13
+ def list_all(folder: nil, query: nil, label_ids: nil, sort: nil, date_from: nil, date_to: nil,
14
+ from_contacts: nil, semantic: nil, category: nil, address: nil, limit: nil, cursor: nil, api_key: nil)
15
+ collect_all(ApiPaths::THREADS,
16
+ list_query(folder, query, label_ids, sort, date_from, date_to, from_contacts, semantic, category, address),
17
+ style: PAGE_TOKEN, limit:, cursor:, api_key:)
18
+ end
19
+
20
+ def iterate(folder: nil, query: nil, label_ids: nil, sort: nil, date_from: nil, date_to: nil, from_contacts: nil,
21
+ semantic: nil, category: nil, address: nil, limit: nil, cursor: nil, api_key: nil, &)
22
+ iterate_pages(ApiPaths::THREADS,
23
+ list_query(folder, query, label_ids, sort, date_from, date_to, from_contacts, semantic, category, address),
24
+ style: PAGE_TOKEN, limit:, cursor:, api_key:, &)
25
+ end
26
+
27
+ def get(id, api_key: nil)
28
+ request(fill(ApiPaths::THREAD, id:), api_key:)
29
+ end
30
+
31
+ def update(id, patch = nil, api_key: nil, **fields)
32
+ request(fill(ApiPaths::THREAD, id:), method: :patch, body: payload(patch, fields), repeatable: true, api_key:)
33
+ end
34
+
35
+ def trash(id, api_key: nil)
36
+ request(fill(ApiPaths::THREAD_TRASH, id:), method: :post, repeatable: true, api_key:)
37
+ end
38
+
39
+ def snooze(id, wake_at, api_key: nil)
40
+ request(fill(ApiPaths::THREAD_SNOOZE, id:), method: :post, body: {"wakeAt" => instant(wake_at)},
41
+ repeatable: true, api_key:)
42
+ end
43
+
44
+ def unsnooze(id, api_key: nil)
45
+ request(fill(ApiPaths::THREAD_UNSNOOZE, id:), method: :post, repeatable: true, api_key:)
46
+ end
47
+
48
+ def mute(id, api_key: nil)
49
+ request(fill(ApiPaths::THREAD_MUTE, id:), method: :post, repeatable: true, api_key:)
50
+ end
51
+
52
+ def unmute(id, api_key: nil)
53
+ request(fill(ApiPaths::THREAD_UNMUTE, id:), method: :post, repeatable: true, api_key:)
54
+ end
55
+
56
+ def list_messages(id, api_key: nil)
57
+ fetch_list(fill(ApiPaths::THREAD_MESSAGES, id:), api_key:)
58
+ end
59
+
60
+ def get_message(id, message_id, api_key: nil)
61
+ request(fill(ApiPaths::THREAD_MESSAGE, id:, messageId: message_id), api_key:)
62
+ end
63
+
64
+ def get_raw_message(id, message_id, api_key: nil)
65
+ request(fill(ApiPaths::THREAD_MESSAGE_RAW, id:, messageId: message_id), binary: true, api_key:)
66
+ end
67
+
68
+ def list_attachments(id, message_id, api_key: nil)
69
+ fetch_list(fill(ApiPaths::THREAD_MESSAGE_ATTACHMENTS, id:, messageId: message_id), api_key:)
70
+ end
71
+
72
+ def list_file_links(id, message_id, include_revoked: nil, limit: nil, cursor: nil, api_key: nil)
73
+ fetch_page(fill(ApiPaths::THREAD_MESSAGE_FILE_LINKS, id:, messageId: message_id),
74
+ file_link_query(include_revoked), limit:, cursor:, api_key:)
75
+ end
76
+
77
+ def list_all_file_links(id, message_id, include_revoked: nil, limit: nil, cursor: nil, api_key: nil)
78
+ collect_all(fill(ApiPaths::THREAD_MESSAGE_FILE_LINKS, id:, messageId: message_id),
79
+ file_link_query(include_revoked), limit:, cursor:, api_key:)
80
+ end
81
+
82
+ def iterate_file_links(id, message_id, include_revoked: nil, limit: nil, cursor: nil, api_key: nil, &)
83
+ iterate_pages(fill(ApiPaths::THREAD_MESSAGE_FILE_LINKS, id:, messageId: message_id),
84
+ file_link_query(include_revoked), limit:, cursor:, api_key:, &)
85
+ end
86
+
87
+ def list_tracking(id, address: nil, api_key: nil)
88
+ fetch_list(fill(ApiPaths::THREAD_TRACKING, id:), query_params(address:), api_key:)
89
+ end
90
+
91
+ def get_delivery(id, address: nil, api_key: nil)
92
+ request(fill(ApiPaths::THREAD_DELIVERY, id:), query: query_params(address:), api_key:)
93
+ end
94
+
95
+ def get_event(id, api_key: nil)
96
+ request(fill(ApiPaths::THREAD_EVENT, id:), api_key:)
97
+ end
98
+
99
+ def list_notes(id, api_key: nil)
100
+ fetch_list(fill(ApiPaths::THREAD_NOTES, id:), api_key:)
101
+ end
102
+
103
+ def create_note(id, body = nil, api_key: nil, **fields)
104
+ request(fill(ApiPaths::THREAD_NOTES, id:), method: :post, body: payload(body, fields), api_key:)
105
+ end
106
+
107
+ def update_note(id, note_id, patch = nil, api_key: nil, **fields)
108
+ request(fill(ApiPaths::THREAD_NOTE, id:, noteId: note_id), method: :patch, body: payload(patch, fields),
109
+ repeatable: true, api_key:)
110
+ end
111
+
112
+ def delete_note(id, note_id, api_key: nil)
113
+ request(fill(ApiPaths::THREAD_NOTE, id:, noteId: note_id), method: :delete, api_key:)
114
+ end
115
+
116
+ def reorder_notes(id, ids, api_key: nil)
117
+ envelope = request(fill(ApiPaths::THREAD_NOTES_REORDER, id:), method: :post, body: {"ids" => ids},
118
+ repeatable: true, api_key:)
119
+ Pagination.items_of(envelope.is_a?(Hash) ? envelope : {})
120
+ end
121
+
122
+ def counts(address: nil, hide_labelled: nil, api_key: nil)
123
+ request(ApiPaths::THREADS_COUNTS, query: query_params(address:, hide_labelled: flag(hide_labelled)), api_key:)
124
+ end
125
+
126
+ def summary(id, api_key: nil)
127
+ request(fill(ApiPaths::THREAD_SUMMARY, id:), api_key:)
128
+ end
129
+
130
+ def reply_suggestions(id, api_key: nil)
131
+ request(fill(ApiPaths::THREAD_REPLY_SUGGESTIONS, id:), api_key:)
132
+ end
133
+
134
+ def restore(id, api_key: nil)
135
+ request(fill(ApiPaths::THREAD_RESTORE, id:), method: :post, repeatable: true, api_key:)
136
+ end
137
+
138
+ def delete(id, api_key: nil)
139
+ request(fill(ApiPaths::THREAD, id:), method: :delete, api_key:)
140
+ end
141
+
142
+ def unsubscribe(id, api_key: nil)
143
+ request(fill(ApiPaths::THREAD_UNSUBSCRIBE, id:), method: :post, api_key:)
144
+ end
145
+
146
+ def list_sender_categories(api_key: nil)
147
+ fetch_list(ApiPaths::SENDER_CATEGORIES, api_key:)
148
+ end
149
+
150
+ def set_sender_category(email, category, api_key: nil)
151
+ request(fill(ApiPaths::SENDER_CATEGORY, email:), method: :put, body: {"category" => category},
152
+ repeatable: true, api_key:)
153
+ end
154
+
155
+ def clear_sender_category(email, api_key: nil)
156
+ request(fill(ApiPaths::SENDER_CATEGORY, email:), method: :delete, api_key:)
157
+ end
158
+
159
+ def get_team(id, api_key: nil)
160
+ request(fill(ApiPaths::THREAD_TEAM, id:), api_key:)
161
+ end
162
+
163
+ def assign(id, assignee_id, api_key: nil)
164
+ request(fill(ApiPaths::THREAD_ASSIGNEE, id:), method: :put, body: {"assigneeId" => assignee_id},
165
+ repeatable: true, api_key:)
166
+ end
167
+
168
+ def unassign(id, api_key: nil)
169
+ request(fill(ApiPaths::THREAD_ASSIGNEE, id:), method: :delete, api_key:)
170
+ end
171
+
172
+ def set_replying(id, api_key: nil)
173
+ request(fill(ApiPaths::THREAD_REPLYING, id:), method: :put, repeatable: true, api_key:)
174
+ end
175
+
176
+ def clear_replying(id, api_key: nil)
177
+ request(fill(ApiPaths::THREAD_REPLYING, id:), method: :delete, repeatable: true, api_key:)
178
+ end
179
+
180
+ def mark_done(id, api_key: nil)
181
+ request(fill(ApiPaths::THREAD_DONE, id:), method: :post, repeatable: true, api_key:)
182
+ end
183
+
184
+ def reopen(id, api_key: nil)
185
+ request(fill(ApiPaths::THREAD_REOPEN, id:), method: :post, repeatable: true, api_key:)
186
+ end
187
+
188
+ def list_comments(id, api_key: nil)
189
+ fetch_list(fill(ApiPaths::THREAD_COMMENTS, id:), api_key:)
190
+ end
191
+
192
+ def create_comment(id, body = nil, api_key: nil, **fields)
193
+ request(fill(ApiPaths::THREAD_COMMENTS, id:), method: :post, body: payload(body, fields), api_key:)
194
+ end
195
+
196
+ def update_comment(id, comment_id, body = nil, api_key: nil, **fields)
197
+ request(fill(ApiPaths::THREAD_COMMENT, id:, commentId: comment_id), method: :patch,
198
+ body: payload(body, fields), repeatable: true, api_key:)
199
+ end
200
+
201
+ def delete_comment(id, comment_id, api_key: nil)
202
+ request(fill(ApiPaths::THREAD_COMMENT, id:, commentId: comment_id), method: :delete, api_key:)
203
+ end
204
+
205
+ private
206
+
207
+ def list_query(folder, query, label_ids, sort, date_from, date_to, from_contacts, semantic, category, address)
208
+ query_params(folder:, query:, label_ids: joined(label_ids), sort:, date_from: instant(date_from),
209
+ date_to: instant(date_to), from_contacts: flag(from_contacts), semantic: flag(semantic), category:,
210
+ address:)
211
+ end
212
+
213
+ def file_link_query(include_revoked)
214
+ query_params(include_revoked: flag(include_revoked))
215
+ end
216
+ end
217
+ end
218
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nextmail
4
+ module Resources
5
+ class Tools < Resource
6
+ def check_dmarc(domain, api_key: nil)
7
+ request(ApiPaths::TOOLS_DMARC, query: query_params(domain:), api_key:)
8
+ end
9
+
10
+ def check_bimi(domain, api_key: nil)
11
+ request(ApiPaths::TOOLS_BIMI, query: query_params(domain:), api_key:)
12
+ end
13
+
14
+ def check_deliverability(domain, api_key: nil)
15
+ request(ApiPaths::TOOLS_DELIVERABILITY, query: query_params(domain:), api_key:)
16
+ end
17
+
18
+ def read_verification_code(body = nil, api_key: nil, **fields)
19
+ request(ApiPaths::TOOLS_VERIFICATION_CODE, method: :post, body: payload(body, fields), api_key:)
20
+ end
21
+
22
+ def check_address(email, deep: nil, api_key: nil)
23
+ request(ApiPaths::TOOLS_ADDRESS, query: query_params(email:, deep: flag(deep)), api_key:)
24
+ end
25
+
26
+ def check_addresses(body = nil, api_key: nil, **fields)
27
+ request(ApiPaths::TOOLS_ADDRESSES, method: :post, body: payload(body, fields), api_key:)
28
+ end
29
+
30
+ def estimate_cost(sends: nil, domains: nil, people: nil, ai_actions: nil, interval: nil, api_key: nil)
31
+ request(ApiPaths::TOOLS_COST, query: query_params(sends:, domains:, people:, ai_actions:, interval:), api_key:)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nextmail
4
+ module Resources
5
+ class Tracking < Resource
6
+ def list(opened: nil, clicked: nil, days: nil, minutes: nil, grain: nil, offset_minutes: nil, address: nil,
7
+ limit: nil, cursor: nil, api_key: nil)
8
+ fetch_page(ApiPaths::TRACKING, list_query(opened, clicked, days, minutes, grain, offset_minutes, address),
9
+ limit:, cursor:, api_key:)
10
+ end
11
+
12
+ def list_all(opened: nil, clicked: nil, days: nil, minutes: nil, grain: nil, offset_minutes: nil, address: nil,
13
+ limit: nil, cursor: nil, api_key: nil)
14
+ collect_all(ApiPaths::TRACKING, list_query(opened, clicked, days, minutes, grain, offset_minutes, address),
15
+ limit:, cursor:, api_key:)
16
+ end
17
+
18
+ def iterate(opened: nil, clicked: nil, days: nil, minutes: nil, grain: nil, offset_minutes: nil, address: nil,
19
+ limit: nil, cursor: nil, api_key: nil, &)
20
+ iterate_pages(ApiPaths::TRACKING, list_query(opened, clicked, days, minutes, grain, offset_minutes, address),
21
+ limit:, cursor:, api_key:, &)
22
+ end
23
+
24
+ def get_stats(days: nil, minutes: nil, grain: nil, offset_minutes: nil, address: nil, api_key: nil)
25
+ request(ApiPaths::TRACKING_STATS, query: query_params(days:, minutes:, grain:, offset_minutes:, address:),
26
+ api_key:)
27
+ end
28
+
29
+ def get(id, api_key: nil)
30
+ request(fill(ApiPaths::TRACKED, id:), api_key:)
31
+ end
32
+
33
+ def list_opens(id, include_machine: nil, address: nil, limit: nil, cursor: nil, api_key: nil)
34
+ fetch_page(fill(ApiPaths::TRACKED_OPENS, id:), hit_query(include_machine, address), limit:, cursor:, api_key:)
35
+ end
36
+
37
+ def list_all_opens(id, include_machine: nil, address: nil, limit: nil, cursor: nil, api_key: nil)
38
+ collect_all(fill(ApiPaths::TRACKED_OPENS, id:), hit_query(include_machine, address), limit:, cursor:,
39
+ api_key:)
40
+ end
41
+
42
+ def iterate_opens(id, include_machine: nil, address: nil, limit: nil, cursor: nil, api_key: nil, &)
43
+ iterate_pages(fill(ApiPaths::TRACKED_OPENS, id:), hit_query(include_machine, address), limit:, cursor:,
44
+ api_key:, &)
45
+ end
46
+
47
+ def list_clicks(id, include_machine: nil, address: nil, limit: nil, cursor: nil, api_key: nil)
48
+ fetch_page(fill(ApiPaths::TRACKED_CLICKS, id:), hit_query(include_machine, address), limit:, cursor:, api_key:)
49
+ end
50
+
51
+ def list_all_clicks(id, include_machine: nil, address: nil, limit: nil, cursor: nil, api_key: nil)
52
+ collect_all(fill(ApiPaths::TRACKED_CLICKS, id:), hit_query(include_machine, address), limit:, cursor:,
53
+ api_key:)
54
+ end
55
+
56
+ def iterate_clicks(id, include_machine: nil, address: nil, limit: nil, cursor: nil, api_key: nil, &)
57
+ iterate_pages(fill(ApiPaths::TRACKED_CLICKS, id:), hit_query(include_machine, address), limit:, cursor:,
58
+ api_key:, &)
59
+ end
60
+
61
+ private
62
+
63
+ def list_query(opened, clicked, days, minutes, grain, offset_minutes, address)
64
+ query_params(opened: flag(opened), clicked: flag(clicked), days:, minutes:, grain:, offset_minutes:, address:)
65
+ end
66
+
67
+ def hit_query(include_machine, address)
68
+ query_params(include_machine: flag(include_machine), address:)
69
+ end
70
+ end
71
+ end
72
+ end