unitpost 0.1.0 → 0.3.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.
@@ -7,7 +7,7 @@ module Unitpost
7
7
  # Resource surface — the hand-written, ergonomic layer (our own style).
8
8
  #
9
9
  # Each resource is a small class with explicit methods mirroring the Node and
10
- # Python SDKs (emails.send, contacts.list/create/get/update/delete, ...). The
10
+ # Python SDKs (email.send, email.templates.list, contacts.create, ...). The
11
11
  # codegen "surface coverage" check fails CI if a spec operation has no method
12
12
  # here. Every method returns a Unitpost::Result and never raises for an API
13
13
  # error. Bodies/params are plain Hashes.
@@ -46,12 +46,44 @@ module Unitpost
46
46
  end
47
47
  end
48
48
 
49
- class Emails < Base
49
+ class Sms < Base
50
+ # SMS channel (beta). Recipient must be E.164; marketing sends require
51
+ # prior express consent on record and honor recipient-local quiet hours.
52
+ # Billing is per segment. When no idempotency_key is given one is
53
+ # generated so a transient retry can't double-send.
54
+ def send(body, idempotency_key: nil)
55
+ @http.request("POST", "/sms", body: body, idempotency_key: idempotency_key || SecureRandom.uuid)
56
+ end
57
+
58
+ def get(id)
59
+ @http.request("GET", "/sms/#{enc(id)}")
60
+ end
61
+
62
+ def list(params = {})
63
+ @http.request("GET", "/sms", query: params)
64
+ end
65
+
66
+ def list_all(params = {})
67
+ paginate("/sms", params)
68
+ end
69
+ end
70
+
71
+ class Email < Base
72
+ attr_reader :topics, :campaigns, :templates, :domains
73
+
74
+ def initialize(http)
75
+ super
76
+ @topics = Topics.new(http)
77
+ @campaigns = Campaigns.new(http)
78
+ @templates = Templates.new(http)
79
+ @domains = Domains.new(http)
80
+ end
81
+
50
82
  # Send or schedule a transactional email. When no idempotency_key is
51
83
  # given the SDK generates one so a transient retry can't double-send; pass
52
84
  # your own to dedupe across separate send calls.
53
85
  def send(body, idempotency_key: nil)
54
- @http.request("POST", "/emails", body: body, idempotency_key: idempotency_key || SecureRandom.uuid)
86
+ @http.request("POST", "/email", body: body, idempotency_key: idempotency_key || SecureRandom.uuid)
55
87
  end
56
88
 
57
89
  # Send up to 100 emails in one request (all-or-nothing validation). Like
@@ -60,49 +92,49 @@ module Unitpost
60
92
  # replays the original result instead of re-sending. Pass your own to
61
93
  # dedupe across separate batch calls.
62
94
  def batch(body, idempotency_key: nil)
63
- @http.request("POST", "/emails/batch", body: body, idempotency_key: idempotency_key || SecureRandom.uuid)
95
+ @http.request("POST", "/email/batch", body: body, idempotency_key: idempotency_key || SecureRandom.uuid)
64
96
  end
65
97
 
66
98
  def get_batch(id)
67
- @http.request("GET", "/emails/batches/#{enc(id)}")
99
+ @http.request("GET", "/email/batches/#{enc(id)}")
68
100
  end
69
101
 
70
102
  def cancel_batch(id)
71
- @http.request("POST", "/emails/batches/#{enc(id)}/cancel")
103
+ @http.request("POST", "/email/batches/#{enc(id)}/cancel")
72
104
  end
73
105
 
74
106
  def list(limit: nil, after: nil, before: nil, **filters)
75
- @http.request("GET", "/emails", query: list_params(limit: limit, after: after, before: before, **filters))
107
+ @http.request("GET", "/email", query: list_params(limit: limit, after: after, before: before, **filters))
76
108
  end
77
109
 
78
110
  def list_all(**params)
79
- paginate("/emails", params)
111
+ paginate("/email", params)
80
112
  end
81
113
 
82
114
  def get(id)
83
- @http.request("GET", "/emails/#{enc(id)}")
115
+ @http.request("GET", "/email/#{enc(id)}")
84
116
  end
85
117
 
86
118
  def update(id, body)
87
- @http.request("PATCH", "/emails/#{enc(id)}", body: body)
119
+ @http.request("PATCH", "/email/#{enc(id)}", body: body)
88
120
  end
89
121
 
90
122
  # Deliverability/engagement aggregates over a rolling window (days: 1–365,
91
123
  # defaults to 30 server-side).
92
124
  def stats(days: nil)
93
- @http.request("GET", "/emails/stats", query: { days: days })
125
+ @http.request("GET", "/email/stats", query: { days: days })
94
126
  end
95
127
 
96
128
  def received_list(limit: nil, after: nil, before: nil)
97
- @http.request("GET", "/emails/received", query: list_params(limit: limit, after: after, before: before))
129
+ @http.request("GET", "/email/received", query: list_params(limit: limit, after: after, before: before))
98
130
  end
99
131
 
100
132
  def received_get(id)
101
- @http.request("GET", "/emails/received/#{enc(id)}")
133
+ @http.request("GET", "/email/received/#{enc(id)}")
102
134
  end
103
135
 
104
136
  def received_attachment_url(id, attachment_id)
105
- @http.request("GET", "/emails/received/#{enc(id)}/attachments/#{enc(attachment_id)}")
137
+ @http.request("GET", "/email/received/#{enc(id)}/attachments/#{enc(attachment_id)}")
106
138
  end
107
139
  end
108
140
 
@@ -214,27 +246,27 @@ module Unitpost
214
246
 
215
247
  class Topics < Base
216
248
  def list(limit: nil, after: nil, before: nil)
217
- @http.request("GET", "/topics", query: list_params(limit: limit, after: after, before: before))
249
+ @http.request("GET", "/email/topics", query: list_params(limit: limit, after: after, before: before))
218
250
  end
219
251
 
220
252
  def list_all(**params)
221
- paginate("/topics", params)
253
+ paginate("/email/topics", params)
222
254
  end
223
255
 
224
256
  def create(body)
225
- @http.request("POST", "/topics", body: body)
257
+ @http.request("POST", "/email/topics", body: body)
226
258
  end
227
259
 
228
260
  def get(id)
229
- @http.request("GET", "/topics/#{enc(id)}")
261
+ @http.request("GET", "/email/topics/#{enc(id)}")
230
262
  end
231
263
 
232
264
  def update(id, body)
233
- @http.request("PATCH", "/topics/#{enc(id)}", body: body)
265
+ @http.request("PATCH", "/email/topics/#{enc(id)}", body: body)
234
266
  end
235
267
 
236
268
  def delete(id)
237
- @http.request("DELETE", "/topics/#{enc(id)}")
269
+ @http.request("DELETE", "/email/topics/#{enc(id)}")
238
270
  end
239
271
 
240
272
  def list_topics(contact_id, limit: nil, after: nil, before: nil)
@@ -248,77 +280,77 @@ module Unitpost
248
280
 
249
281
  class Campaigns < Base
250
282
  def list(limit: nil, after: nil, before: nil)
251
- @http.request("GET", "/campaigns", query: list_params(limit: limit, after: after, before: before))
283
+ @http.request("GET", "/email/campaigns", query: list_params(limit: limit, after: after, before: before))
252
284
  end
253
285
 
254
286
  def list_all(**params)
255
- paginate("/campaigns", params)
287
+ paginate("/email/campaigns", params)
256
288
  end
257
289
 
258
290
  def create(body)
259
- @http.request("POST", "/campaigns", body: body)
291
+ @http.request("POST", "/email/campaigns", body: body)
260
292
  end
261
293
 
262
294
  def get(id)
263
- @http.request("GET", "/campaigns/#{enc(id)}")
295
+ @http.request("GET", "/email/campaigns/#{enc(id)}")
264
296
  end
265
297
 
266
298
  def update(id, body)
267
- @http.request("PATCH", "/campaigns/#{enc(id)}", body: body)
299
+ @http.request("PATCH", "/email/campaigns/#{enc(id)}", body: body)
268
300
  end
269
301
 
270
302
  def delete(id)
271
- @http.request("DELETE", "/campaigns/#{enc(id)}")
303
+ @http.request("DELETE", "/email/campaigns/#{enc(id)}")
272
304
  end
273
305
 
274
306
  def send(id)
275
- @http.request("POST", "/campaigns/#{enc(id)}/send")
307
+ @http.request("POST", "/email/campaigns/#{enc(id)}/send")
276
308
  end
277
309
 
278
310
  def cancel(id)
279
- @http.request("POST", "/campaigns/#{enc(id)}/cancel")
311
+ @http.request("POST", "/email/campaigns/#{enc(id)}/cancel")
280
312
  end
281
313
 
282
314
  def pause(id)
283
- @http.request("POST", "/campaigns/#{enc(id)}/pause")
315
+ @http.request("POST", "/email/campaigns/#{enc(id)}/pause")
284
316
  end
285
317
 
286
318
  def resume(id)
287
- @http.request("POST", "/campaigns/#{enc(id)}/resume")
319
+ @http.request("POST", "/email/campaigns/#{enc(id)}/resume")
288
320
  end
289
321
 
290
322
  def reschedule(id, body)
291
- @http.request("POST", "/campaigns/#{enc(id)}/reschedule", body: body)
323
+ @http.request("POST", "/email/campaigns/#{enc(id)}/reschedule", body: body)
292
324
  end
293
325
 
294
326
  def validate(id)
295
- @http.request("GET", "/campaigns/#{enc(id)}/validate")
327
+ @http.request("GET", "/email/campaigns/#{enc(id)}/validate")
296
328
  end
297
329
  end
298
330
 
299
331
  class Templates < Base
300
332
  def list(limit: nil, after: nil, before: nil)
301
- @http.request("GET", "/templates", query: list_params(limit: limit, after: after, before: before))
333
+ @http.request("GET", "/email/templates", query: list_params(limit: limit, after: after, before: before))
302
334
  end
303
335
 
304
336
  def list_all(**params)
305
- paginate("/templates", params)
337
+ paginate("/email/templates", params)
306
338
  end
307
339
 
308
340
  def create(body)
309
- @http.request("POST", "/templates", body: body)
341
+ @http.request("POST", "/email/templates", body: body)
310
342
  end
311
343
 
312
344
  def get(id)
313
- @http.request("GET", "/templates/#{enc(id)}")
345
+ @http.request("GET", "/email/templates/#{enc(id)}")
314
346
  end
315
347
 
316
348
  def update(id, body)
317
- @http.request("PATCH", "/templates/#{enc(id)}", body: body)
349
+ @http.request("PATCH", "/email/templates/#{enc(id)}", body: body)
318
350
  end
319
351
 
320
352
  def delete(id)
321
- @http.request("DELETE", "/templates/#{enc(id)}")
353
+ @http.request("DELETE", "/email/templates/#{enc(id)}")
322
354
  end
323
355
  end
324
356
 
@@ -337,31 +369,31 @@ module Unitpost
337
369
 
338
370
  class Domains < Base
339
371
  def list(limit: nil, after: nil, before: nil)
340
- @http.request("GET", "/domains", query: list_params(limit: limit, after: after, before: before))
372
+ @http.request("GET", "/email/domains", query: list_params(limit: limit, after: after, before: before))
341
373
  end
342
374
 
343
375
  def list_all(**params)
344
- paginate("/domains", params)
376
+ paginate("/email/domains", params)
345
377
  end
346
378
 
347
379
  def create(body)
348
- @http.request("POST", "/domains", body: body)
380
+ @http.request("POST", "/email/domains", body: body)
349
381
  end
350
382
 
351
383
  def get(id)
352
- @http.request("GET", "/domains/#{enc(id)}")
384
+ @http.request("GET", "/email/domains/#{enc(id)}")
353
385
  end
354
386
 
355
387
  def delete(id)
356
- @http.request("DELETE", "/domains/#{enc(id)}")
388
+ @http.request("DELETE", "/email/domains/#{enc(id)}")
357
389
  end
358
390
 
359
391
  def update(id, body)
360
- @http.request("PATCH", "/domains/#{enc(id)}", body: body)
392
+ @http.request("PATCH", "/email/domains/#{enc(id)}", body: body)
361
393
  end
362
394
 
363
395
  def verify(id)
364
- @http.request("POST", "/domains/#{enc(id)}/verify")
396
+ @http.request("POST", "/email/domains/#{enc(id)}/verify")
365
397
  end
366
398
  end
367
399
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Unitpost
4
- VERSION = "0.1.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unitpost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Unitpost
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-07-27 00:00:00.000000000 Z
11
+ date: 2026-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday