bzapper 0.9.4 → 0.11.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 +2 -1
- data/lib/bzapper/resources/templates.rb +122 -0
- 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: 11d1f4c09306edd0ebee64aae4a21ce94abd01f6b1c970c8d20560312c00ba82
|
|
4
|
+
data.tar.gz: b7282a59b60b37c64ae70389d2a4e33bedf5dc968434b82ea355e37b0ed1823c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e68a0d83d6ec6ad449386fb2d86f821ac073b3726ae39e111aa8ef6b38ce9b671e0f1f352738673fdb70fb48f8a89dd5c672d5cfa85405c6f5a72d7d1a28ee0f
|
|
7
|
+
data.tar.gz: 71ea59c63593644c87876d6582ad452b3604ce5d67ad92cb7e0b17bd2d1f6e6cbe3c5195b918fcb8c7a37fd2a73051709cbb9ac32a2c40b2d0abdcd19b7b6618
|
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.11.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.11.0"
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
## Hello world
|
|
@@ -965,7 +965,8 @@ 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
|
|
@@ -76,6 +76,53 @@ module Bzapper
|
|
|
76
76
|
request("GET", "/templates/#{segment(id, "id")}", timeout: timeout)
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
+
# Edit a template (content goes back to Meta review). `PUT /templates/{id}`
|
|
80
|
+
#
|
|
81
|
+
# Same body as creation; `name` and `language` are the template identity and do not change. Meta
|
|
82
|
+
# allows editing an APPROVED template once every 24 hours and ten times in 30 days (rejected or
|
|
83
|
+
# paused: no limit), sends it back to review (the template returns to `PENDING` and does not
|
|
84
|
+
# send until the decision arrives by webhook) and does not let an approved template change
|
|
85
|
+
# category.
|
|
86
|
+
#
|
|
87
|
+
# @param id [String] parâmetro de caminho
|
|
88
|
+
# @param name [String] (corpo) Lowercase letters, numbers and _. This is the name you send by.
|
|
89
|
+
# @param language [String] (corpo) e.g. pt_BR. Both pt-BR and pt_BR are accepted.
|
|
90
|
+
# @param category [String] (corpo) Decides what the conversation COSTS and what Meta accepts in
|
|
91
|
+
# the content — not an administrative label. UTILITY is cheaper but only covers what the
|
|
92
|
+
# customer already expects; promotional wording in it gets reclassified, and the price changes
|
|
93
|
+
# with it.
|
|
94
|
+
# @param header [Hash, nil] (corpo)
|
|
95
|
+
# @param body [Hash] (corpo)
|
|
96
|
+
# @param footer [String, nil] (corpo) Up to 60 characters. Accepts no variables.
|
|
97
|
+
# @param buttons [Array<Hash>, nil] (corpo)
|
|
98
|
+
# @param code_expiry_minutes [Integer, nil] (corpo) AUTHENTICATION only, 1 to 90. In that
|
|
99
|
+
# category Meta writes the text itself and adds the copy-code button; this is the only thing you
|
|
100
|
+
# set.
|
|
101
|
+
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
102
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
103
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
104
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
105
|
+
# @raise [ArgumentError] parâmetro de caminho vazio, "." ou "..".
|
|
106
|
+
def edit_template(id, name:, language:, category:, body:, header: UNSET, footer: UNSET,
|
|
107
|
+
buttons: UNSET, code_expiry_minutes: UNSET, idempotency_key: nil,
|
|
108
|
+
timeout: nil)
|
|
109
|
+
payload = compact(
|
|
110
|
+
"name" => name,
|
|
111
|
+
"language" => language,
|
|
112
|
+
"category" => category,
|
|
113
|
+
"header" => header,
|
|
114
|
+
"body" => body,
|
|
115
|
+
"footer" => footer,
|
|
116
|
+
"buttons" => buttons,
|
|
117
|
+
"code_expiry_minutes" => code_expiry_minutes
|
|
118
|
+
)
|
|
119
|
+
request("PUT",
|
|
120
|
+
"/templates/#{segment(id, "id")}",
|
|
121
|
+
body: payload,
|
|
122
|
+
idempotency_key: idempotency_key,
|
|
123
|
+
timeout: timeout)
|
|
124
|
+
end
|
|
125
|
+
|
|
79
126
|
# Delete a template. `DELETE /templates/{id}`
|
|
80
127
|
#
|
|
81
128
|
# Removes it here and at Meta. Meta deletes ALL languages of a name at once — so when another
|
|
@@ -95,6 +142,81 @@ module Bzapper
|
|
|
95
142
|
timeout: timeout)
|
|
96
143
|
end
|
|
97
144
|
|
|
145
|
+
# Browse Meta's Template Library (ready-made utility and authentication texts). `GET
|
|
146
|
+
# /templates/library`
|
|
147
|
+
#
|
|
148
|
+
# Texts Meta has already approved. A template created from one of them without changing the text
|
|
149
|
+
# is approved immediately — no 24-hour review.
|
|
150
|
+
#
|
|
151
|
+
# @param search [String, nil] (query) Free text: order, delivery, payment…
|
|
152
|
+
# @param topic [String, nil] (query)
|
|
153
|
+
# @param usecase [String, nil] (query)
|
|
154
|
+
# @param industry [String, nil] (query)
|
|
155
|
+
# @param language [String, nil] (query) e.g. pt_BR.
|
|
156
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
157
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
158
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
159
|
+
def list_library_templates(search: nil, topic: nil, usecase: nil, industry: nil,
|
|
160
|
+
language: nil, timeout: nil)
|
|
161
|
+
query = {
|
|
162
|
+
"search" => search,
|
|
163
|
+
"topic" => topic,
|
|
164
|
+
"usecase" => usecase,
|
|
165
|
+
"industry" => industry,
|
|
166
|
+
"language" => language
|
|
167
|
+
}
|
|
168
|
+
request("GET", "/templates/library", query: query, timeout: timeout)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Create a template from the Template Library. `POST /templates/library`
|
|
172
|
+
#
|
|
173
|
+
# The text is Meta's, unchanged — that is what makes it approved at once. You only provide what
|
|
174
|
+
# the buttons need: the site link of a URL button (with an example of the variable suffix, when
|
|
175
|
+
# there is one) or the phone of a call button. Authentication items take `code_expiry_minutes`.
|
|
176
|
+
#
|
|
177
|
+
# @param library_template_name [String] (corpo)
|
|
178
|
+
# @param name [String, nil] (corpo) Your template name (defaults to the library name).
|
|
179
|
+
# @param language [String] (corpo)
|
|
180
|
+
# @param button_inputs [Array<Hash>, nil] (corpo) What each URL / phone button of the library
|
|
181
|
+
# template needs, in order.
|
|
182
|
+
# @param code_expiry_minutes [Integer, nil] (corpo) Authentication items only (default 10).
|
|
183
|
+
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
184
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
185
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
186
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
187
|
+
def create_template_from_library(library_template_name:, language:, name: UNSET,
|
|
188
|
+
button_inputs: UNSET, code_expiry_minutes: UNSET,
|
|
189
|
+
idempotency_key: nil, timeout: nil)
|
|
190
|
+
payload = compact(
|
|
191
|
+
"library_template_name" => library_template_name,
|
|
192
|
+
"name" => name,
|
|
193
|
+
"language" => language,
|
|
194
|
+
"button_inputs" => button_inputs,
|
|
195
|
+
"code_expiry_minutes" => code_expiry_minutes
|
|
196
|
+
)
|
|
197
|
+
request("POST",
|
|
198
|
+
"/templates/library",
|
|
199
|
+
body: payload,
|
|
200
|
+
idempotency_key: idempotency_key,
|
|
201
|
+
timeout: timeout)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# Performance of each template (sent, delivered, read, failed). `GET /templates/analytics`
|
|
205
|
+
#
|
|
206
|
+
# Counted from the messages sent through each template in the last `days` days, grouped by
|
|
207
|
+
# template name.
|
|
208
|
+
#
|
|
209
|
+
# @param days [Integer, nil] (query)
|
|
210
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
211
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
212
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
213
|
+
def get_template_analytics(days: nil, timeout: nil)
|
|
214
|
+
query = {
|
|
215
|
+
"days" => days
|
|
216
|
+
}
|
|
217
|
+
request("GET", "/templates/analytics", query: query, timeout: timeout)
|
|
218
|
+
end
|
|
219
|
+
|
|
98
220
|
# Import templates that exist at Meta and not here. `POST /templates/sync`
|
|
99
221
|
#
|
|
100
222
|
# For the account that already used the Cloud API before bZapper and created templates in
|
data/lib/bzapper/version.rb
CHANGED