rasket 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,871 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Code generated by scripts/sdk-codegen/run.mjs from packages/api/openapi.json and
4
+ # packages/sdk/surface.json. DO NOT EDIT.
5
+ # Document sha256: 3f790b5e9b4526641b1d17f9b3cdbfcef6fef890214ee69cbaf158bd8163bda8
6
+
7
+ module Rasket
8
+ # Every namespace of the client, as client.emails, client.domains and so on.
9
+ module ClientResources
10
+ attr_reader :emails, :batch, :domains, :webhooks, :suppressions, :contacts, :segments, :broadcasts
11
+
12
+ private
13
+
14
+ def init_resources(http)
15
+ @emails = Resources::Emails.new(http)
16
+ @batch = Resources::Batch.new(http)
17
+ @domains = Resources::Domains.new(http)
18
+ @webhooks = Resources::Webhooks.new(http)
19
+ @suppressions = Resources::Suppressions.new(http)
20
+ @contacts = Resources::Contacts.new(http)
21
+ @segments = Resources::Segments.new(http)
22
+ @broadcasts = Resources::Broadcasts.new(http)
23
+ end
24
+ end
25
+
26
+ module Resources
27
+ # client.emails
28
+ class Emails
29
+ attr_reader :events, :shares, :attachments, :receiving
30
+
31
+ def initialize(http)
32
+ @http = http
33
+ @events = EmailsEvents.new(http)
34
+ @shares = EmailsShares.new(http)
35
+ @attachments = EmailsAttachments.new(http)
36
+ @receiving = EmailsReceiving.new(http)
37
+ end
38
+
39
+ # POST /emails: Send an email. Takes idempotency_key:.
40
+ def send(body, idempotency_key: nil, timeout: nil)
41
+ @http.request("POST", "/emails", body: body, has_body: true, idempotent: true, idempotency_key: idempotency_key, timeout: timeout)
42
+ end
43
+
44
+ # GET /emails/{email_id}: Retrieve a single email
45
+ def get(email_id, timeout: nil)
46
+ @http.request("GET", "/emails/#{HttpClient.segment(email_id)}", timeout: timeout)
47
+ end
48
+
49
+ # GET /emails: List emails, newest first
50
+ def list(query: nil, timeout: nil)
51
+ @http.request("GET", "/emails", query: query, timeout: timeout)
52
+ end
53
+
54
+ # Every item of list, a page at a time, passing the last item's id as after. An Enumerator.
55
+ def list_all(query: nil, timeout: nil)
56
+ HttpClient.paginate(query, "has_more") { |page| list(query: page, timeout: timeout) }
57
+ end
58
+
59
+ # PATCH /emails/{email_id}: Reschedule a scheduled email
60
+ def update(email_id, body, timeout: nil)
61
+ @http.request("PATCH", "/emails/#{HttpClient.segment(email_id)}", body: body, has_body: true, timeout: timeout)
62
+ end
63
+
64
+ # POST /emails/{email_id}/cancel: Cancel a scheduled email
65
+ def cancel(email_id, timeout: nil)
66
+ @http.request("POST", "/emails/#{HttpClient.segment(email_id)}/cancel", timeout: timeout)
67
+ end
68
+
69
+ # POST /emails/{email_id}/share: Create a shareable link for a sent email
70
+ def share(email_id, body = nil, timeout: nil)
71
+ @http.request("POST", "/emails/#{HttpClient.segment(email_id)}/share", body: body, has_body: !body.nil?, timeout: timeout)
72
+ end
73
+
74
+ # GET /emails/metrics: Retrieve account-level email metrics
75
+ def metrics(query: nil, timeout: nil)
76
+ @http.request("GET", "/emails/metrics", query: query, timeout: timeout)
77
+ end
78
+
79
+ # POST /emails/{email_id}/diagnose: Explain what happened to an email
80
+ def diagnose(email_id, timeout: nil)
81
+ @http.request("POST", "/emails/#{HttpClient.segment(email_id)}/diagnose", timeout: timeout)
82
+ end
83
+ end
84
+
85
+ # client.emails.events
86
+ class EmailsEvents
87
+ def initialize(http)
88
+ @http = http
89
+ end
90
+
91
+ # GET /emails/{email_id}/events: List an email's delivery events
92
+ def list(email_id, timeout: nil)
93
+ @http.request("GET", "/emails/#{HttpClient.segment(email_id)}/events", timeout: timeout)
94
+ end
95
+ end
96
+
97
+ # client.emails.shares
98
+ class EmailsShares
99
+ def initialize(http)
100
+ @http = http
101
+ end
102
+
103
+ # GET /emails/{email_id}/shares: List the shareable links of a sent email
104
+ def list(email_id, query: nil, timeout: nil)
105
+ @http.request("GET", "/emails/#{HttpClient.segment(email_id)}/shares", query: query, timeout: timeout)
106
+ end
107
+
108
+ # Every item of list, a page at a time, passing the last item's id as after. An Enumerator.
109
+ def list_all(email_id, query: nil, timeout: nil)
110
+ HttpClient.paginate(query, "has_more") { |page| list(email_id, query: page, timeout: timeout) }
111
+ end
112
+
113
+ # DELETE /emails/{email_id}/shares/{share_id}: Revoke a shareable link
114
+ def remove(email_id, share_id, timeout: nil)
115
+ @http.request("DELETE", "/emails/#{HttpClient.segment(email_id)}/shares/#{HttpClient.segment(share_id)}", timeout: timeout)
116
+ end
117
+ end
118
+
119
+ # client.emails.attachments
120
+ class EmailsAttachments
121
+ def initialize(http)
122
+ @http = http
123
+ end
124
+
125
+ # GET /emails/{email_id}/attachments: List the attachments of a sent email
126
+ def list(email_id, query: nil, timeout: nil)
127
+ @http.request("GET", "/emails/#{HttpClient.segment(email_id)}/attachments", query: query, timeout: timeout)
128
+ end
129
+
130
+ # Every item of list, a page at a time, passing the last item's id as after. An Enumerator.
131
+ def list_all(email_id, query: nil, timeout: nil)
132
+ HttpClient.paginate(query, "has_more") { |page| list(email_id, query: page, timeout: timeout) }
133
+ end
134
+
135
+ # GET /emails/{email_id}/attachments/{attachment_id}: Retrieve one attachment of a sent email
136
+ def get(email_id, attachment_id, timeout: nil)
137
+ @http.request("GET", "/emails/#{HttpClient.segment(email_id)}/attachments/#{HttpClient.segment(attachment_id)}", timeout: timeout)
138
+ end
139
+ end
140
+
141
+ # client.emails.receiving
142
+ class EmailsReceiving
143
+ attr_reader :attachments
144
+
145
+ def initialize(http)
146
+ @http = http
147
+ @attachments = EmailsReceivingAttachments.new(http)
148
+ end
149
+
150
+ # GET /emails/receiving: List received emails
151
+ def list(query: nil, timeout: nil)
152
+ @http.request("GET", "/emails/receiving", query: query, timeout: timeout)
153
+ end
154
+
155
+ # Every item of list, a page at a time, passing the last item's id as after. An Enumerator.
156
+ def list_all(query: nil, timeout: nil)
157
+ HttpClient.paginate(query, "has_more") { |page| list(query: page, timeout: timeout) }
158
+ end
159
+
160
+ # GET /emails/receiving/{email_id}: Retrieve a received email
161
+ def get(email_id, timeout: nil)
162
+ @http.request("GET", "/emails/receiving/#{HttpClient.segment(email_id)}", timeout: timeout)
163
+ end
164
+
165
+ # DELETE /emails/receiving/{email_id}: Delete a received email
166
+ def remove(email_id, timeout: nil)
167
+ @http.request("DELETE", "/emails/receiving/#{HttpClient.segment(email_id)}", timeout: timeout)
168
+ end
169
+ end
170
+
171
+ # client.emails.receiving.attachments
172
+ class EmailsReceivingAttachments
173
+ def initialize(http)
174
+ @http = http
175
+ end
176
+
177
+ # GET /emails/receiving/{email_id}/attachments: List the attachments of a received email
178
+ def list(email_id, query: nil, timeout: nil)
179
+ @http.request("GET", "/emails/receiving/#{HttpClient.segment(email_id)}/attachments", query: query, timeout: timeout)
180
+ end
181
+
182
+ # Every item of list, a page at a time, passing the last item's id as after. An Enumerator.
183
+ def list_all(email_id, query: nil, timeout: nil)
184
+ HttpClient.paginate(query, "has_more") { |page| list(email_id, query: page, timeout: timeout) }
185
+ end
186
+
187
+ # GET /emails/receiving/{email_id}/attachments/{attachment_id}: Retrieve one attachment of a received email
188
+ def get(email_id, attachment_id, timeout: nil)
189
+ @http.request("GET", "/emails/receiving/#{HttpClient.segment(email_id)}/attachments/#{HttpClient.segment(attachment_id)}", timeout: timeout)
190
+ end
191
+ end
192
+
193
+ # client.batch
194
+ class Batch
195
+ def initialize(http)
196
+ @http = http
197
+ end
198
+
199
+ # POST /emails/batch: Send up to 100 emails in one request. Takes idempotency_key:.
200
+ def send(body, idempotency_key: nil, timeout: nil)
201
+ @http.request("POST", "/emails/batch", body: body, has_body: true, idempotent: true, idempotency_key: idempotency_key, timeout: timeout)
202
+ end
203
+ end
204
+
205
+ # client.domains
206
+ class Domains
207
+ attr_reader :claims
208
+
209
+ def initialize(http)
210
+ @http = http
211
+ @claims = DomainsClaims.new(http)
212
+ end
213
+
214
+ # POST /domains: Add a sending domain and generate its DNS records
215
+ def create(body, timeout: nil)
216
+ @http.request("POST", "/domains", body: body, has_body: true, timeout: timeout)
217
+ end
218
+
219
+ # GET /domains/{domain_id}: One domain, with the current status of every record
220
+ def get(domain_id, timeout: nil)
221
+ @http.request("GET", "/domains/#{HttpClient.segment(domain_id)}", timeout: timeout)
222
+ end
223
+
224
+ # GET /domains: List the team's domains
225
+ def list(query: nil, timeout: nil)
226
+ @http.request("GET", "/domains", query: query, timeout: timeout)
227
+ end
228
+
229
+ # Every item of list, a page at a time, passing the last item's id as after. An Enumerator.
230
+ def list_all(query: nil, timeout: nil)
231
+ HttpClient.paginate(query, "has_more") { |page| list(query: page, timeout: timeout) }
232
+ end
233
+
234
+ # PATCH /domains/{domain_id}: Change tracking, TLS, capabilities, the tracking subdomain or the return path
235
+ def update(domain_id, body, timeout: nil)
236
+ @http.request("PATCH", "/domains/#{HttpClient.segment(domain_id)}", body: body, has_body: true, timeout: timeout)
237
+ end
238
+
239
+ # DELETE /domains/{domain_id}: Delete a domain
240
+ def remove(domain_id, timeout: nil)
241
+ @http.request("DELETE", "/domains/#{HttpClient.segment(domain_id)}", timeout: timeout)
242
+ end
243
+
244
+ # POST /domains/{domain_id}/verify: Check this domain's DNS records now
245
+ def verify(domain_id, timeout: nil)
246
+ @http.request("POST", "/domains/#{HttpClient.segment(domain_id)}/verify", timeout: timeout)
247
+ end
248
+
249
+ # GET /domains/{domain_id}/records: Compare a domain's DNS records with what DNS answered
250
+ def records(domain_id, timeout: nil)
251
+ @http.request("GET", "/domains/#{HttpClient.segment(domain_id)}/records", timeout: timeout)
252
+ end
253
+
254
+ # POST /domains/{domain_id}/dkim/regenerate: Generate a new DKIM keypair for this domain
255
+ def regenerate_dkim(domain_id, body, timeout: nil)
256
+ @http.request("POST", "/domains/#{HttpClient.segment(domain_id)}/dkim/regenerate", body: body, has_body: true, timeout: timeout)
257
+ end
258
+
259
+ # POST /domains/{domain_id}/setup-link: Create a setup link for whoever runs this domain's DNS
260
+ def create_setup_link(domain_id, timeout: nil)
261
+ @http.request("POST", "/domains/#{HttpClient.segment(domain_id)}/setup-link", timeout: timeout)
262
+ end
263
+
264
+ # POST /domains/{domain_id}/setup-link/send: Email this domain's setup link to whoever runs its DNS
265
+ def send_setup_link(domain_id, body, timeout: nil)
266
+ @http.request("POST", "/domains/#{HttpClient.segment(domain_id)}/setup-link/send", body: body, has_body: true, timeout: timeout)
267
+ end
268
+
269
+ # POST /domains/{domain_id}/autoconfigure: Publish this domain's DNS records through its provider
270
+ def autoconfigure(domain_id, body, timeout: nil)
271
+ @http.request("POST", "/domains/#{HttpClient.segment(domain_id)}/autoconfigure", body: body, has_body: true, timeout: timeout)
272
+ end
273
+
274
+ # POST /domains/{domain_id}/logo: Upload this domain's brand logo
275
+ def upload_logo(domain_id, body, timeout: nil)
276
+ @http.request("POST", "/domains/#{HttpClient.segment(domain_id)}/logo", body: body, has_body: true, timeout: timeout)
277
+ end
278
+
279
+ # DELETE /domains/{domain_id}/logo: Remove this domain's brand logo
280
+ def remove_logo(domain_id, timeout: nil)
281
+ @http.request("DELETE", "/domains/#{HttpClient.segment(domain_id)}/logo", timeout: timeout)
282
+ end
283
+
284
+ # GET /domains/{domain_id}/logo/certificate: Read this domain's brand certificate
285
+ def get_certificate(domain_id, timeout: nil)
286
+ @http.request("GET", "/domains/#{HttpClient.segment(domain_id)}/logo/certificate", timeout: timeout)
287
+ end
288
+
289
+ # POST /domains/{domain_id}/logo/certificate: Create a certificate signing request
290
+ def request_certificate(domain_id, body, timeout: nil)
291
+ @http.request("POST", "/domains/#{HttpClient.segment(domain_id)}/logo/certificate", body: body, has_body: true, timeout: timeout)
292
+ end
293
+
294
+ # PATCH /domains/{domain_id}/logo/certificate: Install the issued certificate
295
+ def install_certificate(domain_id, body, timeout: nil)
296
+ @http.request("PATCH", "/domains/#{HttpClient.segment(domain_id)}/logo/certificate", body: body, has_body: true, timeout: timeout)
297
+ end
298
+
299
+ # DELETE /domains/{domain_id}/logo/certificate: Remove this domain's brand certificate
300
+ def remove_certificate(domain_id, timeout: nil)
301
+ @http.request("DELETE", "/domains/#{HttpClient.segment(domain_id)}/logo/certificate", timeout: timeout)
302
+ end
303
+
304
+ # DELETE /domains/{domain_id}/autoconfigure/credential: Revoke the stored DNS provider credential
305
+ def remove_autoconfigure_credential(domain_id, timeout: nil)
306
+ @http.request("DELETE", "/domains/#{HttpClient.segment(domain_id)}/autoconfigure/credential", timeout: timeout)
307
+ end
308
+ end
309
+
310
+ # client.domains.claims
311
+ class DomainsClaims
312
+ def initialize(http)
313
+ @http = http
314
+ end
315
+
316
+ # POST /domains/claim: Claim a domain another team has verified
317
+ def create(body, timeout: nil)
318
+ @http.request("POST", "/domains/claim", body: body, has_body: true, timeout: timeout)
319
+ end
320
+
321
+ # GET /domains/{domain_id}/claim: The latest claim for a domain
322
+ def get(domain_id, timeout: nil)
323
+ @http.request("GET", "/domains/#{HttpClient.segment(domain_id)}/claim", timeout: timeout)
324
+ end
325
+
326
+ # POST /domains/{domain_id}/claim/verify: Check a claim's ownership TXT record
327
+ def verify(domain_id, timeout: nil)
328
+ @http.request("POST", "/domains/#{HttpClient.segment(domain_id)}/claim/verify", timeout: timeout)
329
+ end
330
+ end
331
+
332
+ # client.webhooks
333
+ class Webhooks
334
+ attr_reader :events, :attempts, :parked
335
+
336
+ def initialize(http)
337
+ @http = http
338
+ @events = WebhooksEvents.new(http)
339
+ @attempts = WebhooksAttempts.new(http)
340
+ @parked = WebhooksParked.new(http)
341
+ end
342
+
343
+ # POST /webhooks: Create a webhook endpoint and return its signing secret once
344
+ def create(body, timeout: nil)
345
+ @http.request("POST", "/webhooks", body: body, has_body: true, timeout: timeout)
346
+ end
347
+
348
+ # GET /webhooks/{webhook_id}: Read one webhook endpoint
349
+ def get(webhook_id, timeout: nil)
350
+ @http.request("GET", "/webhooks/#{HttpClient.segment(webhook_id)}", timeout: timeout)
351
+ end
352
+
353
+ # GET /webhooks: List the team's webhook endpoints
354
+ def list(query: nil, timeout: nil)
355
+ @http.request("GET", "/webhooks", query: query, timeout: timeout)
356
+ end
357
+
358
+ # Every item of list, a page at a time, passing the last item's id as after. An Enumerator.
359
+ def list_all(query: nil, timeout: nil)
360
+ HttpClient.paginate(query, "has_more") { |page| list(query: page, timeout: timeout) }
361
+ end
362
+
363
+ # PATCH /webhooks/{webhook_id}: Change the endpoint, its subscriptions or its status
364
+ def update(webhook_id, body, timeout: nil)
365
+ @http.request("PATCH", "/webhooks/#{HttpClient.segment(webhook_id)}", body: body, has_body: true, timeout: timeout)
366
+ end
367
+
368
+ # DELETE /webhooks/{webhook_id}: Delete a webhook endpoint
369
+ def remove(webhook_id, timeout: nil)
370
+ @http.request("DELETE", "/webhooks/#{HttpClient.segment(webhook_id)}", timeout: timeout)
371
+ end
372
+
373
+ # POST /webhooks/{webhook_id}/rotate-secret: Rotate the signing secret, keeping the previous one valid for 24 hours
374
+ def rotate_secret(webhook_id, timeout: nil)
375
+ @http.request("POST", "/webhooks/#{HttpClient.segment(webhook_id)}/rotate-secret", timeout: timeout)
376
+ end
377
+
378
+ # Verify a webhook delivery's signature locally and return its payload: Rasket::Webhooks.verify.
379
+ def verify(raw_body, headers, secret, now: nil)
380
+ Webhooks.verify(raw_body, headers, secret, now: now)
381
+ end
382
+ end
383
+
384
+ # client.webhooks.events
385
+ class WebhooksEvents
386
+ def initialize(http)
387
+ @http = http
388
+ end
389
+
390
+ # GET /webhooks/{webhook_id}/events: List the events created for one endpoint
391
+ def list(webhook_id, query: nil, timeout: nil)
392
+ @http.request("GET", "/webhooks/#{HttpClient.segment(webhook_id)}/events", query: query, timeout: timeout)
393
+ end
394
+
395
+ # Every item of list, a page at a time, passing the last item's id as after. An Enumerator.
396
+ def list_all(webhook_id, query: nil, timeout: nil)
397
+ HttpClient.paginate(query, "has_more") { |page| list(webhook_id, query: page, timeout: timeout) }
398
+ end
399
+
400
+ # GET /webhooks/{webhook_id}/events/{event_id}: Read one event, with its payload and its schedule
401
+ def get(webhook_id, event_id, timeout: nil)
402
+ @http.request("GET", "/webhooks/#{HttpClient.segment(webhook_id)}/events/#{HttpClient.segment(event_id)}", timeout: timeout)
403
+ end
404
+
405
+ # POST /webhooks/{webhook_id}/events/{event_id}/replay: Deliver one event again
406
+ def replay(webhook_id, event_id, timeout: nil)
407
+ @http.request("POST", "/webhooks/#{HttpClient.segment(webhook_id)}/events/#{HttpClient.segment(event_id)}/replay", timeout: timeout)
408
+ end
409
+ end
410
+
411
+ # client.webhooks.attempts
412
+ class WebhooksAttempts
413
+ def initialize(http)
414
+ @http = http
415
+ end
416
+
417
+ # GET /webhooks/{webhook_id}/events/{event_id}/attempts: List every delivery attempt made for one event
418
+ def list(webhook_id, event_id, timeout: nil)
419
+ @http.request("GET", "/webhooks/#{HttpClient.segment(webhook_id)}/events/#{HttpClient.segment(event_id)}/attempts", timeout: timeout)
420
+ end
421
+ end
422
+
423
+ # client.webhooks.parked
424
+ class WebhooksParked
425
+ def initialize(http)
426
+ @http = http
427
+ end
428
+
429
+ # GET /webhooks/{webhook_id}/parked: List the events parked while the endpoint was disabled
430
+ def list(webhook_id, query: nil, timeout: nil)
431
+ @http.request("GET", "/webhooks/#{HttpClient.segment(webhook_id)}/parked", query: query, timeout: timeout)
432
+ end
433
+
434
+ # POST /webhooks/{webhook_id}/parked/deliver: Deliver the events parked while the endpoint was disabled
435
+ def deliver(webhook_id, timeout: nil)
436
+ @http.request("POST", "/webhooks/#{HttpClient.segment(webhook_id)}/parked/deliver", timeout: timeout)
437
+ end
438
+ end
439
+
440
+ # client.suppressions
441
+ class Suppressions
442
+ attr_reader :batch
443
+
444
+ def initialize(http)
445
+ @http = http
446
+ @batch = SuppressionsBatch.new(http)
447
+ end
448
+
449
+ # POST /suppressions: Suppress an email address or a phone
450
+ def create(body, timeout: nil)
451
+ @http.request("POST", "/suppressions", body: body, has_body: true, timeout: timeout)
452
+ end
453
+
454
+ # GET /suppressions/{suppression}: Retrieve a suppression by ID or email address
455
+ def get(suppression, timeout: nil)
456
+ @http.request("GET", "/suppressions/#{HttpClient.segment(suppression)}", timeout: timeout)
457
+ end
458
+
459
+ # GET /suppressions: List suppressions
460
+ def list(query: nil, timeout: nil)
461
+ @http.request("GET", "/suppressions", query: query, timeout: timeout)
462
+ end
463
+
464
+ # Every item of list, a page at a time, passing the last item's id as after. An Enumerator.
465
+ def list_all(query: nil, timeout: nil)
466
+ HttpClient.paginate(query, "has_more") { |page| list(query: page, timeout: timeout) }
467
+ end
468
+
469
+ # DELETE /suppressions/{suppression}: Remove a suppression by ID or email address
470
+ def remove(suppression, timeout: nil)
471
+ @http.request("DELETE", "/suppressions/#{HttpClient.segment(suppression)}", timeout: timeout)
472
+ end
473
+ end
474
+
475
+ # client.suppressions.batch
476
+ class SuppressionsBatch
477
+ def initialize(http)
478
+ @http = http
479
+ end
480
+
481
+ # POST /suppressions/batch/add: Add up to 100 suppressions at once
482
+ def add(body, timeout: nil)
483
+ @http.request("POST", "/suppressions/batch/add", body: body, has_body: true, timeout: timeout)
484
+ end
485
+
486
+ # POST /suppressions/batch/remove: Remove up to 100 suppressions at once
487
+ def remove(body, timeout: nil)
488
+ @http.request("POST", "/suppressions/batch/remove", body: body, has_body: true, timeout: timeout)
489
+ end
490
+ end
491
+
492
+ # client.contacts
493
+ class Contacts
494
+ attr_reader :properties, :segments, :topics, :consent, :imports, :verifications, :sms_consent
495
+
496
+ def initialize(http)
497
+ @http = http
498
+ @properties = ContactsProperties.new(http)
499
+ @segments = ContactsSegments.new(http)
500
+ @topics = ContactsTopics.new(http)
501
+ @consent = ContactsConsent.new(http)
502
+ @imports = ContactsImports.new(http)
503
+ @verifications = ContactsVerifications.new(http)
504
+ @sms_consent = ContactsSmsConsent.new(http)
505
+ end
506
+
507
+ # POST /contacts: Create a new contact
508
+ def create(body, timeout: nil)
509
+ @http.request("POST", "/contacts", body: body, has_body: true, timeout: timeout)
510
+ end
511
+
512
+ # GET /contacts/{contact}: Retrieve a single contact by ID or email
513
+ def get(contact, timeout: nil)
514
+ @http.request("GET", "/contacts/#{HttpClient.segment(contact)}", timeout: timeout)
515
+ end
516
+
517
+ # GET /contacts: Retrieve a list of contacts
518
+ def list(query: nil, timeout: nil)
519
+ @http.request("GET", "/contacts", query: query, timeout: timeout)
520
+ end
521
+
522
+ # Every item of list, a page at a time, passing the last item's id as after. An Enumerator.
523
+ def list_all(query: nil, timeout: nil)
524
+ HttpClient.paginate(query, "empty_page") { |page| list(query: page, timeout: timeout) }
525
+ end
526
+
527
+ # PATCH /contacts/{contact}: Update a single contact by ID or email
528
+ def update(contact, body, timeout: nil)
529
+ @http.request("PATCH", "/contacts/#{HttpClient.segment(contact)}", body: body, has_body: true, timeout: timeout)
530
+ end
531
+
532
+ # DELETE /contacts/{contact}: Remove an existing contact by ID or email
533
+ def remove(contact, timeout: nil)
534
+ @http.request("DELETE", "/contacts/#{HttpClient.segment(contact)}", timeout: timeout)
535
+ end
536
+ end
537
+
538
+ # client.contacts.properties
539
+ class ContactsProperties
540
+ def initialize(http)
541
+ @http = http
542
+ end
543
+
544
+ # POST /contact-properties: Create a new contact property
545
+ def create(body, timeout: nil)
546
+ @http.request("POST", "/contact-properties", body: body, has_body: true, timeout: timeout)
547
+ end
548
+
549
+ # GET /contact-properties/{contact_property_id}: Retrieve a single contact property
550
+ def get(contact_property_id, timeout: nil)
551
+ @http.request("GET", "/contact-properties/#{HttpClient.segment(contact_property_id)}", timeout: timeout)
552
+ end
553
+
554
+ # GET /contact-properties: Retrieve a list of contact properties
555
+ def list(query: nil, timeout: nil)
556
+ @http.request("GET", "/contact-properties", query: query, timeout: timeout)
557
+ end
558
+
559
+ # Every item of list, a page at a time, passing the last item's id as after. An Enumerator.
560
+ def list_all(query: nil, timeout: nil)
561
+ HttpClient.paginate(query, "has_more") { |page| list(query: page, timeout: timeout) }
562
+ end
563
+
564
+ # PATCH /contact-properties/{contact_property_id}: Update an existing contact property
565
+ def update(contact_property_id, body, timeout: nil)
566
+ @http.request("PATCH", "/contact-properties/#{HttpClient.segment(contact_property_id)}", body: body, has_body: true, timeout: timeout)
567
+ end
568
+
569
+ # DELETE /contact-properties/{contact_property_id}: Remove an existing contact property
570
+ def remove(contact_property_id, timeout: nil)
571
+ @http.request("DELETE", "/contact-properties/#{HttpClient.segment(contact_property_id)}", timeout: timeout)
572
+ end
573
+ end
574
+
575
+ # client.contacts.segments
576
+ class ContactsSegments
577
+ def initialize(http)
578
+ @http = http
579
+ end
580
+
581
+ # GET /contacts/{contact}/segments: Retrieve a list of segments for a contact
582
+ def list(contact, query: nil, timeout: nil)
583
+ @http.request("GET", "/contacts/#{HttpClient.segment(contact)}/segments", query: query, timeout: timeout)
584
+ end
585
+
586
+ # Every item of list, a page at a time, passing the last item's id as after. An Enumerator.
587
+ def list_all(contact, query: nil, timeout: nil)
588
+ HttpClient.paginate(query, "has_more") { |page| list(contact, query: page, timeout: timeout) }
589
+ end
590
+
591
+ # POST /contacts/{contact}/segments/{segment}: Add a contact to a segment
592
+ def add(contact, segment, timeout: nil)
593
+ @http.request("POST", "/contacts/#{HttpClient.segment(contact)}/segments/#{HttpClient.segment(segment)}", timeout: timeout)
594
+ end
595
+
596
+ # DELETE /contacts/{contact}/segments/{segment}: Remove a contact from a segment
597
+ def remove(contact, segment, timeout: nil)
598
+ @http.request("DELETE", "/contacts/#{HttpClient.segment(contact)}/segments/#{HttpClient.segment(segment)}", timeout: timeout)
599
+ end
600
+ end
601
+
602
+ # client.contacts.topics
603
+ class ContactsTopics
604
+ def initialize(http)
605
+ @http = http
606
+ end
607
+
608
+ # GET /contacts/{contact_id}/topics: Retrieve topics for a contact
609
+ def list(contact_id, query: nil, timeout: nil)
610
+ @http.request("GET", "/contacts/#{HttpClient.segment(contact_id)}/topics", query: query, timeout: timeout)
611
+ end
612
+
613
+ # Every item of list, a page at a time, passing the last item's id as after. An Enumerator.
614
+ def list_all(contact_id, query: nil, timeout: nil)
615
+ HttpClient.paginate(query, "has_more") { |page| list(contact_id, query: page, timeout: timeout) }
616
+ end
617
+
618
+ # PATCH /contacts/{contact_id}/topics: Update topics for a contact
619
+ def update(contact_id, body, timeout: nil)
620
+ @http.request("PATCH", "/contacts/#{HttpClient.segment(contact_id)}/topics", body: body, has_body: true, timeout: timeout)
621
+ end
622
+ end
623
+
624
+ # client.contacts.consent
625
+ class ContactsConsent
626
+ def initialize(http)
627
+ @http = http
628
+ end
629
+
630
+ # GET /contacts/{contact_id}/consent: Retrieve consent history for a contact
631
+ def list(contact_id, query: nil, timeout: nil)
632
+ @http.request("GET", "/contacts/#{HttpClient.segment(contact_id)}/consent", query: query, timeout: timeout)
633
+ end
634
+
635
+ # Every item of list, a page at a time, passing the last item's id as after. An Enumerator.
636
+ def list_all(contact_id, query: nil, timeout: nil)
637
+ HttpClient.paginate(query, "has_more") { |page| list(contact_id, query: page, timeout: timeout) }
638
+ end
639
+ end
640
+
641
+ # client.contacts.imports
642
+ class ContactsImports
643
+ def initialize(http)
644
+ @http = http
645
+ end
646
+
647
+ # POST /contacts/imports: Create a contact import
648
+ def create(body, timeout: nil)
649
+ @http.request("POST", "/contacts/imports", body: body, has_body: true, file_fields: %w[file], timeout: timeout)
650
+ end
651
+
652
+ # GET /contacts/imports: Retrieve a list of contact imports
653
+ def list(query: nil, timeout: nil)
654
+ @http.request("GET", "/contacts/imports", query: query, timeout: timeout)
655
+ end
656
+
657
+ # Every item of list, a page at a time, passing the last item's id as after. An Enumerator.
658
+ def list_all(query: nil, timeout: nil)
659
+ HttpClient.paginate(query, "has_more") { |page| list(query: page, timeout: timeout) }
660
+ end
661
+
662
+ # GET /contacts/imports/{id}: Retrieve a single contact import
663
+ def get(import_id, timeout: nil)
664
+ @http.request("GET", "/contacts/imports/#{HttpClient.segment(import_id)}", timeout: timeout)
665
+ end
666
+ end
667
+
668
+ # client.contacts.verifications
669
+ class ContactsVerifications
670
+ def initialize(http)
671
+ @http = http
672
+ end
673
+
674
+ # POST /contacts/verifications/estimate: Estimate verifying a list
675
+ def estimate(body, timeout: nil)
676
+ @http.request("POST", "/contacts/verifications/estimate", body: body, has_body: true, timeout: timeout)
677
+ end
678
+
679
+ # POST /contacts/verifications: Verify a list. Takes idempotency_key:.
680
+ def create(body, idempotency_key: nil, timeout: nil)
681
+ @http.request("POST", "/contacts/verifications", body: body, has_body: true, idempotent: true, idempotency_key: idempotency_key, timeout: timeout)
682
+ end
683
+
684
+ # GET /contacts/verifications/{id}: Retrieve a list verification
685
+ def get(verification_id, timeout: nil)
686
+ @http.request("GET", "/contacts/verifications/#{HttpClient.segment(verification_id)}", timeout: timeout)
687
+ end
688
+
689
+ # DELETE /contacts/verifications/{id}/invalid-contacts: Delete a verified list's invalid contacts
690
+ def remove_invalid(verification_id, timeout: nil)
691
+ @http.request("DELETE", "/contacts/verifications/#{HttpClient.segment(verification_id)}/invalid-contacts", timeout: timeout)
692
+ end
693
+
694
+ # POST /contacts/verifications/{id}/tag-risky: Tag a verified list's risky contacts
695
+ def tag_risky(verification_id, timeout: nil)
696
+ @http.request("POST", "/contacts/verifications/#{HttpClient.segment(verification_id)}/tag-risky", timeout: timeout)
697
+ end
698
+ end
699
+
700
+ # client.contacts.sms_consent
701
+ class ContactsSmsConsent
702
+ def initialize(http)
703
+ @http = http
704
+ end
705
+
706
+ # PATCH /contacts/{contact_id}/sms-consent: Set a contact's consent to marketing texts
707
+ def update(contact_id, body, timeout: nil)
708
+ @http.request("PATCH", "/contacts/#{HttpClient.segment(contact_id)}/sms-consent", body: body, has_body: true, timeout: timeout)
709
+ end
710
+ end
711
+
712
+ # client.segments
713
+ class Segments
714
+ def initialize(http)
715
+ @http = http
716
+ end
717
+
718
+ # POST /segments: Create a new segment
719
+ def create(body, timeout: nil)
720
+ @http.request("POST", "/segments", body: body, has_body: true, timeout: timeout)
721
+ end
722
+
723
+ # GET /segments/{segment}: Retrieve a single segment
724
+ def get(segment, timeout: nil)
725
+ @http.request("GET", "/segments/#{HttpClient.segment(segment)}", timeout: timeout)
726
+ end
727
+
728
+ # GET /segments: Retrieve a list of segments
729
+ def list(query: nil, timeout: nil)
730
+ @http.request("GET", "/segments", query: query, timeout: timeout)
731
+ end
732
+
733
+ # Every item of list, a page at a time, passing the last item's id as after. An Enumerator.
734
+ def list_all(query: nil, timeout: nil)
735
+ HttpClient.paginate(query, "has_more") { |page| list(query: page, timeout: timeout) }
736
+ end
737
+
738
+ # PATCH /segments/{segment}: Update an existing segment
739
+ def update(segment, body, timeout: nil)
740
+ @http.request("PATCH", "/segments/#{HttpClient.segment(segment)}", body: body, has_body: true, timeout: timeout)
741
+ end
742
+
743
+ # DELETE /segments/{segment}: Remove an existing segment
744
+ def remove(segment, timeout: nil)
745
+ @http.request("DELETE", "/segments/#{HttpClient.segment(segment)}", timeout: timeout)
746
+ end
747
+
748
+ # GET /segments/{segment}/contacts: Retrieve the contacts in a segment
749
+ def contacts(segment, query: nil, timeout: nil)
750
+ @http.request("GET", "/segments/#{HttpClient.segment(segment)}/contacts", query: query, timeout: timeout)
751
+ end
752
+
753
+ # Every item of contacts, a page at a time, passing the last item's id as after. An Enumerator.
754
+ def contacts_all(segment, query: nil, timeout: nil)
755
+ HttpClient.paginate(query, "has_more") { |page| contacts(segment, query: page, timeout: timeout) }
756
+ end
757
+
758
+ # POST /segments/{segment}/contacts/batch/add: Add up to 100 contacts to a segment
759
+ def add_contacts(segment, body, timeout: nil)
760
+ @http.request("POST", "/segments/#{HttpClient.segment(segment)}/contacts/batch/add", body: body, has_body: true, timeout: timeout)
761
+ end
762
+
763
+ # POST /segments/{segment}/contacts/batch/remove: Remove up to 100 contacts from a segment
764
+ def remove_contacts(segment, body, timeout: nil)
765
+ @http.request("POST", "/segments/#{HttpClient.segment(segment)}/contacts/batch/remove", body: body, has_body: true, timeout: timeout)
766
+ end
767
+
768
+ # GET /segments/{segment}/metrics: Retrieve the size of a segment
769
+ def metrics(segment, timeout: nil)
770
+ @http.request("GET", "/segments/#{HttpClient.segment(segment)}/metrics", timeout: timeout)
771
+ end
772
+
773
+ # POST /segments/preview: Count the contacts a filter matches
774
+ def preview(body, timeout: nil)
775
+ @http.request("POST", "/segments/preview", body: body, has_body: true, timeout: timeout)
776
+ end
777
+ end
778
+
779
+ # client.broadcasts
780
+ class Broadcasts
781
+ def initialize(http)
782
+ @http = http
783
+ end
784
+
785
+ # POST /broadcasts: Create a broadcast
786
+ def create(body, timeout: nil)
787
+ @http.request("POST", "/broadcasts", body: body, has_body: true, timeout: timeout)
788
+ end
789
+
790
+ # GET /broadcasts/{id}: Retrieve a single broadcast
791
+ def get(broadcast_id, timeout: nil)
792
+ @http.request("GET", "/broadcasts/#{HttpClient.segment(broadcast_id)}", timeout: timeout)
793
+ end
794
+
795
+ # GET /broadcasts: Retrieve a list of broadcasts
796
+ def list(query: nil, timeout: nil)
797
+ @http.request("GET", "/broadcasts", query: query, timeout: timeout)
798
+ end
799
+
800
+ # Every item of list, a page at a time, passing the last item's id as after. An Enumerator.
801
+ def list_all(query: nil, timeout: nil)
802
+ HttpClient.paginate(query, "has_more") { |page| list(query: page, timeout: timeout) }
803
+ end
804
+
805
+ # PATCH /broadcasts/{id}: Update an existing broadcast
806
+ def update(broadcast_id, body, timeout: nil)
807
+ @http.request("PATCH", "/broadcasts/#{HttpClient.segment(broadcast_id)}", body: body, has_body: true, timeout: timeout)
808
+ end
809
+
810
+ # DELETE /broadcasts/{id}: Remove an existing broadcast that is in the draft status
811
+ def remove(broadcast_id, timeout: nil)
812
+ @http.request("DELETE", "/broadcasts/#{HttpClient.segment(broadcast_id)}", timeout: timeout)
813
+ end
814
+
815
+ # POST /broadcasts/{id}/send: Send or schedule a broadcast
816
+ def send(broadcast_id, body = nil, timeout: nil)
817
+ @http.request("POST", "/broadcasts/#{HttpClient.segment(broadcast_id)}/send", body: body, has_body: !body.nil?, timeout: timeout)
818
+ end
819
+
820
+ # POST /broadcasts/{id}/cancel: Cancel a broadcast
821
+ def cancel(broadcast_id, timeout: nil)
822
+ @http.request("POST", "/broadcasts/#{HttpClient.segment(broadcast_id)}/cancel", timeout: timeout)
823
+ end
824
+
825
+ # GET /broadcasts/{id}/recipients: Retrieve broadcast recipients
826
+ def recipients(broadcast_id, query:, timeout: nil)
827
+ @http.request("GET", "/broadcasts/#{HttpClient.segment(broadcast_id)}/recipients", query: query, timeout: timeout)
828
+ end
829
+
830
+ # Every item of recipients, a page at a time, passing the last item's id as after. An Enumerator.
831
+ def recipients_all(broadcast_id, query: nil, timeout: nil)
832
+ HttpClient.paginate(query, "has_more") { |page| recipients(broadcast_id, query: page, timeout: timeout) }
833
+ end
834
+
835
+ # GET /broadcasts/{id}/clicked-links: Retrieve a broadcast's clicked links
836
+ def clicked_links(broadcast_id, query: nil, timeout: nil)
837
+ @http.request("GET", "/broadcasts/#{HttpClient.segment(broadcast_id)}/clicked-links", query: query, timeout: timeout)
838
+ end
839
+
840
+ # Every item of clicked_links, a page at a time, passing the last item's id as after. An Enumerator.
841
+ def clicked_links_all(broadcast_id, query: nil, timeout: nil)
842
+ HttpClient.paginate(query, "has_more") { |page| clicked_links(broadcast_id, query: page, timeout: timeout) }
843
+ end
844
+
845
+ # GET /broadcasts/{id}/checklist: Check what would stop a broadcast from sending
846
+ def checklist(broadcast_id, timeout: nil)
847
+ @http.request("GET", "/broadcasts/#{HttpClient.segment(broadcast_id)}/checklist", timeout: timeout)
848
+ end
849
+
850
+ # POST /broadcasts/{id}/checks: Check a broadcast's content before sending
851
+ def checks(broadcast_id, timeout: nil)
852
+ @http.request("POST", "/broadcasts/#{HttpClient.segment(broadcast_id)}/checks", timeout: timeout)
853
+ end
854
+
855
+ # POST /broadcasts/{id}/duplicate: Duplicate a broadcast
856
+ def duplicate(broadcast_id, timeout: nil)
857
+ @http.request("POST", "/broadcasts/#{HttpClient.segment(broadcast_id)}/duplicate", timeout: timeout)
858
+ end
859
+
860
+ # POST /broadcasts/{id}/save-as-template: Save a broadcast as a template
861
+ def save_as_template(broadcast_id, timeout: nil)
862
+ @http.request("POST", "/broadcasts/#{HttpClient.segment(broadcast_id)}/save-as-template", timeout: timeout)
863
+ end
864
+
865
+ # POST /broadcasts/{id}/test: Send a test of a broadcast. Takes idempotency_key:.
866
+ def send_test(broadcast_id, body, idempotency_key: nil, timeout: nil)
867
+ @http.request("POST", "/broadcasts/#{HttpClient.segment(broadcast_id)}/test", body: body, has_body: true, idempotent: true, idempotency_key: idempotency_key, timeout: timeout)
868
+ end
869
+ end
870
+ end
871
+ end