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.
- checksums.yaml +7 -0
- data/README.md +183 -0
- data/lib/nextmail/api_paths.rb +447 -0
- data/lib/nextmail/client.rb +81 -0
- data/lib/nextmail/constants.rb +1621 -0
- data/lib/nextmail/credentials.rb +53 -0
- data/lib/nextmail/decode.rb +34 -0
- data/lib/nextmail/defaults.rb +114 -0
- data/lib/nextmail/endpoint.rb +144 -0
- data/lib/nextmail/errors.rb +121 -0
- data/lib/nextmail/http.rb +172 -0
- data/lib/nextmail/image_crop.rb +38 -0
- data/lib/nextmail/languages.rb +42 -0
- data/lib/nextmail/pagination.rb +63 -0
- data/lib/nextmail/protocol.rb +221 -0
- data/lib/nextmail/raw_body.rb +83 -0
- data/lib/nextmail/request_path.rb +50 -0
- data/lib/nextmail/resource.rb +109 -0
- data/lib/nextmail/resources/account.rb +155 -0
- data/lib/nextmail/resources/addresses.rb +38 -0
- data/lib/nextmail/resources/analytics.rb +19 -0
- data/lib/nextmail/resources/app_host.rb +23 -0
- data/lib/nextmail/resources/audiences.rb +95 -0
- data/lib/nextmail/resources/automations.rb +125 -0
- data/lib/nextmail/resources/billing.rb +76 -0
- data/lib/nextmail/resources/bookings.rb +100 -0
- data/lib/nextmail/resources/branding.rb +24 -0
- data/lib/nextmail/resources/broadcasts.rb +102 -0
- data/lib/nextmail/resources/calendar.rb +153 -0
- data/lib/nextmail/resources/chats.rb +62 -0
- data/lib/nextmail/resources/connected_mailboxes.rb +35 -0
- data/lib/nextmail/resources/connectors.rb +75 -0
- data/lib/nextmail/resources/contacts.rb +197 -0
- data/lib/nextmail/resources/dns_connections.rb +23 -0
- data/lib/nextmail/resources/domains.rb +264 -0
- data/lib/nextmail/resources/drafts.rb +36 -0
- data/lib/nextmail/resources/emails.rb +120 -0
- data/lib/nextmail/resources/encryption.rb +19 -0
- data/lib/nextmail/resources/events.rb +22 -0
- data/lib/nextmail/resources/exports.rb +27 -0
- data/lib/nextmail/resources/files.rb +82 -0
- data/lib/nextmail/resources/follow_ups.rb +21 -0
- data/lib/nextmail/resources/forms.rb +112 -0
- data/lib/nextmail/resources/imports.rb +106 -0
- data/lib/nextmail/resources/keys.rb +126 -0
- data/lib/nextmail/resources/knowledge.rb +137 -0
- data/lib/nextmail/resources/labels.rb +43 -0
- data/lib/nextmail/resources/languages.rb +11 -0
- data/lib/nextmail/resources/me.rb +57 -0
- data/lib/nextmail/resources/members.rb +100 -0
- data/lib/nextmail/resources/out_of_office.rb +28 -0
- data/lib/nextmail/resources/provider_imports.rb +48 -0
- data/lib/nextmail/resources/roles.rb +39 -0
- data/lib/nextmail/resources/rules.rb +73 -0
- data/lib/nextmail/resources/security.rb +39 -0
- data/lib/nextmail/resources/segments.rb +31 -0
- data/lib/nextmail/resources/senders.rb +19 -0
- data/lib/nextmail/resources/sending.rb +23 -0
- data/lib/nextmail/resources/settings.rb +16 -0
- data/lib/nextmail/resources/signatures.rb +41 -0
- data/lib/nextmail/resources/subscriptions.rb +55 -0
- data/lib/nextmail/resources/support.rb +11 -0
- data/lib/nextmail/resources/suppressions.rb +43 -0
- data/lib/nextmail/resources/tasks.rb +95 -0
- data/lib/nextmail/resources/temp_mail.rb +67 -0
- data/lib/nextmail/resources/templates.rb +153 -0
- data/lib/nextmail/resources/threads.rb +218 -0
- data/lib/nextmail/resources/tools.rb +35 -0
- data/lib/nextmail/resources/tracking.rb +72 -0
- data/lib/nextmail/resources/webhooks.rb +170 -0
- data/lib/nextmail/resources/workspaces.rb +40 -0
- data/lib/nextmail/results.rb +33 -0
- data/lib/nextmail/transport.rb +272 -0
- data/lib/nextmail/update_notice.rb +69 -0
- data/lib/nextmail/version.rb +5 -0
- data/lib/nextmail/webhook.rb +82 -0
- data/lib/nextmail/wire.rb +102 -0
- data/lib/nextmail.rb +126 -0
- metadata +122 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Domains < Resource
|
|
6
|
+
def list(q: nil, limit: nil, cursor: nil, api_key: nil)
|
|
7
|
+
fetch_page(ApiPaths::DOMAINS, query_params(q:), limit:, cursor:, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(q: nil, limit: nil, cursor: nil, api_key: nil)
|
|
11
|
+
collect_all(ApiPaths::DOMAINS, query_params(q:), limit:, cursor:, api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def iterate(q: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
15
|
+
iterate_pages(ApiPaths::DOMAINS, query_params(q:), limit:, cursor:, api_key:, &)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get(id, api_key: nil)
|
|
19
|
+
request(fill(ApiPaths::DOMAIN, id:), api_key:)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create(body = nil, api_key: nil, **fields)
|
|
23
|
+
request(ApiPaths::DOMAINS, method: :post, body: payload(body, fields), api_key:)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def verify(id, api_key: nil)
|
|
27
|
+
request(fill(ApiPaths::DOMAIN_VERIFY, id:), method: :post, repeatable: true, api_key:)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def update(id, patch = nil, api_key: nil, **fields)
|
|
31
|
+
request(fill(ApiPaths::DOMAIN, id:), method: :patch, body: payload(patch, fields), repeatable: true, api_key:)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def delete(id, api_key: nil)
|
|
35
|
+
request(fill(ApiPaths::DOMAIN, id:), method: :delete, api_key:)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def get_logo(id, api_key: nil)
|
|
39
|
+
request(fill(ApiPaths::DOMAIN_LOGO, id:), api_key:)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def set_logo(id, body = nil, api_key: nil, **fields)
|
|
43
|
+
request(fill(ApiPaths::DOMAIN_LOGO, id:), method: :put, body: payload(body, fields), repeatable: true, api_key:)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def remove_logo(id, api_key: nil)
|
|
47
|
+
request(fill(ApiPaths::DOMAIN_LOGO, id:), method: :delete, repeatable: true, api_key:)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def set_logo_certificate(id, body = nil, api_key: nil, **fields)
|
|
51
|
+
request(fill(ApiPaths::DOMAIN_LOGO_CERTIFICATE, id:), method: :put, body: payload(body, fields),
|
|
52
|
+
repeatable: true, api_key:)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def remove_logo_certificate(id, api_key: nil)
|
|
56
|
+
request(fill(ApiPaths::DOMAIN_LOGO_CERTIFICATE, id:), method: :delete, repeatable: true, api_key:)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def list_addresses(id, limit: nil, cursor: nil, api_key: nil)
|
|
60
|
+
fetch_page(fill(ApiPaths::DOMAIN_ADDRESSES, id:), limit:, cursor:, api_key:)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def list_all_addresses(id, limit: nil, cursor: nil, api_key: nil)
|
|
64
|
+
collect_all(fill(ApiPaths::DOMAIN_ADDRESSES, id:), limit:, cursor:, api_key:)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def iterate_addresses(id, limit: nil, cursor: nil, api_key: nil, &)
|
|
68
|
+
iterate_pages(fill(ApiPaths::DOMAIN_ADDRESSES, id:), limit:, cursor:, api_key:, &)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def create_address(id, body = nil, api_key: nil, **fields)
|
|
72
|
+
request(fill(ApiPaths::DOMAIN_ADDRESSES, id:), method: :post, body: payload(body, fields), repeatable: true,
|
|
73
|
+
api_key:)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def get_address(id, address_id, api_key: nil)
|
|
77
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS, id:, addressId: address_id), api_key:)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def update_address(id, address_id, patch = nil, api_key: nil, **fields)
|
|
81
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS, id:, addressId: address_id), method: :patch,
|
|
82
|
+
body: payload(patch, fields), repeatable: true, api_key:)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def set_address_photo(id, address_id, data, content_type: nil, crop: nil, api_key: nil)
|
|
86
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_PHOTO, id:, addressId: address_id), method: :put,
|
|
87
|
+
query: crop_query(crop), raw: data, content_type: raw_content_type(data, content_type), repeatable: true,
|
|
88
|
+
timeout: upload_timeout, api_key:)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def remove_address_photo(id, address_id, api_key: nil)
|
|
92
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_PHOTO, id:, addressId: address_id), method: :delete, repeatable: true,
|
|
93
|
+
api_key:)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def start_gravatar_publish(id, address_id, api_key: nil)
|
|
97
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_PHOTO_GRAVATAR, id:, addressId: address_id), method: :post, api_key:)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def delete_address(id, address_id, api_key: nil)
|
|
101
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS, id:, addressId: address_id), method: :delete, api_key:)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def list_address_forwards(id, address_id, api_key: nil)
|
|
105
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_FORWARDS, id:, addressId: address_id), api_key:)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def add_address_forwards(id, address_id, body = nil, api_key: nil, **fields)
|
|
109
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_FORWARDS, id:, addressId: address_id), method: :post,
|
|
110
|
+
body: payload(body, fields), api_key:)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def update_address_forward(id, address_id, forward_id, patch = nil, api_key: nil, **fields)
|
|
114
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_FORWARD, id:, addressId: address_id, forwardId: forward_id),
|
|
115
|
+
method: :patch, body: payload(patch, fields), repeatable: true, api_key:)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def delete_address_forward(id, address_id, forward_id, api_key: nil)
|
|
119
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_FORWARD, id:, addressId: address_id, forwardId: forward_id),
|
|
120
|
+
method: :delete, api_key:)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def resend_address_forward_consent(id, address_id, forward_id, api_key: nil)
|
|
124
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_FORWARD_RESEND, id:, addressId: address_id, forwardId: forward_id),
|
|
125
|
+
method: :post, api_key:)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def list_address_members(id, address_id, api_key: nil)
|
|
129
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_MEMBERS, id:, addressId: address_id), api_key:)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def get_address_login(id, address_id, api_key: nil)
|
|
133
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_LOGIN, id:, addressId: address_id), api_key:)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def set_address_login(id, address_id, body = nil, api_key: nil, **fields)
|
|
137
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_LOGIN, id:, addressId: address_id), method: :put,
|
|
138
|
+
body: payload(body, fields), api_key:)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def delete_address_login(id, address_id, api_key: nil)
|
|
142
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_LOGIN, id:, addressId: address_id), method: :delete, api_key:)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def get_mail_app_settings(id, address_id, api_key: nil)
|
|
146
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_MAIL_APPS, id:, addressId: address_id), api_key:)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def update_mail_app_settings(id, address_id, patch = nil, api_key: nil, **fields)
|
|
150
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_MAIL_APPS, id:, addressId: address_id), method: :patch,
|
|
151
|
+
body: payload(patch, fields), repeatable: true, api_key:)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def get_address_limits(id, address_id, api_key: nil)
|
|
155
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_LIMITS, id:, addressId: address_id), api_key:)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def update_address_limits(id, address_id, patch = nil, api_key: nil, **fields)
|
|
159
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_LIMITS, id:, addressId: address_id), method: :patch,
|
|
160
|
+
body: payload(patch, fields), repeatable: true, api_key:)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def list_app_passwords(id, address_id, api_key: nil)
|
|
164
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_APP_PASSWORDS, id:, addressId: address_id), api_key:)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def create_app_password(id, address_id, body = nil, api_key: nil, **fields)
|
|
168
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_APP_PASSWORDS, id:, addressId: address_id), method: :post,
|
|
169
|
+
body: payload(body, fields), api_key:)
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def update_app_password(id, address_id, password_id, patch = nil, api_key: nil, **fields)
|
|
173
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_APP_PASSWORD, id:, addressId: address_id, passwordId: password_id),
|
|
174
|
+
method: :patch, body: payload(patch, fields), repeatable: true, api_key:)
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def delete_app_password(id, address_id, password_id, api_key: nil)
|
|
178
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_APP_PASSWORD, id:, addressId: address_id, passwordId: password_id),
|
|
179
|
+
method: :delete, api_key:)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def send_mail_app_setup(id, address_id, body = nil, api_key: nil, **fields)
|
|
183
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_MAIL_APP_SETUP, id:, addressId: address_id), method: :post,
|
|
184
|
+
body: payload(body, fields), api_key:)
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def create_mail_app_profile_link(id, address_id, body = nil, api_key: nil, **fields)
|
|
188
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_MAIL_APP_PROFILE_LINK, id:, addressId: address_id), method: :post,
|
|
189
|
+
body: payload(body, fields), api_key:)
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def get_dns(id, refresh: nil, api_key: nil)
|
|
193
|
+
request(fill(ApiPaths::DOMAIN_DNS, id:), query: query_params(refresh:), api_key:)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def set_dns_zone(id, body = nil, api_key: nil, **fields)
|
|
197
|
+
request(fill(ApiPaths::DOMAIN_DNS, id:), method: :put, body: payload(body, fields), api_key:)
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def sync_dns(id, body = nil, api_key: nil, **fields)
|
|
201
|
+
request(fill(ApiPaths::DOMAIN_DNS_SYNC, id:), method: :post, body: payload(body, fields), api_key:)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def list_routes(id, limit: nil, cursor: nil, api_key: nil)
|
|
205
|
+
fetch_page(fill(ApiPaths::DOMAIN_ROUTES, id:), limit:, cursor:, api_key:)
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def list_all_routes(id, limit: nil, cursor: nil, api_key: nil)
|
|
209
|
+
collect_all(fill(ApiPaths::DOMAIN_ROUTES, id:), limit:, cursor:, api_key:)
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def iterate_routes(id, limit: nil, cursor: nil, api_key: nil, &)
|
|
213
|
+
iterate_pages(fill(ApiPaths::DOMAIN_ROUTES, id:), limit:, cursor:, api_key:, &)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def create_route(id, body = nil, api_key: nil, **fields)
|
|
217
|
+
request(fill(ApiPaths::DOMAIN_ROUTES, id:), method: :post, body: payload(body, fields), api_key:)
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def get_route(id, route_id, api_key: nil)
|
|
221
|
+
request(fill(ApiPaths::DOMAIN_ROUTE, id:, routeId: route_id), api_key:)
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def update_route(id, route_id, patch = nil, api_key: nil, **fields)
|
|
225
|
+
request(fill(ApiPaths::DOMAIN_ROUTE, id:, routeId: route_id), method: :patch, body: payload(patch, fields),
|
|
226
|
+
api_key:)
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
def test_route(id, body = nil, api_key: nil, **fields)
|
|
230
|
+
request(fill(ApiPaths::DOMAIN_ROUTE_TEST, id:), method: :post, body: payload(body, fields), repeatable: true,
|
|
231
|
+
api_key:)
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
def delete_route(id, route_id, api_key: nil)
|
|
235
|
+
request(fill(ApiPaths::DOMAIN_ROUTE, id:, routeId: route_id), method: :delete, api_key:)
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def list_group_members(id, address_id, limit: nil, cursor: nil, api_key: nil)
|
|
239
|
+
fetch_page(fill(ApiPaths::DOMAIN_ADDRESS_GROUP_MEMBERS, id:, addressId: address_id), limit:, cursor:,
|
|
240
|
+
api_key:)
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
def list_all_group_members(id, address_id, limit: nil, cursor: nil, api_key: nil)
|
|
244
|
+
collect_all(fill(ApiPaths::DOMAIN_ADDRESS_GROUP_MEMBERS, id:, addressId: address_id), limit:, cursor:,
|
|
245
|
+
api_key:)
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def iterate_group_members(id, address_id, limit: nil, cursor: nil, api_key: nil, &)
|
|
249
|
+
iterate_pages(fill(ApiPaths::DOMAIN_ADDRESS_GROUP_MEMBERS, id:, addressId: address_id), limit:, cursor:,
|
|
250
|
+
api_key:, &)
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
def add_group_members(id, address_id, body = nil, api_key: nil, **fields)
|
|
254
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_GROUP_MEMBERS, id:, addressId: address_id), method: :post,
|
|
255
|
+
body: payload(body, fields), api_key:)
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
def remove_group_member(id, address_id, member_id, api_key: nil)
|
|
259
|
+
request(fill(ApiPaths::DOMAIN_ADDRESS_GROUP_MEMBER, id:, addressId: address_id, memberId: member_id),
|
|
260
|
+
method: :delete, api_key:)
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Drafts < Resource
|
|
6
|
+
def list(query: nil, limit: nil, cursor: nil, api_key: nil)
|
|
7
|
+
fetch_page(ApiPaths::DRAFTS, query_params(query:), style: PAGE_TOKEN, limit:, cursor:, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(query: nil, limit: nil, cursor: nil, api_key: nil)
|
|
11
|
+
collect_all(ApiPaths::DRAFTS, query_params(query:), style: PAGE_TOKEN, limit:, cursor:, api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def iterate(query: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
15
|
+
iterate_pages(ApiPaths::DRAFTS, query_params(query:), style: PAGE_TOKEN, limit:, cursor:, api_key:, &)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get(id, api_key: nil)
|
|
19
|
+
request(fill(ApiPaths::DRAFT, id:), api_key:)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create(body = nil, api_key: nil, **fields)
|
|
23
|
+
request(ApiPaths::DRAFTS, method: :post, body: Wire.with_attachments(payload(body, fields)), api_key:)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def update(id, body = nil, api_key: nil, **fields)
|
|
27
|
+
request(fill(ApiPaths::DRAFT, id:), method: :patch, body: Wire.with_attachments(payload(body, fields)),
|
|
28
|
+
api_key:)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def delete(id, api_key: nil)
|
|
32
|
+
request(fill(ApiPaths::DRAFT, id:), method: :delete, api_key:)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Emails < Resource
|
|
6
|
+
def send(body = nil, idempotency_key: nil, api_key: nil, **fields)
|
|
7
|
+
request(ApiPaths::EMAILS, method: :post, body: Wire.email(payload(body, fields)), idempotent: true,
|
|
8
|
+
idempotency_key:, repeatable: true, api_key:)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def send_batch(emails, idempotency_key: nil, api_key: nil)
|
|
12
|
+
wire = emails.map { |email| Wire.email(payload(email, {})) }
|
|
13
|
+
result = request(ApiPaths::EMAILS_BATCH, method: :post, body: {"emails" => wire}, idempotent: true,
|
|
14
|
+
idempotency_key:, repeatable: true, api_key:)
|
|
15
|
+
envelope = result.is_a?(Hash) ? result : {}
|
|
16
|
+
|
|
17
|
+
BatchResult.new(items: Pagination.items_of(envelope), sent: envelope[:sent], failed: envelope[:failed])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def translate(body = nil, api_key: nil, **fields)
|
|
21
|
+
request(ApiPaths::EMAILS_TRANSLATE, method: :post, body: payload(body, fields), api_key:)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def check(body = nil, api_key: nil, **fields)
|
|
25
|
+
request(ApiPaths::EMAILS_CHECK, method: :post, body: payload(body, fields), api_key:)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def list(status: nil, from: nil, broadcast_id: nil, scheduled_from: nil, scheduled_to: nil, since: nil,
|
|
29
|
+
until: nil, recipient: nil, tag: nil, limit: nil, cursor: nil, api_key: nil)
|
|
30
|
+
query = list_query(status, from, broadcast_id, scheduled_from, scheduled_to)
|
|
31
|
+
.merge(sent_query(since, binding.local_variable_get(:until), recipient, tag))
|
|
32
|
+
fetch_page(ApiPaths::EMAILS, query, limit:, cursor:, api_key:)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def list_all(status: nil, from: nil, broadcast_id: nil, scheduled_from: nil, scheduled_to: nil, since: nil,
|
|
36
|
+
until: nil, recipient: nil, tag: nil, limit: nil, cursor: nil, api_key: nil)
|
|
37
|
+
query = list_query(status, from, broadcast_id, scheduled_from, scheduled_to)
|
|
38
|
+
.merge(sent_query(since, binding.local_variable_get(:until), recipient, tag))
|
|
39
|
+
collect_all(ApiPaths::EMAILS, query, limit:, cursor:, api_key:)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def iterate(status: nil, from: nil, broadcast_id: nil, scheduled_from: nil, scheduled_to: nil, since: nil,
|
|
43
|
+
until: nil, recipient: nil, tag: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
44
|
+
query = list_query(status, from, broadcast_id, scheduled_from, scheduled_to)
|
|
45
|
+
.merge(sent_query(since, binding.local_variable_get(:until), recipient, tag))
|
|
46
|
+
iterate_pages(ApiPaths::EMAILS, query, limit:, cursor:, api_key:, &)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def get(id, api_key: nil)
|
|
50
|
+
request(fill(ApiPaths::EMAIL, id:), api_key:)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def list_events(id, address: nil, message_id: nil, limit: nil, cursor: nil, api_key: nil)
|
|
54
|
+
fetch_page(fill(ApiPaths::EMAIL_EVENTS, id:), query_params(address:, message_id:), limit:, cursor:, api_key:)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def list_all_events(id, address: nil, message_id: nil, limit: nil, cursor: nil, api_key: nil)
|
|
58
|
+
collect_all(fill(ApiPaths::EMAIL_EVENTS, id:), query_params(address:, message_id:), limit:, cursor:, api_key:)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def iterate_events(id, address: nil, message_id: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
62
|
+
iterate_pages(fill(ApiPaths::EMAIL_EVENTS, id:), query_params(address:, message_id:), limit:, cursor:,
|
|
63
|
+
api_key:, &)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def list_events_by_message_id(message_id, address: nil, limit: nil, cursor: nil, api_key: nil)
|
|
67
|
+
fetch_page(ApiPaths::EMAILS_EVENTS, query_params(address:, message_id:), limit:, cursor:, api_key:)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def list_all_events_by_message_id(message_id, address: nil, limit: nil, cursor: nil, api_key: nil)
|
|
71
|
+
collect_all(ApiPaths::EMAILS_EVENTS, query_params(address:, message_id:), limit:, cursor:, api_key:)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def iterate_events_by_message_id(message_id, address: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
75
|
+
iterate_pages(ApiPaths::EMAILS_EVENTS, query_params(address:, message_id:), limit:, cursor:, api_key:, &)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def get_tracking(id, address: nil, api_key: nil)
|
|
79
|
+
request(fill(ApiPaths::EMAIL_TRACKING, id:), query: query_params(address:), api_key:)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def cancel(id, api_key: nil)
|
|
83
|
+
request(fill(ApiPaths::EMAIL_CANCEL, id:), method: :post, repeatable: true, api_key:)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def reschedule(id, scheduled_at, api_key: nil)
|
|
87
|
+
request(fill(ApiPaths::EMAIL, id:), method: :patch, body: {"scheduledAt" => instant(scheduled_at)},
|
|
88
|
+
repeatable: true, api_key:)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def update(id, patch = nil, api_key: nil, **fields)
|
|
92
|
+
request(fill(ApiPaths::EMAIL, id:), method: :patch, body: Wire.recipients(payload(patch, fields)),
|
|
93
|
+
repeatable: true, api_key:)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def compose(body = nil, api_key: nil, **fields)
|
|
97
|
+
request(ApiPaths::EMAILS_COMPOSE, method: :post, body: payload(body, fields), api_key:)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def rewrite(body = nil, api_key: nil, **fields)
|
|
101
|
+
request(ApiPaths::EMAILS_REWRITE, method: :post, body: payload(body, fields), api_key:)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def suggest_subject(body = nil, api_key: nil, **fields)
|
|
105
|
+
request(ApiPaths::EMAILS_SUBJECT, method: :post, body: payload(body, fields), api_key:)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
private
|
|
109
|
+
|
|
110
|
+
def list_query(status, from, broadcast_id, scheduled_from, scheduled_to)
|
|
111
|
+
query_params(status: joined(status), from:, broadcast_id:, scheduled_from: instant(scheduled_from),
|
|
112
|
+
scheduled_to: instant(scheduled_to))
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def sent_query(since, until_value, recipient, tag)
|
|
116
|
+
query_params(since: instant(since), until: instant(until_value), recipient:, tag:)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Encryption < Resource
|
|
6
|
+
def list_keys(api_key: nil)
|
|
7
|
+
fetch_list(ApiPaths::ENCRYPTION_KEYS, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def publish_key(body = nil, api_key: nil, **fields)
|
|
11
|
+
request(ApiPaths::ENCRYPTION_KEYS, method: :post, body: payload(body, fields), api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def lookup_keys(addresses:, api_key: nil)
|
|
15
|
+
fetch_list(ApiPaths::ENCRYPTION_KEYS_LOOKUP, query_params(addresses: joined(addresses)), api_key:)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Events < Resource
|
|
6
|
+
def send(body = nil, idempotency_key: nil, api_key: nil, **fields)
|
|
7
|
+
request(ApiPaths::EVENTS, method: :post, body: payload(body, fields), idempotent: true, idempotency_key:,
|
|
8
|
+
repeatable: true, api_key:)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def send_batch(events, idempotency_key: nil, api_key: nil)
|
|
12
|
+
wire = events.map { |event| payload(event, {}) }
|
|
13
|
+
request(ApiPaths::EVENTS_BATCH, method: :post, body: {"events" => wire}, idempotent: true, idempotency_key:,
|
|
14
|
+
repeatable: true, api_key:)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def list_names(api_key: nil)
|
|
18
|
+
fetch_list(ApiPaths::EVENT_NAMES, api_key:)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Exports < Resource
|
|
6
|
+
def preview(api_key: nil)
|
|
7
|
+
request(ApiPaths::MAILBOX_EXPORTS_PREVIEW, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list(limit: nil, offset: nil, api_key: nil)
|
|
11
|
+
request(ApiPaths::MAILBOX_EXPORTS, query: query_params(limit:, offset:), api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def get(id, api_key: nil)
|
|
15
|
+
request(fill(ApiPaths::MAILBOX_EXPORT, id:), api_key:)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def start(api_key: nil)
|
|
19
|
+
request(ApiPaths::MAILBOX_EXPORTS, method: :post, api_key:)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def download(id, api_key: nil)
|
|
23
|
+
request(fill(ApiPaths::MAILBOX_EXPORT_CONTENT, id:), binary: true, api_key:)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Files < Resource
|
|
6
|
+
def list(q: nil, kind: nil, direction: nil, address: nil, since: nil, until: nil, sort: nil, limit: nil,
|
|
7
|
+
cursor: nil, api_key: nil)
|
|
8
|
+
query = list_query(q, kind, direction, address, since, binding.local_variable_get(:until), sort)
|
|
9
|
+
fetch_page(ApiPaths::FILES, query, limit:, cursor:, api_key:)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def list_all(q: nil, kind: nil, direction: nil, address: nil, since: nil, until: nil, sort: nil, limit: nil,
|
|
13
|
+
cursor: nil, api_key: nil)
|
|
14
|
+
query = list_query(q, kind, direction, address, since, binding.local_variable_get(:until), sort)
|
|
15
|
+
collect_all(ApiPaths::FILES, query, limit:, cursor:, api_key:)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def iterate(q: nil, kind: nil, direction: nil, address: nil, since: nil, until: nil, sort: nil, limit: nil,
|
|
19
|
+
cursor: nil, api_key: nil, &)
|
|
20
|
+
query = list_query(q, kind, direction, address, since, binding.local_variable_get(:until), sort)
|
|
21
|
+
iterate_pages(ApiPaths::FILES, query, limit:, cursor:, api_key:, &)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def get(id, api_key: nil)
|
|
25
|
+
request(fill(ApiPaths::FILE, id:), api_key:)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def stats(api_key: nil)
|
|
29
|
+
request(ApiPaths::FILES_STATS, api_key:)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def download(id, api_key: nil)
|
|
33
|
+
request(fill(ApiPaths::FILE_CONTENT, id:), binary: true, api_key:)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def list_links(id, limit: nil, cursor: nil, api_key: nil)
|
|
37
|
+
fetch_page(fill(ApiPaths::FILE_LINKS, id:), limit:, cursor:, api_key:)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def list_all_links(id, limit: nil, cursor: nil, api_key: nil)
|
|
41
|
+
collect_all(fill(ApiPaths::FILE_LINKS, id:), limit:, cursor:, api_key:)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def iterate_links(id, limit: nil, cursor: nil, api_key: nil, &)
|
|
45
|
+
iterate_pages(fill(ApiPaths::FILE_LINKS, id:), limit:, cursor:, api_key:, &)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def create_link(id, domain: nil, reuse: nil, api_key: nil)
|
|
49
|
+
body = (domain.nil? || domain == "") ? {} : {"domain" => domain}
|
|
50
|
+
body["reuse"] = reuse unless reuse.nil?
|
|
51
|
+
request(fill(ApiPaths::FILE_LINKS, id:), method: :post, body:, api_key:)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def revoke_link(id, link_id, api_key: nil)
|
|
55
|
+
request(fill(ApiPaths::FILE_LINK, id:, linkId: link_id), method: :delete, repeatable: true, api_key:)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def revoke_all_links(id, api_key: nil)
|
|
59
|
+
request(fill(ApiPaths::FILE_LINKS, id:), method: :delete, repeatable: true, api_key:)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def upload(data, filename: nil, content_type: nil, timeout: nil, api_key: nil)
|
|
63
|
+
request(ApiPaths::FILES, method: :post, query: query_params(filename: upload_name(data, filename)), raw: data,
|
|
64
|
+
content_type: raw_content_type(data, content_type), timeout: upload_timeout(timeout), api_key:)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def delete(id, api_key: nil)
|
|
68
|
+
request(fill(ApiPaths::FILE, id:), method: :delete, api_key:)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def delete_many(ids, api_key: nil)
|
|
72
|
+
request(ApiPaths::FILES_BATCH_DELETE, method: :post, body: {"ids" => ids}, api_key:)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
private
|
|
76
|
+
|
|
77
|
+
def list_query(q, kind, direction, address, since, until_value, sort)
|
|
78
|
+
query_params(q:, kind:, direction:, address:, since: instant(since), until: instant(until_value), sort:)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class FollowUps < Resource
|
|
6
|
+
def list(status: nil, thread_id: nil, limit: nil, api_key: nil)
|
|
7
|
+
fetch_list(ApiPaths::FOLLOW_UPS, query_params(status:, thread_id:, limit:), api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def set(body = nil, api_key: nil, **fields)
|
|
11
|
+
wire = payload(body, fields).slice("threadId", "remindAt")
|
|
12
|
+
wire["remindAt"] = instant(wire["remindAt"]) if wire.key?("remindAt")
|
|
13
|
+
request(ApiPaths::FOLLOW_UPS, method: :post, body: wire, repeatable: true, api_key:)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def cancel(id, api_key: nil)
|
|
17
|
+
request(fill(ApiPaths::FOLLOW_UP, id:), method: :delete, repeatable: true, api_key:)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|