bzapper 0.10.0 → 0.12.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/README.md +2 -2
- data/lib/bzapper/resources/messages.rb +13 -3
- data/lib/bzapper/resources/templates.rb +42 -6
- 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: 998078a5f587bcde4ab77546e85feccdb12009697a8f97ade20469caae5979cd
|
|
4
|
+
data.tar.gz: 780a11f95211ffefb8724d8eb53d87735e2bb2e973c159c347a1a91a5101d32b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2f5020a7b89637785eb7e1e1271c0894371091fd75b8565fa7bbcee2f551e8cb3dcee86ded113c6f111221b1213efb446468262b487972f7d76f7e6101f679ac
|
|
7
|
+
data.tar.gz: 301bc5a4cab89bcad5353cf1c254f9e1f54f639ec6c32abf126ee76624aab53f9f336185fb31b449f2a7981d00fde912984f994c8e20cf8be4c92e4a3734cfb6
|
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.12.0
|
|
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.12.0"
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
## Hello world
|
|
@@ -965,11 +965,18 @@ module Bzapper
|
|
|
965
965
|
# @param header_variables [Array<String>, nil] (corpo) Text header: the value of its variable.
|
|
966
966
|
# Image, video or document header: the media URL for THIS send in the first position — omitted,
|
|
967
967
|
# the sample media registered when the template was created goes out (Meta requires the media on
|
|
968
|
-
# every send).
|
|
968
|
+
# every send). Location header: `[latitude, longitude, place name, address]` (the last two
|
|
969
|
+
# optional).
|
|
969
970
|
# @param button_variables [Array<String>, nil] (corpo) Values for dynamic URL buttons, by button
|
|
970
971
|
# index. Empty entries are skipped.
|
|
971
972
|
# @param code [String, nil] (corpo) AUTHENTICATION templates only. Meta requires the code both
|
|
972
973
|
# in the body and in the copy-code button; we place it in both.
|
|
974
|
+
# @param offer_expires_at [Time, String, nil] (corpo) Limited-time offer with `has_expiration`:
|
|
975
|
+
# the deadline of THIS send (RFC 3339) — the countdown runs to it. Required for that template;
|
|
976
|
+
# returns 422 before Meta otherwise.
|
|
977
|
+
# @param cards [Array<Hash>, nil] (corpo) Carousel templates: the values of each card, in order.
|
|
978
|
+
# `header_url` is the media of the card for this send (omitted, the sample registered at
|
|
979
|
+
# creation goes out).
|
|
973
980
|
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
974
981
|
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
975
982
|
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
@@ -979,7 +986,8 @@ module Bzapper
|
|
|
979
986
|
client_reference: UNSET, mentions: UNSET, scheduled_at: UNSET,
|
|
980
987
|
groups: UNSET, tags: UNSET, force: UNSET, language: UNSET,
|
|
981
988
|
variables: UNSET, header_variables: UNSET, button_variables: UNSET,
|
|
982
|
-
code: UNSET,
|
|
989
|
+
code: UNSET, offer_expires_at: UNSET, cards: UNSET, idempotency_key: nil,
|
|
990
|
+
timeout: nil)
|
|
983
991
|
payload = compact(
|
|
984
992
|
"instance_id" => instance_id,
|
|
985
993
|
"pool_id" => pool_id,
|
|
@@ -998,7 +1006,9 @@ module Bzapper
|
|
|
998
1006
|
"variables" => variables,
|
|
999
1007
|
"header_variables" => header_variables,
|
|
1000
1008
|
"button_variables" => button_variables,
|
|
1001
|
-
"code" => code
|
|
1009
|
+
"code" => code,
|
|
1010
|
+
"offer_expires_at" => offer_expires_at,
|
|
1011
|
+
"cards" => cards
|
|
1002
1012
|
)
|
|
1003
1013
|
request("POST",
|
|
1004
1014
|
"/messages/template",
|
|
@@ -41,13 +41,21 @@ module Bzapper
|
|
|
41
41
|
# @param code_expiry_minutes [Integer, nil] (corpo) AUTHENTICATION only, 1 to 90. In that
|
|
42
42
|
# category Meta writes the text itself and adds the copy-code button; this is the only thing you
|
|
43
43
|
# set.
|
|
44
|
+
# @param limited_time_offer [Hash, nil] (corpo) MARKETING only. Turns the template into a
|
|
45
|
+
# limited-time offer: a badge (up to 16 characters) and, with `has_expiration`, a countdown to
|
|
46
|
+
# the deadline sent in `offer_expires_at`. No footer; header only image or video; needs a URL
|
|
47
|
+
# button (and, with a deadline, the copy-code button).
|
|
48
|
+
# @param cards [Array<Hash>, nil] (corpo) Carousel (MARKETING or UTILITY): 2 to 10 cards. The
|
|
49
|
+
# template keeps only the opening `body`; each card has its own image or video, text (up to 160
|
|
50
|
+
# characters) and 1–2 buttons (quick reply, URL or phone). Meta requires the same media type and
|
|
51
|
+
# the same button types, in the same order, on every card.
|
|
44
52
|
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
45
53
|
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
46
54
|
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
47
55
|
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
48
56
|
def create_template(name:, language:, category:, body:, header: UNSET, footer: UNSET,
|
|
49
|
-
buttons: UNSET, code_expiry_minutes: UNSET,
|
|
50
|
-
timeout: nil)
|
|
57
|
+
buttons: UNSET, code_expiry_minutes: UNSET, limited_time_offer: UNSET,
|
|
58
|
+
cards: UNSET, idempotency_key: nil, timeout: nil)
|
|
51
59
|
payload = compact(
|
|
52
60
|
"name" => name,
|
|
53
61
|
"language" => language,
|
|
@@ -56,7 +64,9 @@ module Bzapper
|
|
|
56
64
|
"body" => body,
|
|
57
65
|
"footer" => footer,
|
|
58
66
|
"buttons" => buttons,
|
|
59
|
-
"code_expiry_minutes" => code_expiry_minutes
|
|
67
|
+
"code_expiry_minutes" => code_expiry_minutes,
|
|
68
|
+
"limited_time_offer" => limited_time_offer,
|
|
69
|
+
"cards" => cards
|
|
60
70
|
)
|
|
61
71
|
request("POST",
|
|
62
72
|
"/templates",
|
|
@@ -98,14 +108,22 @@ module Bzapper
|
|
|
98
108
|
# @param code_expiry_minutes [Integer, nil] (corpo) AUTHENTICATION only, 1 to 90. In that
|
|
99
109
|
# category Meta writes the text itself and adds the copy-code button; this is the only thing you
|
|
100
110
|
# set.
|
|
111
|
+
# @param limited_time_offer [Hash, nil] (corpo) MARKETING only. Turns the template into a
|
|
112
|
+
# limited-time offer: a badge (up to 16 characters) and, with `has_expiration`, a countdown to
|
|
113
|
+
# the deadline sent in `offer_expires_at`. No footer; header only image or video; needs a URL
|
|
114
|
+
# button (and, with a deadline, the copy-code button).
|
|
115
|
+
# @param cards [Array<Hash>, nil] (corpo) Carousel (MARKETING or UTILITY): 2 to 10 cards. The
|
|
116
|
+
# template keeps only the opening `body`; each card has its own image or video, text (up to 160
|
|
117
|
+
# characters) and 1–2 buttons (quick reply, URL or phone). Meta requires the same media type and
|
|
118
|
+
# the same button types, in the same order, on every card.
|
|
101
119
|
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
102
120
|
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
103
121
|
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
104
122
|
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
105
123
|
# @raise [ArgumentError] parâmetro de caminho vazio, "." ou "..".
|
|
106
124
|
def edit_template(id, name:, language:, category:, body:, header: UNSET, footer: UNSET,
|
|
107
|
-
buttons: UNSET, code_expiry_minutes: UNSET,
|
|
108
|
-
timeout: nil)
|
|
125
|
+
buttons: UNSET, code_expiry_minutes: UNSET, limited_time_offer: UNSET,
|
|
126
|
+
cards: UNSET, idempotency_key: nil, timeout: nil)
|
|
109
127
|
payload = compact(
|
|
110
128
|
"name" => name,
|
|
111
129
|
"language" => language,
|
|
@@ -114,7 +132,9 @@ module Bzapper
|
|
|
114
132
|
"body" => body,
|
|
115
133
|
"footer" => footer,
|
|
116
134
|
"buttons" => buttons,
|
|
117
|
-
"code_expiry_minutes" => code_expiry_minutes
|
|
135
|
+
"code_expiry_minutes" => code_expiry_minutes,
|
|
136
|
+
"limited_time_offer" => limited_time_offer,
|
|
137
|
+
"cards" => cards
|
|
118
138
|
)
|
|
119
139
|
request("PUT",
|
|
120
140
|
"/templates/#{segment(id, "id")}",
|
|
@@ -201,6 +221,22 @@ module Bzapper
|
|
|
201
221
|
timeout: timeout)
|
|
202
222
|
end
|
|
203
223
|
|
|
224
|
+
# Performance of each template (sent, delivered, read, failed). `GET /templates/analytics`
|
|
225
|
+
#
|
|
226
|
+
# Counted from the messages sent through each template in the last `days` days, grouped by
|
|
227
|
+
# template name.
|
|
228
|
+
#
|
|
229
|
+
# @param days [Integer, nil] (query)
|
|
230
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
231
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
232
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
233
|
+
def get_template_analytics(days: nil, timeout: nil)
|
|
234
|
+
query = {
|
|
235
|
+
"days" => days
|
|
236
|
+
}
|
|
237
|
+
request("GET", "/templates/analytics", query: query, timeout: timeout)
|
|
238
|
+
end
|
|
239
|
+
|
|
204
240
|
# Import templates that exist at Meta and not here. `POST /templates/sync`
|
|
205
241
|
#
|
|
206
242
|
# For the account that already used the Cloud API before bZapper and created templates in
|
data/lib/bzapper/version.rb
CHANGED