bzapper 0.14.1 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/bzapper/resources/contacts.rb +25 -8
- data/lib/bzapper/resources/templates.rb +67 -4
- data/lib/bzapper/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 18ae11339f76e3c6d9f321c25afa3ec4010d4d8da7bdfe73f304f0480291988d
|
|
4
|
+
data.tar.gz: 16cfc74032ba4d425e50de9377f8dc5002a5600b3b409d270bdc0fc361b79acb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b11c1f25b4d64990782786a8b9e8a2ced755113c1b73e6052fc23bb00986b9afda21f4c04f2eaca1b2934281c2d786f6a5420824f5fdd5d4014dbf96bcf71315
|
|
7
|
+
data.tar.gz: db8baaabaf935f779f76ef8ff9d9e9c0f692f6d909966a96a2d6c505e4b360cbad2af16ae2bd2b661411cf4169c8f1bc3f8c87029e78c34a96b036d77b7da65b
|
data/README.md
CHANGED
|
@@ -10,13 +10,13 @@ Zero dependências de runtime (só biblioteca padrão: `net/http`, `json`, `open
|
|
|
10
10
|
## Instalação
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
gem install bzapper -v 0.
|
|
13
|
+
gem install bzapper -v 0.15.1
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
Ou no `Gemfile` — **fixe a versão exata** (cada release declara se muda a superfície pública):
|
|
17
17
|
|
|
18
18
|
```ruby
|
|
19
|
-
gem "bzapper", "0.
|
|
19
|
+
gem "bzapper", "0.15.1"
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
## Hello world
|
|
@@ -190,7 +190,7 @@ O vínculo contato ↔ projeto/número é mantido **automaticamente** pela API.
|
|
|
190
190
|
### Importar em lote
|
|
191
191
|
|
|
192
192
|
Até **1000** contatos por chamada, upsert por telefone: o novo entra como
|
|
193
|
-
`pending_validation` (
|
|
193
|
+
`pending_validation` (já pode receber campanha e vira ativo quando a pessoa responde), o que já existe só recebe os campos
|
|
194
194
|
informados — valor em branco não apaga o que está lá. Linha ruim vai para `errors` e **não**
|
|
195
195
|
derruba o resto; contato suprimido/opt-out/bloqueado aparece em `skipped_rows` e nunca
|
|
196
196
|
ressuscita. Tags e grupos são criados na hora. `dry_run: true` valida tudo e não grava nada.
|
|
@@ -78,7 +78,10 @@ module Bzapper
|
|
|
78
78
|
# Name/email/document/address are optional. Idempotent by phone: if the contact already exists,
|
|
79
79
|
# only its empty fields are filled (never overwritten) and it is returned with 201.
|
|
80
80
|
#
|
|
81
|
-
# @param phone [String] (corpo) +DDIdigits (E.164 without spaces)
|
|
81
|
+
# @param phone [String] (corpo) +DDIdigits (E.164 without spaces), or the WhatsApp LID
|
|
82
|
+
# (`<digits>@lid`).
|
|
83
|
+
# @param lid [String, nil] (corpo) WhatsApp LID (`<digits>@lid`). With a phone too, the LID-only
|
|
84
|
+
# contact merges into the phone one.
|
|
82
85
|
# @param name [String, nil] (corpo)
|
|
83
86
|
# @param email [String, nil] (corpo)
|
|
84
87
|
# @param document [String, nil] (corpo)
|
|
@@ -88,10 +91,11 @@ module Bzapper
|
|
|
88
91
|
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
89
92
|
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
90
93
|
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
91
|
-
def create_contact(phone:,
|
|
92
|
-
address: UNSET, idempotency_key: nil, timeout: nil)
|
|
94
|
+
def create_contact(phone:, lid: UNSET, name: UNSET, email: UNSET, document: UNSET,
|
|
95
|
+
document_type: UNSET, address: UNSET, idempotency_key: nil, timeout: nil)
|
|
93
96
|
payload = compact(
|
|
94
97
|
"phone" => phone,
|
|
98
|
+
"lid" => lid,
|
|
95
99
|
"name" => name,
|
|
96
100
|
"email" => email,
|
|
97
101
|
"document" => document,
|
|
@@ -107,23 +111,36 @@ module Bzapper
|
|
|
107
111
|
|
|
108
112
|
# Import contacts in bulk. `POST /contacts/import`
|
|
109
113
|
#
|
|
110
|
-
# Upserts up to 1000 contacts by phone in one call.
|
|
111
|
-
#
|
|
112
|
-
#
|
|
114
|
+
# Upserts up to 1000 contacts by phone — or by WhatsApp LID — in one call. Each row's `phone`
|
|
115
|
+
# takes the number with country code OR the LID (`123456789012345@lid`): the API tells which one
|
|
116
|
+
# it is and stores it in the right place. A LID-only contact is addressed by the LID until its
|
|
117
|
+
# phone becomes known (on the first send, or when the person replies), when it gets the phone —
|
|
118
|
+
# or merges into the contact that already had it. A list of just numbers/LIDs with no name
|
|
119
|
+
# works: name and the rest fill in when the person replies. Top-level `tags` and `groups` apply
|
|
120
|
+
# to every row. A new contact is created with `source: import` and `status: pending_validation`;
|
|
121
|
+
# it can already receive campaigns, and becomes `active` when the person replies. An existing
|
|
122
|
+
# one has only its informed fields updated — a blank value never erases what is there. A
|
|
113
123
|
# suppressed/opted-out/blocked contact is reported in `skipped_rows` and never resurrected. Tags
|
|
114
124
|
# and groups are created on demand. A bad row is reported in `errors` and does NOT fail the rest
|
|
115
125
|
# of the call. `dry_run` validates everything and writes nothing.
|
|
116
126
|
#
|
|
117
127
|
# @param contacts [Array<Hash>] (corpo)
|
|
118
128
|
# @param dry_run [Boolean, nil] (corpo) Validates and reports without writing anything.
|
|
129
|
+
# @param tags [Array<String>, nil] (corpo) Tags applied to EVERY row (added to each row's own
|
|
130
|
+
# tags).
|
|
131
|
+
# @param groups [Array<String>, nil] (corpo) Groups applied to EVERY row (added to each row's
|
|
132
|
+
# own groups).
|
|
119
133
|
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
120
134
|
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
121
135
|
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
122
136
|
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
123
|
-
def import_contacts(contacts:, dry_run: UNSET,
|
|
137
|
+
def import_contacts(contacts:, dry_run: UNSET, tags: UNSET, groups: UNSET,
|
|
138
|
+
idempotency_key: nil, timeout: nil)
|
|
124
139
|
payload = compact(
|
|
125
140
|
"contacts" => contacts,
|
|
126
|
-
"dry_run" => dry_run
|
|
141
|
+
"dry_run" => dry_run,
|
|
142
|
+
"tags" => tags,
|
|
143
|
+
"groups" => groups
|
|
127
144
|
)
|
|
128
145
|
request("POST",
|
|
129
146
|
"/contacts/import",
|
|
@@ -221,6 +221,67 @@ module Bzapper
|
|
|
221
221
|
timeout: timeout)
|
|
222
222
|
end
|
|
223
223
|
|
|
224
|
+
# Check a template against Meta's rules without submitting it. `POST /templates/validate`
|
|
225
|
+
#
|
|
226
|
+
# The same validation as creation (variables, examples, lengths, buttons, category rules, offer
|
|
227
|
+
# and carousel rules, a repeated name), with no call to Meta and no submission spent. Use it
|
|
228
|
+
# while the template is being written — the panel does — to never send what Meta would reject.
|
|
229
|
+
# `?id=` checks an edit (its own name does not count as repeated; an approved template cannot
|
|
230
|
+
# change category).
|
|
231
|
+
#
|
|
232
|
+
# @param id [String, nil] (query) Template being edited.
|
|
233
|
+
# @param name [String] (corpo) Lowercase letters, numbers and _. This is the name you send by.
|
|
234
|
+
# @param language [String] (corpo) e.g. pt_BR. Both pt-BR and pt_BR are accepted.
|
|
235
|
+
# @param category [String] (corpo) Decides what the conversation COSTS and what Meta accepts in
|
|
236
|
+
# the content — not an administrative label. UTILITY is cheaper but only covers what the
|
|
237
|
+
# customer already expects; promotional wording in it gets reclassified, and the price changes
|
|
238
|
+
# with it.
|
|
239
|
+
# @param header [Hash, nil] (corpo)
|
|
240
|
+
# @param body [Hash] (corpo)
|
|
241
|
+
# @param footer [String, nil] (corpo) Up to 60 characters. Accepts no variables.
|
|
242
|
+
# @param buttons [Array<Hash>, nil] (corpo)
|
|
243
|
+
# @param code_expiry_minutes [Integer, nil] (corpo) AUTHENTICATION only, 1 to 90. In that
|
|
244
|
+
# category Meta writes the text itself and adds the copy-code button; this is the only thing you
|
|
245
|
+
# set.
|
|
246
|
+
# @param limited_time_offer [Hash, nil] (corpo) MARKETING only. Turns the template into a
|
|
247
|
+
# limited-time offer: a badge (up to 16 characters) and, with `has_expiration`, a countdown to
|
|
248
|
+
# the deadline sent in `offer_expires_at`. No footer; header only image or video; needs a URL
|
|
249
|
+
# button (and, with a deadline, the copy-code button).
|
|
250
|
+
# @param cards [Array<Hash>, nil] (corpo) Carousel (MARKETING or UTILITY): 2 to 10 cards. The
|
|
251
|
+
# template keeps only the opening `body`; each card has its own image or video, text (up to 160
|
|
252
|
+
# characters) and 1–2 buttons (quick reply, URL or phone). Meta requires the same media type and
|
|
253
|
+
# the same button types, in the same order, on every card.
|
|
254
|
+
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
255
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
256
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
257
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
258
|
+
def validate_template(name:, language:, category:, body:, id: nil, header: UNSET,
|
|
259
|
+
footer: UNSET, buttons: UNSET, code_expiry_minutes: UNSET,
|
|
260
|
+
limited_time_offer: UNSET, cards: UNSET, idempotency_key: nil,
|
|
261
|
+
timeout: nil)
|
|
262
|
+
query = {
|
|
263
|
+
"id" => id
|
|
264
|
+
}
|
|
265
|
+
payload = compact(
|
|
266
|
+
"name" => name,
|
|
267
|
+
"language" => language,
|
|
268
|
+
"category" => category,
|
|
269
|
+
"header" => header,
|
|
270
|
+
"body" => body,
|
|
271
|
+
"footer" => footer,
|
|
272
|
+
"buttons" => buttons,
|
|
273
|
+
"code_expiry_minutes" => code_expiry_minutes,
|
|
274
|
+
"limited_time_offer" => limited_time_offer,
|
|
275
|
+
"cards" => cards
|
|
276
|
+
)
|
|
277
|
+
request("POST",
|
|
278
|
+
"/templates/validate",
|
|
279
|
+
query: query,
|
|
280
|
+
body: payload,
|
|
281
|
+
idempotency_key: idempotency_key,
|
|
282
|
+
timeout: timeout)
|
|
283
|
+
end
|
|
284
|
+
|
|
224
285
|
# Performance of each template (sent, delivered, read, failed). `GET /templates/analytics`
|
|
225
286
|
#
|
|
226
287
|
# Counted from the messages sent through each template in the last `days` days, grouped by
|
|
@@ -305,10 +366,12 @@ module Bzapper
|
|
|
305
366
|
# /templates/otp`
|
|
306
367
|
#
|
|
307
368
|
# Must be an APPROVED template of the Authentication category or — until Meta releases that
|
|
308
|
-
# category for the account (business verification + 2,000 daily limit) — a provisional
|
|
309
|
-
#
|
|
310
|
-
#
|
|
311
|
-
#
|
|
369
|
+
# category for the account (business verification + 2,000 daily limit) — a provisional template:
|
|
370
|
+
# MARKETING with a copy-code button and at most one body variable (the customer copies only the
|
|
371
|
+
# code; Meta accepts that button only in Marketing — costlier, and not delivered to people who
|
|
372
|
+
# opted out of marketing), or UTILITY with exactly one body variable that receives the code in
|
|
373
|
+
# the text. An empty `template_id` clears the choice (the first approved Authentication template
|
|
374
|
+
# is used again).
|
|
312
375
|
#
|
|
313
376
|
# @param template_id [String, nil] (corpo) Empty clears the choice.
|
|
314
377
|
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
data/lib/bzapper/version.rb
CHANGED