billionsend 0.1.0
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/CHANGELOG.md +15 -0
- data/LICENSE +21 -0
- data/README.md +258 -0
- data/lib/billionsend/client.rb +253 -0
- data/lib/billionsend/errors.rb +115 -0
- data/lib/billionsend/pagination.rb +39 -0
- data/lib/billionsend/resources.rb +3436 -0
- data/lib/billionsend/streaming.rb +284 -0
- data/lib/billionsend/transport.rb +163 -0
- data/lib/billionsend/version.rb +5 -0
- data/lib/billionsend/webhooks.rb +104 -0
- data/lib/billionsend.rb +20 -0
- metadata +55 -0
|
@@ -0,0 +1,3436 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Generated by script/generate.rb from openapi/api.openapi.json. Do not edit.
|
|
4
|
+
|
|
5
|
+
module BillionSend
|
|
6
|
+
# The API's operations, one class per group of its operationIds.
|
|
7
|
+
module Resources
|
|
8
|
+
# Shared by every resource: holds the client the requests go through.
|
|
9
|
+
class Base
|
|
10
|
+
def initialize(client)
|
|
11
|
+
@client = client
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def inspect
|
|
15
|
+
"#<#{self.class.name}>"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Operations on agent.
|
|
20
|
+
class Agent < Base
|
|
21
|
+
# Sign up as an agent.
|
|
22
|
+
#
|
|
23
|
+
# BillionSend extension, no API key needed. Creates an account for an agent without a person
|
|
24
|
+
# present: a team named after the agent, one inbox on the shared domain (no DNS) and an
|
|
25
|
+
# inbox-scoped key for it, so the agent can receive mail at once. The account is
|
|
26
|
+
# **unclaimed**: it only receives, and every send answers 403 `team_unclaimed`. A claim link
|
|
27
|
+
# goes to `human_email`; the person opens it, signs in and claims the account, which becomes
|
|
28
|
+
# theirs on the Free plan (the key keeps working, as an inbox-scoped key under their team). An
|
|
29
|
+
# account nobody claims deletes itself 7 days after signup. Limits: 3 signups per client
|
|
30
|
+
# address per hour, 100 per hour in all, 3 per `human_email` per day.
|
|
31
|
+
#
|
|
32
|
+
# +POST /agent/signup+
|
|
33
|
+
#
|
|
34
|
+
# @return [Hash] the parsed JSON answer
|
|
35
|
+
def signup(params, extra_headers: nil, timeout: nil)
|
|
36
|
+
@client.request(
|
|
37
|
+
"POST",
|
|
38
|
+
"/agent/signup",
|
|
39
|
+
body: params,
|
|
40
|
+
auth: false,
|
|
41
|
+
extra_headers: extra_headers,
|
|
42
|
+
timeout: timeout
|
|
43
|
+
)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Get the account's claim status.
|
|
47
|
+
#
|
|
48
|
+
# BillionSend extension. Whether the account behind the key is still unclaimed, when it
|
|
49
|
+
# deletes itself, and what it may do meanwhile. Any key may ask; an account a person has
|
|
50
|
+
# claimed answers `claimed` with no limits.
|
|
51
|
+
#
|
|
52
|
+
# +GET /agent/status+
|
|
53
|
+
#
|
|
54
|
+
# @return [Hash] the parsed JSON answer
|
|
55
|
+
def status(extra_headers: nil, timeout: nil)
|
|
56
|
+
@client.request(
|
|
57
|
+
"GET",
|
|
58
|
+
"/agent/status",
|
|
59
|
+
extra_headers: extra_headers,
|
|
60
|
+
timeout: timeout
|
|
61
|
+
)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Send the claim link again.
|
|
65
|
+
#
|
|
66
|
+
# BillionSend extension. Sends the claim link to the address given at signup again; the
|
|
67
|
+
# earlier link stops working. At most 5 claim emails in all, ten minutes apart.
|
|
68
|
+
#
|
|
69
|
+
# +POST /agent/claim-email+
|
|
70
|
+
#
|
|
71
|
+
# @return [Hash] the parsed JSON answer
|
|
72
|
+
def claim_email(extra_headers: nil, timeout: nil)
|
|
73
|
+
@client.request(
|
|
74
|
+
"POST",
|
|
75
|
+
"/agent/claim-email",
|
|
76
|
+
extra_headers: extra_headers,
|
|
77
|
+
timeout: timeout
|
|
78
|
+
)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Operations on api keys.
|
|
83
|
+
class ApiKeys < Base
|
|
84
|
+
# Create an API key.
|
|
85
|
+
#
|
|
86
|
+
# +POST /api-keys+
|
|
87
|
+
#
|
|
88
|
+
# @return [Hash] the parsed JSON answer
|
|
89
|
+
def create(params, extra_headers: nil, timeout: nil)
|
|
90
|
+
@client.request(
|
|
91
|
+
"POST",
|
|
92
|
+
"/api-keys",
|
|
93
|
+
body: params,
|
|
94
|
+
extra_headers: extra_headers,
|
|
95
|
+
timeout: timeout
|
|
96
|
+
)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# List API keys.
|
|
100
|
+
#
|
|
101
|
+
# Newest first, with cursor pagination: `after` takes the last id of a page and pages toward
|
|
102
|
+
# older items, `before` takes the first id and pages back toward newer ones. A key held to one
|
|
103
|
+
# domain lists only the keys held to that same domain.
|
|
104
|
+
#
|
|
105
|
+
# +GET /api-keys+
|
|
106
|
+
#
|
|
107
|
+
# @return [Hash] the parsed JSON answer
|
|
108
|
+
def list(limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
109
|
+
@client.request(
|
|
110
|
+
"GET",
|
|
111
|
+
"/api-keys",
|
|
112
|
+
query: { "limit" => limit, "after" => after, "before" => before },
|
|
113
|
+
extra_headers: extra_headers,
|
|
114
|
+
timeout: timeout
|
|
115
|
+
)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Every item of +list+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
119
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
120
|
+
#
|
|
121
|
+
# @return [Enumerator<Hash>]
|
|
122
|
+
def list_all(limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
123
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
124
|
+
@client.request(
|
|
125
|
+
"GET",
|
|
126
|
+
"/api-keys",
|
|
127
|
+
query: { "limit" => limit, "after" => page_after, "before" => page_before },
|
|
128
|
+
extra_headers: extra_headers,
|
|
129
|
+
timeout: timeout
|
|
130
|
+
)
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Delete an API key.
|
|
135
|
+
#
|
|
136
|
+
# A key held to one domain deletes only keys held to that same domain; any other key is not
|
|
137
|
+
# found.
|
|
138
|
+
#
|
|
139
|
+
# +DELETE /api-keys/{id}+
|
|
140
|
+
#
|
|
141
|
+
# @return [Hash] the parsed JSON answer
|
|
142
|
+
def delete(id, extra_headers: nil, timeout: nil)
|
|
143
|
+
@client.request(
|
|
144
|
+
"DELETE",
|
|
145
|
+
"/api-keys/#{Client.encode_path(id)}",
|
|
146
|
+
extra_headers: extra_headers,
|
|
147
|
+
timeout: timeout
|
|
148
|
+
)
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Operations on audiences.
|
|
153
|
+
class Audiences < Base
|
|
154
|
+
# @return [AudiencesContacts]
|
|
155
|
+
def contacts
|
|
156
|
+
@contacts ||= AudiencesContacts.new(@client)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Operations on audiences contacts.
|
|
161
|
+
class AudiencesContacts < Base
|
|
162
|
+
# Create a contact.
|
|
163
|
+
#
|
|
164
|
+
# +POST /audiences/{audienceId}/contacts+
|
|
165
|
+
#
|
|
166
|
+
# @return [Hash] the parsed JSON answer
|
|
167
|
+
def create(audience_id, params, extra_headers: nil, timeout: nil)
|
|
168
|
+
@client.request(
|
|
169
|
+
"POST",
|
|
170
|
+
"/audiences/#{Client.encode_path(audience_id)}/contacts",
|
|
171
|
+
body: params,
|
|
172
|
+
extra_headers: extra_headers,
|
|
173
|
+
timeout: timeout
|
|
174
|
+
)
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# Retrieve a contact.
|
|
178
|
+
#
|
|
179
|
+
# +GET /audiences/{audienceId}/contacts/{id}+
|
|
180
|
+
#
|
|
181
|
+
# @return [Hash] the parsed JSON answer
|
|
182
|
+
def get(audience_id, id, extra_headers: nil, timeout: nil)
|
|
183
|
+
@client.request(
|
|
184
|
+
"GET",
|
|
185
|
+
"/audiences/#{Client.encode_path(audience_id)}/contacts/#{Client.encode_path(id)}",
|
|
186
|
+
extra_headers: extra_headers,
|
|
187
|
+
timeout: timeout
|
|
188
|
+
)
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# Update a contact.
|
|
192
|
+
#
|
|
193
|
+
# +PATCH /audiences/{audienceId}/contacts/{id}+
|
|
194
|
+
#
|
|
195
|
+
# @return [Hash] the parsed JSON answer
|
|
196
|
+
def update(audience_id, id, params = nil, extra_headers: nil, timeout: nil)
|
|
197
|
+
@client.request(
|
|
198
|
+
"PATCH",
|
|
199
|
+
"/audiences/#{Client.encode_path(audience_id)}/contacts/#{Client.encode_path(id)}",
|
|
200
|
+
body: params,
|
|
201
|
+
extra_headers: extra_headers,
|
|
202
|
+
timeout: timeout
|
|
203
|
+
)
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Delete a contact.
|
|
207
|
+
#
|
|
208
|
+
# +DELETE /audiences/{audienceId}/contacts/{id}+
|
|
209
|
+
#
|
|
210
|
+
# @return [Hash] the parsed JSON answer
|
|
211
|
+
def delete(audience_id, id, erase: nil, extra_headers: nil, timeout: nil)
|
|
212
|
+
@client.request(
|
|
213
|
+
"DELETE",
|
|
214
|
+
"/audiences/#{Client.encode_path(audience_id)}/contacts/#{Client.encode_path(id)}",
|
|
215
|
+
query: { "erase" => erase },
|
|
216
|
+
extra_headers: extra_headers,
|
|
217
|
+
timeout: timeout
|
|
218
|
+
)
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
# Operations on broadcasts.
|
|
223
|
+
class Broadcasts < Base
|
|
224
|
+
# Create a broadcast.
|
|
225
|
+
#
|
|
226
|
+
# +POST /broadcasts+
|
|
227
|
+
#
|
|
228
|
+
# @return [Hash] the parsed JSON answer
|
|
229
|
+
def create(params, extra_headers: nil, timeout: nil)
|
|
230
|
+
@client.request(
|
|
231
|
+
"POST",
|
|
232
|
+
"/broadcasts",
|
|
233
|
+
body: params,
|
|
234
|
+
extra_headers: extra_headers,
|
|
235
|
+
timeout: timeout
|
|
236
|
+
)
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
# List broadcasts.
|
|
240
|
+
#
|
|
241
|
+
# Newest first, with cursor pagination: `after` takes the last id of a page and pages toward
|
|
242
|
+
# older items, `before` takes the first id and pages back toward newer ones.
|
|
243
|
+
#
|
|
244
|
+
# +GET /broadcasts+
|
|
245
|
+
#
|
|
246
|
+
# @return [Hash] the parsed JSON answer
|
|
247
|
+
def list(limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
248
|
+
@client.request(
|
|
249
|
+
"GET",
|
|
250
|
+
"/broadcasts",
|
|
251
|
+
query: { "limit" => limit, "after" => after, "before" => before },
|
|
252
|
+
extra_headers: extra_headers,
|
|
253
|
+
timeout: timeout
|
|
254
|
+
)
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
# Every item of +list+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
258
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
259
|
+
#
|
|
260
|
+
# @return [Enumerator<Hash>]
|
|
261
|
+
def list_all(limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
262
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
263
|
+
@client.request(
|
|
264
|
+
"GET",
|
|
265
|
+
"/broadcasts",
|
|
266
|
+
query: { "limit" => limit, "after" => page_after, "before" => page_before },
|
|
267
|
+
extra_headers: extra_headers,
|
|
268
|
+
timeout: timeout
|
|
269
|
+
)
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
# Retrieve a broadcast.
|
|
274
|
+
#
|
|
275
|
+
# +GET /broadcasts/{id}+
|
|
276
|
+
#
|
|
277
|
+
# @return [Hash] the parsed JSON answer
|
|
278
|
+
def get(id, extra_headers: nil, timeout: nil)
|
|
279
|
+
@client.request(
|
|
280
|
+
"GET",
|
|
281
|
+
"/broadcasts/#{Client.encode_path(id)}",
|
|
282
|
+
extra_headers: extra_headers,
|
|
283
|
+
timeout: timeout
|
|
284
|
+
)
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
# Update a broadcast.
|
|
288
|
+
#
|
|
289
|
+
# +PATCH /broadcasts/{id}+
|
|
290
|
+
#
|
|
291
|
+
# @return [Hash] the parsed JSON answer
|
|
292
|
+
def update(id, params = nil, extra_headers: nil, timeout: nil)
|
|
293
|
+
@client.request(
|
|
294
|
+
"PATCH",
|
|
295
|
+
"/broadcasts/#{Client.encode_path(id)}",
|
|
296
|
+
body: params,
|
|
297
|
+
extra_headers: extra_headers,
|
|
298
|
+
timeout: timeout
|
|
299
|
+
)
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
# Delete a broadcast.
|
|
303
|
+
#
|
|
304
|
+
# +DELETE /broadcasts/{id}+
|
|
305
|
+
#
|
|
306
|
+
# @return [Hash] the parsed JSON answer
|
|
307
|
+
def delete(id, extra_headers: nil, timeout: nil)
|
|
308
|
+
@client.request(
|
|
309
|
+
"DELETE",
|
|
310
|
+
"/broadcasts/#{Client.encode_path(id)}",
|
|
311
|
+
extra_headers: extra_headers,
|
|
312
|
+
timeout: timeout
|
|
313
|
+
)
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
# Send a broadcast.
|
|
317
|
+
#
|
|
318
|
+
# +POST /broadcasts/{id}/send+
|
|
319
|
+
#
|
|
320
|
+
# @return [Hash] the parsed JSON answer
|
|
321
|
+
def send(id, params = nil, extra_headers: nil, timeout: nil)
|
|
322
|
+
@client.request(
|
|
323
|
+
"POST",
|
|
324
|
+
"/broadcasts/#{Client.encode_path(id)}/send",
|
|
325
|
+
body: params,
|
|
326
|
+
extra_headers: extra_headers,
|
|
327
|
+
timeout: timeout
|
|
328
|
+
)
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
# Duplicate a broadcast.
|
|
332
|
+
#
|
|
333
|
+
# Copy any broadcast, whatever its status, into a new draft named "<name> (copy)": audience,
|
|
334
|
+
# sender, subject, reply-to, preview text and content come along; schedule, send times and
|
|
335
|
+
# counts do not.
|
|
336
|
+
#
|
|
337
|
+
# +POST /broadcasts/{id}/duplicate+
|
|
338
|
+
#
|
|
339
|
+
# @return [Hash] the parsed JSON answer
|
|
340
|
+
def duplicate(id, extra_headers: nil, timeout: nil)
|
|
341
|
+
@client.request(
|
|
342
|
+
"POST",
|
|
343
|
+
"/broadcasts/#{Client.encode_path(id)}/duplicate",
|
|
344
|
+
extra_headers: extra_headers,
|
|
345
|
+
timeout: timeout
|
|
346
|
+
)
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
# Cancel a broadcast.
|
|
350
|
+
#
|
|
351
|
+
# +POST /broadcasts/{id}/cancel+
|
|
352
|
+
#
|
|
353
|
+
# @return [Hash] the parsed JSON answer
|
|
354
|
+
def cancel(id, extra_headers: nil, timeout: nil)
|
|
355
|
+
@client.request(
|
|
356
|
+
"POST",
|
|
357
|
+
"/broadcasts/#{Client.encode_path(id)}/cancel",
|
|
358
|
+
extra_headers: extra_headers,
|
|
359
|
+
timeout: timeout
|
|
360
|
+
)
|
|
361
|
+
end
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
# Operations on contact properties.
|
|
365
|
+
class ContactProperties < Base
|
|
366
|
+
# Create a property.
|
|
367
|
+
#
|
|
368
|
+
# +POST /contact-properties+
|
|
369
|
+
#
|
|
370
|
+
# @return [Hash] the parsed JSON answer
|
|
371
|
+
def create(params, extra_headers: nil, timeout: nil)
|
|
372
|
+
@client.request(
|
|
373
|
+
"POST",
|
|
374
|
+
"/contact-properties",
|
|
375
|
+
body: params,
|
|
376
|
+
extra_headers: extra_headers,
|
|
377
|
+
timeout: timeout
|
|
378
|
+
)
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
# List properties.
|
|
382
|
+
#
|
|
383
|
+
# Newest first, with cursor pagination: `after` takes the last id of a page and pages toward
|
|
384
|
+
# older items, `before` takes the first id and pages back toward newer ones.
|
|
385
|
+
#
|
|
386
|
+
# +GET /contact-properties+
|
|
387
|
+
#
|
|
388
|
+
# @return [Hash] the parsed JSON answer
|
|
389
|
+
def list(limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
390
|
+
@client.request(
|
|
391
|
+
"GET",
|
|
392
|
+
"/contact-properties",
|
|
393
|
+
query: { "limit" => limit, "after" => after, "before" => before },
|
|
394
|
+
extra_headers: extra_headers,
|
|
395
|
+
timeout: timeout
|
|
396
|
+
)
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
# Every item of +list+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
400
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
401
|
+
#
|
|
402
|
+
# @return [Enumerator<Hash>]
|
|
403
|
+
def list_all(limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
404
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
405
|
+
@client.request(
|
|
406
|
+
"GET",
|
|
407
|
+
"/contact-properties",
|
|
408
|
+
query: { "limit" => limit, "after" => page_after, "before" => page_before },
|
|
409
|
+
extra_headers: extra_headers,
|
|
410
|
+
timeout: timeout
|
|
411
|
+
)
|
|
412
|
+
end
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
# Retrieve a property.
|
|
416
|
+
#
|
|
417
|
+
# +GET /contact-properties/{id}+
|
|
418
|
+
#
|
|
419
|
+
# @return [Hash] the parsed JSON answer
|
|
420
|
+
def get(id, extra_headers: nil, timeout: nil)
|
|
421
|
+
@client.request(
|
|
422
|
+
"GET",
|
|
423
|
+
"/contact-properties/#{Client.encode_path(id)}",
|
|
424
|
+
extra_headers: extra_headers,
|
|
425
|
+
timeout: timeout
|
|
426
|
+
)
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
# Update a property.
|
|
430
|
+
#
|
|
431
|
+
# +PATCH /contact-properties/{id}+
|
|
432
|
+
#
|
|
433
|
+
# @return [Hash] the parsed JSON answer
|
|
434
|
+
def update(id, params = nil, extra_headers: nil, timeout: nil)
|
|
435
|
+
@client.request(
|
|
436
|
+
"PATCH",
|
|
437
|
+
"/contact-properties/#{Client.encode_path(id)}",
|
|
438
|
+
body: params,
|
|
439
|
+
extra_headers: extra_headers,
|
|
440
|
+
timeout: timeout
|
|
441
|
+
)
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
# Delete a property.
|
|
445
|
+
#
|
|
446
|
+
# +DELETE /contact-properties/{id}+
|
|
447
|
+
#
|
|
448
|
+
# @return [Hash] the parsed JSON answer
|
|
449
|
+
def delete(id, extra_headers: nil, timeout: nil)
|
|
450
|
+
@client.request(
|
|
451
|
+
"DELETE",
|
|
452
|
+
"/contact-properties/#{Client.encode_path(id)}",
|
|
453
|
+
extra_headers: extra_headers,
|
|
454
|
+
timeout: timeout
|
|
455
|
+
)
|
|
456
|
+
end
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
# Operations on contacts.
|
|
460
|
+
class Contacts < Base
|
|
461
|
+
# @return [ContactsBatch]
|
|
462
|
+
def batch
|
|
463
|
+
@batch ||= ContactsBatch.new(@client)
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
# @return [ContactsSegments]
|
|
467
|
+
def segments
|
|
468
|
+
@segments ||= ContactsSegments.new(@client)
|
|
469
|
+
end
|
|
470
|
+
|
|
471
|
+
# @return [ContactsTopics]
|
|
472
|
+
def topics
|
|
473
|
+
@topics ||= ContactsTopics.new(@client)
|
|
474
|
+
end
|
|
475
|
+
|
|
476
|
+
# Create a contact.
|
|
477
|
+
#
|
|
478
|
+
# +POST /contacts+
|
|
479
|
+
#
|
|
480
|
+
# @return [Hash] the parsed JSON answer
|
|
481
|
+
def create(params, extra_headers: nil, timeout: nil)
|
|
482
|
+
@client.request(
|
|
483
|
+
"POST",
|
|
484
|
+
"/contacts",
|
|
485
|
+
body: params,
|
|
486
|
+
extra_headers: extra_headers,
|
|
487
|
+
timeout: timeout
|
|
488
|
+
)
|
|
489
|
+
end
|
|
490
|
+
|
|
491
|
+
# List contacts.
|
|
492
|
+
#
|
|
493
|
+
# Newest first, with cursor pagination: `after` takes the last id of a page and pages toward
|
|
494
|
+
# older items, `before` takes the first id and pages back toward newer ones.
|
|
495
|
+
#
|
|
496
|
+
# +GET /contacts+
|
|
497
|
+
#
|
|
498
|
+
# @return [Hash] the parsed JSON answer
|
|
499
|
+
def list(limit: nil, after: nil, before: nil, include: nil, extra_headers: nil, timeout: nil)
|
|
500
|
+
@client.request(
|
|
501
|
+
"GET",
|
|
502
|
+
"/contacts",
|
|
503
|
+
query: { "limit" => limit, "after" => after, "before" => before, "include" => include },
|
|
504
|
+
extra_headers: extra_headers,
|
|
505
|
+
timeout: timeout
|
|
506
|
+
)
|
|
507
|
+
end
|
|
508
|
+
|
|
509
|
+
# Every item of +list+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
510
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
511
|
+
#
|
|
512
|
+
# @return [Enumerator<Hash>]
|
|
513
|
+
def list_all(
|
|
514
|
+
limit: nil,
|
|
515
|
+
after: nil,
|
|
516
|
+
before: nil,
|
|
517
|
+
include: nil,
|
|
518
|
+
extra_headers: nil,
|
|
519
|
+
timeout: nil
|
|
520
|
+
)
|
|
521
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
522
|
+
@client.request(
|
|
523
|
+
"GET",
|
|
524
|
+
"/contacts",
|
|
525
|
+
query: {
|
|
526
|
+
"limit" => limit,
|
|
527
|
+
"after" => page_after,
|
|
528
|
+
"before" => page_before,
|
|
529
|
+
"include" => include
|
|
530
|
+
},
|
|
531
|
+
extra_headers: extra_headers,
|
|
532
|
+
timeout: timeout
|
|
533
|
+
)
|
|
534
|
+
end
|
|
535
|
+
end
|
|
536
|
+
|
|
537
|
+
# Retrieve a contact.
|
|
538
|
+
#
|
|
539
|
+
# +GET /contacts/{id}+
|
|
540
|
+
#
|
|
541
|
+
# @return [Hash] the parsed JSON answer
|
|
542
|
+
def get(id, extra_headers: nil, timeout: nil)
|
|
543
|
+
@client.request(
|
|
544
|
+
"GET",
|
|
545
|
+
"/contacts/#{Client.encode_path(id)}",
|
|
546
|
+
extra_headers: extra_headers,
|
|
547
|
+
timeout: timeout
|
|
548
|
+
)
|
|
549
|
+
end
|
|
550
|
+
|
|
551
|
+
# Update a contact.
|
|
552
|
+
#
|
|
553
|
+
# +PATCH /contacts/{id}+
|
|
554
|
+
#
|
|
555
|
+
# @return [Hash] the parsed JSON answer
|
|
556
|
+
def update(id, params = nil, extra_headers: nil, timeout: nil)
|
|
557
|
+
@client.request(
|
|
558
|
+
"PATCH",
|
|
559
|
+
"/contacts/#{Client.encode_path(id)}",
|
|
560
|
+
body: params,
|
|
561
|
+
extra_headers: extra_headers,
|
|
562
|
+
timeout: timeout
|
|
563
|
+
)
|
|
564
|
+
end
|
|
565
|
+
|
|
566
|
+
# Delete a contact.
|
|
567
|
+
#
|
|
568
|
+
# Deletes the contact and its segment memberships. Its emails stay in the log; pass
|
|
569
|
+
# `erase=true` to also scrub the address from email history, event payloads and API logs.
|
|
570
|
+
#
|
|
571
|
+
# +DELETE /contacts/{id}+
|
|
572
|
+
#
|
|
573
|
+
# @return [Hash] the parsed JSON answer
|
|
574
|
+
def delete(id, erase: nil, extra_headers: nil, timeout: nil)
|
|
575
|
+
@client.request(
|
|
576
|
+
"DELETE",
|
|
577
|
+
"/contacts/#{Client.encode_path(id)}",
|
|
578
|
+
query: { "erase" => erase },
|
|
579
|
+
extra_headers: extra_headers,
|
|
580
|
+
timeout: timeout
|
|
581
|
+
)
|
|
582
|
+
end
|
|
583
|
+
|
|
584
|
+
# Get a preferences link.
|
|
585
|
+
#
|
|
586
|
+
# BillionSend extension. Returns the contact's hosted preferences URL, so a product settings
|
|
587
|
+
# screen can deep-link into it. The page lists the team's unbound public topics and carries
|
|
588
|
+
# the team-wide unsubscribe, in the team's default look: the link belongs to no domain. The
|
|
589
|
+
# link is a signed, contact-scoped capability with no expiry: anyone holding it can change
|
|
590
|
+
# that contact's preferences, so hand it only to the contact.
|
|
591
|
+
#
|
|
592
|
+
# +POST /contacts/{id}/preferences-link+
|
|
593
|
+
#
|
|
594
|
+
# @return [Hash] the parsed JSON answer
|
|
595
|
+
def preferences_link(id, extra_headers: nil, timeout: nil)
|
|
596
|
+
@client.request(
|
|
597
|
+
"POST",
|
|
598
|
+
"/contacts/#{Client.encode_path(id)}/preferences-link",
|
|
599
|
+
extra_headers: extra_headers,
|
|
600
|
+
timeout: timeout
|
|
601
|
+
)
|
|
602
|
+
end
|
|
603
|
+
end
|
|
604
|
+
|
|
605
|
+
# Operations on contacts batch.
|
|
606
|
+
class ContactsBatch < Base
|
|
607
|
+
# Read contacts in bulk.
|
|
608
|
+
#
|
|
609
|
+
# BillionSend extension: returns up to 1000 contacts by id or by email address in one request,
|
|
610
|
+
# in request order, optionally with their properties and topic subscriptions. Entries that
|
|
611
|
+
# match no contact are listed under `missing` instead of failing the call. One call counts as
|
|
612
|
+
# one request against the rate limit.
|
|
613
|
+
#
|
|
614
|
+
# +POST /contacts/batch/get+
|
|
615
|
+
#
|
|
616
|
+
# @return [Hash] the parsed JSON answer
|
|
617
|
+
def get(params, extra_headers: nil, timeout: nil)
|
|
618
|
+
@client.request(
|
|
619
|
+
"POST",
|
|
620
|
+
"/contacts/batch/get",
|
|
621
|
+
body: params,
|
|
622
|
+
extra_headers: extra_headers,
|
|
623
|
+
timeout: timeout
|
|
624
|
+
)
|
|
625
|
+
end
|
|
626
|
+
|
|
627
|
+
# Delete in bulk.
|
|
628
|
+
#
|
|
629
|
+
# Deletes up to 1000 contacts by id or by email address in one request and lists the rows
|
|
630
|
+
# actually deleted; unknown ids or addresses are skipped. Emails stay in the log; `erase:
|
|
631
|
+
# true` also scrubs each address from email history, event payloads and API logs, like DELETE
|
|
632
|
+
# /contacts/{id}?erase=true.
|
|
633
|
+
#
|
|
634
|
+
# +POST /contacts/batch/remove+
|
|
635
|
+
#
|
|
636
|
+
# @return [Hash] the parsed JSON answer
|
|
637
|
+
def remove(params, extra_headers: nil, timeout: nil)
|
|
638
|
+
@client.request(
|
|
639
|
+
"POST",
|
|
640
|
+
"/contacts/batch/remove",
|
|
641
|
+
body: params,
|
|
642
|
+
extra_headers: extra_headers,
|
|
643
|
+
timeout: timeout
|
|
644
|
+
)
|
|
645
|
+
end
|
|
646
|
+
|
|
647
|
+
# Create in bulk.
|
|
648
|
+
#
|
|
649
|
+
# Creates up to 1000 contacts in one request. Each item is a CreateContactRequest.
|
|
650
|
+
# `on_conflict` decides what happens to an email that already belongs to a contact — `error`
|
|
651
|
+
# (default), `skip`, or `upsert`. An upsert updates `first_name`/`last_name` only when
|
|
652
|
+
# provided, merges `properties` (provided keys overwrite), adds `segments` and upserts
|
|
653
|
+
# `topics`. `unsubscribed: true` opts the contact out; `unsubscribed: false` on an already
|
|
654
|
+
# unsubscribed contact is ignored — a batch never re-subscribes anyone, that stays an explicit
|
|
655
|
+
# PATCH /contacts/{id}. The `x-batch-validation` header picks strict (default, all-or-nothing)
|
|
656
|
+
# or permissive (valid subset written, failures listed in `errors`).
|
|
657
|
+
#
|
|
658
|
+
# +POST /contacts/batch+
|
|
659
|
+
#
|
|
660
|
+
# @return [Hash] the parsed JSON answer
|
|
661
|
+
def create(params, on_conflict: nil, batch_validation: nil, extra_headers: nil, timeout: nil)
|
|
662
|
+
@client.request(
|
|
663
|
+
"POST",
|
|
664
|
+
"/contacts/batch",
|
|
665
|
+
query: { "on_conflict" => on_conflict },
|
|
666
|
+
headers: { "x-batch-validation" => batch_validation },
|
|
667
|
+
body: params,
|
|
668
|
+
extra_headers: extra_headers,
|
|
669
|
+
timeout: timeout
|
|
670
|
+
)
|
|
671
|
+
end
|
|
672
|
+
end
|
|
673
|
+
|
|
674
|
+
# Operations on contacts segments.
|
|
675
|
+
class ContactsSegments < Base
|
|
676
|
+
# Add to a segment.
|
|
677
|
+
#
|
|
678
|
+
# +POST /contacts/{id}/segments/{segmentId}+
|
|
679
|
+
#
|
|
680
|
+
# @return [Hash] the parsed JSON answer
|
|
681
|
+
def add(id, segment_id, extra_headers: nil, timeout: nil)
|
|
682
|
+
@client.request(
|
|
683
|
+
"POST",
|
|
684
|
+
"/contacts/#{Client.encode_path(id)}/segments/#{Client.encode_path(segment_id)}",
|
|
685
|
+
extra_headers: extra_headers,
|
|
686
|
+
timeout: timeout
|
|
687
|
+
)
|
|
688
|
+
end
|
|
689
|
+
|
|
690
|
+
# Leave a segment.
|
|
691
|
+
#
|
|
692
|
+
# +DELETE /contacts/{id}/segments/{segmentId}+
|
|
693
|
+
#
|
|
694
|
+
# @return [Hash] the parsed JSON answer
|
|
695
|
+
def remove(id, segment_id, extra_headers: nil, timeout: nil)
|
|
696
|
+
@client.request(
|
|
697
|
+
"DELETE",
|
|
698
|
+
"/contacts/#{Client.encode_path(id)}/segments/#{Client.encode_path(segment_id)}",
|
|
699
|
+
extra_headers: extra_headers,
|
|
700
|
+
timeout: timeout
|
|
701
|
+
)
|
|
702
|
+
end
|
|
703
|
+
end
|
|
704
|
+
|
|
705
|
+
# Operations on contacts topics.
|
|
706
|
+
class ContactsTopics < Base
|
|
707
|
+
# List contact topics.
|
|
708
|
+
#
|
|
709
|
+
# +GET /contacts/{id}/topics+
|
|
710
|
+
#
|
|
711
|
+
# @return [Hash] the parsed JSON answer
|
|
712
|
+
def list(id, extra_headers: nil, timeout: nil)
|
|
713
|
+
@client.request(
|
|
714
|
+
"GET",
|
|
715
|
+
"/contacts/#{Client.encode_path(id)}/topics",
|
|
716
|
+
extra_headers: extra_headers,
|
|
717
|
+
timeout: timeout
|
|
718
|
+
)
|
|
719
|
+
end
|
|
720
|
+
|
|
721
|
+
# Update contact topics.
|
|
722
|
+
#
|
|
723
|
+
# +PATCH /contacts/{id}/topics+
|
|
724
|
+
#
|
|
725
|
+
# @return [Hash] the parsed JSON answer
|
|
726
|
+
def update(id, params, extra_headers: nil, timeout: nil)
|
|
727
|
+
@client.request(
|
|
728
|
+
"PATCH",
|
|
729
|
+
"/contacts/#{Client.encode_path(id)}/topics",
|
|
730
|
+
body: params,
|
|
731
|
+
extra_headers: extra_headers,
|
|
732
|
+
timeout: timeout
|
|
733
|
+
)
|
|
734
|
+
end
|
|
735
|
+
end
|
|
736
|
+
|
|
737
|
+
# Operations on deliverability.
|
|
738
|
+
class Deliverability < Base
|
|
739
|
+
# Get deliverability.
|
|
740
|
+
#
|
|
741
|
+
# +GET /deliverability+
|
|
742
|
+
#
|
|
743
|
+
# @return [Hash] the parsed JSON answer
|
|
744
|
+
def get(extra_headers: nil, timeout: nil)
|
|
745
|
+
@client.request(
|
|
746
|
+
"GET",
|
|
747
|
+
"/deliverability",
|
|
748
|
+
extra_headers: extra_headers,
|
|
749
|
+
timeout: timeout
|
|
750
|
+
)
|
|
751
|
+
end
|
|
752
|
+
end
|
|
753
|
+
|
|
754
|
+
# Operations on domains.
|
|
755
|
+
class Domains < Base
|
|
756
|
+
# Create a domain.
|
|
757
|
+
#
|
|
758
|
+
# +POST /domains+
|
|
759
|
+
#
|
|
760
|
+
# @return [Hash] the parsed JSON answer
|
|
761
|
+
def create(params, extra_headers: nil, timeout: nil)
|
|
762
|
+
@client.request(
|
|
763
|
+
"POST",
|
|
764
|
+
"/domains",
|
|
765
|
+
body: params,
|
|
766
|
+
extra_headers: extra_headers,
|
|
767
|
+
timeout: timeout
|
|
768
|
+
)
|
|
769
|
+
end
|
|
770
|
+
|
|
771
|
+
# List domains.
|
|
772
|
+
#
|
|
773
|
+
# Newest first, with cursor pagination: `after` takes the last id of a page and pages toward
|
|
774
|
+
# older items, `before` takes the first id and pages back toward newer ones. The team's
|
|
775
|
+
# subdomain of the shared domain, when it has one, is the last row (`shared: true`).
|
|
776
|
+
#
|
|
777
|
+
# +GET /domains+
|
|
778
|
+
#
|
|
779
|
+
# @return [Hash] the parsed JSON answer
|
|
780
|
+
def list(limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
781
|
+
@client.request(
|
|
782
|
+
"GET",
|
|
783
|
+
"/domains",
|
|
784
|
+
query: { "limit" => limit, "after" => after, "before" => before },
|
|
785
|
+
extra_headers: extra_headers,
|
|
786
|
+
timeout: timeout
|
|
787
|
+
)
|
|
788
|
+
end
|
|
789
|
+
|
|
790
|
+
# Every item of +list+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
791
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
792
|
+
#
|
|
793
|
+
# @return [Enumerator<Hash>]
|
|
794
|
+
def list_all(limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
795
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
796
|
+
@client.request(
|
|
797
|
+
"GET",
|
|
798
|
+
"/domains",
|
|
799
|
+
query: { "limit" => limit, "after" => page_after, "before" => page_before },
|
|
800
|
+
extra_headers: extra_headers,
|
|
801
|
+
timeout: timeout
|
|
802
|
+
)
|
|
803
|
+
end
|
|
804
|
+
end
|
|
805
|
+
|
|
806
|
+
# Retrieve a domain.
|
|
807
|
+
#
|
|
808
|
+
# +GET /domains/{id}+
|
|
809
|
+
#
|
|
810
|
+
# @return [Hash] the parsed JSON answer
|
|
811
|
+
def get(id, extra_headers: nil, timeout: nil)
|
|
812
|
+
@client.request(
|
|
813
|
+
"GET",
|
|
814
|
+
"/domains/#{Client.encode_path(id)}",
|
|
815
|
+
extra_headers: extra_headers,
|
|
816
|
+
timeout: timeout
|
|
817
|
+
)
|
|
818
|
+
end
|
|
819
|
+
|
|
820
|
+
# Update a domain.
|
|
821
|
+
#
|
|
822
|
+
# +PATCH /domains/{id}+
|
|
823
|
+
#
|
|
824
|
+
# @return [Hash] the parsed JSON answer
|
|
825
|
+
def update(id, params = nil, extra_headers: nil, timeout: nil)
|
|
826
|
+
@client.request(
|
|
827
|
+
"PATCH",
|
|
828
|
+
"/domains/#{Client.encode_path(id)}",
|
|
829
|
+
body: params,
|
|
830
|
+
extra_headers: extra_headers,
|
|
831
|
+
timeout: timeout
|
|
832
|
+
)
|
|
833
|
+
end
|
|
834
|
+
|
|
835
|
+
# Delete a domain.
|
|
836
|
+
#
|
|
837
|
+
# +DELETE /domains/{id}+
|
|
838
|
+
#
|
|
839
|
+
# @return [Hash] the parsed JSON answer
|
|
840
|
+
def delete(id, extra_headers: nil, timeout: nil)
|
|
841
|
+
@client.request(
|
|
842
|
+
"DELETE",
|
|
843
|
+
"/domains/#{Client.encode_path(id)}",
|
|
844
|
+
extra_headers: extra_headers,
|
|
845
|
+
timeout: timeout
|
|
846
|
+
)
|
|
847
|
+
end
|
|
848
|
+
|
|
849
|
+
# Verify a domain.
|
|
850
|
+
#
|
|
851
|
+
# +POST /domains/{id}/verify+
|
|
852
|
+
#
|
|
853
|
+
# @return [Hash] the parsed JSON answer
|
|
854
|
+
def verify(id, extra_headers: nil, timeout: nil)
|
|
855
|
+
@client.request(
|
|
856
|
+
"POST",
|
|
857
|
+
"/domains/#{Client.encode_path(id)}/verify",
|
|
858
|
+
extra_headers: extra_headers,
|
|
859
|
+
timeout: timeout
|
|
860
|
+
)
|
|
861
|
+
end
|
|
862
|
+
end
|
|
863
|
+
|
|
864
|
+
# Operations on emails.
|
|
865
|
+
class Emails < Base
|
|
866
|
+
# @return [EmailsMetrics]
|
|
867
|
+
def metrics
|
|
868
|
+
@metrics ||= EmailsMetrics.new(@client)
|
|
869
|
+
end
|
|
870
|
+
|
|
871
|
+
# @return [EmailsReceiving]
|
|
872
|
+
def receiving
|
|
873
|
+
@receiving ||= EmailsReceiving.new(@client)
|
|
874
|
+
end
|
|
875
|
+
|
|
876
|
+
# Send an email.
|
|
877
|
+
#
|
|
878
|
+
# Sent with an Idempotency-Key: +idempotency_key+ when given, else one made up for this call,
|
|
879
|
+
# so that its retries never send twice.
|
|
880
|
+
#
|
|
881
|
+
# +POST /emails+
|
|
882
|
+
#
|
|
883
|
+
# @return [Hash] the parsed JSON answer
|
|
884
|
+
def send(params, idempotency_key: nil, extra_headers: nil, timeout: nil)
|
|
885
|
+
@client.request(
|
|
886
|
+
"POST",
|
|
887
|
+
"/emails",
|
|
888
|
+
body: params,
|
|
889
|
+
idempotency_key: idempotency_key,
|
|
890
|
+
auto_idempotency_key: true,
|
|
891
|
+
extra_headers: extra_headers,
|
|
892
|
+
timeout: timeout
|
|
893
|
+
)
|
|
894
|
+
end
|
|
895
|
+
|
|
896
|
+
# List emails.
|
|
897
|
+
#
|
|
898
|
+
# Newest first, with cursor pagination: `after` takes the last id of a page and pages toward
|
|
899
|
+
# older items, `before` takes the first id and pages back toward newer ones.
|
|
900
|
+
#
|
|
901
|
+
# +GET /emails+
|
|
902
|
+
#
|
|
903
|
+
# @return [Hash] the parsed JSON answer
|
|
904
|
+
def list(limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
905
|
+
@client.request(
|
|
906
|
+
"GET",
|
|
907
|
+
"/emails",
|
|
908
|
+
query: { "limit" => limit, "after" => after, "before" => before },
|
|
909
|
+
extra_headers: extra_headers,
|
|
910
|
+
timeout: timeout
|
|
911
|
+
)
|
|
912
|
+
end
|
|
913
|
+
|
|
914
|
+
# Every item of +list+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
915
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
916
|
+
#
|
|
917
|
+
# @return [Enumerator<Hash>]
|
|
918
|
+
def list_all(limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
919
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
920
|
+
@client.request(
|
|
921
|
+
"GET",
|
|
922
|
+
"/emails",
|
|
923
|
+
query: { "limit" => limit, "after" => page_after, "before" => page_before },
|
|
924
|
+
extra_headers: extra_headers,
|
|
925
|
+
timeout: timeout
|
|
926
|
+
)
|
|
927
|
+
end
|
|
928
|
+
end
|
|
929
|
+
|
|
930
|
+
# Send a batch of emails.
|
|
931
|
+
#
|
|
932
|
+
# Sent with an Idempotency-Key: +idempotency_key+ when given, else one made up for this call,
|
|
933
|
+
# so that its retries never send twice.
|
|
934
|
+
#
|
|
935
|
+
# +POST /emails/batch+
|
|
936
|
+
#
|
|
937
|
+
# @return [Hash] the parsed JSON answer
|
|
938
|
+
def batch(
|
|
939
|
+
params,
|
|
940
|
+
batch_validation: nil,
|
|
941
|
+
idempotency_key: nil,
|
|
942
|
+
extra_headers: nil,
|
|
943
|
+
timeout: nil
|
|
944
|
+
)
|
|
945
|
+
@client.request(
|
|
946
|
+
"POST",
|
|
947
|
+
"/emails/batch",
|
|
948
|
+
headers: { "x-batch-validation" => batch_validation },
|
|
949
|
+
body: params,
|
|
950
|
+
idempotency_key: idempotency_key,
|
|
951
|
+
auto_idempotency_key: true,
|
|
952
|
+
extra_headers: extra_headers,
|
|
953
|
+
timeout: timeout
|
|
954
|
+
)
|
|
955
|
+
end
|
|
956
|
+
|
|
957
|
+
# Cancel an email.
|
|
958
|
+
#
|
|
959
|
+
# +POST /emails/{id}/cancel+
|
|
960
|
+
#
|
|
961
|
+
# @return [Hash] the parsed JSON answer
|
|
962
|
+
def cancel(id, extra_headers: nil, timeout: nil)
|
|
963
|
+
@client.request(
|
|
964
|
+
"POST",
|
|
965
|
+
"/emails/#{Client.encode_path(id)}/cancel",
|
|
966
|
+
extra_headers: extra_headers,
|
|
967
|
+
timeout: timeout
|
|
968
|
+
)
|
|
969
|
+
end
|
|
970
|
+
|
|
971
|
+
# Update an email.
|
|
972
|
+
#
|
|
973
|
+
# +PATCH /emails/{id}+
|
|
974
|
+
#
|
|
975
|
+
# @return [Hash] the parsed JSON answer
|
|
976
|
+
def update(id, params, extra_headers: nil, timeout: nil)
|
|
977
|
+
@client.request(
|
|
978
|
+
"PATCH",
|
|
979
|
+
"/emails/#{Client.encode_path(id)}",
|
|
980
|
+
body: params,
|
|
981
|
+
extra_headers: extra_headers,
|
|
982
|
+
timeout: timeout
|
|
983
|
+
)
|
|
984
|
+
end
|
|
985
|
+
|
|
986
|
+
# Retrieve an email.
|
|
987
|
+
#
|
|
988
|
+
# +GET /emails/{id}+
|
|
989
|
+
#
|
|
990
|
+
# @return [Hash] the parsed JSON answer
|
|
991
|
+
def get(id, extra_headers: nil, timeout: nil)
|
|
992
|
+
@client.request(
|
|
993
|
+
"GET",
|
|
994
|
+
"/emails/#{Client.encode_path(id)}",
|
|
995
|
+
extra_headers: extra_headers,
|
|
996
|
+
timeout: timeout
|
|
997
|
+
)
|
|
998
|
+
end
|
|
999
|
+
|
|
1000
|
+
# Delete an email.
|
|
1001
|
+
#
|
|
1002
|
+
# +DELETE /emails/{id}+
|
|
1003
|
+
#
|
|
1004
|
+
# @return [Hash] the parsed JSON answer
|
|
1005
|
+
def delete(id, extra_headers: nil, timeout: nil)
|
|
1006
|
+
@client.request(
|
|
1007
|
+
"DELETE",
|
|
1008
|
+
"/emails/#{Client.encode_path(id)}",
|
|
1009
|
+
extra_headers: extra_headers,
|
|
1010
|
+
timeout: timeout
|
|
1011
|
+
)
|
|
1012
|
+
end
|
|
1013
|
+
|
|
1014
|
+
# Get email insights.
|
|
1015
|
+
#
|
|
1016
|
+
# +GET /emails/{id}/insights+
|
|
1017
|
+
#
|
|
1018
|
+
# @return [Hash] the parsed JSON answer
|
|
1019
|
+
def insights(id, extra_headers: nil, timeout: nil)
|
|
1020
|
+
@client.request(
|
|
1021
|
+
"GET",
|
|
1022
|
+
"/emails/#{Client.encode_path(id)}/insights",
|
|
1023
|
+
extra_headers: extra_headers,
|
|
1024
|
+
timeout: timeout
|
|
1025
|
+
)
|
|
1026
|
+
end
|
|
1027
|
+
end
|
|
1028
|
+
|
|
1029
|
+
# Operations on emails metrics.
|
|
1030
|
+
class EmailsMetrics < Base
|
|
1031
|
+
# Get email metrics.
|
|
1032
|
+
#
|
|
1033
|
+
# +GET /emails/metrics+
|
|
1034
|
+
#
|
|
1035
|
+
# @return [Hash] the parsed JSON answer
|
|
1036
|
+
def call(
|
|
1037
|
+
start_date: nil,
|
|
1038
|
+
end_date: nil,
|
|
1039
|
+
timezone: nil,
|
|
1040
|
+
granularity: nil,
|
|
1041
|
+
metrics: nil,
|
|
1042
|
+
dimensions: nil,
|
|
1043
|
+
domain_id: nil,
|
|
1044
|
+
email_id: nil,
|
|
1045
|
+
broadcast_id: nil,
|
|
1046
|
+
extra_headers: nil,
|
|
1047
|
+
timeout: nil
|
|
1048
|
+
)
|
|
1049
|
+
@client.request(
|
|
1050
|
+
"GET",
|
|
1051
|
+
"/emails/metrics",
|
|
1052
|
+
query: {
|
|
1053
|
+
"start_date" => start_date,
|
|
1054
|
+
"end_date" => end_date,
|
|
1055
|
+
"timezone" => timezone,
|
|
1056
|
+
"granularity" => granularity,
|
|
1057
|
+
"metrics" => metrics,
|
|
1058
|
+
"dimensions" => dimensions,
|
|
1059
|
+
"domain_id" => domain_id,
|
|
1060
|
+
"email_id" => email_id,
|
|
1061
|
+
"broadcast_id" => broadcast_id
|
|
1062
|
+
},
|
|
1063
|
+
extra_headers: extra_headers,
|
|
1064
|
+
timeout: timeout
|
|
1065
|
+
)
|
|
1066
|
+
end
|
|
1067
|
+
|
|
1068
|
+
# Get clicks by link.
|
|
1069
|
+
#
|
|
1070
|
+
# +GET /emails/metrics/links+
|
|
1071
|
+
#
|
|
1072
|
+
# @return [Hash] the parsed JSON answer
|
|
1073
|
+
def links(
|
|
1074
|
+
start_date: nil,
|
|
1075
|
+
end_date: nil,
|
|
1076
|
+
domain_id: nil,
|
|
1077
|
+
broadcast_id: nil,
|
|
1078
|
+
limit: nil,
|
|
1079
|
+
extra_headers: nil,
|
|
1080
|
+
timeout: nil
|
|
1081
|
+
)
|
|
1082
|
+
@client.request(
|
|
1083
|
+
"GET",
|
|
1084
|
+
"/emails/metrics/links",
|
|
1085
|
+
query: {
|
|
1086
|
+
"start_date" => start_date,
|
|
1087
|
+
"end_date" => end_date,
|
|
1088
|
+
"domain_id" => domain_id,
|
|
1089
|
+
"broadcast_id" => broadcast_id,
|
|
1090
|
+
"limit" => limit
|
|
1091
|
+
},
|
|
1092
|
+
extra_headers: extra_headers,
|
|
1093
|
+
timeout: timeout
|
|
1094
|
+
)
|
|
1095
|
+
end
|
|
1096
|
+
|
|
1097
|
+
# Get opens and clicks by country.
|
|
1098
|
+
#
|
|
1099
|
+
# +GET /emails/metrics/countries+
|
|
1100
|
+
#
|
|
1101
|
+
# @return [Hash] the parsed JSON answer
|
|
1102
|
+
def countries(
|
|
1103
|
+
start_date: nil,
|
|
1104
|
+
end_date: nil,
|
|
1105
|
+
domain_id: nil,
|
|
1106
|
+
broadcast_id: nil,
|
|
1107
|
+
extra_headers: nil,
|
|
1108
|
+
timeout: nil
|
|
1109
|
+
)
|
|
1110
|
+
@client.request(
|
|
1111
|
+
"GET",
|
|
1112
|
+
"/emails/metrics/countries",
|
|
1113
|
+
query: {
|
|
1114
|
+
"start_date" => start_date,
|
|
1115
|
+
"end_date" => end_date,
|
|
1116
|
+
"domain_id" => domain_id,
|
|
1117
|
+
"broadcast_id" => broadcast_id
|
|
1118
|
+
},
|
|
1119
|
+
extra_headers: extra_headers,
|
|
1120
|
+
timeout: timeout
|
|
1121
|
+
)
|
|
1122
|
+
end
|
|
1123
|
+
|
|
1124
|
+
# Get opens by mail client.
|
|
1125
|
+
#
|
|
1126
|
+
# +GET /emails/metrics/clients+
|
|
1127
|
+
#
|
|
1128
|
+
# @return [Hash] the parsed JSON answer
|
|
1129
|
+
def clients(
|
|
1130
|
+
start_date: nil,
|
|
1131
|
+
end_date: nil,
|
|
1132
|
+
domain_id: nil,
|
|
1133
|
+
broadcast_id: nil,
|
|
1134
|
+
extra_headers: nil,
|
|
1135
|
+
timeout: nil
|
|
1136
|
+
)
|
|
1137
|
+
@client.request(
|
|
1138
|
+
"GET",
|
|
1139
|
+
"/emails/metrics/clients",
|
|
1140
|
+
query: {
|
|
1141
|
+
"start_date" => start_date,
|
|
1142
|
+
"end_date" => end_date,
|
|
1143
|
+
"domain_id" => domain_id,
|
|
1144
|
+
"broadcast_id" => broadcast_id
|
|
1145
|
+
},
|
|
1146
|
+
extra_headers: extra_headers,
|
|
1147
|
+
timeout: timeout
|
|
1148
|
+
)
|
|
1149
|
+
end
|
|
1150
|
+
end
|
|
1151
|
+
|
|
1152
|
+
# Operations on emails receiving.
|
|
1153
|
+
class EmailsReceiving < Base
|
|
1154
|
+
# @return [EmailsReceivingAttachments]
|
|
1155
|
+
def attachments
|
|
1156
|
+
@attachments ||= EmailsReceivingAttachments.new(@client)
|
|
1157
|
+
end
|
|
1158
|
+
|
|
1159
|
+
# Reply to an email.
|
|
1160
|
+
#
|
|
1161
|
+
# BillionSend extension: replies server-side, threaded with In-Reply-To and References. It
|
|
1162
|
+
# goes out from the inbox the email reached (`inbox_id` picks one), else from the first
|
|
1163
|
+
# address it was received for, or from `from`. A reply from an inbox runs its rules and may be
|
|
1164
|
+
# held as a draft (202). Accepts an `Idempotency-Key`. Needs a full access key.
|
|
1165
|
+
#
|
|
1166
|
+
# Sent with an Idempotency-Key: +idempotency_key+ when given, else one made up for this call,
|
|
1167
|
+
# so that its retries never send twice.
|
|
1168
|
+
#
|
|
1169
|
+
# +POST /emails/receiving/{id}/reply+
|
|
1170
|
+
#
|
|
1171
|
+
# @return [Hash] the parsed JSON answer
|
|
1172
|
+
def reply(id, params = nil, idempotency_key: nil, extra_headers: nil, timeout: nil)
|
|
1173
|
+
@client.request(
|
|
1174
|
+
"POST",
|
|
1175
|
+
"/emails/receiving/#{Client.encode_path(id)}/reply",
|
|
1176
|
+
body: params,
|
|
1177
|
+
idempotency_key: idempotency_key,
|
|
1178
|
+
auto_idempotency_key: true,
|
|
1179
|
+
extra_headers: extra_headers,
|
|
1180
|
+
timeout: timeout
|
|
1181
|
+
)
|
|
1182
|
+
end
|
|
1183
|
+
|
|
1184
|
+
# Forward an email.
|
|
1185
|
+
#
|
|
1186
|
+
# BillionSend extension: forwards server-side, inline under a note (default) or with the
|
|
1187
|
+
# original attached as forwarded_message.eml (`mode: attachment`), within 10 MiB. An email
|
|
1188
|
+
# that carries malware is never forwarded. Sender rules and the 202 draft answer are those of
|
|
1189
|
+
# the reply. Accepts an `Idempotency-Key`. Needs a full access key.
|
|
1190
|
+
#
|
|
1191
|
+
# Sent with an Idempotency-Key: +idempotency_key+ when given, else one made up for this call,
|
|
1192
|
+
# so that its retries never send twice.
|
|
1193
|
+
#
|
|
1194
|
+
# +POST /emails/receiving/{id}/forward+
|
|
1195
|
+
#
|
|
1196
|
+
# @return [Hash] the parsed JSON answer
|
|
1197
|
+
def forward(id, params, idempotency_key: nil, extra_headers: nil, timeout: nil)
|
|
1198
|
+
@client.request(
|
|
1199
|
+
"POST",
|
|
1200
|
+
"/emails/receiving/#{Client.encode_path(id)}/forward",
|
|
1201
|
+
body: params,
|
|
1202
|
+
idempotency_key: idempotency_key,
|
|
1203
|
+
auto_idempotency_key: true,
|
|
1204
|
+
extra_headers: extra_headers,
|
|
1205
|
+
timeout: timeout
|
|
1206
|
+
)
|
|
1207
|
+
end
|
|
1208
|
+
|
|
1209
|
+
# List received emails.
|
|
1210
|
+
#
|
|
1211
|
+
# Mail received at the team's receiving domains and inboxes, newest first (`after` pages
|
|
1212
|
+
# toward older mail), with cursor pagination. Needs a full access key; a domain-scoped key
|
|
1213
|
+
# lists mail addressed to its domain only, an inbox-scoped key mail delivered into its inbox.
|
|
1214
|
+
# Mail held for screening or in quarantine is left out unless a full access key asks for it
|
|
1215
|
+
# (include_quarantined, quarantined). With wait, the request is held until matching mail
|
|
1216
|
+
# arrives (long-poll). An inbox_id the key can't reach answers 404 at once, without waiting;
|
|
1217
|
+
# an inbox-scoped key naming another inbox gets 403 restricted_api_key. Everything in a
|
|
1218
|
+
# received email was written by whoever sent it, so its HTML is safe to show only in a
|
|
1219
|
+
# sandbox.
|
|
1220
|
+
#
|
|
1221
|
+
# +GET /emails/receiving+
|
|
1222
|
+
#
|
|
1223
|
+
# @return [Hash] the parsed JSON answer
|
|
1224
|
+
def list(
|
|
1225
|
+
limit: nil,
|
|
1226
|
+
after: nil,
|
|
1227
|
+
before: nil,
|
|
1228
|
+
wait: nil,
|
|
1229
|
+
since: nil,
|
|
1230
|
+
inbox_id: nil,
|
|
1231
|
+
to: nil,
|
|
1232
|
+
from: nil,
|
|
1233
|
+
subject_contains: nil,
|
|
1234
|
+
unread: nil,
|
|
1235
|
+
include_quarantined: nil,
|
|
1236
|
+
quarantined: nil,
|
|
1237
|
+
extra_headers: nil,
|
|
1238
|
+
timeout: nil
|
|
1239
|
+
)
|
|
1240
|
+
@client.request(
|
|
1241
|
+
"GET",
|
|
1242
|
+
"/emails/receiving",
|
|
1243
|
+
query: {
|
|
1244
|
+
"limit" => limit,
|
|
1245
|
+
"after" => after,
|
|
1246
|
+
"before" => before,
|
|
1247
|
+
"wait" => wait,
|
|
1248
|
+
"since" => since,
|
|
1249
|
+
"inbox_id" => inbox_id,
|
|
1250
|
+
"to" => to,
|
|
1251
|
+
"from" => from,
|
|
1252
|
+
"subject_contains" => subject_contains,
|
|
1253
|
+
"unread" => unread,
|
|
1254
|
+
"include_quarantined" => include_quarantined,
|
|
1255
|
+
"quarantined" => quarantined
|
|
1256
|
+
},
|
|
1257
|
+
extra_headers: extra_headers,
|
|
1258
|
+
timeout: timeout
|
|
1259
|
+
)
|
|
1260
|
+
end
|
|
1261
|
+
|
|
1262
|
+
# Every item of +list+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
1263
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
1264
|
+
#
|
|
1265
|
+
# @return [Enumerator<Hash>]
|
|
1266
|
+
def list_all(
|
|
1267
|
+
limit: nil,
|
|
1268
|
+
after: nil,
|
|
1269
|
+
before: nil,
|
|
1270
|
+
wait: nil,
|
|
1271
|
+
since: nil,
|
|
1272
|
+
inbox_id: nil,
|
|
1273
|
+
to: nil,
|
|
1274
|
+
from: nil,
|
|
1275
|
+
subject_contains: nil,
|
|
1276
|
+
unread: nil,
|
|
1277
|
+
include_quarantined: nil,
|
|
1278
|
+
quarantined: nil,
|
|
1279
|
+
extra_headers: nil,
|
|
1280
|
+
timeout: nil
|
|
1281
|
+
)
|
|
1282
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
1283
|
+
@client.request(
|
|
1284
|
+
"GET",
|
|
1285
|
+
"/emails/receiving",
|
|
1286
|
+
query: {
|
|
1287
|
+
"limit" => limit,
|
|
1288
|
+
"after" => page_after,
|
|
1289
|
+
"before" => page_before,
|
|
1290
|
+
"wait" => wait,
|
|
1291
|
+
"since" => since,
|
|
1292
|
+
"inbox_id" => inbox_id,
|
|
1293
|
+
"to" => to,
|
|
1294
|
+
"from" => from,
|
|
1295
|
+
"subject_contains" => subject_contains,
|
|
1296
|
+
"unread" => unread,
|
|
1297
|
+
"include_quarantined" => include_quarantined,
|
|
1298
|
+
"quarantined" => quarantined
|
|
1299
|
+
},
|
|
1300
|
+
extra_headers: extra_headers,
|
|
1301
|
+
timeout: timeout
|
|
1302
|
+
)
|
|
1303
|
+
end
|
|
1304
|
+
end
|
|
1305
|
+
|
|
1306
|
+
# Get a received email.
|
|
1307
|
+
#
|
|
1308
|
+
# One received email with its html, text, headers, authentication results and a signed link to
|
|
1309
|
+
# the original message, plus BillionSend's screening, verdicts, the extracted read and, where
|
|
1310
|
+
# allowed, its verification code or sign-in link. Needs a full access key. An inbox-scoped key
|
|
1311
|
+
# or an MCP token gets 403 email_quarantined for held mail, and 404 while it is being
|
|
1312
|
+
# screened. Everything in a received email was written by whoever sent it, so its HTML is safe
|
|
1313
|
+
# to show only in a sandbox.
|
|
1314
|
+
#
|
|
1315
|
+
# +GET /emails/receiving/{id}+
|
|
1316
|
+
#
|
|
1317
|
+
# @return [Hash] the parsed JSON answer
|
|
1318
|
+
def get(id, html_format: nil, extra_headers: nil, timeout: nil)
|
|
1319
|
+
@client.request(
|
|
1320
|
+
"GET",
|
|
1321
|
+
"/emails/receiving/#{Client.encode_path(id)}",
|
|
1322
|
+
query: { "html_format" => html_format },
|
|
1323
|
+
extra_headers: extra_headers,
|
|
1324
|
+
timeout: timeout
|
|
1325
|
+
)
|
|
1326
|
+
end
|
|
1327
|
+
|
|
1328
|
+
# Delete a received email.
|
|
1329
|
+
#
|
|
1330
|
+
# BillionSend extension: erases one received email now, its sealed content, inbox memberships
|
|
1331
|
+
# and received secrets with it, and threads it leaves empty. Needs a full access key that is
|
|
1332
|
+
# not scoped to an inbox; for an MCP token, the owner or admin role. Webhook payloads already
|
|
1333
|
+
# sent keep their metadata until the payload retention strips them.
|
|
1334
|
+
#
|
|
1335
|
+
# +DELETE /emails/receiving/{id}+
|
|
1336
|
+
#
|
|
1337
|
+
# @return [Hash] the parsed JSON answer
|
|
1338
|
+
def delete(id, extra_headers: nil, timeout: nil)
|
|
1339
|
+
@client.request(
|
|
1340
|
+
"DELETE",
|
|
1341
|
+
"/emails/receiving/#{Client.encode_path(id)}",
|
|
1342
|
+
extra_headers: extra_headers,
|
|
1343
|
+
timeout: timeout
|
|
1344
|
+
)
|
|
1345
|
+
end
|
|
1346
|
+
end
|
|
1347
|
+
|
|
1348
|
+
# Operations on emails receiving attachments.
|
|
1349
|
+
class EmailsReceivingAttachments < Base
|
|
1350
|
+
# List attachments.
|
|
1351
|
+
#
|
|
1352
|
+
# The attachments and inline parts of one received email, each with a signed download link
|
|
1353
|
+
# valid for one hour; all of them unless `limit` is given. Needs a full access key. The links
|
|
1354
|
+
# of an email that carries malware answer 410.
|
|
1355
|
+
#
|
|
1356
|
+
# +GET /emails/receiving/{email_id}/attachments+
|
|
1357
|
+
#
|
|
1358
|
+
# @return [Hash] the parsed JSON answer
|
|
1359
|
+
def list(email_id, limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
1360
|
+
@client.request(
|
|
1361
|
+
"GET",
|
|
1362
|
+
"/emails/receiving/#{Client.encode_path(email_id)}/attachments",
|
|
1363
|
+
query: { "limit" => limit, "after" => after, "before" => before },
|
|
1364
|
+
extra_headers: extra_headers,
|
|
1365
|
+
timeout: timeout
|
|
1366
|
+
)
|
|
1367
|
+
end
|
|
1368
|
+
|
|
1369
|
+
# Every item of +list+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
1370
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
1371
|
+
#
|
|
1372
|
+
# @return [Enumerator<Hash>]
|
|
1373
|
+
def list_all(email_id, limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
1374
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
1375
|
+
@client.request(
|
|
1376
|
+
"GET",
|
|
1377
|
+
"/emails/receiving/#{Client.encode_path(email_id)}/attachments",
|
|
1378
|
+
query: { "limit" => limit, "after" => page_after, "before" => page_before },
|
|
1379
|
+
extra_headers: extra_headers,
|
|
1380
|
+
timeout: timeout
|
|
1381
|
+
)
|
|
1382
|
+
end
|
|
1383
|
+
end
|
|
1384
|
+
|
|
1385
|
+
# Get an attachment.
|
|
1386
|
+
#
|
|
1387
|
+
# One attachment's metadata and a signed download link valid for one hour. Needs a full access
|
|
1388
|
+
# key.
|
|
1389
|
+
#
|
|
1390
|
+
# +GET /emails/receiving/{email_id}/attachments/{id}+
|
|
1391
|
+
#
|
|
1392
|
+
# @return [Hash] the parsed JSON answer
|
|
1393
|
+
def get(email_id, id, extra_headers: nil, timeout: nil)
|
|
1394
|
+
@client.request(
|
|
1395
|
+
"GET",
|
|
1396
|
+
"/emails/receiving/#{Client.encode_path(email_id)}/attachments/#{Client.encode_path(id)}",
|
|
1397
|
+
extra_headers: extra_headers,
|
|
1398
|
+
timeout: timeout
|
|
1399
|
+
)
|
|
1400
|
+
end
|
|
1401
|
+
|
|
1402
|
+
# Get an attachment's text.
|
|
1403
|
+
#
|
|
1404
|
+
# The text of a PDF, Word (.docx) or Excel (.xlsx) attachment, read once after the email
|
|
1405
|
+
# arrives and kept with it for the content retention period (BillionSend extension). Until the
|
|
1406
|
+
# read has run the status is pending. Needs a full access key. An email that carries malware
|
|
1407
|
+
# answers 410.
|
|
1408
|
+
#
|
|
1409
|
+
# +GET /emails/receiving/{email_id}/attachments/{id}/text+
|
|
1410
|
+
#
|
|
1411
|
+
# @return [Hash] the parsed JSON answer
|
|
1412
|
+
def text(email_id, id, extra_headers: nil, timeout: nil)
|
|
1413
|
+
@client.request(
|
|
1414
|
+
"GET",
|
|
1415
|
+
"/emails/receiving/#{Client.encode_path(email_id)}/attachments/#{Client.encode_path(id)}/text",
|
|
1416
|
+
extra_headers: extra_headers,
|
|
1417
|
+
timeout: timeout
|
|
1418
|
+
)
|
|
1419
|
+
end
|
|
1420
|
+
end
|
|
1421
|
+
|
|
1422
|
+
# Operations on inboxes.
|
|
1423
|
+
class Inboxes < Base
|
|
1424
|
+
# @return [InboxesAgent]
|
|
1425
|
+
def agent
|
|
1426
|
+
@agent ||= InboxesAgent.new(@client)
|
|
1427
|
+
end
|
|
1428
|
+
|
|
1429
|
+
# @return [InboxesCodes]
|
|
1430
|
+
def codes
|
|
1431
|
+
@codes ||= InboxesCodes.new(@client)
|
|
1432
|
+
end
|
|
1433
|
+
|
|
1434
|
+
# @return [InboxesDrafts]
|
|
1435
|
+
def drafts
|
|
1436
|
+
@drafts ||= InboxesDrafts.new(@client)
|
|
1437
|
+
end
|
|
1438
|
+
|
|
1439
|
+
# @return [InboxesEvents]
|
|
1440
|
+
def events
|
|
1441
|
+
@events ||= InboxesEvents.new(@client)
|
|
1442
|
+
end
|
|
1443
|
+
|
|
1444
|
+
# @return [InboxesLabels]
|
|
1445
|
+
def labels
|
|
1446
|
+
@labels ||= InboxesLabels.new(@client)
|
|
1447
|
+
end
|
|
1448
|
+
|
|
1449
|
+
# @return [InboxesQuarantine]
|
|
1450
|
+
def quarantine
|
|
1451
|
+
@quarantine ||= InboxesQuarantine.new(@client)
|
|
1452
|
+
end
|
|
1453
|
+
|
|
1454
|
+
# @return [InboxesSafety]
|
|
1455
|
+
def safety
|
|
1456
|
+
@safety ||= InboxesSafety.new(@client)
|
|
1457
|
+
end
|
|
1458
|
+
|
|
1459
|
+
# @return [InboxesThreads]
|
|
1460
|
+
def threads
|
|
1461
|
+
@threads ||= InboxesThreads.new(@client)
|
|
1462
|
+
end
|
|
1463
|
+
|
|
1464
|
+
# Create an inbox.
|
|
1465
|
+
#
|
|
1466
|
+
# An address that receives into threads, on one of your verified domains (receiving on, or
|
|
1467
|
+
# forwarding: true) or, with email_address omitted, an address on the shared inbox domain that
|
|
1468
|
+
# needs no DNS: username names it, or it is random. domain_id takes a row of GET /domains
|
|
1469
|
+
# instead of email_address: the team's shared subdomain, or one of your domains with username.
|
|
1470
|
+
# It never expires unless expires_in says so. Returns the full inbox. BillionSend extensions:
|
|
1471
|
+
# username, domain_id, kind (agent by default), expires_in and safety.
|
|
1472
|
+
#
|
|
1473
|
+
# +POST /inboxes+
|
|
1474
|
+
#
|
|
1475
|
+
# @return [Hash] the parsed JSON answer
|
|
1476
|
+
def create(params = nil, extra_headers: nil, timeout: nil)
|
|
1477
|
+
@client.request(
|
|
1478
|
+
"POST",
|
|
1479
|
+
"/inboxes",
|
|
1480
|
+
body: params,
|
|
1481
|
+
extra_headers: extra_headers,
|
|
1482
|
+
timeout: timeout
|
|
1483
|
+
)
|
|
1484
|
+
end
|
|
1485
|
+
|
|
1486
|
+
# List inboxes.
|
|
1487
|
+
#
|
|
1488
|
+
# The team's inboxes, newest first (`after` pages toward older ones). An inbox-scoped key
|
|
1489
|
+
# lists only its inbox.
|
|
1490
|
+
#
|
|
1491
|
+
# +GET /inboxes+
|
|
1492
|
+
#
|
|
1493
|
+
# @return [Hash] the parsed JSON answer
|
|
1494
|
+
def list(limit: nil, after: nil, before: nil, kind: nil, extra_headers: nil, timeout: nil)
|
|
1495
|
+
@client.request(
|
|
1496
|
+
"GET",
|
|
1497
|
+
"/inboxes",
|
|
1498
|
+
query: { "limit" => limit, "after" => after, "before" => before, "kind" => kind },
|
|
1499
|
+
extra_headers: extra_headers,
|
|
1500
|
+
timeout: timeout
|
|
1501
|
+
)
|
|
1502
|
+
end
|
|
1503
|
+
|
|
1504
|
+
# Every item of +list+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
1505
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
1506
|
+
#
|
|
1507
|
+
# @return [Enumerator<Hash>]
|
|
1508
|
+
def list_all(limit: nil, after: nil, before: nil, kind: nil, extra_headers: nil, timeout: nil)
|
|
1509
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
1510
|
+
@client.request(
|
|
1511
|
+
"GET",
|
|
1512
|
+
"/inboxes",
|
|
1513
|
+
query: {
|
|
1514
|
+
"limit" => limit,
|
|
1515
|
+
"after" => page_after,
|
|
1516
|
+
"before" => page_before,
|
|
1517
|
+
"kind" => kind
|
|
1518
|
+
},
|
|
1519
|
+
extra_headers: extra_headers,
|
|
1520
|
+
timeout: timeout
|
|
1521
|
+
)
|
|
1522
|
+
end
|
|
1523
|
+
end
|
|
1524
|
+
|
|
1525
|
+
# Retrieve an inbox.
|
|
1526
|
+
#
|
|
1527
|
+
# By id, or by its email address (case-insensitive). An expired inbox is not found.
|
|
1528
|
+
#
|
|
1529
|
+
# +GET /inboxes/{inbox_id}+
|
|
1530
|
+
#
|
|
1531
|
+
# @return [Hash] the parsed JSON answer
|
|
1532
|
+
def get(inbox_id, extra_headers: nil, timeout: nil)
|
|
1533
|
+
@client.request(
|
|
1534
|
+
"GET",
|
|
1535
|
+
"/inboxes/#{Client.encode_path(inbox_id)}",
|
|
1536
|
+
extra_headers: extra_headers,
|
|
1537
|
+
timeout: timeout
|
|
1538
|
+
)
|
|
1539
|
+
end
|
|
1540
|
+
|
|
1541
|
+
# Update an inbox.
|
|
1542
|
+
#
|
|
1543
|
+
# Its name or from_name; BillionSend extension: expires_in, a new lifetime counted from now.
|
|
1544
|
+
# On a shared-domain inbox a new from_name is reviewed first (503 while that review is
|
|
1545
|
+
# unavailable). Returns the full inbox.
|
|
1546
|
+
#
|
|
1547
|
+
# +PATCH /inboxes/{inbox_id}+
|
|
1548
|
+
#
|
|
1549
|
+
# @return [Hash] the parsed JSON answer
|
|
1550
|
+
def update(inbox_id, params = nil, extra_headers: nil, timeout: nil)
|
|
1551
|
+
@client.request(
|
|
1552
|
+
"PATCH",
|
|
1553
|
+
"/inboxes/#{Client.encode_path(inbox_id)}",
|
|
1554
|
+
body: params,
|
|
1555
|
+
extra_headers: extra_headers,
|
|
1556
|
+
timeout: timeout
|
|
1557
|
+
)
|
|
1558
|
+
end
|
|
1559
|
+
|
|
1560
|
+
# Delete an inbox.
|
|
1561
|
+
#
|
|
1562
|
+
# Its threads, drafts, labels and the messages only it received go with it, and its address
|
|
1563
|
+
# stops receiving. Its inbox-scoped API keys are revoked. Needs the owner, admin or developer
|
|
1564
|
+
# role, or a full access team key.
|
|
1565
|
+
#
|
|
1566
|
+
# +DELETE /inboxes/{inbox_id}+
|
|
1567
|
+
#
|
|
1568
|
+
# @return [Hash] the parsed JSON answer
|
|
1569
|
+
def delete(inbox_id, extra_headers: nil, timeout: nil)
|
|
1570
|
+
@client.request(
|
|
1571
|
+
"DELETE",
|
|
1572
|
+
"/inboxes/#{Client.encode_path(inbox_id)}",
|
|
1573
|
+
extra_headers: extra_headers,
|
|
1574
|
+
timeout: timeout
|
|
1575
|
+
)
|
|
1576
|
+
end
|
|
1577
|
+
|
|
1578
|
+
# Send an email from an inbox.
|
|
1579
|
+
#
|
|
1580
|
+
# Sends a new conversation from the inbox address in one call (`to`, `subject`, `html` and/or
|
|
1581
|
+
# `text`, optional `cc`, `bcc` and `attachments` as POST /emails takes them). It runs the same
|
|
1582
|
+
# rules as a reply: an inbox that may not start conversations, a first-time recipient past the
|
|
1583
|
+
# ramp, or `requires_approval: true` keeps it as a draft for a person to approve and the
|
|
1584
|
+
# answer is 202 with the Draft. Accepts an `Idempotency-Key`. An inbox on the shared domain
|
|
1585
|
+
# takes no attachments.
|
|
1586
|
+
#
|
|
1587
|
+
# Sent with an Idempotency-Key: +idempotency_key+ when given, else one made up for this call,
|
|
1588
|
+
# so that its retries never send twice.
|
|
1589
|
+
#
|
|
1590
|
+
# +POST /inboxes/{inbox_id}/emails+
|
|
1591
|
+
#
|
|
1592
|
+
# @return [Hash] the parsed JSON answer
|
|
1593
|
+
def send(inbox_id, params, idempotency_key: nil, extra_headers: nil, timeout: nil)
|
|
1594
|
+
@client.request(
|
|
1595
|
+
"POST",
|
|
1596
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/emails",
|
|
1597
|
+
body: params,
|
|
1598
|
+
idempotency_key: idempotency_key,
|
|
1599
|
+
auto_idempotency_key: true,
|
|
1600
|
+
extra_headers: extra_headers,
|
|
1601
|
+
timeout: timeout
|
|
1602
|
+
)
|
|
1603
|
+
end
|
|
1604
|
+
end
|
|
1605
|
+
|
|
1606
|
+
# Operations on inboxes agent.
|
|
1607
|
+
class InboxesAgent < Base
|
|
1608
|
+
# Get agent settings.
|
|
1609
|
+
#
|
|
1610
|
+
# Hosted-agent settings. BillionSend runs no agent of its own, so an inbox never has one.
|
|
1611
|
+
#
|
|
1612
|
+
# +GET /inboxes/{inbox_id}/agent+
|
|
1613
|
+
#
|
|
1614
|
+
# @return [Hash] the parsed JSON answer
|
|
1615
|
+
def get(inbox_id, extra_headers: nil, timeout: nil)
|
|
1616
|
+
@client.request(
|
|
1617
|
+
"GET",
|
|
1618
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/agent",
|
|
1619
|
+
extra_headers: extra_headers,
|
|
1620
|
+
timeout: timeout
|
|
1621
|
+
)
|
|
1622
|
+
end
|
|
1623
|
+
end
|
|
1624
|
+
|
|
1625
|
+
# Operations on inboxes codes.
|
|
1626
|
+
class InboxesCodes < Base
|
|
1627
|
+
# Get latest code.
|
|
1628
|
+
#
|
|
1629
|
+
# BillionSend extension: the newest code or sign-in link in delivered mail, never from held
|
|
1630
|
+
# mail or senders that failed authentication; links are never fetched. max_age counts from
|
|
1631
|
+
# delivery, so a code released from quarantine counts from its release; since skips mail
|
|
1632
|
+
# received at or before it, so a second sign-in waits for its own code. wait > 0 long-polls
|
|
1633
|
+
# until one arrives (status timeout when none did). Always 200; status none when there is
|
|
1634
|
+
# nothing.
|
|
1635
|
+
#
|
|
1636
|
+
# +GET /inboxes/{inbox_id}/codes/latest+
|
|
1637
|
+
#
|
|
1638
|
+
# @return [Hash] the parsed JSON answer
|
|
1639
|
+
def latest(
|
|
1640
|
+
inbox_id,
|
|
1641
|
+
from: nil,
|
|
1642
|
+
wait: nil,
|
|
1643
|
+
max_age: nil,
|
|
1644
|
+
since: nil,
|
|
1645
|
+
extra_headers: nil,
|
|
1646
|
+
timeout: nil
|
|
1647
|
+
)
|
|
1648
|
+
@client.request(
|
|
1649
|
+
"GET",
|
|
1650
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/codes/latest",
|
|
1651
|
+
query: { "from" => from, "wait" => wait, "max_age" => max_age, "since" => since },
|
|
1652
|
+
extra_headers: extra_headers,
|
|
1653
|
+
timeout: timeout
|
|
1654
|
+
)
|
|
1655
|
+
end
|
|
1656
|
+
end
|
|
1657
|
+
|
|
1658
|
+
# Operations on inboxes drafts.
|
|
1659
|
+
class InboxesDrafts < Base
|
|
1660
|
+
# Create a draft.
|
|
1661
|
+
#
|
|
1662
|
+
# A standalone draft, or with `thread_id` and `reply_to_email_id` a reply draft in that
|
|
1663
|
+
# thread. One unsent reply draft per email: creating another answers 200 with the existing
|
|
1664
|
+
# one. A reply draft copies no recipients; set `to` before sending. `attachments` are kept
|
|
1665
|
+
# encrypted with the draft until it is sent, rejected, expired or deleted. Nothing is sent
|
|
1666
|
+
# until POST /inboxes/{inbox_id}/drafts/{draft_id}/send, or until `send_at` (BillionSend
|
|
1667
|
+
# extension) when it is given: the draft is then sent as the caller at that time, through
|
|
1668
|
+
# every rule and limit, and must have a recipient. With `send_at`, a reply draft for an email
|
|
1669
|
+
# that already has one answers 409 instead of the existing draft.
|
|
1670
|
+
#
|
|
1671
|
+
# +POST /inboxes/{inbox_id}/drafts+
|
|
1672
|
+
#
|
|
1673
|
+
# @return [Hash] the parsed JSON answer
|
|
1674
|
+
def create(inbox_id, params = nil, extra_headers: nil, timeout: nil)
|
|
1675
|
+
@client.request(
|
|
1676
|
+
"POST",
|
|
1677
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/drafts",
|
|
1678
|
+
body: params,
|
|
1679
|
+
extra_headers: extra_headers,
|
|
1680
|
+
timeout: timeout
|
|
1681
|
+
)
|
|
1682
|
+
end
|
|
1683
|
+
|
|
1684
|
+
# List drafts.
|
|
1685
|
+
#
|
|
1686
|
+
# Unsent drafts (draft and pending_approval), most recently updated first; `after` pages
|
|
1687
|
+
# toward older ones.
|
|
1688
|
+
#
|
|
1689
|
+
# +GET /inboxes/{inbox_id}/drafts+
|
|
1690
|
+
#
|
|
1691
|
+
# @return [Hash] the parsed JSON answer
|
|
1692
|
+
def list(inbox_id, limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
1693
|
+
@client.request(
|
|
1694
|
+
"GET",
|
|
1695
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/drafts",
|
|
1696
|
+
query: { "limit" => limit, "after" => after, "before" => before },
|
|
1697
|
+
extra_headers: extra_headers,
|
|
1698
|
+
timeout: timeout
|
|
1699
|
+
)
|
|
1700
|
+
end
|
|
1701
|
+
|
|
1702
|
+
# Every item of +list+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
1703
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
1704
|
+
#
|
|
1705
|
+
# @return [Enumerator<Hash>]
|
|
1706
|
+
def list_all(inbox_id, limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
1707
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
1708
|
+
@client.request(
|
|
1709
|
+
"GET",
|
|
1710
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/drafts",
|
|
1711
|
+
query: { "limit" => limit, "after" => page_after, "before" => page_before },
|
|
1712
|
+
extra_headers: extra_headers,
|
|
1713
|
+
timeout: timeout
|
|
1714
|
+
)
|
|
1715
|
+
end
|
|
1716
|
+
end
|
|
1717
|
+
|
|
1718
|
+
# Retrieve a draft.
|
|
1719
|
+
#
|
|
1720
|
+
# One draft with its body, also after it was sent (status sent, email_id set).
|
|
1721
|
+
#
|
|
1722
|
+
# +GET /inboxes/{inbox_id}/drafts/{draft_id}+
|
|
1723
|
+
#
|
|
1724
|
+
# @return [Hash] the parsed JSON answer
|
|
1725
|
+
def get(inbox_id, draft_id, extra_headers: nil, timeout: nil)
|
|
1726
|
+
@client.request(
|
|
1727
|
+
"GET",
|
|
1728
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/drafts/#{Client.encode_path(draft_id)}",
|
|
1729
|
+
extra_headers: extra_headers,
|
|
1730
|
+
timeout: timeout
|
|
1731
|
+
)
|
|
1732
|
+
end
|
|
1733
|
+
|
|
1734
|
+
# Update a draft.
|
|
1735
|
+
#
|
|
1736
|
+
# Each given field replaces the stored one; null clears it. Setting html or text replaces the
|
|
1737
|
+
# whole body: the part left out becomes null. `attachments` replaces the whole list (null or
|
|
1738
|
+
# an empty list removes the files). A sent draft, or one that changed during the request,
|
|
1739
|
+
# answers 409. An edit by an agent sends a draft waiting for approval back to draft. `send_at`
|
|
1740
|
+
# (BillionSend extension) schedules the draft to be sent as the caller, or reschedules it, and
|
|
1741
|
+
# clears `send_error`; null cancels the schedule. A draft waiting for approval cannot be
|
|
1742
|
+
# scheduled (409). When the scheduled send goes out, the draft becomes sent; when the inbox's
|
|
1743
|
+
# rules hold it, pending_approval; when it is refused (the key revoked, the inbox deleted, a
|
|
1744
|
+
# limit reached), it stays a draft with `send_at` null, `send_error` set and an
|
|
1745
|
+
# `inbox.draft.send_failed` webhook.
|
|
1746
|
+
#
|
|
1747
|
+
# +PATCH /inboxes/{inbox_id}/drafts/{draft_id}+
|
|
1748
|
+
#
|
|
1749
|
+
# @return [Hash] the parsed JSON answer
|
|
1750
|
+
def update(inbox_id, draft_id, params = nil, extra_headers: nil, timeout: nil)
|
|
1751
|
+
@client.request(
|
|
1752
|
+
"PATCH",
|
|
1753
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/drafts/#{Client.encode_path(draft_id)}",
|
|
1754
|
+
body: params,
|
|
1755
|
+
extra_headers: extra_headers,
|
|
1756
|
+
timeout: timeout
|
|
1757
|
+
)
|
|
1758
|
+
end
|
|
1759
|
+
|
|
1760
|
+
# Delete a draft.
|
|
1761
|
+
#
|
|
1762
|
+
# Removes an unsent draft; a sent one answers 409.
|
|
1763
|
+
#
|
|
1764
|
+
# +DELETE /inboxes/{inbox_id}/drafts/{draft_id}+
|
|
1765
|
+
#
|
|
1766
|
+
# @return [Hash] the parsed JSON answer
|
|
1767
|
+
def delete(inbox_id, draft_id, extra_headers: nil, timeout: nil)
|
|
1768
|
+
@client.request(
|
|
1769
|
+
"DELETE",
|
|
1770
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/drafts/#{Client.encode_path(draft_id)}",
|
|
1771
|
+
extra_headers: extra_headers,
|
|
1772
|
+
timeout: timeout
|
|
1773
|
+
)
|
|
1774
|
+
end
|
|
1775
|
+
|
|
1776
|
+
# Send a draft.
|
|
1777
|
+
#
|
|
1778
|
+
# Sends the draft from the inbox address; the body is optional and only ever holds `headers`,
|
|
1779
|
+
# which are not supported yet (an empty value is fine), and an `Idempotency-Key` is accepted.
|
|
1780
|
+
# Answers the sent email's id. A draft waiting for approval goes out only when a person or a
|
|
1781
|
+
# team-wide full access key sends it (403 approval_required otherwise), and their send skips
|
|
1782
|
+
# the inbox's rules but never the team's limits or the shared domain's rules. An agent's send
|
|
1783
|
+
# of a draft runs the rules and may hold it (202).
|
|
1784
|
+
#
|
|
1785
|
+
# Sent with an Idempotency-Key: +idempotency_key+ when given, else one made up for this call,
|
|
1786
|
+
# so that its retries never send twice.
|
|
1787
|
+
#
|
|
1788
|
+
# +POST /inboxes/{inbox_id}/drafts/{draft_id}/send+
|
|
1789
|
+
#
|
|
1790
|
+
# @return [Hash] the parsed JSON answer
|
|
1791
|
+
def send(
|
|
1792
|
+
inbox_id,
|
|
1793
|
+
draft_id,
|
|
1794
|
+
params = nil,
|
|
1795
|
+
idempotency_key: nil,
|
|
1796
|
+
extra_headers: nil,
|
|
1797
|
+
timeout: nil
|
|
1798
|
+
)
|
|
1799
|
+
@client.request(
|
|
1800
|
+
"POST",
|
|
1801
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/drafts/#{Client.encode_path(draft_id)}/send",
|
|
1802
|
+
body: params,
|
|
1803
|
+
idempotency_key: idempotency_key,
|
|
1804
|
+
auto_idempotency_key: true,
|
|
1805
|
+
extra_headers: extra_headers,
|
|
1806
|
+
timeout: timeout
|
|
1807
|
+
)
|
|
1808
|
+
end
|
|
1809
|
+
|
|
1810
|
+
# Reject a draft.
|
|
1811
|
+
#
|
|
1812
|
+
# BillionSend extension: a person or a team-wide full access key turns down a draft waiting
|
|
1813
|
+
# for approval. It stays readable with status rejected; webhooks report it deleted.
|
|
1814
|
+
#
|
|
1815
|
+
# +POST /inboxes/{inbox_id}/drafts/{draft_id}/reject+
|
|
1816
|
+
#
|
|
1817
|
+
# @return [Hash] the parsed JSON answer
|
|
1818
|
+
def reject(inbox_id, draft_id, extra_headers: nil, timeout: nil)
|
|
1819
|
+
@client.request(
|
|
1820
|
+
"POST",
|
|
1821
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/drafts/#{Client.encode_path(draft_id)}/reject",
|
|
1822
|
+
extra_headers: extra_headers,
|
|
1823
|
+
timeout: timeout
|
|
1824
|
+
)
|
|
1825
|
+
end
|
|
1826
|
+
end
|
|
1827
|
+
|
|
1828
|
+
# Operations on inboxes events.
|
|
1829
|
+
class InboxesEvents < Base
|
|
1830
|
+
# Stream inbox events.
|
|
1831
|
+
#
|
|
1832
|
+
# BillionSend extension: a server-sent event stream of every inbox event of the team, named
|
|
1833
|
+
# like the webhook events (inbox.email.received, inbox.thread.created, email.received, …;
|
|
1834
|
+
# types narrows them), each carrying the webhook payload's data. Send the key as a Bearer
|
|
1835
|
+
# header; the stream stays open, and a client that reconnects with Last-Event-ID resumes
|
|
1836
|
+
# without losing events. Needs a team-wide key: a key held to one domain streams one inbox at
|
|
1837
|
+
# a time. An agent (an inbox-scoped key, or an MCP connection) never receives the events about
|
|
1838
|
+
# held mail (inbox.email.quarantined), replay included, and naming them in types is a 403. A
|
|
1839
|
+
# stream closes within a few seconds once its key is revoked, its person leaves the team or
|
|
1840
|
+
# its inbox is gone; it is also closed every ten minutes or so, and the client reconnects with
|
|
1841
|
+
# Last-Event-ID. Streams are capped per key and per team on each API process (429
|
|
1842
|
+
# too_many_streams).
|
|
1843
|
+
#
|
|
1844
|
+
# +GET /inboxes/events+
|
|
1845
|
+
#
|
|
1846
|
+
# @return [BillionSend::EventStream]
|
|
1847
|
+
def stream(
|
|
1848
|
+
types: nil,
|
|
1849
|
+
last_event_id: nil,
|
|
1850
|
+
max_reconnects: 5,
|
|
1851
|
+
extra_headers: nil,
|
|
1852
|
+
timeout: nil
|
|
1853
|
+
)
|
|
1854
|
+
@client.stream_events(
|
|
1855
|
+
"/inboxes/events",
|
|
1856
|
+
query: { "types" => types },
|
|
1857
|
+
last_event_id: last_event_id,
|
|
1858
|
+
max_reconnects: max_reconnects,
|
|
1859
|
+
extra_headers: extra_headers,
|
|
1860
|
+
timeout: timeout
|
|
1861
|
+
)
|
|
1862
|
+
end
|
|
1863
|
+
|
|
1864
|
+
# Stream one inbox's events.
|
|
1865
|
+
#
|
|
1866
|
+
# BillionSend extension: the event stream of one inbox, as GET /inboxes/events, ending when
|
|
1867
|
+
# the inbox is deleted or expires. An inbox-scoped key may stream its own inbox, without the
|
|
1868
|
+
# events about held mail.
|
|
1869
|
+
#
|
|
1870
|
+
# +GET /inboxes/{inbox_id}/events+
|
|
1871
|
+
#
|
|
1872
|
+
# @return [BillionSend::EventStream]
|
|
1873
|
+
def stream_inbox(
|
|
1874
|
+
inbox_id,
|
|
1875
|
+
types: nil,
|
|
1876
|
+
last_event_id: nil,
|
|
1877
|
+
max_reconnects: 5,
|
|
1878
|
+
extra_headers: nil,
|
|
1879
|
+
timeout: nil
|
|
1880
|
+
)
|
|
1881
|
+
@client.stream_events(
|
|
1882
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/events",
|
|
1883
|
+
query: { "types" => types },
|
|
1884
|
+
last_event_id: last_event_id,
|
|
1885
|
+
max_reconnects: max_reconnects,
|
|
1886
|
+
extra_headers: extra_headers,
|
|
1887
|
+
timeout: timeout
|
|
1888
|
+
)
|
|
1889
|
+
end
|
|
1890
|
+
end
|
|
1891
|
+
|
|
1892
|
+
# Operations on inboxes labels.
|
|
1893
|
+
class InboxesLabels < Base
|
|
1894
|
+
# List an inbox's labels.
|
|
1895
|
+
#
|
|
1896
|
+
# Oldest first, every label (at most 100), unpaged.
|
|
1897
|
+
#
|
|
1898
|
+
# +GET /inboxes/{inbox_id}/labels+
|
|
1899
|
+
#
|
|
1900
|
+
# @return [Hash] the parsed JSON answer
|
|
1901
|
+
def list(inbox_id, extra_headers: nil, timeout: nil)
|
|
1902
|
+
@client.request(
|
|
1903
|
+
"GET",
|
|
1904
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/labels",
|
|
1905
|
+
extra_headers: extra_headers,
|
|
1906
|
+
timeout: timeout
|
|
1907
|
+
)
|
|
1908
|
+
end
|
|
1909
|
+
|
|
1910
|
+
# Create a label.
|
|
1911
|
+
#
|
|
1912
|
+
# A named, colored tag of one inbox: at most 100, names unique regardless of case. A color is
|
|
1913
|
+
# picked when omitted.
|
|
1914
|
+
#
|
|
1915
|
+
# +POST /inboxes/{inbox_id}/labels+
|
|
1916
|
+
#
|
|
1917
|
+
# @return [Hash] the parsed JSON answer
|
|
1918
|
+
def create(inbox_id, params, extra_headers: nil, timeout: nil)
|
|
1919
|
+
@client.request(
|
|
1920
|
+
"POST",
|
|
1921
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/labels",
|
|
1922
|
+
body: params,
|
|
1923
|
+
extra_headers: extra_headers,
|
|
1924
|
+
timeout: timeout
|
|
1925
|
+
)
|
|
1926
|
+
end
|
|
1927
|
+
|
|
1928
|
+
# Update a label.
|
|
1929
|
+
#
|
|
1930
|
+
# +PATCH /inboxes/{inbox_id}/labels/{label_id}+
|
|
1931
|
+
#
|
|
1932
|
+
# @return [Hash] the parsed JSON answer
|
|
1933
|
+
def update(inbox_id, label_id, params = nil, extra_headers: nil, timeout: nil)
|
|
1934
|
+
@client.request(
|
|
1935
|
+
"PATCH",
|
|
1936
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/labels/#{Client.encode_path(label_id)}",
|
|
1937
|
+
body: params,
|
|
1938
|
+
extra_headers: extra_headers,
|
|
1939
|
+
timeout: timeout
|
|
1940
|
+
)
|
|
1941
|
+
end
|
|
1942
|
+
|
|
1943
|
+
# Delete a label.
|
|
1944
|
+
#
|
|
1945
|
+
# Also takes it off every thread, with no per-thread event.
|
|
1946
|
+
#
|
|
1947
|
+
# +DELETE /inboxes/{inbox_id}/labels/{label_id}+
|
|
1948
|
+
#
|
|
1949
|
+
# @return [Hash] the parsed JSON answer
|
|
1950
|
+
def delete(inbox_id, label_id, extra_headers: nil, timeout: nil)
|
|
1951
|
+
@client.request(
|
|
1952
|
+
"DELETE",
|
|
1953
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/labels/#{Client.encode_path(label_id)}",
|
|
1954
|
+
extra_headers: extra_headers,
|
|
1955
|
+
timeout: timeout
|
|
1956
|
+
)
|
|
1957
|
+
end
|
|
1958
|
+
end
|
|
1959
|
+
|
|
1960
|
+
# Operations on inboxes quarantine.
|
|
1961
|
+
class InboxesQuarantine < Base
|
|
1962
|
+
# List quarantine.
|
|
1963
|
+
#
|
|
1964
|
+
# BillionSend extension: the inbox's held messages, newest first, metadata only. Not for
|
|
1965
|
+
# inbox-scoped keys.
|
|
1966
|
+
#
|
|
1967
|
+
# +GET /inboxes/{inbox_id}/quarantine+
|
|
1968
|
+
#
|
|
1969
|
+
# @return [Hash] the parsed JSON answer
|
|
1970
|
+
def list(inbox_id, limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
1971
|
+
@client.request(
|
|
1972
|
+
"GET",
|
|
1973
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/quarantine",
|
|
1974
|
+
query: { "limit" => limit, "after" => after, "before" => before },
|
|
1975
|
+
extra_headers: extra_headers,
|
|
1976
|
+
timeout: timeout
|
|
1977
|
+
)
|
|
1978
|
+
end
|
|
1979
|
+
|
|
1980
|
+
# Every item of +list+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
1981
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
1982
|
+
#
|
|
1983
|
+
# @return [Enumerator<Hash>]
|
|
1984
|
+
def list_all(inbox_id, limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
1985
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
1986
|
+
@client.request(
|
|
1987
|
+
"GET",
|
|
1988
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/quarantine",
|
|
1989
|
+
query: { "limit" => limit, "after" => page_after, "before" => page_before },
|
|
1990
|
+
extra_headers: extra_headers,
|
|
1991
|
+
timeout: timeout
|
|
1992
|
+
)
|
|
1993
|
+
end
|
|
1994
|
+
end
|
|
1995
|
+
|
|
1996
|
+
# Release an email.
|
|
1997
|
+
#
|
|
1998
|
+
# BillionSend extension: delivers a held message to the inbox. Mail held before screening ran
|
|
1999
|
+
# (not_allowlisted, unauthenticated_sender, failed_auth) is screened first when screening can
|
|
2000
|
+
# run, and stays held when the judge scores it at 80 or more (409 held_by_screening);
|
|
2001
|
+
# otherwise it is never screened again. trust_sender also adds the sender to the allowlist,
|
|
2002
|
+
# only for mail held as not_allowlisted from a verified (external) sender. MCP connections
|
|
2003
|
+
# release for an agent: never mail held for prompt injection, phishing, a virus or failed
|
|
2004
|
+
# authentication (403 forbidden), and any other hold only once screening, run at every MCP
|
|
2005
|
+
# release, scores it under 80; while screening can't run, nothing is released (503
|
|
2006
|
+
# screening_unavailable). Not for inbox-scoped keys.
|
|
2007
|
+
#
|
|
2008
|
+
# +POST /inboxes/{inbox_id}/quarantine/{email_id}/release+
|
|
2009
|
+
#
|
|
2010
|
+
# @return [Hash] the parsed JSON answer
|
|
2011
|
+
def release(inbox_id, email_id, params = nil, extra_headers: nil, timeout: nil)
|
|
2012
|
+
@client.request(
|
|
2013
|
+
"POST",
|
|
2014
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/quarantine/#{Client.encode_path(email_id)}/release",
|
|
2015
|
+
body: params,
|
|
2016
|
+
extra_headers: extra_headers,
|
|
2017
|
+
timeout: timeout
|
|
2018
|
+
)
|
|
2019
|
+
end
|
|
2020
|
+
end
|
|
2021
|
+
|
|
2022
|
+
# Operations on inboxes safety.
|
|
2023
|
+
class InboxesSafety < Base
|
|
2024
|
+
# Get safety rules.
|
|
2025
|
+
#
|
|
2026
|
+
# BillionSend extension: who may write in, screening, code extraction, what the inbox may send
|
|
2027
|
+
# and where it forwards.
|
|
2028
|
+
#
|
|
2029
|
+
# +GET /inboxes/{inbox_id}/safety+
|
|
2030
|
+
#
|
|
2031
|
+
# @return [Hash] the parsed JSON answer
|
|
2032
|
+
def get(inbox_id, extra_headers: nil, timeout: nil)
|
|
2033
|
+
@client.request(
|
|
2034
|
+
"GET",
|
|
2035
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/safety",
|
|
2036
|
+
extra_headers: extra_headers,
|
|
2037
|
+
timeout: timeout
|
|
2038
|
+
)
|
|
2039
|
+
end
|
|
2040
|
+
|
|
2041
|
+
# Update safety rules.
|
|
2042
|
+
#
|
|
2043
|
+
# BillionSend extension: any subset of the rules, merged over the stored ones. Needs the
|
|
2044
|
+
# owner, admin or developer role, or a full access team key; inbox-scoped keys and MCP can't
|
|
2045
|
+
# change them.
|
|
2046
|
+
#
|
|
2047
|
+
# +PATCH /inboxes/{inbox_id}/safety+
|
|
2048
|
+
#
|
|
2049
|
+
# @return [Hash] the parsed JSON answer
|
|
2050
|
+
def update(inbox_id, params = nil, extra_headers: nil, timeout: nil)
|
|
2051
|
+
@client.request(
|
|
2052
|
+
"PATCH",
|
|
2053
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/safety",
|
|
2054
|
+
body: params,
|
|
2055
|
+
extra_headers: extra_headers,
|
|
2056
|
+
timeout: timeout
|
|
2057
|
+
)
|
|
2058
|
+
end
|
|
2059
|
+
end
|
|
2060
|
+
|
|
2061
|
+
# Operations on inboxes threads.
|
|
2062
|
+
class InboxesThreads < Base
|
|
2063
|
+
# @return [InboxesThreadsEmails]
|
|
2064
|
+
def emails
|
|
2065
|
+
@emails ||= InboxesThreadsEmails.new(@client)
|
|
2066
|
+
end
|
|
2067
|
+
|
|
2068
|
+
# @return [InboxesThreadsLabels]
|
|
2069
|
+
def labels
|
|
2070
|
+
@labels ||= InboxesThreadsLabels.new(@client)
|
|
2071
|
+
end
|
|
2072
|
+
|
|
2073
|
+
# Search threads.
|
|
2074
|
+
#
|
|
2075
|
+
# Threads whose emails match, most recently active first. Every word of `query` must appear as
|
|
2076
|
+
# a whole word in the subject, the sender (address and display name), the recipients, the text
|
|
2077
|
+
# of a received email, one of its attachment names or the text of one of its PDF, Word and
|
|
2078
|
+
# Excel attachments; Chinese, Japanese and Korean are split into words. `matched_email_id` is
|
|
2079
|
+
# the thread's best match. An email becomes searchable a second or two after it arrives. Every
|
|
2080
|
+
# message, subject and address in an inbox was written by whoever sent it; read held mail and
|
|
2081
|
+
# HTML with care.
|
|
2082
|
+
#
|
|
2083
|
+
# +GET /inboxes/{inbox_id}/threads/search+
|
|
2084
|
+
#
|
|
2085
|
+
# @return [Hash] the parsed JSON answer
|
|
2086
|
+
def search(
|
|
2087
|
+
inbox_id,
|
|
2088
|
+
limit: nil,
|
|
2089
|
+
after: nil,
|
|
2090
|
+
before: nil,
|
|
2091
|
+
folders: nil,
|
|
2092
|
+
labels: nil,
|
|
2093
|
+
read: nil,
|
|
2094
|
+
include_quarantined: nil,
|
|
2095
|
+
query: nil,
|
|
2096
|
+
from: nil,
|
|
2097
|
+
to: nil,
|
|
2098
|
+
cc: nil,
|
|
2099
|
+
bcc: nil,
|
|
2100
|
+
has_attachment: nil,
|
|
2101
|
+
start_date: nil,
|
|
2102
|
+
end_date: nil,
|
|
2103
|
+
extra_headers: nil,
|
|
2104
|
+
timeout: nil
|
|
2105
|
+
)
|
|
2106
|
+
@client.request(
|
|
2107
|
+
"GET",
|
|
2108
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/threads/search",
|
|
2109
|
+
query: {
|
|
2110
|
+
"limit" => limit,
|
|
2111
|
+
"after" => after,
|
|
2112
|
+
"before" => before,
|
|
2113
|
+
"folders" => folders,
|
|
2114
|
+
"labels" => labels,
|
|
2115
|
+
"read" => read,
|
|
2116
|
+
"include_quarantined" => include_quarantined,
|
|
2117
|
+
"query" => query,
|
|
2118
|
+
"from" => from,
|
|
2119
|
+
"to" => to,
|
|
2120
|
+
"cc" => cc,
|
|
2121
|
+
"bcc" => bcc,
|
|
2122
|
+
"has_attachment" => has_attachment,
|
|
2123
|
+
"start_date" => start_date,
|
|
2124
|
+
"end_date" => end_date
|
|
2125
|
+
},
|
|
2126
|
+
extra_headers: extra_headers,
|
|
2127
|
+
timeout: timeout
|
|
2128
|
+
)
|
|
2129
|
+
end
|
|
2130
|
+
|
|
2131
|
+
# Every item of +search+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
2132
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
2133
|
+
#
|
|
2134
|
+
# @return [Enumerator<Hash>]
|
|
2135
|
+
def search_all(
|
|
2136
|
+
inbox_id,
|
|
2137
|
+
limit: nil,
|
|
2138
|
+
after: nil,
|
|
2139
|
+
before: nil,
|
|
2140
|
+
folders: nil,
|
|
2141
|
+
labels: nil,
|
|
2142
|
+
read: nil,
|
|
2143
|
+
include_quarantined: nil,
|
|
2144
|
+
query: nil,
|
|
2145
|
+
from: nil,
|
|
2146
|
+
to: nil,
|
|
2147
|
+
cc: nil,
|
|
2148
|
+
bcc: nil,
|
|
2149
|
+
has_attachment: nil,
|
|
2150
|
+
start_date: nil,
|
|
2151
|
+
end_date: nil,
|
|
2152
|
+
extra_headers: nil,
|
|
2153
|
+
timeout: nil
|
|
2154
|
+
)
|
|
2155
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
2156
|
+
@client.request(
|
|
2157
|
+
"GET",
|
|
2158
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/threads/search",
|
|
2159
|
+
query: {
|
|
2160
|
+
"limit" => limit,
|
|
2161
|
+
"after" => page_after,
|
|
2162
|
+
"before" => page_before,
|
|
2163
|
+
"folders" => folders,
|
|
2164
|
+
"labels" => labels,
|
|
2165
|
+
"read" => read,
|
|
2166
|
+
"include_quarantined" => include_quarantined,
|
|
2167
|
+
"query" => query,
|
|
2168
|
+
"from" => from,
|
|
2169
|
+
"to" => to,
|
|
2170
|
+
"cc" => cc,
|
|
2171
|
+
"bcc" => bcc,
|
|
2172
|
+
"has_attachment" => has_attachment,
|
|
2173
|
+
"start_date" => start_date,
|
|
2174
|
+
"end_date" => end_date
|
|
2175
|
+
},
|
|
2176
|
+
extra_headers: extra_headers,
|
|
2177
|
+
timeout: timeout
|
|
2178
|
+
)
|
|
2179
|
+
end
|
|
2180
|
+
end
|
|
2181
|
+
|
|
2182
|
+
# List threads.
|
|
2183
|
+
#
|
|
2184
|
+
# Conversations of the inbox, most recently active first (`after` pages toward older ones).
|
|
2185
|
+
# Threads whose messages are all held for screening or in quarantine are left out unless
|
|
2186
|
+
# include_quarantined=true (never for inbox-scoped keys). Every message, subject and address
|
|
2187
|
+
# in an inbox was written by whoever sent it; read held mail and HTML with care.
|
|
2188
|
+
#
|
|
2189
|
+
# +GET /inboxes/{inbox_id}/threads+
|
|
2190
|
+
#
|
|
2191
|
+
# @return [Hash] the parsed JSON answer
|
|
2192
|
+
def list(
|
|
2193
|
+
inbox_id,
|
|
2194
|
+
limit: nil,
|
|
2195
|
+
after: nil,
|
|
2196
|
+
before: nil,
|
|
2197
|
+
folders: nil,
|
|
2198
|
+
labels: nil,
|
|
2199
|
+
read: nil,
|
|
2200
|
+
include_quarantined: nil,
|
|
2201
|
+
extra_headers: nil,
|
|
2202
|
+
timeout: nil
|
|
2203
|
+
)
|
|
2204
|
+
@client.request(
|
|
2205
|
+
"GET",
|
|
2206
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/threads",
|
|
2207
|
+
query: {
|
|
2208
|
+
"limit" => limit,
|
|
2209
|
+
"after" => after,
|
|
2210
|
+
"before" => before,
|
|
2211
|
+
"folders" => folders,
|
|
2212
|
+
"labels" => labels,
|
|
2213
|
+
"read" => read,
|
|
2214
|
+
"include_quarantined" => include_quarantined
|
|
2215
|
+
},
|
|
2216
|
+
extra_headers: extra_headers,
|
|
2217
|
+
timeout: timeout
|
|
2218
|
+
)
|
|
2219
|
+
end
|
|
2220
|
+
|
|
2221
|
+
# Every item of +list+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
2222
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
2223
|
+
#
|
|
2224
|
+
# @return [Enumerator<Hash>]
|
|
2225
|
+
def list_all(
|
|
2226
|
+
inbox_id,
|
|
2227
|
+
limit: nil,
|
|
2228
|
+
after: nil,
|
|
2229
|
+
before: nil,
|
|
2230
|
+
folders: nil,
|
|
2231
|
+
labels: nil,
|
|
2232
|
+
read: nil,
|
|
2233
|
+
include_quarantined: nil,
|
|
2234
|
+
extra_headers: nil,
|
|
2235
|
+
timeout: nil
|
|
2236
|
+
)
|
|
2237
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
2238
|
+
@client.request(
|
|
2239
|
+
"GET",
|
|
2240
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/threads",
|
|
2241
|
+
query: {
|
|
2242
|
+
"limit" => limit,
|
|
2243
|
+
"after" => page_after,
|
|
2244
|
+
"before" => page_before,
|
|
2245
|
+
"folders" => folders,
|
|
2246
|
+
"labels" => labels,
|
|
2247
|
+
"read" => read,
|
|
2248
|
+
"include_quarantined" => include_quarantined
|
|
2249
|
+
},
|
|
2250
|
+
extra_headers: extra_headers,
|
|
2251
|
+
timeout: timeout
|
|
2252
|
+
)
|
|
2253
|
+
end
|
|
2254
|
+
end
|
|
2255
|
+
|
|
2256
|
+
# Retrieve a thread.
|
|
2257
|
+
#
|
|
2258
|
+
# The thread's subject, folder, labels and read state; its emails are listed apart.
|
|
2259
|
+
#
|
|
2260
|
+
# +GET /inboxes/{inbox_id}/threads/{thread_id}+
|
|
2261
|
+
#
|
|
2262
|
+
# @return [Hash] the parsed JSON answer
|
|
2263
|
+
def get(inbox_id, thread_id, extra_headers: nil, timeout: nil)
|
|
2264
|
+
@client.request(
|
|
2265
|
+
"GET",
|
|
2266
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/threads/#{Client.encode_path(thread_id)}",
|
|
2267
|
+
extra_headers: extra_headers,
|
|
2268
|
+
timeout: timeout
|
|
2269
|
+
)
|
|
2270
|
+
end
|
|
2271
|
+
|
|
2272
|
+
# Update a thread.
|
|
2273
|
+
#
|
|
2274
|
+
# Mark every message read or unread, or move it to inbox, archive, spam or trash (moving out
|
|
2275
|
+
# of trash restores it). Labels have their own routes: POST, PUT and DELETE
|
|
2276
|
+
# /inboxes/{inbox_id}/threads/{thread_id}/labels.
|
|
2277
|
+
#
|
|
2278
|
+
# +PATCH /inboxes/{inbox_id}/threads/{thread_id}+
|
|
2279
|
+
#
|
|
2280
|
+
# @return [Hash] the parsed JSON answer
|
|
2281
|
+
def update(inbox_id, thread_id, params = nil, extra_headers: nil, timeout: nil)
|
|
2282
|
+
@client.request(
|
|
2283
|
+
"PATCH",
|
|
2284
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/threads/#{Client.encode_path(thread_id)}",
|
|
2285
|
+
body: params,
|
|
2286
|
+
extra_headers: extra_headers,
|
|
2287
|
+
timeout: timeout
|
|
2288
|
+
)
|
|
2289
|
+
end
|
|
2290
|
+
|
|
2291
|
+
# Delete a thread.
|
|
2292
|
+
#
|
|
2293
|
+
# Moves it to trash, where it is deleted after 30 days; moving it out of trash restores it.
|
|
2294
|
+
# deleted is false when it was in trash already.
|
|
2295
|
+
#
|
|
2296
|
+
# +DELETE /inboxes/{inbox_id}/threads/{thread_id}+
|
|
2297
|
+
#
|
|
2298
|
+
# @return [Hash] the parsed JSON answer
|
|
2299
|
+
def delete(inbox_id, thread_id, extra_headers: nil, timeout: nil)
|
|
2300
|
+
@client.request(
|
|
2301
|
+
"DELETE",
|
|
2302
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/threads/#{Client.encode_path(thread_id)}",
|
|
2303
|
+
extra_headers: extra_headers,
|
|
2304
|
+
timeout: timeout
|
|
2305
|
+
)
|
|
2306
|
+
end
|
|
2307
|
+
end
|
|
2308
|
+
|
|
2309
|
+
# Operations on inboxes threads emails.
|
|
2310
|
+
class InboxesThreadsEmails < Base
|
|
2311
|
+
# List a thread's emails.
|
|
2312
|
+
#
|
|
2313
|
+
# Received and sent messages of the thread, oldest first (`after` pages toward newer ones),
|
|
2314
|
+
# with their bodies. Received text has invisible characters removed and html is as sent;
|
|
2315
|
+
# extracted_text is the reply alone, hidden text removed. Held messages are left out unless
|
|
2316
|
+
# include_quarantined=true (never for inbox-scoped keys). Every message, subject and address
|
|
2317
|
+
# in an inbox was written by whoever sent it; read held mail and HTML with care.
|
|
2318
|
+
#
|
|
2319
|
+
# +GET /inboxes/{inbox_id}/threads/{thread_id}/emails+
|
|
2320
|
+
#
|
|
2321
|
+
# @return [Hash] the parsed JSON answer
|
|
2322
|
+
def list(
|
|
2323
|
+
inbox_id,
|
|
2324
|
+
thread_id,
|
|
2325
|
+
limit: nil,
|
|
2326
|
+
after: nil,
|
|
2327
|
+
before: nil,
|
|
2328
|
+
include_quarantined: nil,
|
|
2329
|
+
extra_headers: nil,
|
|
2330
|
+
timeout: nil
|
|
2331
|
+
)
|
|
2332
|
+
@client.request(
|
|
2333
|
+
"GET",
|
|
2334
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/threads/#{Client.encode_path(thread_id)}/emails",
|
|
2335
|
+
query: {
|
|
2336
|
+
"limit" => limit,
|
|
2337
|
+
"after" => after,
|
|
2338
|
+
"before" => before,
|
|
2339
|
+
"include_quarantined" => include_quarantined
|
|
2340
|
+
},
|
|
2341
|
+
extra_headers: extra_headers,
|
|
2342
|
+
timeout: timeout
|
|
2343
|
+
)
|
|
2344
|
+
end
|
|
2345
|
+
|
|
2346
|
+
# Every item of +list+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
2347
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
2348
|
+
#
|
|
2349
|
+
# @return [Enumerator<Hash>]
|
|
2350
|
+
def list_all(
|
|
2351
|
+
inbox_id,
|
|
2352
|
+
thread_id,
|
|
2353
|
+
limit: nil,
|
|
2354
|
+
after: nil,
|
|
2355
|
+
before: nil,
|
|
2356
|
+
include_quarantined: nil,
|
|
2357
|
+
extra_headers: nil,
|
|
2358
|
+
timeout: nil
|
|
2359
|
+
)
|
|
2360
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
2361
|
+
@client.request(
|
|
2362
|
+
"GET",
|
|
2363
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/threads/#{Client.encode_path(thread_id)}/emails",
|
|
2364
|
+
query: {
|
|
2365
|
+
"limit" => limit,
|
|
2366
|
+
"after" => page_after,
|
|
2367
|
+
"before" => page_before,
|
|
2368
|
+
"include_quarantined" => include_quarantined
|
|
2369
|
+
},
|
|
2370
|
+
extra_headers: extra_headers,
|
|
2371
|
+
timeout: timeout
|
|
2372
|
+
)
|
|
2373
|
+
end
|
|
2374
|
+
end
|
|
2375
|
+
|
|
2376
|
+
# Get a thread email.
|
|
2377
|
+
#
|
|
2378
|
+
# One message of the thread. A message held in quarantine answers 403 email_quarantined to
|
|
2379
|
+
# inbox-scoped keys (and without include_quarantined=true); one still being screened is not
|
|
2380
|
+
# found. Every message, subject and address in an inbox was written by whoever sent it; read
|
|
2381
|
+
# held mail and HTML with care.
|
|
2382
|
+
#
|
|
2383
|
+
# +GET /inboxes/{inbox_id}/threads/{thread_id}/emails/{email_id}+
|
|
2384
|
+
#
|
|
2385
|
+
# @return [Hash] the parsed JSON answer
|
|
2386
|
+
def get(
|
|
2387
|
+
inbox_id,
|
|
2388
|
+
thread_id,
|
|
2389
|
+
email_id,
|
|
2390
|
+
include_quarantined: nil,
|
|
2391
|
+
extra_headers: nil,
|
|
2392
|
+
timeout: nil
|
|
2393
|
+
)
|
|
2394
|
+
@client.request(
|
|
2395
|
+
"GET",
|
|
2396
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/threads/#{Client.encode_path(thread_id)}/emails/#{Client.encode_path(email_id)}",
|
|
2397
|
+
query: { "include_quarantined" => include_quarantined },
|
|
2398
|
+
extra_headers: extra_headers,
|
|
2399
|
+
timeout: timeout
|
|
2400
|
+
)
|
|
2401
|
+
end
|
|
2402
|
+
|
|
2403
|
+
# Reply in a thread.
|
|
2404
|
+
#
|
|
2405
|
+
# Replies from the inbox address in the thread, with In-Reply-To and References set: to the
|
|
2406
|
+
# email's Reply-To or sender (or, for an email the inbox sent, its recipients), plus everyone
|
|
2407
|
+
# else on it with `reply_all`. Bcc is never copied. Takes `attachments` as POST /emails does.
|
|
2408
|
+
# Accepts an `Idempotency-Key`. When the inbox's rules hold the reply (or `requires_approval`
|
|
2409
|
+
# is true) it is kept as a draft for a person to approve and the answer is 202 with the Draft.
|
|
2410
|
+
#
|
|
2411
|
+
# Sent with an Idempotency-Key: +idempotency_key+ when given, else one made up for this call,
|
|
2412
|
+
# so that its retries never send twice.
|
|
2413
|
+
#
|
|
2414
|
+
# +POST /inboxes/{inbox_id}/threads/{thread_id}/emails/{email_id}/reply+
|
|
2415
|
+
#
|
|
2416
|
+
# @return [Hash] the parsed JSON answer
|
|
2417
|
+
def reply(
|
|
2418
|
+
inbox_id,
|
|
2419
|
+
thread_id,
|
|
2420
|
+
email_id,
|
|
2421
|
+
params = nil,
|
|
2422
|
+
idempotency_key: nil,
|
|
2423
|
+
extra_headers: nil,
|
|
2424
|
+
timeout: nil
|
|
2425
|
+
)
|
|
2426
|
+
@client.request(
|
|
2427
|
+
"POST",
|
|
2428
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/threads/#{Client.encode_path(thread_id)}/emails/#{Client.encode_path(email_id)}/reply",
|
|
2429
|
+
body: params,
|
|
2430
|
+
idempotency_key: idempotency_key,
|
|
2431
|
+
auto_idempotency_key: true,
|
|
2432
|
+
extra_headers: extra_headers,
|
|
2433
|
+
timeout: timeout
|
|
2434
|
+
)
|
|
2435
|
+
end
|
|
2436
|
+
|
|
2437
|
+
# Forward a thread email.
|
|
2438
|
+
#
|
|
2439
|
+
# Forwards the email from the inbox address, quoted under "---------- Forwarded message
|
|
2440
|
+
# ---------" with its From, Date, Subject and To, after an optional note. Its attachments go
|
|
2441
|
+
# along, with any `attachments` you add, within 10 MiB in all. An email that carries malware
|
|
2442
|
+
# is never forwarded. Accepts an `Idempotency-Key`; a forward the inbox's rules hold answers
|
|
2443
|
+
# 202 with the Draft.
|
|
2444
|
+
#
|
|
2445
|
+
# Sent with an Idempotency-Key: +idempotency_key+ when given, else one made up for this call,
|
|
2446
|
+
# so that its retries never send twice.
|
|
2447
|
+
#
|
|
2448
|
+
# +POST /inboxes/{inbox_id}/threads/{thread_id}/emails/{email_id}/forward+
|
|
2449
|
+
#
|
|
2450
|
+
# @return [Hash] the parsed JSON answer
|
|
2451
|
+
def forward(
|
|
2452
|
+
inbox_id,
|
|
2453
|
+
thread_id,
|
|
2454
|
+
email_id,
|
|
2455
|
+
params,
|
|
2456
|
+
idempotency_key: nil,
|
|
2457
|
+
extra_headers: nil,
|
|
2458
|
+
timeout: nil
|
|
2459
|
+
)
|
|
2460
|
+
@client.request(
|
|
2461
|
+
"POST",
|
|
2462
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/threads/#{Client.encode_path(thread_id)}/emails/#{Client.encode_path(email_id)}/forward",
|
|
2463
|
+
body: params,
|
|
2464
|
+
idempotency_key: idempotency_key,
|
|
2465
|
+
auto_idempotency_key: true,
|
|
2466
|
+
extra_headers: extra_headers,
|
|
2467
|
+
timeout: timeout
|
|
2468
|
+
)
|
|
2469
|
+
end
|
|
2470
|
+
end
|
|
2471
|
+
|
|
2472
|
+
# Operations on inboxes threads labels.
|
|
2473
|
+
class InboxesThreadsLabels < Base
|
|
2474
|
+
# Add labels to a thread.
|
|
2475
|
+
#
|
|
2476
|
+
# Puts 1-10 of the inbox's labels on the thread and keeps the ones it has. If any label is
|
|
2477
|
+
# unknown, nothing changes (404). Answers every label on the thread afterwards; one
|
|
2478
|
+
# inbox.thread.labels.updated event reports the request.
|
|
2479
|
+
#
|
|
2480
|
+
# +POST /inboxes/{inbox_id}/threads/{thread_id}/labels+
|
|
2481
|
+
#
|
|
2482
|
+
# @return [Hash] the parsed JSON answer
|
|
2483
|
+
def add(inbox_id, thread_id, params, extra_headers: nil, timeout: nil)
|
|
2484
|
+
@client.request(
|
|
2485
|
+
"POST",
|
|
2486
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/threads/#{Client.encode_path(thread_id)}/labels",
|
|
2487
|
+
body: params,
|
|
2488
|
+
extra_headers: extra_headers,
|
|
2489
|
+
timeout: timeout
|
|
2490
|
+
)
|
|
2491
|
+
end
|
|
2492
|
+
|
|
2493
|
+
# Set a thread's labels.
|
|
2494
|
+
#
|
|
2495
|
+
# Replaces the thread's labels with exactly these (up to 100; [] takes them all off). The
|
|
2496
|
+
# labels stay in the inbox. If any label is unknown, nothing changes (404). Answers every
|
|
2497
|
+
# label on the thread afterwards.
|
|
2498
|
+
#
|
|
2499
|
+
# +PUT /inboxes/{inbox_id}/threads/{thread_id}/labels+
|
|
2500
|
+
#
|
|
2501
|
+
# @return [Hash] the parsed JSON answer
|
|
2502
|
+
def set(inbox_id, thread_id, params, extra_headers: nil, timeout: nil)
|
|
2503
|
+
@client.request(
|
|
2504
|
+
"PUT",
|
|
2505
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/threads/#{Client.encode_path(thread_id)}/labels",
|
|
2506
|
+
body: params,
|
|
2507
|
+
extra_headers: extra_headers,
|
|
2508
|
+
timeout: timeout
|
|
2509
|
+
)
|
|
2510
|
+
end
|
|
2511
|
+
|
|
2512
|
+
# Remove a thread label.
|
|
2513
|
+
#
|
|
2514
|
+
# Takes one label off the thread; the label stays in the inbox and on its other threads. A
|
|
2515
|
+
# label that is not on the thread changes nothing. Answers every label on the thread
|
|
2516
|
+
# afterwards.
|
|
2517
|
+
#
|
|
2518
|
+
# +DELETE /inboxes/{inbox_id}/threads/{thread_id}/labels/{label_id}+
|
|
2519
|
+
#
|
|
2520
|
+
# @return [Hash] the parsed JSON answer
|
|
2521
|
+
def remove(inbox_id, thread_id, label_id, extra_headers: nil, timeout: nil)
|
|
2522
|
+
@client.request(
|
|
2523
|
+
"DELETE",
|
|
2524
|
+
"/inboxes/#{Client.encode_path(inbox_id)}/threads/#{Client.encode_path(thread_id)}/labels/#{Client.encode_path(label_id)}",
|
|
2525
|
+
extra_headers: extra_headers,
|
|
2526
|
+
timeout: timeout
|
|
2527
|
+
)
|
|
2528
|
+
end
|
|
2529
|
+
end
|
|
2530
|
+
|
|
2531
|
+
# Operations on segments.
|
|
2532
|
+
class Segments < Base
|
|
2533
|
+
# @return [SegmentsContacts]
|
|
2534
|
+
def contacts
|
|
2535
|
+
@contacts ||= SegmentsContacts.new(@client)
|
|
2536
|
+
end
|
|
2537
|
+
|
|
2538
|
+
# Create a segment.
|
|
2539
|
+
#
|
|
2540
|
+
# +POST /segments+
|
|
2541
|
+
#
|
|
2542
|
+
# @return [Hash] the parsed JSON answer
|
|
2543
|
+
def create(params, extra_headers: nil, timeout: nil)
|
|
2544
|
+
@client.request(
|
|
2545
|
+
"POST",
|
|
2546
|
+
"/segments",
|
|
2547
|
+
body: params,
|
|
2548
|
+
extra_headers: extra_headers,
|
|
2549
|
+
timeout: timeout
|
|
2550
|
+
)
|
|
2551
|
+
end
|
|
2552
|
+
|
|
2553
|
+
# List segments.
|
|
2554
|
+
#
|
|
2555
|
+
# Newest first, with cursor pagination: `after` takes the last id of a page and pages toward
|
|
2556
|
+
# older items, `before` takes the first id and pages back toward newer ones.
|
|
2557
|
+
#
|
|
2558
|
+
# +GET /segments+
|
|
2559
|
+
#
|
|
2560
|
+
# @return [Hash] the parsed JSON answer
|
|
2561
|
+
def list(limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
2562
|
+
@client.request(
|
|
2563
|
+
"GET",
|
|
2564
|
+
"/segments",
|
|
2565
|
+
query: { "limit" => limit, "after" => after, "before" => before },
|
|
2566
|
+
extra_headers: extra_headers,
|
|
2567
|
+
timeout: timeout
|
|
2568
|
+
)
|
|
2569
|
+
end
|
|
2570
|
+
|
|
2571
|
+
# Every item of +list+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
2572
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
2573
|
+
#
|
|
2574
|
+
# @return [Enumerator<Hash>]
|
|
2575
|
+
def list_all(limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
2576
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
2577
|
+
@client.request(
|
|
2578
|
+
"GET",
|
|
2579
|
+
"/segments",
|
|
2580
|
+
query: { "limit" => limit, "after" => page_after, "before" => page_before },
|
|
2581
|
+
extra_headers: extra_headers,
|
|
2582
|
+
timeout: timeout
|
|
2583
|
+
)
|
|
2584
|
+
end
|
|
2585
|
+
end
|
|
2586
|
+
|
|
2587
|
+
# Retrieve a segment.
|
|
2588
|
+
#
|
|
2589
|
+
# +GET /segments/{id}+
|
|
2590
|
+
#
|
|
2591
|
+
# @return [Hash] the parsed JSON answer
|
|
2592
|
+
def get(id, extra_headers: nil, timeout: nil)
|
|
2593
|
+
@client.request(
|
|
2594
|
+
"GET",
|
|
2595
|
+
"/segments/#{Client.encode_path(id)}",
|
|
2596
|
+
extra_headers: extra_headers,
|
|
2597
|
+
timeout: timeout
|
|
2598
|
+
)
|
|
2599
|
+
end
|
|
2600
|
+
|
|
2601
|
+
# Update a segment.
|
|
2602
|
+
#
|
|
2603
|
+
# +PATCH /segments/{id}+
|
|
2604
|
+
#
|
|
2605
|
+
# @return [Hash] the parsed JSON answer
|
|
2606
|
+
def update(id, params = nil, extra_headers: nil, timeout: nil)
|
|
2607
|
+
@client.request(
|
|
2608
|
+
"PATCH",
|
|
2609
|
+
"/segments/#{Client.encode_path(id)}",
|
|
2610
|
+
body: params,
|
|
2611
|
+
extra_headers: extra_headers,
|
|
2612
|
+
timeout: timeout
|
|
2613
|
+
)
|
|
2614
|
+
end
|
|
2615
|
+
|
|
2616
|
+
# Delete a segment.
|
|
2617
|
+
#
|
|
2618
|
+
# +DELETE /segments/{id}+
|
|
2619
|
+
#
|
|
2620
|
+
# @return [Hash] the parsed JSON answer
|
|
2621
|
+
def delete(id, extra_headers: nil, timeout: nil)
|
|
2622
|
+
@client.request(
|
|
2623
|
+
"DELETE",
|
|
2624
|
+
"/segments/#{Client.encode_path(id)}",
|
|
2625
|
+
extra_headers: extra_headers,
|
|
2626
|
+
timeout: timeout
|
|
2627
|
+
)
|
|
2628
|
+
end
|
|
2629
|
+
end
|
|
2630
|
+
|
|
2631
|
+
# Operations on segments contacts.
|
|
2632
|
+
class SegmentsContacts < Base
|
|
2633
|
+
# List segment contacts.
|
|
2634
|
+
#
|
|
2635
|
+
# Newest first, with cursor pagination: `after` takes the last id of a page and pages toward
|
|
2636
|
+
# older items, `before` takes the first id and pages back toward newer ones.
|
|
2637
|
+
#
|
|
2638
|
+
# +GET /segments/{id}/contacts+
|
|
2639
|
+
#
|
|
2640
|
+
# @return [Hash] the parsed JSON answer
|
|
2641
|
+
def list(
|
|
2642
|
+
id,
|
|
2643
|
+
limit: nil,
|
|
2644
|
+
after: nil,
|
|
2645
|
+
before: nil,
|
|
2646
|
+
include: nil,
|
|
2647
|
+
extra_headers: nil,
|
|
2648
|
+
timeout: nil
|
|
2649
|
+
)
|
|
2650
|
+
@client.request(
|
|
2651
|
+
"GET",
|
|
2652
|
+
"/segments/#{Client.encode_path(id)}/contacts",
|
|
2653
|
+
query: { "limit" => limit, "after" => after, "before" => before, "include" => include },
|
|
2654
|
+
extra_headers: extra_headers,
|
|
2655
|
+
timeout: timeout
|
|
2656
|
+
)
|
|
2657
|
+
end
|
|
2658
|
+
|
|
2659
|
+
# Every item of +list+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
2660
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
2661
|
+
#
|
|
2662
|
+
# @return [Enumerator<Hash>]
|
|
2663
|
+
def list_all(
|
|
2664
|
+
id,
|
|
2665
|
+
limit: nil,
|
|
2666
|
+
after: nil,
|
|
2667
|
+
before: nil,
|
|
2668
|
+
include: nil,
|
|
2669
|
+
extra_headers: nil,
|
|
2670
|
+
timeout: nil
|
|
2671
|
+
)
|
|
2672
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
2673
|
+
@client.request(
|
|
2674
|
+
"GET",
|
|
2675
|
+
"/segments/#{Client.encode_path(id)}/contacts",
|
|
2676
|
+
query: {
|
|
2677
|
+
"limit" => limit,
|
|
2678
|
+
"after" => page_after,
|
|
2679
|
+
"before" => page_before,
|
|
2680
|
+
"include" => include
|
|
2681
|
+
},
|
|
2682
|
+
extra_headers: extra_headers,
|
|
2683
|
+
timeout: timeout
|
|
2684
|
+
)
|
|
2685
|
+
end
|
|
2686
|
+
end
|
|
2687
|
+
end
|
|
2688
|
+
|
|
2689
|
+
# Operations on suppressions.
|
|
2690
|
+
class Suppressions < Base
|
|
2691
|
+
# @return [SuppressionsBatch]
|
|
2692
|
+
def batch
|
|
2693
|
+
@batch ||= SuppressionsBatch.new(@client)
|
|
2694
|
+
end
|
|
2695
|
+
|
|
2696
|
+
# Add a suppression.
|
|
2697
|
+
#
|
|
2698
|
+
# +POST /suppressions+
|
|
2699
|
+
#
|
|
2700
|
+
# @return [Hash] the parsed JSON answer
|
|
2701
|
+
def create(params, extra_headers: nil, timeout: nil)
|
|
2702
|
+
@client.request(
|
|
2703
|
+
"POST",
|
|
2704
|
+
"/suppressions",
|
|
2705
|
+
body: params,
|
|
2706
|
+
extra_headers: extra_headers,
|
|
2707
|
+
timeout: timeout
|
|
2708
|
+
)
|
|
2709
|
+
end
|
|
2710
|
+
|
|
2711
|
+
# List suppressions.
|
|
2712
|
+
#
|
|
2713
|
+
# Newest first, with cursor pagination: `after` takes the last id of a page and pages toward
|
|
2714
|
+
# older items, `before` takes the first id and pages back toward newer ones.
|
|
2715
|
+
#
|
|
2716
|
+
# +GET /suppressions+
|
|
2717
|
+
#
|
|
2718
|
+
# @return [Hash] the parsed JSON answer
|
|
2719
|
+
def list(limit: nil, after: nil, before: nil, origin: nil, extra_headers: nil, timeout: nil)
|
|
2720
|
+
@client.request(
|
|
2721
|
+
"GET",
|
|
2722
|
+
"/suppressions",
|
|
2723
|
+
query: { "limit" => limit, "after" => after, "before" => before, "origin" => origin },
|
|
2724
|
+
extra_headers: extra_headers,
|
|
2725
|
+
timeout: timeout
|
|
2726
|
+
)
|
|
2727
|
+
end
|
|
2728
|
+
|
|
2729
|
+
# Every item of +list+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
2730
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
2731
|
+
#
|
|
2732
|
+
# @return [Enumerator<Hash>]
|
|
2733
|
+
def list_all(
|
|
2734
|
+
limit: nil,
|
|
2735
|
+
after: nil,
|
|
2736
|
+
before: nil,
|
|
2737
|
+
origin: nil,
|
|
2738
|
+
extra_headers: nil,
|
|
2739
|
+
timeout: nil
|
|
2740
|
+
)
|
|
2741
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
2742
|
+
@client.request(
|
|
2743
|
+
"GET",
|
|
2744
|
+
"/suppressions",
|
|
2745
|
+
query: {
|
|
2746
|
+
"limit" => limit,
|
|
2747
|
+
"after" => page_after,
|
|
2748
|
+
"before" => page_before,
|
|
2749
|
+
"origin" => origin
|
|
2750
|
+
},
|
|
2751
|
+
extra_headers: extra_headers,
|
|
2752
|
+
timeout: timeout
|
|
2753
|
+
)
|
|
2754
|
+
end
|
|
2755
|
+
end
|
|
2756
|
+
|
|
2757
|
+
# Retrieve a suppression.
|
|
2758
|
+
#
|
|
2759
|
+
# +GET /suppressions/{id}+
|
|
2760
|
+
#
|
|
2761
|
+
# @return [Hash] the parsed JSON answer
|
|
2762
|
+
def get(id, extra_headers: nil, timeout: nil)
|
|
2763
|
+
@client.request(
|
|
2764
|
+
"GET",
|
|
2765
|
+
"/suppressions/#{Client.encode_path(id)}",
|
|
2766
|
+
extra_headers: extra_headers,
|
|
2767
|
+
timeout: timeout
|
|
2768
|
+
)
|
|
2769
|
+
end
|
|
2770
|
+
|
|
2771
|
+
# Remove a suppression.
|
|
2772
|
+
#
|
|
2773
|
+
# +DELETE /suppressions/{id}+
|
|
2774
|
+
#
|
|
2775
|
+
# @return [Hash] the parsed JSON answer
|
|
2776
|
+
def delete(id, extra_headers: nil, timeout: nil)
|
|
2777
|
+
@client.request(
|
|
2778
|
+
"DELETE",
|
|
2779
|
+
"/suppressions/#{Client.encode_path(id)}",
|
|
2780
|
+
extra_headers: extra_headers,
|
|
2781
|
+
timeout: timeout
|
|
2782
|
+
)
|
|
2783
|
+
end
|
|
2784
|
+
end
|
|
2785
|
+
|
|
2786
|
+
# Operations on suppressions batch.
|
|
2787
|
+
class SuppressionsBatch < Base
|
|
2788
|
+
# Add in bulk.
|
|
2789
|
+
#
|
|
2790
|
+
# +POST /suppressions/batch/add+
|
|
2791
|
+
#
|
|
2792
|
+
# @return [Hash] the parsed JSON answer
|
|
2793
|
+
def add(params, extra_headers: nil, timeout: nil)
|
|
2794
|
+
@client.request(
|
|
2795
|
+
"POST",
|
|
2796
|
+
"/suppressions/batch/add",
|
|
2797
|
+
body: params,
|
|
2798
|
+
extra_headers: extra_headers,
|
|
2799
|
+
timeout: timeout
|
|
2800
|
+
)
|
|
2801
|
+
end
|
|
2802
|
+
|
|
2803
|
+
# Remove in bulk.
|
|
2804
|
+
#
|
|
2805
|
+
# +POST /suppressions/batch/remove+
|
|
2806
|
+
#
|
|
2807
|
+
# @return [Hash] the parsed JSON answer
|
|
2808
|
+
def remove(params, extra_headers: nil, timeout: nil)
|
|
2809
|
+
@client.request(
|
|
2810
|
+
"POST",
|
|
2811
|
+
"/suppressions/batch/remove",
|
|
2812
|
+
body: params,
|
|
2813
|
+
extra_headers: extra_headers,
|
|
2814
|
+
timeout: timeout
|
|
2815
|
+
)
|
|
2816
|
+
end
|
|
2817
|
+
end
|
|
2818
|
+
|
|
2819
|
+
# Operations on templates.
|
|
2820
|
+
class Templates < Base
|
|
2821
|
+
# Create a template.
|
|
2822
|
+
#
|
|
2823
|
+
# +POST /templates+
|
|
2824
|
+
#
|
|
2825
|
+
# @return [Hash] the parsed JSON answer
|
|
2826
|
+
def create(params, extra_headers: nil, timeout: nil)
|
|
2827
|
+
@client.request(
|
|
2828
|
+
"POST",
|
|
2829
|
+
"/templates",
|
|
2830
|
+
body: params,
|
|
2831
|
+
extra_headers: extra_headers,
|
|
2832
|
+
timeout: timeout
|
|
2833
|
+
)
|
|
2834
|
+
end
|
|
2835
|
+
|
|
2836
|
+
# List templates.
|
|
2837
|
+
#
|
|
2838
|
+
# Newest first, with cursor pagination: `after` takes the last id of a page and pages toward
|
|
2839
|
+
# older items, `before` takes the first id and pages back toward newer ones.
|
|
2840
|
+
#
|
|
2841
|
+
# +GET /templates+
|
|
2842
|
+
#
|
|
2843
|
+
# @return [Hash] the parsed JSON answer
|
|
2844
|
+
def list(limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
2845
|
+
@client.request(
|
|
2846
|
+
"GET",
|
|
2847
|
+
"/templates",
|
|
2848
|
+
query: { "limit" => limit, "after" => after, "before" => before },
|
|
2849
|
+
extra_headers: extra_headers,
|
|
2850
|
+
timeout: timeout
|
|
2851
|
+
)
|
|
2852
|
+
end
|
|
2853
|
+
|
|
2854
|
+
# Every item of +list+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
2855
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
2856
|
+
#
|
|
2857
|
+
# @return [Enumerator<Hash>]
|
|
2858
|
+
def list_all(limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
2859
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
2860
|
+
@client.request(
|
|
2861
|
+
"GET",
|
|
2862
|
+
"/templates",
|
|
2863
|
+
query: { "limit" => limit, "after" => page_after, "before" => page_before },
|
|
2864
|
+
extra_headers: extra_headers,
|
|
2865
|
+
timeout: timeout
|
|
2866
|
+
)
|
|
2867
|
+
end
|
|
2868
|
+
end
|
|
2869
|
+
|
|
2870
|
+
# Retrieve a template.
|
|
2871
|
+
#
|
|
2872
|
+
# +GET /templates/{id}+
|
|
2873
|
+
#
|
|
2874
|
+
# @return [Hash] the parsed JSON answer
|
|
2875
|
+
def get(id, extra_headers: nil, timeout: nil)
|
|
2876
|
+
@client.request(
|
|
2877
|
+
"GET",
|
|
2878
|
+
"/templates/#{Client.encode_path(id)}",
|
|
2879
|
+
extra_headers: extra_headers,
|
|
2880
|
+
timeout: timeout
|
|
2881
|
+
)
|
|
2882
|
+
end
|
|
2883
|
+
|
|
2884
|
+
# Update a template.
|
|
2885
|
+
#
|
|
2886
|
+
# +PATCH /templates/{id}+
|
|
2887
|
+
#
|
|
2888
|
+
# @return [Hash] the parsed JSON answer
|
|
2889
|
+
def update(id, params = nil, extra_headers: nil, timeout: nil)
|
|
2890
|
+
@client.request(
|
|
2891
|
+
"PATCH",
|
|
2892
|
+
"/templates/#{Client.encode_path(id)}",
|
|
2893
|
+
body: params,
|
|
2894
|
+
extra_headers: extra_headers,
|
|
2895
|
+
timeout: timeout
|
|
2896
|
+
)
|
|
2897
|
+
end
|
|
2898
|
+
|
|
2899
|
+
# Delete a template.
|
|
2900
|
+
#
|
|
2901
|
+
# +DELETE /templates/{id}+
|
|
2902
|
+
#
|
|
2903
|
+
# @return [Hash] the parsed JSON answer
|
|
2904
|
+
def delete(id, extra_headers: nil, timeout: nil)
|
|
2905
|
+
@client.request(
|
|
2906
|
+
"DELETE",
|
|
2907
|
+
"/templates/#{Client.encode_path(id)}",
|
|
2908
|
+
extra_headers: extra_headers,
|
|
2909
|
+
timeout: timeout
|
|
2910
|
+
)
|
|
2911
|
+
end
|
|
2912
|
+
|
|
2913
|
+
# Publish a template.
|
|
2914
|
+
#
|
|
2915
|
+
# +POST /templates/{id}/publish+
|
|
2916
|
+
#
|
|
2917
|
+
# @return [Hash] the parsed JSON answer
|
|
2918
|
+
def publish(id, extra_headers: nil, timeout: nil)
|
|
2919
|
+
@client.request(
|
|
2920
|
+
"POST",
|
|
2921
|
+
"/templates/#{Client.encode_path(id)}/publish",
|
|
2922
|
+
extra_headers: extra_headers,
|
|
2923
|
+
timeout: timeout
|
|
2924
|
+
)
|
|
2925
|
+
end
|
|
2926
|
+
|
|
2927
|
+
# Duplicate a template.
|
|
2928
|
+
#
|
|
2929
|
+
# +POST /templates/{id}/duplicate+
|
|
2930
|
+
#
|
|
2931
|
+
# @return [Hash] the parsed JSON answer
|
|
2932
|
+
def duplicate(id, extra_headers: nil, timeout: nil)
|
|
2933
|
+
@client.request(
|
|
2934
|
+
"POST",
|
|
2935
|
+
"/templates/#{Client.encode_path(id)}/duplicate",
|
|
2936
|
+
extra_headers: extra_headers,
|
|
2937
|
+
timeout: timeout
|
|
2938
|
+
)
|
|
2939
|
+
end
|
|
2940
|
+
end
|
|
2941
|
+
|
|
2942
|
+
# Operations on topics.
|
|
2943
|
+
class Topics < Base
|
|
2944
|
+
# Create a topic.
|
|
2945
|
+
#
|
|
2946
|
+
# +POST /topics+
|
|
2947
|
+
#
|
|
2948
|
+
# @return [Hash] the parsed JSON answer
|
|
2949
|
+
def create(params, extra_headers: nil, timeout: nil)
|
|
2950
|
+
@client.request(
|
|
2951
|
+
"POST",
|
|
2952
|
+
"/topics",
|
|
2953
|
+
body: params,
|
|
2954
|
+
extra_headers: extra_headers,
|
|
2955
|
+
timeout: timeout
|
|
2956
|
+
)
|
|
2957
|
+
end
|
|
2958
|
+
|
|
2959
|
+
# List topics.
|
|
2960
|
+
#
|
|
2961
|
+
# +GET /topics+
|
|
2962
|
+
#
|
|
2963
|
+
# @return [Hash] the parsed JSON answer
|
|
2964
|
+
def list(extra_headers: nil, timeout: nil)
|
|
2965
|
+
@client.request(
|
|
2966
|
+
"GET",
|
|
2967
|
+
"/topics",
|
|
2968
|
+
extra_headers: extra_headers,
|
|
2969
|
+
timeout: timeout
|
|
2970
|
+
)
|
|
2971
|
+
end
|
|
2972
|
+
|
|
2973
|
+
# Retrieve a topic.
|
|
2974
|
+
#
|
|
2975
|
+
# +GET /topics/{id}+
|
|
2976
|
+
#
|
|
2977
|
+
# @return [Hash] the parsed JSON answer
|
|
2978
|
+
def get(id, extra_headers: nil, timeout: nil)
|
|
2979
|
+
@client.request(
|
|
2980
|
+
"GET",
|
|
2981
|
+
"/topics/#{Client.encode_path(id)}",
|
|
2982
|
+
extra_headers: extra_headers,
|
|
2983
|
+
timeout: timeout
|
|
2984
|
+
)
|
|
2985
|
+
end
|
|
2986
|
+
|
|
2987
|
+
# Update a topic.
|
|
2988
|
+
#
|
|
2989
|
+
# +PATCH /topics/{id}+
|
|
2990
|
+
#
|
|
2991
|
+
# @return [Hash] the parsed JSON answer
|
|
2992
|
+
def update(id, params = nil, extra_headers: nil, timeout: nil)
|
|
2993
|
+
@client.request(
|
|
2994
|
+
"PATCH",
|
|
2995
|
+
"/topics/#{Client.encode_path(id)}",
|
|
2996
|
+
body: params,
|
|
2997
|
+
extra_headers: extra_headers,
|
|
2998
|
+
timeout: timeout
|
|
2999
|
+
)
|
|
3000
|
+
end
|
|
3001
|
+
|
|
3002
|
+
# Delete a topic.
|
|
3003
|
+
#
|
|
3004
|
+
# +DELETE /topics/{id}+
|
|
3005
|
+
#
|
|
3006
|
+
# @return [Hash] the parsed JSON answer
|
|
3007
|
+
def delete(id, extra_headers: nil, timeout: nil)
|
|
3008
|
+
@client.request(
|
|
3009
|
+
"DELETE",
|
|
3010
|
+
"/topics/#{Client.encode_path(id)}",
|
|
3011
|
+
extra_headers: extra_headers,
|
|
3012
|
+
timeout: timeout
|
|
3013
|
+
)
|
|
3014
|
+
end
|
|
3015
|
+
end
|
|
3016
|
+
|
|
3017
|
+
# Operations on unsubscribes.
|
|
3018
|
+
class Unsubscribes < Base
|
|
3019
|
+
# List unsubscribes.
|
|
3020
|
+
#
|
|
3021
|
+
# Newest first, with cursor pagination: `after` takes the last id of a page and pages toward
|
|
3022
|
+
# older items, `before` takes the first id and pages back toward newer ones.
|
|
3023
|
+
#
|
|
3024
|
+
# +GET /unsubscribes+
|
|
3025
|
+
#
|
|
3026
|
+
# @return [Hash] the parsed JSON answer
|
|
3027
|
+
def list(
|
|
3028
|
+
limit: nil,
|
|
3029
|
+
after: nil,
|
|
3030
|
+
before: nil,
|
|
3031
|
+
domain_id: nil,
|
|
3032
|
+
extra_headers: nil,
|
|
3033
|
+
timeout: nil
|
|
3034
|
+
)
|
|
3035
|
+
@client.request(
|
|
3036
|
+
"GET",
|
|
3037
|
+
"/unsubscribes",
|
|
3038
|
+
query: {
|
|
3039
|
+
"limit" => limit,
|
|
3040
|
+
"after" => after,
|
|
3041
|
+
"before" => before,
|
|
3042
|
+
"domain_id" => domain_id
|
|
3043
|
+
},
|
|
3044
|
+
extra_headers: extra_headers,
|
|
3045
|
+
timeout: timeout
|
|
3046
|
+
)
|
|
3047
|
+
end
|
|
3048
|
+
|
|
3049
|
+
# Every item of +list+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
3050
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
3051
|
+
#
|
|
3052
|
+
# @return [Enumerator<Hash>]
|
|
3053
|
+
def list_all(
|
|
3054
|
+
limit: nil,
|
|
3055
|
+
after: nil,
|
|
3056
|
+
before: nil,
|
|
3057
|
+
domain_id: nil,
|
|
3058
|
+
extra_headers: nil,
|
|
3059
|
+
timeout: nil
|
|
3060
|
+
)
|
|
3061
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
3062
|
+
@client.request(
|
|
3063
|
+
"GET",
|
|
3064
|
+
"/unsubscribes",
|
|
3065
|
+
query: {
|
|
3066
|
+
"limit" => limit,
|
|
3067
|
+
"after" => page_after,
|
|
3068
|
+
"before" => page_before,
|
|
3069
|
+
"domain_id" => domain_id
|
|
3070
|
+
},
|
|
3071
|
+
extra_headers: extra_headers,
|
|
3072
|
+
timeout: timeout
|
|
3073
|
+
)
|
|
3074
|
+
end
|
|
3075
|
+
end
|
|
3076
|
+
|
|
3077
|
+
# Record an unsubscribe.
|
|
3078
|
+
#
|
|
3079
|
+
# +POST /unsubscribes+
|
|
3080
|
+
#
|
|
3081
|
+
# @return [Hash] the parsed JSON answer
|
|
3082
|
+
def create(params, extra_headers: nil, timeout: nil)
|
|
3083
|
+
@client.request(
|
|
3084
|
+
"POST",
|
|
3085
|
+
"/unsubscribes",
|
|
3086
|
+
body: params,
|
|
3087
|
+
extra_headers: extra_headers,
|
|
3088
|
+
timeout: timeout
|
|
3089
|
+
)
|
|
3090
|
+
end
|
|
3091
|
+
|
|
3092
|
+
# Delete an unsubscribe.
|
|
3093
|
+
#
|
|
3094
|
+
# +DELETE /unsubscribes/{id}+
|
|
3095
|
+
#
|
|
3096
|
+
# @return [Hash] the parsed JSON answer
|
|
3097
|
+
def delete(id, extra_headers: nil, timeout: nil)
|
|
3098
|
+
@client.request(
|
|
3099
|
+
"DELETE",
|
|
3100
|
+
"/unsubscribes/#{Client.encode_path(id)}",
|
|
3101
|
+
extra_headers: extra_headers,
|
|
3102
|
+
timeout: timeout
|
|
3103
|
+
)
|
|
3104
|
+
end
|
|
3105
|
+
end
|
|
3106
|
+
|
|
3107
|
+
# Operations on usage.
|
|
3108
|
+
class Usage < Base
|
|
3109
|
+
# Get usage.
|
|
3110
|
+
#
|
|
3111
|
+
# +GET /usage+
|
|
3112
|
+
#
|
|
3113
|
+
# @return [Hash] the parsed JSON answer
|
|
3114
|
+
def get(extra_headers: nil, timeout: nil)
|
|
3115
|
+
@client.request(
|
|
3116
|
+
"GET",
|
|
3117
|
+
"/usage",
|
|
3118
|
+
extra_headers: extra_headers,
|
|
3119
|
+
timeout: timeout
|
|
3120
|
+
)
|
|
3121
|
+
end
|
|
3122
|
+
end
|
|
3123
|
+
|
|
3124
|
+
# Operations on verifications.
|
|
3125
|
+
class Verifications < Base
|
|
3126
|
+
# Check verification availability.
|
|
3127
|
+
#
|
|
3128
|
+
# +GET /verifications/availability+
|
|
3129
|
+
#
|
|
3130
|
+
# @return [Hash] the parsed JSON answer
|
|
3131
|
+
def availability(extra_headers: nil, timeout: nil)
|
|
3132
|
+
@client.request(
|
|
3133
|
+
"GET",
|
|
3134
|
+
"/verifications/availability",
|
|
3135
|
+
extra_headers: extra_headers,
|
|
3136
|
+
timeout: timeout
|
|
3137
|
+
)
|
|
3138
|
+
end
|
|
3139
|
+
|
|
3140
|
+
# Estimate a verification.
|
|
3141
|
+
#
|
|
3142
|
+
# How many of the target's contacts were never verified and what verifying them would cost.
|
|
3143
|
+
# Changes nothing.
|
|
3144
|
+
#
|
|
3145
|
+
# +POST /verifications/estimate+
|
|
3146
|
+
#
|
|
3147
|
+
# @return [Hash] the parsed JSON answer
|
|
3148
|
+
def estimate(params, extra_headers: nil, timeout: nil)
|
|
3149
|
+
@client.request(
|
|
3150
|
+
"POST",
|
|
3151
|
+
"/verifications/estimate",
|
|
3152
|
+
body: params,
|
|
3153
|
+
extra_headers: extra_headers,
|
|
3154
|
+
timeout: timeout
|
|
3155
|
+
)
|
|
3156
|
+
end
|
|
3157
|
+
|
|
3158
|
+
# Start a verification.
|
|
3159
|
+
#
|
|
3160
|
+
# Starts deep verification of the target's contacts, one run per 50,000 of them. Contacts
|
|
3161
|
+
# verified before are skipped unless recheck is true, and a contact already being verified
|
|
3162
|
+
# never joins a second run. Paid plans only; billed per verified address on the monthly
|
|
3163
|
+
# invoice.
|
|
3164
|
+
#
|
|
3165
|
+
# +POST /verifications+
|
|
3166
|
+
#
|
|
3167
|
+
# @return [Hash] the parsed JSON answer
|
|
3168
|
+
def create(params, extra_headers: nil, timeout: nil)
|
|
3169
|
+
@client.request(
|
|
3170
|
+
"POST",
|
|
3171
|
+
"/verifications",
|
|
3172
|
+
body: params,
|
|
3173
|
+
extra_headers: extra_headers,
|
|
3174
|
+
timeout: timeout
|
|
3175
|
+
)
|
|
3176
|
+
end
|
|
3177
|
+
|
|
3178
|
+
# List verifications.
|
|
3179
|
+
#
|
|
3180
|
+
# Newest first, with cursor pagination: `after` takes the last id of a page and pages toward
|
|
3181
|
+
# older items, `before` takes the first id and pages back toward newer ones.
|
|
3182
|
+
#
|
|
3183
|
+
# +GET /verifications+
|
|
3184
|
+
#
|
|
3185
|
+
# @return [Hash] the parsed JSON answer
|
|
3186
|
+
def list(limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
3187
|
+
@client.request(
|
|
3188
|
+
"GET",
|
|
3189
|
+
"/verifications",
|
|
3190
|
+
query: { "limit" => limit, "after" => after, "before" => before },
|
|
3191
|
+
extra_headers: extra_headers,
|
|
3192
|
+
timeout: timeout
|
|
3193
|
+
)
|
|
3194
|
+
end
|
|
3195
|
+
|
|
3196
|
+
# Every item of +list+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
3197
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
3198
|
+
#
|
|
3199
|
+
# @return [Enumerator<Hash>]
|
|
3200
|
+
def list_all(limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
3201
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
3202
|
+
@client.request(
|
|
3203
|
+
"GET",
|
|
3204
|
+
"/verifications",
|
|
3205
|
+
query: { "limit" => limit, "after" => page_after, "before" => page_before },
|
|
3206
|
+
extra_headers: extra_headers,
|
|
3207
|
+
timeout: timeout
|
|
3208
|
+
)
|
|
3209
|
+
end
|
|
3210
|
+
end
|
|
3211
|
+
|
|
3212
|
+
# Retrieve a verification.
|
|
3213
|
+
#
|
|
3214
|
+
# +GET /verifications/{id}+
|
|
3215
|
+
#
|
|
3216
|
+
# @return [Hash] the parsed JSON answer
|
|
3217
|
+
def get(id, extra_headers: nil, timeout: nil)
|
|
3218
|
+
@client.request(
|
|
3219
|
+
"GET",
|
|
3220
|
+
"/verifications/#{Client.encode_path(id)}",
|
|
3221
|
+
extra_headers: extra_headers,
|
|
3222
|
+
timeout: timeout
|
|
3223
|
+
)
|
|
3224
|
+
end
|
|
3225
|
+
end
|
|
3226
|
+
|
|
3227
|
+
# Operations on webhooks.
|
|
3228
|
+
class Webhooks < Base
|
|
3229
|
+
# Create a webhook.
|
|
3230
|
+
#
|
|
3231
|
+
# +POST /webhooks+
|
|
3232
|
+
#
|
|
3233
|
+
# @return [Hash] the parsed JSON answer
|
|
3234
|
+
def create(params, extra_headers: nil, timeout: nil)
|
|
3235
|
+
@client.request(
|
|
3236
|
+
"POST",
|
|
3237
|
+
"/webhooks",
|
|
3238
|
+
body: params,
|
|
3239
|
+
extra_headers: extra_headers,
|
|
3240
|
+
timeout: timeout
|
|
3241
|
+
)
|
|
3242
|
+
end
|
|
3243
|
+
|
|
3244
|
+
# List webhooks.
|
|
3245
|
+
#
|
|
3246
|
+
# Newest first, with cursor pagination: `after` takes the last id of a page and pages toward
|
|
3247
|
+
# older items, `before` takes the first id and pages back toward newer ones.
|
|
3248
|
+
#
|
|
3249
|
+
# +GET /webhooks+
|
|
3250
|
+
#
|
|
3251
|
+
# @return [Hash] the parsed JSON answer
|
|
3252
|
+
def list(limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
3253
|
+
@client.request(
|
|
3254
|
+
"GET",
|
|
3255
|
+
"/webhooks",
|
|
3256
|
+
query: { "limit" => limit, "after" => after, "before" => before },
|
|
3257
|
+
extra_headers: extra_headers,
|
|
3258
|
+
timeout: timeout
|
|
3259
|
+
)
|
|
3260
|
+
end
|
|
3261
|
+
|
|
3262
|
+
# Every item of +list+, as an Enumerator that fetches pages as it goes. Walks in the list's
|
|
3263
|
+
# own order, from +after+ (or the first page) on; pass +before+ instead to walk the other way.
|
|
3264
|
+
#
|
|
3265
|
+
# @return [Enumerator<Hash>]
|
|
3266
|
+
def list_all(limit: nil, after: nil, before: nil, extra_headers: nil, timeout: nil)
|
|
3267
|
+
Pagination.each_item(after: after, before: before) do |page_after, page_before|
|
|
3268
|
+
@client.request(
|
|
3269
|
+
"GET",
|
|
3270
|
+
"/webhooks",
|
|
3271
|
+
query: { "limit" => limit, "after" => page_after, "before" => page_before },
|
|
3272
|
+
extra_headers: extra_headers,
|
|
3273
|
+
timeout: timeout
|
|
3274
|
+
)
|
|
3275
|
+
end
|
|
3276
|
+
end
|
|
3277
|
+
|
|
3278
|
+
# Retrieve a webhook.
|
|
3279
|
+
#
|
|
3280
|
+
# +GET /webhooks/{id}+
|
|
3281
|
+
#
|
|
3282
|
+
# @return [Hash] the parsed JSON answer
|
|
3283
|
+
def get(id, extra_headers: nil, timeout: nil)
|
|
3284
|
+
@client.request(
|
|
3285
|
+
"GET",
|
|
3286
|
+
"/webhooks/#{Client.encode_path(id)}",
|
|
3287
|
+
extra_headers: extra_headers,
|
|
3288
|
+
timeout: timeout
|
|
3289
|
+
)
|
|
3290
|
+
end
|
|
3291
|
+
|
|
3292
|
+
# Update a webhook.
|
|
3293
|
+
#
|
|
3294
|
+
# +PATCH /webhooks/{id}+
|
|
3295
|
+
#
|
|
3296
|
+
# @return [Hash] the parsed JSON answer
|
|
3297
|
+
def update(id, params = nil, extra_headers: nil, timeout: nil)
|
|
3298
|
+
@client.request(
|
|
3299
|
+
"PATCH",
|
|
3300
|
+
"/webhooks/#{Client.encode_path(id)}",
|
|
3301
|
+
body: params,
|
|
3302
|
+
extra_headers: extra_headers,
|
|
3303
|
+
timeout: timeout
|
|
3304
|
+
)
|
|
3305
|
+
end
|
|
3306
|
+
|
|
3307
|
+
# Delete a webhook.
|
|
3308
|
+
#
|
|
3309
|
+
# +DELETE /webhooks/{id}+
|
|
3310
|
+
#
|
|
3311
|
+
# @return [Hash] the parsed JSON answer
|
|
3312
|
+
def delete(id, extra_headers: nil, timeout: nil)
|
|
3313
|
+
@client.request(
|
|
3314
|
+
"DELETE",
|
|
3315
|
+
"/webhooks/#{Client.encode_path(id)}",
|
|
3316
|
+
extra_headers: extra_headers,
|
|
3317
|
+
timeout: timeout
|
|
3318
|
+
)
|
|
3319
|
+
end
|
|
3320
|
+
|
|
3321
|
+
# Rotate signing secret.
|
|
3322
|
+
#
|
|
3323
|
+
# BillionSend extension. Mints a new signing secret (or takes the one in signing_secret) and
|
|
3324
|
+
# returns it. For overlap_hours the previous secret keeps signing too: every delivery in that
|
|
3325
|
+
# window carries both signatures, space-separated in webhook-signature, so the receiver can
|
|
3326
|
+
# switch at any point without a gap. A second rotation inside the window replaces the previous
|
|
3327
|
+
# secret.
|
|
3328
|
+
#
|
|
3329
|
+
# +POST /webhooks/{id}/rotate+
|
|
3330
|
+
#
|
|
3331
|
+
# @return [Hash] the parsed JSON answer
|
|
3332
|
+
def rotate(id, params = nil, extra_headers: nil, timeout: nil)
|
|
3333
|
+
@client.request(
|
|
3334
|
+
"POST",
|
|
3335
|
+
"/webhooks/#{Client.encode_path(id)}/rotate",
|
|
3336
|
+
body: params,
|
|
3337
|
+
extra_headers: extra_headers,
|
|
3338
|
+
timeout: timeout
|
|
3339
|
+
)
|
|
3340
|
+
end
|
|
3341
|
+
end
|
|
3342
|
+
|
|
3343
|
+
# The top-level resources, included into BillionSend::Client.
|
|
3344
|
+
module Root
|
|
3345
|
+
# @return [Resources::Agent]
|
|
3346
|
+
def agent
|
|
3347
|
+
@agent ||= Agent.new(self)
|
|
3348
|
+
end
|
|
3349
|
+
|
|
3350
|
+
# @return [Resources::ApiKeys]
|
|
3351
|
+
def api_keys
|
|
3352
|
+
@api_keys ||= ApiKeys.new(self)
|
|
3353
|
+
end
|
|
3354
|
+
|
|
3355
|
+
# @return [Resources::Audiences]
|
|
3356
|
+
def audiences
|
|
3357
|
+
@audiences ||= Audiences.new(self)
|
|
3358
|
+
end
|
|
3359
|
+
|
|
3360
|
+
# @return [Resources::Broadcasts]
|
|
3361
|
+
def broadcasts
|
|
3362
|
+
@broadcasts ||= Broadcasts.new(self)
|
|
3363
|
+
end
|
|
3364
|
+
|
|
3365
|
+
# @return [Resources::ContactProperties]
|
|
3366
|
+
def contact_properties
|
|
3367
|
+
@contact_properties ||= ContactProperties.new(self)
|
|
3368
|
+
end
|
|
3369
|
+
|
|
3370
|
+
# @return [Resources::Contacts]
|
|
3371
|
+
def contacts
|
|
3372
|
+
@contacts ||= Contacts.new(self)
|
|
3373
|
+
end
|
|
3374
|
+
|
|
3375
|
+
# @return [Resources::Deliverability]
|
|
3376
|
+
def deliverability
|
|
3377
|
+
@deliverability ||= Deliverability.new(self)
|
|
3378
|
+
end
|
|
3379
|
+
|
|
3380
|
+
# @return [Resources::Domains]
|
|
3381
|
+
def domains
|
|
3382
|
+
@domains ||= Domains.new(self)
|
|
3383
|
+
end
|
|
3384
|
+
|
|
3385
|
+
# @return [Resources::Emails]
|
|
3386
|
+
def emails
|
|
3387
|
+
@emails ||= Emails.new(self)
|
|
3388
|
+
end
|
|
3389
|
+
|
|
3390
|
+
# @return [Resources::Inboxes]
|
|
3391
|
+
def inboxes
|
|
3392
|
+
@inboxes ||= Inboxes.new(self)
|
|
3393
|
+
end
|
|
3394
|
+
|
|
3395
|
+
# @return [Resources::Segments]
|
|
3396
|
+
def segments
|
|
3397
|
+
@segments ||= Segments.new(self)
|
|
3398
|
+
end
|
|
3399
|
+
|
|
3400
|
+
# @return [Resources::Suppressions]
|
|
3401
|
+
def suppressions
|
|
3402
|
+
@suppressions ||= Suppressions.new(self)
|
|
3403
|
+
end
|
|
3404
|
+
|
|
3405
|
+
# @return [Resources::Templates]
|
|
3406
|
+
def templates
|
|
3407
|
+
@templates ||= Templates.new(self)
|
|
3408
|
+
end
|
|
3409
|
+
|
|
3410
|
+
# @return [Resources::Topics]
|
|
3411
|
+
def topics
|
|
3412
|
+
@topics ||= Topics.new(self)
|
|
3413
|
+
end
|
|
3414
|
+
|
|
3415
|
+
# @return [Resources::Unsubscribes]
|
|
3416
|
+
def unsubscribes
|
|
3417
|
+
@unsubscribes ||= Unsubscribes.new(self)
|
|
3418
|
+
end
|
|
3419
|
+
|
|
3420
|
+
# @return [Resources::Usage]
|
|
3421
|
+
def usage
|
|
3422
|
+
@usage ||= Usage.new(self)
|
|
3423
|
+
end
|
|
3424
|
+
|
|
3425
|
+
# @return [Resources::Verifications]
|
|
3426
|
+
def verifications
|
|
3427
|
+
@verifications ||= Verifications.new(self)
|
|
3428
|
+
end
|
|
3429
|
+
|
|
3430
|
+
# @return [Resources::Webhooks]
|
|
3431
|
+
def webhooks
|
|
3432
|
+
@webhooks ||= Webhooks.new(self)
|
|
3433
|
+
end
|
|
3434
|
+
end
|
|
3435
|
+
end
|
|
3436
|
+
end
|