unitpost 0.3.0 → 0.5.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 +4 -4
- data/CHANGELOG.md +320 -0
- data/README.md +98 -13
- data/lib/unitpost/client.rb +19 -3
- data/lib/unitpost/errors.rb +5 -3
- data/lib/unitpost/generated/operations.rb +2784 -77
- data/lib/unitpost/generated/sms_models.rb +353 -0
- data/lib/unitpost/organization.rb +322 -0
- data/lib/unitpost/resources.rb +1330 -13
- data/lib/unitpost/version.rb +1 -1
- data/lib/unitpost.rb +1 -0
- metadata +19 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b9c30feb45d5c2c61b8864eceafaed89cd2e5c3a6772f38b82b6a66d172123c9
|
|
4
|
+
data.tar.gz: 75df846f78c581bc9f07324a27c07d4e83cc6c2c42a01a754e60b2b8aa6a94f4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9d8d63e1af38582e3f11f9db4007645b8ebd95a38e982b1cf94892969f6e8d15dcb47a296c6d1d3ca3e996aacb5f4c7b3c79996aec89c7f513b0c8f1b7466b08
|
|
7
|
+
data.tar.gz: 0b9296847df6c269fb17a1e5ea1b86de5efb8bdbdfbd7e04106db71b083be70217608537aad24e5b284646e3978a711b06a9496a0fa31f047004c9e0480e59e0
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Notable changes to the Unitpost Ruby SDK. Changes to the API itself (new
|
|
4
|
+
operations, new fields, behavior changes) are in the API changelog:
|
|
5
|
+
https://www.unitpost.com/docs/changelog.
|
|
6
|
+
|
|
7
|
+
To release, move the `Unreleased` items under a `## X.Y.Z` heading in the same
|
|
8
|
+
change that bumps the version (docs/sdk/RELEASING.md).
|
|
9
|
+
|
|
10
|
+
## Unreleased
|
|
11
|
+
|
|
12
|
+
## 0.5.0
|
|
13
|
+
|
|
14
|
+
- `Unitpost::OrganizationClient` gains `shared_plan`: `get`, `list_workspaces`, `add_workspace`, `update_workspace`, `remove_workspace` (the organization's shared plan; adding and removing take an optional `idempotency_key:`, or the SDK mints one). Reads need `organizations:read`; the three writes need `organizations:billing`. Buying, upgrading or ending the shared plan stays in the dashboard.
|
|
15
|
+
- SMS tags: `sms.send(..., tags: [{ name:, value: }])` (up to 10) and the `tag` filter on `sms.list(tag: ...)` / `sms.list_all(tag: ...)` (`tag` is `name:value`; several comma-separated must all match; received texts have none). The SMS object carries `tags` (`SmsTagsItem`).
|
|
16
|
+
- `Unitpost::OrganizationClient` iterators: `webhooks.list_all`, `webhooks.list_all_deliveries(webhook_id)` and `usage.list_all` (pages by `workspace_id`). The delivery log needs `organizations:write`.
|
|
17
|
+
- `spend_caps` (new, ADR-0172): the workspace's monthly spend caps. `get` reads the SMS-purchase cap, its `max_cents` and what it counted this UTC month; `update(body)` sets or clears it and needs `spend_caps:write`, which no key preset includes. A workspace its organization pays for answers `403 billed_by_organization`.
|
|
18
|
+
- `Unitpost::OrganizationClient` (new, ADR-0171): the client for an
|
|
19
|
+
organization key (`ok_live_...`), made with the key and the organization's id
|
|
20
|
+
(`UNITPOST_ORG_KEY` and `UNITPOST_ORGANIZATION_ID` when left out). It has
|
|
21
|
+
`workspaces` (`list`, `list_all`, `create` with an idempotency key, `get`,
|
|
22
|
+
`update`, `close`, `restore`), `workspace_keys.create`, `webhooks` (the
|
|
23
|
+
organization's endpoints), `usage.list` and `plan_quotes` (`create`, `get`,
|
|
24
|
+
`confirm` with an idempotency key). The workspace client `Unitpost::Client`
|
|
25
|
+
doesn't carry them.
|
|
26
|
+
- `sms.add_contact(id)`, `sms.list_join_keywords(number_id)`, `sms.add_join_keyword(number_id, body)`, `sms.remove_join_keyword(number_id, keyword_id)`: add a texter as a contact and manage text-to-join keywords.
|
|
27
|
+
- `SmsFailureCode` gains `sms_not_in_plan`: SMS wasn't on the plan when a text was due (the paid plan ended after its grace, or the plan is 100% discounted). Not charged.
|
|
28
|
+
- SMS numbers and registrations, start to finish (ADR-0160, 2026-11-12):
|
|
29
|
+
`sms.get_number(id)`, `sms.release_number(id, { force: true },
|
|
30
|
+
idempotency_key: ...)` (permanent), `sms.registrations.get(id)`,
|
|
31
|
+
`sms.registrations.remove(id)` (a 10DLC setup with no number) and
|
|
32
|
+
`sms.registrations.replace(id)` (an approved brand registration).
|
|
33
|
+
- Files and SMS onboarding by API (ADR-0159, 2026-11-12):
|
|
34
|
+
- `files` (new): `list(purpose: ...)`, `create(body, idempotency_key:
|
|
35
|
+
...)`, `get(id)`, `delete(id)`. A file (`file_` id) is bytes handed to
|
|
36
|
+
the API for one `purpose` (`sms_opt_in_evidence`, `sms_document`,
|
|
37
|
+
`image`) from a `url`, base64 `data`, or an upload session, used by
|
|
38
|
+
`file_id` and expiring after 24 hours.
|
|
39
|
+
- `sms`: a brand's documents (`list_brand_documents(brand_id)`,
|
|
40
|
+
`add_brand_document(brand_id, body, idempotency_key: ...)`,
|
|
41
|
+
`get_brand_document`, `remove_brand_document`, and
|
|
42
|
+
`brand_document_url`, a 5-minute signed link), and
|
|
43
|
+
`resubmit_number(number_id, body, idempotency_key: ...)` for a toll-free
|
|
44
|
+
verification carriers sent back.
|
|
45
|
+
- `sms.registrations`: `resubmit(id, body, idempotency_key: ...)` for a
|
|
46
|
+
10DLC campaign carriers sent back, and `request_number(id,
|
|
47
|
+
idempotency_key: ...)` to retry a failed number whose fee is committed.
|
|
48
|
+
- Every new write generates an Idempotency-Key when you don't pass one.
|
|
49
|
+
- `Unitpost::Error#details` entries document the optional `"code"`, a
|
|
50
|
+
machine-readable reason for the entry, such as the SMS skip word on `to`
|
|
51
|
+
(`out_of_reach`).
|
|
52
|
+
- The SMS list takes `sender_id`, a number's `snum_…` id: that number's
|
|
53
|
+
texts, both directions. A value it can't apply is ignored and named in the
|
|
54
|
+
`Unitpost-Warning` response header; `Unitpost-Strict: true` refuses it.
|
|
55
|
+
- `sms.quotes` (new): `create(body)`, `get(id)` and `confirm(id, {
|
|
56
|
+
confirm_token: ... }, idempotency_key: ...)` buy SMS carrier resources
|
|
57
|
+
(`squote_` ids): register a 10DLC brand, vet it, register a campaign, order
|
|
58
|
+
a number. `confirm` generates an Idempotency-Key when you don't pass one, so
|
|
59
|
+
a retry can't buy twice. `create` prices the order and binds what it buys
|
|
60
|
+
(the brand's and program's content, the price) and returns `due_now_cents`,
|
|
61
|
+
`monthly_cents`, `line_items` and a single-use `confirm_token` (`sqct_`),
|
|
62
|
+
only in that response; a quote lasts 10 minutes and charges nothing. The
|
|
63
|
+
confirm places the order at that price, or answers `409` when the price or
|
|
64
|
+
content changed. It needs `sms:purchase`, which no key preset includes, and
|
|
65
|
+
the workspace owner's monthly cap for SMS purchases by API (no cap set
|
|
66
|
+
refuses it). Show the person the price and get their yes before confirming.
|
|
67
|
+
- `logs.list` (new `logs` resource): the workspace's API request log, newest
|
|
68
|
+
first and cursor-paginated (`rlog_` ids). Each row is one call: `method`,
|
|
69
|
+
`path`, `status`, `duration_ms`, `api_key_id` and its `request_id` (the
|
|
70
|
+
`x-request-id`), never the caller's IP or a body; rows are kept 30 days.
|
|
71
|
+
Filters: `status:` (a code or `"2xx"`…`"5xx"`), `api_key_id:`, `method:`,
|
|
72
|
+
`path_prefix:`, `request_id:`, `created_after:`, `created_before:`. It needs
|
|
73
|
+
`apikeys:read`, which no key preset includes.
|
|
74
|
+
- Opt many contacts out of a topic at once: `email.topics.opt_out(id, body,
|
|
75
|
+
idempotency_key: nil)` and `sms.topics.opt_out(...)` (exactly one of
|
|
76
|
+
`contact_ids` or `emails`, up to 1,000, or `segment_id`). They answer the
|
|
77
|
+
job (202); follow it with `jobs.get(id)`. The SDK mints an idempotency key
|
|
78
|
+
when you pass none, so a retry answers the same job. There is no bulk
|
|
79
|
+
opt-in. Needs `topics:write` (a segment also `segments:read`).
|
|
80
|
+
- `sms.registrations.list`, `sms.test_destinations.list`,
|
|
81
|
+
`sms.consent_setups.list`, `sms.billing.list_resources` and
|
|
82
|
+
`sms.messaging_programs.list` take `limit:`, `after:` and `before:`: the
|
|
83
|
+
five lists are cursor-paginated, newest first.
|
|
84
|
+
- New response fields are optional in the models (the API always sends
|
|
85
|
+
them): `SmsBrand` takes them as keywords that default to `nil`, after its
|
|
86
|
+
0.4.0 members.
|
|
87
|
+
- The activity log, an API key's usage, several topic preferences at once and
|
|
88
|
+
list search. `workspace.list_activity` and `list_all_activity`: the
|
|
89
|
+
workspace's activity log, newest first (cursor-paginated on `act_` ids):
|
|
90
|
+
what changed, when, who (`actor.name`) and, for a change over the API, MCP
|
|
91
|
+
or Ask Unit, how (`actor.via`, with the API key). Narrow it with `subject:`
|
|
92
|
+
(and `subject_id:`), `contact_id:`, `campaign_id:`, `q:` and `channel:
|
|
93
|
+
"email"` (an unknown keyword is a `422`). It needs `activity:read`.
|
|
94
|
+
`api_keys.usage(id)`: a key's requests in the last 24 hours (`requests_24h`,
|
|
95
|
+
`client_errors_24h`, `server_errors_24h`, `rate_limited_24h`) and
|
|
96
|
+
`last_used_at`. `api_keys.list` now also works with an API key or an MCP
|
|
97
|
+
sign-in (it was dashboard-session only); with one, `list` and `usage` need
|
|
98
|
+
`apikeys:read`. Creating and revoking keys stay in the dashboard. No key
|
|
99
|
+
preset includes `activity:read` or `apikeys:read`.
|
|
100
|
+
`email.topics.update_topics(contact_id, { topics: [{ topic_id:, subscribed:
|
|
101
|
+
}] })` (`PATCH /contacts/{id}/topics`, up to 50) changes several of a
|
|
102
|
+
contact's preferences at once, leaves the others as they are, and answers
|
|
103
|
+
the list (`"object" => "list"`, `"data"`); `set_topic` is unchanged.
|
|
104
|
+
`email.list` and `list_all` take `q:` (an exact recipient, or part of the
|
|
105
|
+
subject or the sender), `source:` (`"api"`, `"smtp"`, `"test"`, `"batch"`,
|
|
106
|
+
`"campaign"` or `"reply"`) and `outcome:` (`"delivered"`, `"opened"`,
|
|
107
|
+
`"clicked"`, `"unsubscribed"`, `"bounced"`, `"complained"`, `"failed"` or
|
|
108
|
+
`"pending"`; with `campaign_id:`, who opened or clicked it). `sms.list` and
|
|
109
|
+
`list_all` take `q` (the message text, or 3 or more digits of either number)
|
|
110
|
+
and `type` (`"transactional"` or `"marketing"`) in their params hash. A `q`,
|
|
111
|
+
`source`, `outcome` or `type` value the API can't apply is ignored and named
|
|
112
|
+
in the `Unitpost-Warning` response header; `Unitpost-Strict: true` refuses
|
|
113
|
+
it.
|
|
114
|
+
- List filters and a stats period. `suppressions.list` and `list_all` take
|
|
115
|
+
`q:` (part of the address), `reason:`, `created_after:` and
|
|
116
|
+
`created_before:` (`scope` stays, deprecated). `webhooks.list_deliveries`
|
|
117
|
+
and `list_all_deliveries` take `status:` (comma-separated, e.g.
|
|
118
|
+
`"failed,exhausted"`) and `event_type:`. `email.stats` keeps `days:` and
|
|
119
|
+
takes a period instead: `from:` and `to:`, with `grain:` (`"5m"`, `"1h"` or
|
|
120
|
+
`"1d"`) and `tz:` for `series`, the send volume per bucket, and `domain_id:`
|
|
121
|
+
for one sending domain. These lists ignored the filters before, so a value
|
|
122
|
+
the API can't apply is ignored and named in the `Unitpost-Warning` response
|
|
123
|
+
header; `Unitpost-Strict: true` refuses it. Responses: `webhooks.get` adds
|
|
124
|
+
`backlog` (`queued`, `failed`: what a flush would send); `email.stats` adds
|
|
125
|
+
the permanent and transient bounces, `suppressed`, `unsubscribed`,
|
|
126
|
+
`rates.unsubscribe`, `domain_id`, `from`, `to` and `series`; topics add
|
|
127
|
+
`subscriber_count` and `unsubscribed_count`; `usage.get` adds the plan's
|
|
128
|
+
`limits` and `features`.
|
|
129
|
+
- Who is calling, an email's events, a received email's original and
|
|
130
|
+
template rendering. `workspace.whoami`: the workspace, the credential (an
|
|
131
|
+
API key or an OAuth sign-in, never its secret), its `capabilities` and the
|
|
132
|
+
workspace's rate limit; any valid credential may call it, so call it first
|
|
133
|
+
to see what a key may do.
|
|
134
|
+
`email.list_events(id, limit: ..., after: ..., before: ...)`: one email's
|
|
135
|
+
delivery events, oldest first, with each event's detail under the webhook's
|
|
136
|
+
names (cursor-paginated on `emev_` ids; no `list_all`).
|
|
137
|
+
`email.received_raw(id)`: a signed URL (about 5 minutes) to a received
|
|
138
|
+
message's original `.eml`, the way to read a body over 256 KB; a copy of
|
|
139
|
+
your own send is a `403`.
|
|
140
|
+
`email.templates.render(id, { variables: ..., subject: ..., contact_id: ... })`:
|
|
141
|
+
the subject, HTML and text a send would carry, and its
|
|
142
|
+
`missing_variables`; it sends and stores nothing, so it takes no
|
|
143
|
+
idempotency key, and the body is optional. `list_events` and
|
|
144
|
+
`received_raw` need `emails:read`; `render` needs `templates:read`.
|
|
145
|
+
- SMS brands and registrations. On `sms`:
|
|
146
|
+
`create_brand(body, idempotency_key: ...)`, `get_brand(id)` and
|
|
147
|
+
`update_brand(id, { ... })` (send `{ archived: ... }` alone to archive or
|
|
148
|
+
restore). A new resource on `sms`: `sms.registrations.list`, which is
|
|
149
|
+
cursor-paginated (no `list_all`). Creating a brand is free and makes no
|
|
150
|
+
carrier call; its tax id is write-only (read back as
|
|
151
|
+
`tax_id_on_file`), and a locked brand refuses carrier-field edits with
|
|
152
|
+
`409 brand_locked`. The reads need `sms:read`; the brand writes need
|
|
153
|
+
`sms:manage`. Registering a brand with carriers (a paid step), ordering
|
|
154
|
+
numbers and a brand's documents stay in the dashboard.
|
|
155
|
+
- SMS setup. On `sms.templates`: `usage(id)` and
|
|
156
|
+
`test_send(id, { to: ..., variables: ..., sender_id: ... }, idempotency_key: ...)`.
|
|
157
|
+
Four new resources on `sms`: `sms.messaging_programs.list(archived: ...)`,
|
|
158
|
+
`create(body, idempotency_key: ...)`, `get(id)`, `update(id, { ... })`,
|
|
159
|
+
`delete(id)` (it archives) and `duplicate(id, idempotency_key: ...)`;
|
|
160
|
+
`sms.test_destinations.list` and `delete(id)`; `sms.consent_setups.list`;
|
|
161
|
+
and `sms.billing.list_resources`. These four lists are cursor-paginated (no
|
|
162
|
+
`list_all`). A test text goes only to the simulator or a verified test
|
|
163
|
+
number, and is billed like any text. The reads need `sms:read`
|
|
164
|
+
(`usage` needs `templates:read`); the test send needs `sms:send`; the
|
|
165
|
+
program writes and removing a test number need `sms:manage` (FULL keys have
|
|
166
|
+
it, SENDING keys don't). Ordering numbers, sender
|
|
167
|
+
registrations and payments stay in the dashboard.
|
|
168
|
+
- Brand Kit writes and imports on `brand_kits`:
|
|
169
|
+
`brand_kits.create({ name: ..., make_default: ... })`,
|
|
170
|
+
`brand_kits.update(id, { ... })`, `brand_kits.delete(id)`,
|
|
171
|
+
`brand_kits.reset(id)`, `brand_kits.set_default(id)` and
|
|
172
|
+
`brand_kits.add_graphic(id, { url: ..., role: ..., label: ... })`;
|
|
173
|
+
`brand_kits.import({ ... })`,
|
|
174
|
+
`brand_kits.get_import(id)`, `brand_kits.accept_import(id, { ... })` (the
|
|
175
|
+
body is optional) and `brand_kits.cancel_import(id)`. An import builds a
|
|
176
|
+
profile from a website (`url`) or the brand's own words (`text`) in the
|
|
177
|
+
background (`202`; follow it with `get_import`). By default it is applied
|
|
178
|
+
when it lands; with `review: true` it stops at a proposal for
|
|
179
|
+
`accept_import`. Deleting the last profile is a `409` (reset it instead).
|
|
180
|
+
`add_graphic` brings an image from a public https URL into the image library
|
|
181
|
+
and pins it. The writes, and starting, accepting or canceling an import,
|
|
182
|
+
need the `branding:write` capability, which no key preset grants: tick it on
|
|
183
|
+
the key. The reads stay `templates:read`.
|
|
184
|
+
- Three new resources. Image library:
|
|
185
|
+
`library_images.list(limit: ..., after: ..., before: ...)`,
|
|
186
|
+
`library_images.list_all`,
|
|
187
|
+
`library_images.create({ ... }, idempotency_key: ...)`,
|
|
188
|
+
`library_images.get(id)`, `library_images.update(id, { alt: ... })` and
|
|
189
|
+
`library_images.delete(id, force: true)`. Branding: `branding.get`,
|
|
190
|
+
`branding.update({ ... })`, `branding.set_logo({ ... })` and
|
|
191
|
+
`branding.remove_logo`. Workspace:
|
|
192
|
+
`workspace.update({ name: ... })`, `workspace.set_image({ ... })` and
|
|
193
|
+
`workspace.remove_image`. The library holds the images a template embeds:
|
|
194
|
+
an image's `path` (`/img/…`) goes in a template's `<Image src>`. `create`
|
|
195
|
+
uploads from a public https `url` or base64 `data` (PNG, JPEG, GIF or
|
|
196
|
+
WebP, up to 5 MB) and takes an `idempotency_key`, minted when you don't
|
|
197
|
+
pass one, so a retried upload stores one image. Deleting an image that a
|
|
198
|
+
template, a campaign or sent mail uses is a `409` `resource_in_use` unless
|
|
199
|
+
you pass `force: true` (sent as `?force=true`). `branding` is the look of
|
|
200
|
+
marketing emails' footer and the hosted unsubscribe page, as Settings →
|
|
201
|
+
Brand shows it (`nil` restores a default). `workspace` renames the
|
|
202
|
+
workspace and sets its image. `remove_logo` and `remove_image` answer the
|
|
203
|
+
updated object. The branding writes and every `workspace` call need the
|
|
204
|
+
`branding:write` capability, which no key preset grants: tick it on the
|
|
205
|
+
key.
|
|
206
|
+
- Jobs: `jobs.list(status: ..., kind: ..., limit: ..., after: ..., before: ...)`,
|
|
207
|
+
`jobs.cancel(id)`, `jobs.retry(id)` and `jobs.download(id)`. Contacts:
|
|
208
|
+
`contacts.export({ q: ..., status: ..., segment_id: ... })` (the filters of
|
|
209
|
+
`contacts.list`). Segments: `segments.preview(id)`,
|
|
210
|
+
`segments.preview_filter({ filter: ... })`, `segments.all_contacts` and
|
|
211
|
+
`segments.update_member(id, contact, { subscribed: ... })`.
|
|
212
|
+
`export` starts a background job that writes a CSV of every contact, or
|
|
213
|
+
of the ones the filters match (one export at a time: another while it runs
|
|
214
|
+
is a `409`); follow it with `jobs.get`, then `jobs.download` gives a signed URL to
|
|
215
|
+
the file that expires in 5 minutes. `jobs.list` lists your background jobs;
|
|
216
|
+
`cancel` stops a queued or running one, and `retry` resumes a `FAILED`
|
|
217
|
+
one from where it stopped. `retry` is a Ruby keyword, so call it with its
|
|
218
|
+
receiver (`client.jobs.retry(id)`). `preview` and `preview_filter`
|
|
219
|
+
count who a saved segment or an unsaved filter reaches and how many of them
|
|
220
|
+
a campaign would mail; nothing is saved. `all_contacts` returns the
|
|
221
|
+
managed "All subscribed contacts" segment, made the first time you ask.
|
|
222
|
+
`update_member` opts a member out of a static segment's sends, or back
|
|
223
|
+
in, without removing it. None of these takes an idempotency key.
|
|
224
|
+
- Webhooks: `webhooks.replay_delivery(id, delivery_id)` and
|
|
225
|
+
`webhooks.flush(id, { include_failed: ... })`. Email:
|
|
226
|
+
`email.retry(id, idempotency_key: ...)` and
|
|
227
|
+
`email.list_batches(limit: ..., after: ..., before: ...)`. Domains: sender
|
|
228
|
+
addresses with `email.domains.list_senders(domain_id: ..., limit: ..., after: ..., before: ...)`,
|
|
229
|
+
`create_sender({ address: ..., display_name: ... })`, `get_sender(id)`,
|
|
230
|
+
`update_sender(id, { display_name: ... })` and `delete_sender(id)`.
|
|
231
|
+
`replay_delivery` delivers one event again with the same event id, and `flush`
|
|
232
|
+
delivers the deliveries held while a webhook was suspended (with
|
|
233
|
+
`include_failed`, also the ones that failed for good); both need the
|
|
234
|
+
webhook enabled (`409` otherwise). `retry` sends a failed email again on
|
|
235
|
+
the same id (an email that can't be retried is a `409` saying why); it
|
|
236
|
+
sends real email, so it takes an idempotency key and generates one when you
|
|
237
|
+
don't pass it. `retry` is a Ruby keyword, so call it with its receiver
|
|
238
|
+
(`client.email.retry(id)`). `list_batches` lists your batch sends with the same
|
|
239
|
+
rollup as `get_batch`. A
|
|
240
|
+
sender is a saved From address on one of your domains; saving a mailbox
|
|
241
|
+
that is already saved there is a `409`.
|
|
242
|
+
- Email templates:
|
|
243
|
+
`email.templates.duplicate(id, { name: ... }, idempotency_key: ...)`,
|
|
244
|
+
`email.templates.from_library({ slug: ..., name: ... }, idempotency_key: ...)`,
|
|
245
|
+
`email.templates.usage(id)`,
|
|
246
|
+
`email.templates.list_versions(id, limit: ..., after: ...)` and
|
|
247
|
+
`email.templates.restore_version(id, version)`.
|
|
248
|
+
`duplicate` copies a template into a new draft, and `from_library` adds a
|
|
249
|
+
gallery email as a draft Design template (the ones marked for paid plans are
|
|
250
|
+
`403 limit_reached` on the free plan); both take an idempotency key and
|
|
251
|
+
generate one when you don't pass it. `usage` says what uses a template and
|
|
252
|
+
whether an edit would be accepted now. `list_versions` pages by version
|
|
253
|
+
number: pass the last row's `version` as `after`. `restore_version` puts a
|
|
254
|
+
version back and is refused with `409` while a live campaign renders the
|
|
255
|
+
template.
|
|
256
|
+
- Inbox conversations: a new `email.threads` resource with
|
|
257
|
+
`list(q: ..., limit: ..., after: ...)`, `get(id)`,
|
|
258
|
+
`delete(id)` and `reply(id, body, idempotency_key: ...)`. A conversation is a received
|
|
259
|
+
message plus the replies and forwards sent from it, as Emails → Received
|
|
260
|
+
shows them. `list` pages with `next_cursor` (pass it as `after`; it is not a
|
|
261
|
+
row id); `delete` erases the received messages for good. `reply` replies, replies all or forwards one
|
|
262
|
+
received message and sends real email, so it takes an idempotency key and
|
|
263
|
+
generates one when you don't pass it.
|
|
264
|
+
- Email campaigns: `email.campaigns.stats(id)`,
|
|
265
|
+
`email.campaigns.list_stats(ids)`,
|
|
266
|
+
`email.campaigns.list_recipients(id, status: ..., limit: ..., after: ...)`,
|
|
267
|
+
`email.campaigns.list_affected(id)`, `email.campaigns.remove_affected(id)`
|
|
268
|
+
and `email.campaigns.request_review(id)`. SMS campaigns:
|
|
269
|
+
`sms.campaigns.list_recipients(id, limit: ..., after: ..., before: ..., q: ...)`.
|
|
270
|
+
`stats` reads a campaign's results: delivered, unique opens and clicks,
|
|
271
|
+
unsubscribes, bounces, complaints and their rates. `list_stats` reads them
|
|
272
|
+
for up to 100 campaigns at once. On an email campaign, `list_recipients`
|
|
273
|
+
lists who a send now would reach and why any other member would be left out;
|
|
274
|
+
pass the page's `next_cursor` as `after` for the next page. After an
|
|
275
|
+
automatic quality pause, `list_affected` lists the hard-bounced and
|
|
276
|
+
complained addresses, `remove_affected` takes them out of the campaign's
|
|
277
|
+
static segment, and `request_review` asks for the review a repeat pause
|
|
278
|
+
needs before `resume`. Both are safe to repeat: a second call removes no one
|
|
279
|
+
and notifies no one. On an SMS campaign, `list_recipients` lists how each
|
|
280
|
+
recipient fared, with `skipped_by_reason` counts for the whole campaign.
|
|
281
|
+
- Contacts: `contacts.addresses(id_or_email)`,
|
|
282
|
+
`contacts.activity(id_or_email, limit: ...)`,
|
|
283
|
+
`contacts.list_segments(id_or_email)` and
|
|
284
|
+
`contacts.retry_import(id)`. SMS:
|
|
285
|
+
`sms.request_sms_opt_in(contact_id, { phone: ... }, idempotency_key: ...)`.
|
|
286
|
+
`request_sms_opt_in` texts the contact a
|
|
287
|
+
request to reply YES to confirm marketing texts. It sends a real text, so it
|
|
288
|
+
sends the idempotency key you pass, or one it makes up, and a retry returns
|
|
289
|
+
the same text instead of sending another.
|
|
290
|
+
- Contacts carry `phone`, their SMS number in E.164, on create, update and
|
|
291
|
+
read. `null` on update removes the number only with the `Unitpost-Strict: true` header; without it the number is kept and the response warns. Setting it records no SMS
|
|
292
|
+
consent: record that with `sms.record_sms_consent`.
|
|
293
|
+
- `contacts.list` now takes keyword filters: it and `contacts.list_all` take
|
|
294
|
+
`q:`, `status:` (`subscribed` | `unsubscribed`), `phone:` (`has` | `none`),
|
|
295
|
+
`segment_id:` and `segment_subscription:` (`subscribed` | `opted_out`);
|
|
296
|
+
`email.list` / `email.list_all` take `to:` and `contact_id:`.
|
|
297
|
+
- Email and SMS campaigns: `unschedule(id)` and `duplicate(id, { name: ... }, idempotency_key: ...)`. Unschedule moves a scheduled campaign
|
|
298
|
+
back to a draft; duplicate copies a campaign into a new draft. Duplicate
|
|
299
|
+
sends the idempotency key you pass, or one it makes up, so a retry returns
|
|
300
|
+
the same copy instead of making a second one.
|
|
301
|
+
- The campaign update model takes `name`, `subject`, `from`, `preview_text`,
|
|
302
|
+
`template_id` and `segment_id`: the API now edits these on a draft.
|
|
303
|
+
- The email campaign and segment lists take the optional `archived` query
|
|
304
|
+
parameter (`archived=true` lists archived rows).
|
|
305
|
+
- The API now answers `422` for a misnamed send time (`send_at`,
|
|
306
|
+
`scheduledAt` on SMS, …) on sends and campaign writes, instead of sending at
|
|
307
|
+
once or dropping it. Use `scheduled_at`.
|
|
308
|
+
- Campaign create's `403` now says which refusal it is: `limit_reached` for
|
|
309
|
+
the plan's contact limit, `domain_not_found` / `domain_blocked` /
|
|
310
|
+
`domain_not_verified` for the sender (it was always `domain_not_verified`).
|
|
311
|
+
Read `error.code` to tell them apart.
|
|
312
|
+
- Domains: the update model takes `capabilities` (`{ receiving: "enabled" |
|
|
313
|
+
"disabled" }` turns receiving on or off), and domain reads carry
|
|
314
|
+
`capabilities` and a `receiving` object (status, the MX record to publish,
|
|
315
|
+
the last checks).
|
|
316
|
+
|
|
317
|
+
## 0.4.0
|
|
318
|
+
|
|
319
|
+
The release this changelog starts from. Earlier changes are in the git history
|
|
320
|
+
(tags `sdk-ruby-v*`).
|
data/README.md
CHANGED
|
@@ -47,23 +47,72 @@ Every method returns a `Unitpost::Result` with `#data` and `#error` (and a
|
|
|
47
47
|
Pass `api_key:` to `Unitpost::Client.new`, or set `UNITPOST_API_KEY`. Create a
|
|
48
48
|
key at [unitpost.com → Settings → API keys](https://www.unitpost.com).
|
|
49
49
|
|
|
50
|
+
## Organization keys
|
|
51
|
+
|
|
52
|
+
A platform that gives each of its customers a workspace uses an organization
|
|
53
|
+
key (`ok_live_...`) with the second client, `Unitpost::OrganizationClient`. It
|
|
54
|
+
takes the key and the organization's id (`org_...`), and reads
|
|
55
|
+
`UNITPOST_ORG_KEY` and `UNITPOST_ORGANIZATION_ID` when you leave them out:
|
|
56
|
+
|
|
57
|
+
```ruby
|
|
58
|
+
require "unitpost"
|
|
59
|
+
|
|
60
|
+
org = Unitpost::OrganizationClient.new # or (api_key: "ok_live_...", organization_id: "org_...")
|
|
61
|
+
|
|
62
|
+
workspace = org.workspaces.create({ name: "Acme Bakery", external_id: "cust_42" }).data
|
|
63
|
+
minted = org.workspace_keys.create(workspace["id"], { name: "Production", scope: "sending" }).data
|
|
64
|
+
|
|
65
|
+
# Work inside that workspace with its own key.
|
|
66
|
+
acme = Unitpost::Client.new(api_key: minted["key"])
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
| Accessor | Covers |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| `workspaces` | `list` (`external_id:` filter), `list_all`, `create` (takes an idempotency key), `get`, `update`, `close`, `restore` |
|
|
72
|
+
| `workspace_keys` | `create(workspace_id, body)`: mint a workspace key; the secret is in that answer only |
|
|
73
|
+
| `webhooks` | The organization's endpoints (events from every workspace, each with `workspace_id` and `external_id`): `list`, `list_all`, `create`, `get`, `update`, `delete`, `rotate_secret`, `test`, `list_deliveries` (needs `organizations:write`), `list_all_deliveries`, `replay_delivery`, `flush`, `verify` |
|
|
74
|
+
| `usage` | `list(period:)`, `list_all`: usage per workspace for its billing period |
|
|
75
|
+
| `plan_quotes` | Change a workspace's plan: `create` prices it, `get`, `confirm` applies and charges it (takes an idempotency key) |
|
|
76
|
+
| `shared_plan` | The organization's shared plan: `get`, `list_workspaces`, `add_workspace`, `update_workspace` (its cap), `remove_workspace` (adding and removing take an idempotency key) |
|
|
77
|
+
|
|
78
|
+
Each client takes one kind of key: the organization client only calls
|
|
79
|
+
`/organizations/{id}/...` routes, and the API answers `401` to an organization
|
|
80
|
+
key on any other route. An Owner or Admin makes the key in the dashboard under
|
|
81
|
+
Organization → API.
|
|
82
|
+
|
|
50
83
|
## Client surface
|
|
51
84
|
|
|
52
85
|
| Accessor | Covers |
|
|
53
86
|
| --- | --- |
|
|
54
|
-
| `email` | Send, batch, list, get, update, stats, inbound (`received_
|
|
87
|
+
| `email` | Send, batch, list, get, update, stats, one email's delivery events (`list_events`), inbound (`received_*`; the original `.eml` with `received_raw`), retry a failed email (`retry`, takes an idempotency key), batches (`list_batches`, `get_batch`, `cancel_batch`) |
|
|
55
88
|
| `email.topics` | Topics + contact topic prefs |
|
|
56
|
-
| `email.campaigns` | Draft, schedule, send, pause/resume |
|
|
57
|
-
| `email.templates` | Template CRUD |
|
|
58
|
-
| `email.domains` | Domains + verify |
|
|
59
|
-
| `
|
|
89
|
+
| `email.campaigns` | Draft, schedule, send, pause/resume, results (`stats`, `list_stats`), who a send would reach (`list_recipients`), quality-pause recovery (`list_affected`, `remove_affected`, `request_review`) |
|
|
90
|
+
| `email.templates` | Template CRUD, `duplicate`, add from the gallery (`from_library`), what uses it (`usage`), history (`list_versions`, `restore_version`), render it without sending (`render`, which lists `missing_variables`) |
|
|
91
|
+
| `email.domains` | Domains + verify, `diagnose`, saved From addresses (`list_senders`, `create_sender`, `get_sender`, `update_sender`, `delete_sender`) |
|
|
92
|
+
| `email.threads` | Inbox conversations: `list` (`q`; page with `next_cursor`), `get`, `delete`, `reply` (reply, reply all or forward; takes an idempotency key) |
|
|
93
|
+
| `sms` | Send, get, list, make the sender of a received text a contact (`add_contact`, which needs `contacts:write`), `brands`, a brand (`create_brand`, which takes an idempotency key, `get_brand`, `update_brand`; the writes need `sms:manage`), `numbers`, one number (`get_number`), a toll-free verification carriers sent back (`resubmit_number`, takes an idempotency key), release a number (`release_number`, PERMANENT: its fee ends and it can't be had back; `{ force: true }` releases it although campaigns are scheduled on it or texts are queued through it; takes an idempotency key and needs `sms:manage`), a number's text-to-join keywords (`list_join_keywords`, `add_join_keyword`, `remove_join_keyword`; the writes need `sms:manage`), a brand's documents (`list_brand_documents`, `add_brand_document` with a `file_id` or `text` (takes an idempotency key), `get_brand_document`, `remove_brand_document`, `brand_document_url`, a 5-minute signed link), contact SMS consent, `request_sms_opt_in` (reply-YES confirmation). Available on paid plans: on the free plan `send` returns a `403` with code `limit_reached`, while the reads keep working. |
|
|
94
|
+
| `sms.templates` | Template CRUD, what uses it (`usage`), one test text to a simulator number or a verified number from `sms.test_destinations` (`test_send`, billed like any text; takes an idempotency key) |
|
|
95
|
+
| `sms.messaging_programs` | What a sender registration says your texts are for: `list` (`archived: true` includes archived ones), `create` and `duplicate` (each takes an idempotency key), `get`, `update`, `delete` (archives). The writes need `sms:manage` |
|
|
96
|
+
| `sms.test_destinations` | Verified test numbers: `list`, `delete` (needs `sms:manage`). Adding and verifying one stays in the dashboard |
|
|
97
|
+
| `sms.consent_setups` | Where and how people opt in to your texts: `list` |
|
|
98
|
+
| `sms.billing` | Recurring SMS charges: `list_resources` |
|
|
99
|
+
| `sms.registrations` | Carrier registrations and their review state: `list`, `get`, a 10DLC campaign carriers sent back (`resubmit`), a failed number whose fee is committed (`request_number`), take down a 10DLC setup with no number (`remove`), archive an approved brand registration to register it again (`replace`); the writes take an idempotency key and need `sms:manage` |
|
|
100
|
+
| `sms.quotes` | Buy carrier resources (register a 10DLC brand, vet it, register a campaign, order a number): `create` prices the order and returns a single-use `confirm_token`; `confirm` places it (takes an idempotency key; one is generated when you don't pass one). The confirm needs `sms:purchase`, which no key preset includes, and the owner's monthly cap for SMS purchases by API. Show the person the price first. Release a number with `sms.release_number` |
|
|
101
|
+
| `contacts` | CRUD, list filters, import jobs (start, cancel, retry), addresses, recent activity, the segments it is in (`list_segments`; add or remove it with `segments.add_member` / `segments.remove_member`), export to CSV (`export`, a background job) |
|
|
60
102
|
| `contact_fields` | Custom field definitions |
|
|
61
|
-
| `segments` | Segments + membership |
|
|
62
|
-
| `brand_kits` | Brand
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
103
|
+
| `segments` | Segments + membership, opt a member in or out (`update_member`), who it reaches (`preview`, and `preview_filter` for an unsaved filter), the managed all-contacts segment (`all_contacts`) |
|
|
104
|
+
| `brand_kits` | Brand Kit profiles: `list`, `get`, `create`, `update`, `delete`, `reset`, `set_default`, `add_graphic`, and imports from a website or the brand's own words (`import`, `get_import`, `accept_import`, `cancel_import`). The writes and starting, accepting or canceling an import need the `branding:write` capability, which no key preset grants |
|
|
105
|
+
| `library_images` | The image library templates embed (`/img/…` paths): `list`, `list_all`, `create` (takes an idempotency key), `get`, `update`, `delete` (`force: true` deletes an image in use) |
|
|
106
|
+
| `files` | Files handed to the API for one purpose and used by `file_id` (a brand document, SMS opt-in evidence, an image): `list` (`purpose:` filters), `create` (a `url`, base64 `data`, or an upload session; takes an idempotency key), `get`, `delete`. A file expires 24 hours after it is created |
|
|
107
|
+
| `branding` | The email footer and unsubscribe page look: `get`, `update`, `set_logo`, `remove_logo`. The writes need the `branding:write` capability, which no key preset grants |
|
|
108
|
+
| `workspace` | Who is calling and what it may do (`whoami`, any credential), the activity log (`list_activity`, `list_all_activity`; needs `activity:read`), and the workspace's name and image: `update`, `set_image`, `remove_image`. Those three need `branding:write`. No key preset grants either capability |
|
|
109
|
+
| `webhooks` | Endpoints + `verify`, the delivery log (`list_deliveries`), replay one delivery (`replay_delivery`), deliver the backlog (`flush`) |
|
|
110
|
+
| `api_keys` | `list` and a key's last 24 hours (`usage`), which need `apikeys:read` (on no key preset); `create` and `delete` need a dashboard session |
|
|
111
|
+
| `logs` | The API request log, newest first: `list` (each call's method, path, status, duration, key and request id; never the IP or a body; kept 30 days). Filters: `status:`, `api_key_id:`, `method:`, `path_prefix:`, `request_id:`, `created_after:` / `created_before:`. Needs `apikeys:read` (on no key preset) |
|
|
65
112
|
| `suppressions` | Suppression list |
|
|
113
|
+
| `jobs` | Background jobs: `list`, `get`, `cancel`, `retry`, a finished job's file (`download`) |
|
|
66
114
|
| `usage` | Billing-period usage snapshot |
|
|
115
|
+
| `spend_caps` | `get`, `update`: the monthly spend cap on SMS purchases made with a key or an app and what it counted this month; `update` needs `spend_caps:write`, which no key preset grants |
|
|
67
116
|
|
|
68
117
|
## Pagination
|
|
69
118
|
|
|
@@ -84,7 +133,7 @@ complaints are added automatically; you can also add your own:
|
|
|
84
133
|
unitpost.suppressions.create({ email: "bounced@example.com", reason: "manual" })
|
|
85
134
|
unitpost.suppressions.create({ emails: ["a@example.com", "b@example.com"] })
|
|
86
135
|
|
|
87
|
-
# Look one up by id or email; list
|
|
136
|
+
# Look one up by id or email; list your own; un-suppress.
|
|
88
137
|
unitpost.suppressions.get("bounced@example.com")
|
|
89
138
|
unitpost.suppressions.list_all.each { |s| puts "#{s["email"]} #{s["reason"]}" }
|
|
90
139
|
unitpost.suppressions.delete("bounced@example.com")
|
|
@@ -104,12 +153,47 @@ event = Unitpost.verify_webhook(
|
|
|
104
153
|
)
|
|
105
154
|
```
|
|
106
155
|
|
|
107
|
-
Or from the client
|
|
156
|
+
Or from the client:
|
|
108
157
|
|
|
109
158
|
```ruby
|
|
110
159
|
event = client.webhooks.verify(payload: raw_body, secret: secret, headers: request.headers)
|
|
111
160
|
```
|
|
112
161
|
|
|
162
|
+
## Receive a text and answer it
|
|
163
|
+
|
|
164
|
+
US toll-free, 10DLC and Canadian numbers take replies (`two_way` is true on
|
|
165
|
+
`sms.numbers`). Subscribe a webhook to `sms.received`, skip STOP and texts
|
|
166
|
+
Unitpost already answered, read the conversation with `participant`, and answer
|
|
167
|
+
without `from` so the reply leaves from the number they texted.
|
|
168
|
+
|
|
169
|
+
```ruby
|
|
170
|
+
require "unitpost"
|
|
171
|
+
|
|
172
|
+
unitpost = Unitpost::Client.new # reads UNITPOST_API_KEY
|
|
173
|
+
|
|
174
|
+
# Your webhook endpoint, subscribed to sms.received. Pass the RAW body.
|
|
175
|
+
def on_webhook(unitpost, raw_body, headers)
|
|
176
|
+
event = Unitpost.verify_webhook(
|
|
177
|
+
payload: raw_body,
|
|
178
|
+
secret: ENV.fetch("UNITPOST_WEBHOOK_SECRET"), # whsec_…
|
|
179
|
+
headers: headers
|
|
180
|
+
)
|
|
181
|
+
return unless event["type"] == "sms.received"
|
|
182
|
+
|
|
183
|
+
reply = event["data"]
|
|
184
|
+
return if reply["keyword"] == "OPT_OUT" || reply["auto_replied"] # STOP, or already answered
|
|
185
|
+
|
|
186
|
+
# The whole conversation with this person, both directions, newest first.
|
|
187
|
+
# Other filters: direction, status, from, to, contact_id, campaign_id,
|
|
188
|
+
# created_after, created_before.
|
|
189
|
+
history = unitpost.sms.list(participant: reply["from"], limit: 20)
|
|
190
|
+
answer = your_agent(history.data, reply["body"].to_s)
|
|
191
|
+
|
|
192
|
+
# No :from: the answer goes out from the number they texted.
|
|
193
|
+
unitpost.sms.send({ to: reply["from"], body: answer })
|
|
194
|
+
end
|
|
195
|
+
```
|
|
196
|
+
|
|
113
197
|
## Idempotency
|
|
114
198
|
|
|
115
199
|
`email.send` and `email.batch` are safe to retry by default — when you don't
|
|
@@ -145,7 +229,8 @@ unitpost = Unitpost::Client.new(max_retries: 2, retry_base_delay: 0.5, max_retry
|
|
|
145
229
|
| | |
|
|
146
230
|
| --- | --- |
|
|
147
231
|
| Docs + API reference | https://www.unitpost.com/docs |
|
|
148
|
-
| Product
|
|
232
|
+
| Product guides | https://www.unitpost.com/guides |
|
|
233
|
+
| SMTP | https://www.unitpost.com/docs/smtp |
|
|
149
234
|
| OpenAPI JSON | https://www.unitpost.com/api/v1/openapi.json |
|
|
150
235
|
| LLM index | https://www.unitpost.com/llms.txt |
|
|
151
236
|
| Dashboard / API keys | https://www.unitpost.com |
|
|
@@ -153,7 +238,7 @@ unitpost = Unitpost::Client.new(max_retries: 2, retry_base_delay: 0.5, max_retry
|
|
|
153
238
|
| Template gallery | https://www.unitpost.com/templates/gallery |
|
|
154
239
|
| Playground | https://www.unitpost.com/playground |
|
|
155
240
|
| Migration Assistant | https://www.unitpost.com/migration |
|
|
156
|
-
| MCP + Agent Skills | https://www.unitpost.com/
|
|
241
|
+
| MCP + Agent Skills | https://www.unitpost.com/docs/ai/mcp · https://www.unitpost.com/docs/ai/skills |
|
|
157
242
|
| Support | support@unitpost.com |
|
|
158
243
|
|
|
159
244
|
## License
|
data/lib/unitpost/client.rb
CHANGED
|
@@ -15,9 +15,10 @@ module Unitpost
|
|
|
15
15
|
# puts result.data["id"]
|
|
16
16
|
# end
|
|
17
17
|
class Client
|
|
18
|
-
attr_reader :email, :contacts, :contact_fields, :segments,
|
|
19
|
-
:brand_kits, :
|
|
20
|
-
:
|
|
18
|
+
attr_reader :email, :sms, :contacts, :contact_fields, :segments,
|
|
19
|
+
:brand_kits, :library_images, :files, :branding, :workspace,
|
|
20
|
+
:webhooks, :api_keys, :logs, :suppressions,
|
|
21
|
+
:jobs, :usage, :spend_caps
|
|
21
22
|
|
|
22
23
|
def initialize(api_key: nil, base_url: nil, timeout: 30, headers: {}, adapter: nil, stubs: nil,
|
|
23
24
|
max_retries: 2, retry_base_delay: 0.5, max_retry_delay: 20.0, sleeper: nil)
|
|
@@ -34,16 +35,31 @@ module Unitpost
|
|
|
34
35
|
sleeper: sleeper
|
|
35
36
|
)
|
|
36
37
|
@email = Resources::Email.new(http)
|
|
38
|
+
# SMS channel. Available on paid plans: on the free plan `send` returns
|
|
39
|
+
# a 403 with code `limit_reached`; reads keep working.
|
|
40
|
+
@sms = Resources::Sms.new(http)
|
|
37
41
|
@contacts = Resources::Contacts.new(http)
|
|
38
42
|
@contact_fields = Resources::ContactFields.new(http)
|
|
39
43
|
@segments = Resources::Segments.new(http)
|
|
40
44
|
@brand_kits = Resources::BrandKits.new(http)
|
|
45
|
+
# The image library templates embed (`/img/...` paths).
|
|
46
|
+
@library_images = Resources::LibraryImages.new(http)
|
|
47
|
+
# Files handed to the API for one purpose, used by file_id.
|
|
48
|
+
@files = Resources::Files.new(http)
|
|
49
|
+
# The email footer and unsubscribe page look, and the workspace's name
|
|
50
|
+
# and image. Their writes need branding:write (on no key preset).
|
|
51
|
+
@branding = Resources::Branding.new(http)
|
|
52
|
+
@workspace = Resources::Workspace.new(http)
|
|
41
53
|
@webhooks = Resources::Webhooks.new(http)
|
|
42
54
|
@api_keys = Resources::ApiKeys.new(http)
|
|
55
|
+
# The API request log. Needs apikeys:read (on no key preset).
|
|
56
|
+
@logs = Resources::Logs.new(http)
|
|
43
57
|
@suppressions = Resources::Suppressions.new(http)
|
|
44
58
|
# NOTE (pre-launch): `events` is intentionally absent while the
|
|
45
59
|
# custom-events surface is behind the launch gate.
|
|
60
|
+
@jobs = Resources::Jobs.new(http)
|
|
46
61
|
@usage = Resources::Usage.new(http)
|
|
62
|
+
@spend_caps = Resources::SpendCaps.new(http)
|
|
47
63
|
end
|
|
48
64
|
end
|
|
49
65
|
end
|
data/lib/unitpost/errors.rb
CHANGED
|
@@ -5,9 +5,11 @@ module Unitpost
|
|
|
5
5
|
class Error < StandardError
|
|
6
6
|
attr_reader :code, :status, :request_id, :details
|
|
7
7
|
|
|
8
|
-
# +details+ holds field
|
|
9
|
-
#
|
|
10
|
-
# "message" => "<why>" } hashes
|
|
8
|
+
# +details+ holds per-field problems (present on 422 validation_error
|
|
9
|
+
# and on refused sends): an array of { "field" => "<dotted.path>",
|
|
10
|
+
# "message" => "<why>" } hashes, plus an optional machine-readable
|
|
11
|
+
# "code" (e.g. the SMS skip word on "to": "out_of_reach"). Empty array
|
|
12
|
+
# otherwise.
|
|
11
13
|
def initialize(code:, message:, status:, request_id: nil, details: nil)
|
|
12
14
|
super(message)
|
|
13
15
|
@code = code
|