bzapper 0.9.4 → 0.10.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/templates.rb +106 -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: 84d17cde4c28892c1f57d54e891bf6bf1d9b68e711046f8276515f775922d8da
|
|
4
|
+
data.tar.gz: d44bcc3fdda4b5e4e66d02972b0e8b7b0434a61e92d0cf059ef0f6149be1caf4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b8104c3e9059859bba1ca20c5b5a8281b47b3939c23358139549e8cb503bd2b8b0a921dd0d94bda75b85a3c8524d336d29545c6fe330b81ae0cec3c84c95750b
|
|
7
|
+
data.tar.gz: d712bbd689f1f8cf9559162ddbe6a4c2720398f79b88dfbf3ec0c22a40ee383411165e6307092d4a7af0375a3d456be5ae9aa8019ca26f774ce23816ea24b103
|
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.10.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.10.0"
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
## Hello world
|
|
@@ -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,65 @@ 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
|
+
|
|
98
204
|
# Import templates that exist at Meta and not here. `POST /templates/sync`
|
|
99
205
|
#
|
|
100
206
|
# For the account that already used the Cloud API before bZapper and created templates in
|
data/lib/bzapper/version.rb
CHANGED