bzapper 0.7.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 +7 -0
- data/LICENSE +21 -0
- data/README.md +323 -0
- data/lib/bzapper/client.rb +122 -0
- data/lib/bzapper/codec.rb +112 -0
- data/lib/bzapper/errors.rb +126 -0
- data/lib/bzapper/resources/accounts.rb +394 -0
- data/lib/bzapper/resources/advanced.rb +388 -0
- data/lib/bzapper/resources/advisories.rb +39 -0
- data/lib/bzapper/resources/base.rb +56 -0
- data/lib/bzapper/resources/billing.rb +177 -0
- data/lib/bzapper/resources/campaigns.rb +273 -0
- data/lib/bzapper/resources/connect.rb +35 -0
- data/lib/bzapper/resources/contacts.rb +481 -0
- data/lib/bzapper/resources/conversations.rb +47 -0
- data/lib/bzapper/resources/groups.rb +252 -0
- data/lib/bzapper/resources/instances.rb +287 -0
- data/lib/bzapper/resources/messages.rb +920 -0
- data/lib/bzapper/resources/partner.rb +134 -0
- data/lib/bzapper/resources/pools.rb +69 -0
- data/lib/bzapper/resources/scheduling.rb +38 -0
- data/lib/bzapper/resources/system.rb +21 -0
- data/lib/bzapper/resources/usage.rb +42 -0
- data/lib/bzapper/resources/webhooks.rb +147 -0
- data/lib/bzapper/resources.rb +100 -0
- data/lib/bzapper/transport.rb +248 -0
- data/lib/bzapper/unset.rb +27 -0
- data/lib/bzapper/upload.rb +61 -0
- data/lib/bzapper/version.rb +7 -0
- data/lib/bzapper/webhook.rb +194 -0
- data/lib/bzapper.rb +30 -0
- metadata +74 -0
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# GERADO por script/generate.rb a partir de packages/sdk/openapi.yaml — não edite à mão.
|
|
4
|
+
|
|
5
|
+
module Bzapper
|
|
6
|
+
module Resources
|
|
7
|
+
# Contatos (CRM), tags, grupos de contatos, opt-in/out, supressões e checagem — `client.contacts`.
|
|
8
|
+
class Contacts < Base
|
|
9
|
+
# Contact base (list + filters). `GET /contacts`
|
|
10
|
+
#
|
|
11
|
+
# Lists the tenant's contacts — CRM fields plus name (WhatsApp push name), phone, avatar (best
|
|
12
|
+
# effort) and activity. Supports rich filtering (search, tags/groups, location, document,
|
|
13
|
+
# activity/creation windows) and offset pagination.
|
|
14
|
+
#
|
|
15
|
+
# @param search [String, nil] (query) Filter by name, phone, email or document.
|
|
16
|
+
# @param tags [Array<String>, nil] (query) Tag keys (repeat the param or a CSV list).
|
|
17
|
+
# @param tags_match [String, nil] (query) Match ANY (default) or ALL of `tags`.
|
|
18
|
+
# @param groups [Array<String>, nil] (query) Contact-group keys (repeat the param or a CSV
|
|
19
|
+
# list).
|
|
20
|
+
# @param project_id [String, nil] (query) Scope by project (alternative to the X-Project-Id
|
|
21
|
+
# header).
|
|
22
|
+
# @param instance_id [String, nil] (query) Filter by a number (instance) the contact interacted
|
|
23
|
+
# with. The contact↔number link is maintained automatically by the API (inbound/outbound
|
|
24
|
+
# correlation).
|
|
25
|
+
# @param status [String, nil] (query)
|
|
26
|
+
# @param city [String, nil] (query)
|
|
27
|
+
# @param state [String, nil] (query)
|
|
28
|
+
# @param country [String, nil] (query)
|
|
29
|
+
# @param zip [String, nil] (query)
|
|
30
|
+
# @param document [String, nil] (query)
|
|
31
|
+
# @param has_email [Boolean, nil] (query) Only contacts that have (true) or lack (false) an
|
|
32
|
+
# email.
|
|
33
|
+
# @param last_activity_after [Time, String, nil] (query) last_message_at ≥ this instant
|
|
34
|
+
# (RFC3339).
|
|
35
|
+
# @param last_activity_before [Time, String, nil] (query) last_message_at ≤ this instant
|
|
36
|
+
# (RFC3339).
|
|
37
|
+
# @param created_after [Time, String, nil] (query) created_at ≥ this instant (RFC3339).
|
|
38
|
+
# @param created_before [Time, String, nil] (query) created_at ≤ this instant (RFC3339).
|
|
39
|
+
# @param sort [String, nil] (query)
|
|
40
|
+
# @param limit [Integer, nil] (query)
|
|
41
|
+
# @param offset [Integer, nil] (query)
|
|
42
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
43
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
44
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
45
|
+
def list_contacts(search: nil, tags: nil, tags_match: nil, groups: nil, project_id: nil,
|
|
46
|
+
instance_id: nil, status: nil, city: nil, state: nil, country: nil,
|
|
47
|
+
zip: nil, document: nil, has_email: nil, last_activity_after: nil,
|
|
48
|
+
last_activity_before: nil, created_after: nil, created_before: nil,
|
|
49
|
+
sort: nil, limit: nil, offset: nil, timeout: nil)
|
|
50
|
+
query = {
|
|
51
|
+
"search" => search,
|
|
52
|
+
"tags" => tags,
|
|
53
|
+
"tags_match" => tags_match,
|
|
54
|
+
"groups" => groups,
|
|
55
|
+
"project_id" => project_id,
|
|
56
|
+
"instance_id" => instance_id,
|
|
57
|
+
"status" => status,
|
|
58
|
+
"city" => city,
|
|
59
|
+
"state" => state,
|
|
60
|
+
"country" => country,
|
|
61
|
+
"zip" => zip,
|
|
62
|
+
"document" => document,
|
|
63
|
+
"has_email" => has_email,
|
|
64
|
+
"last_activity_after" => last_activity_after,
|
|
65
|
+
"last_activity_before" => last_activity_before,
|
|
66
|
+
"created_after" => created_after,
|
|
67
|
+
"created_before" => created_before,
|
|
68
|
+
"sort" => sort,
|
|
69
|
+
"limit" => limit,
|
|
70
|
+
"offset" => offset
|
|
71
|
+
}
|
|
72
|
+
request("GET", "/contacts", query: query, timeout: timeout)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Create a contact. `POST /contacts`
|
|
76
|
+
#
|
|
77
|
+
# Creates a contact in the base with CRM fields. `phone` is required (+DDIdigits).
|
|
78
|
+
# Name/email/document/address are optional. Idempotent by phone: if the contact already exists,
|
|
79
|
+
# only its empty fields are filled (never overwritten) and it is returned with 201.
|
|
80
|
+
#
|
|
81
|
+
# @param phone [String] (corpo) +DDIdigits (E.164 without spaces).
|
|
82
|
+
# @param name [String, nil] (corpo)
|
|
83
|
+
# @param email [String, nil] (corpo)
|
|
84
|
+
# @param document [String, nil] (corpo)
|
|
85
|
+
# @param document_type [String, nil] (corpo)
|
|
86
|
+
# @param address [Hash, nil] (corpo) Postal address of the contact.
|
|
87
|
+
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
88
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
89
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
90
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
91
|
+
def create_contact(phone:, name: UNSET, email: UNSET, document: UNSET, document_type: UNSET,
|
|
92
|
+
address: UNSET, idempotency_key: nil, timeout: nil)
|
|
93
|
+
payload = compact(
|
|
94
|
+
"phone" => phone,
|
|
95
|
+
"name" => name,
|
|
96
|
+
"email" => email,
|
|
97
|
+
"document" => document,
|
|
98
|
+
"document_type" => document_type,
|
|
99
|
+
"address" => address
|
|
100
|
+
)
|
|
101
|
+
request("POST",
|
|
102
|
+
"/contacts",
|
|
103
|
+
body: payload,
|
|
104
|
+
idempotency_key: idempotency_key,
|
|
105
|
+
timeout: timeout)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Get a contact. `GET /contacts/{id}`
|
|
109
|
+
#
|
|
110
|
+
# @param id [String] Contact ID (UUID).
|
|
111
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
112
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
113
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
114
|
+
# @raise [ArgumentError] parâmetro de caminho vazio, "." ou "..".
|
|
115
|
+
def get_contact(id, timeout: nil)
|
|
116
|
+
request("GET", "/contacts/#{segment(id, "id")}", timeout: timeout)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Update a contact. `PATCH /contacts/{id}`
|
|
120
|
+
#
|
|
121
|
+
# Partial update of the contact's CRM fields.
|
|
122
|
+
#
|
|
123
|
+
# @param id [String] Contact ID (UUID).
|
|
124
|
+
# @param name [String, nil] (corpo)
|
|
125
|
+
# @param email [String, nil] (corpo)
|
|
126
|
+
# @param document [String, nil] (corpo)
|
|
127
|
+
# @param document_type [String, nil] (corpo)
|
|
128
|
+
# @param address [Hash, nil] (corpo) Postal address of the contact.
|
|
129
|
+
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
130
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
131
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
132
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
133
|
+
# @raise [ArgumentError] parâmetro de caminho vazio, "." ou "..".
|
|
134
|
+
def update_contact(id, name: UNSET, email: UNSET, document: UNSET, document_type: UNSET,
|
|
135
|
+
address: UNSET, idempotency_key: nil, timeout: nil)
|
|
136
|
+
payload = compact(
|
|
137
|
+
"name" => name,
|
|
138
|
+
"email" => email,
|
|
139
|
+
"document" => document,
|
|
140
|
+
"document_type" => document_type,
|
|
141
|
+
"address" => address
|
|
142
|
+
)
|
|
143
|
+
request("PATCH",
|
|
144
|
+
"/contacts/#{segment(id, "id")}",
|
|
145
|
+
body: payload,
|
|
146
|
+
idempotency_key: idempotency_key,
|
|
147
|
+
timeout: timeout)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# Delete a contact. `DELETE /contacts/{id}`
|
|
151
|
+
#
|
|
152
|
+
# @param id [String] Contact ID (UUID).
|
|
153
|
+
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
154
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
155
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
156
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
157
|
+
# @raise [ArgumentError] parâmetro de caminho vazio, "." ou "..".
|
|
158
|
+
def delete_contact(id, idempotency_key: nil, timeout: nil)
|
|
159
|
+
request("DELETE",
|
|
160
|
+
"/contacts/#{segment(id, "id")}",
|
|
161
|
+
idempotency_key: idempotency_key,
|
|
162
|
+
timeout: timeout)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# Contact timeline (messages + events). `GET /contacts/{id}/history`
|
|
166
|
+
#
|
|
167
|
+
# Unified chronological history of the contact — messages (inbound/outbound) and events
|
|
168
|
+
# (opt-out, notes, tag/group changes, status transitions).
|
|
169
|
+
#
|
|
170
|
+
# @param id [String] Contact ID (UUID).
|
|
171
|
+
# @param limit [Integer, nil] (query) Max items.
|
|
172
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
173
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
174
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
175
|
+
# @raise [ArgumentError] parâmetro de caminho vazio, "." ou "..".
|
|
176
|
+
def get_contact_history(id, limit: nil, timeout: nil)
|
|
177
|
+
query = {
|
|
178
|
+
"limit" => limit
|
|
179
|
+
}
|
|
180
|
+
request("GET", "/contacts/#{segment(id, "id")}/history", query: query, timeout: timeout)
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# Add an internal note to the contact. `POST /contacts/{id}/notes`
|
|
184
|
+
#
|
|
185
|
+
# The note is internal (audit/CRM), never sent to the contact. Appears in the timeline.
|
|
186
|
+
#
|
|
187
|
+
# @param id [String] Contact ID (UUID).
|
|
188
|
+
# @param body [String] (corpo) Note text (internal, not sent to the contact).
|
|
189
|
+
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
190
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
191
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
192
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
193
|
+
# @raise [ArgumentError] parâmetro de caminho vazio, "." ou "..".
|
|
194
|
+
def add_contact_note(id, body:, idempotency_key: nil, timeout: nil)
|
|
195
|
+
payload = compact(
|
|
196
|
+
"body" => body
|
|
197
|
+
)
|
|
198
|
+
request("POST",
|
|
199
|
+
"/contacts/#{segment(id, "id")}/notes",
|
|
200
|
+
body: payload,
|
|
201
|
+
idempotency_key: idempotency_key,
|
|
202
|
+
timeout: timeout)
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# Add/remove tags on the contact. `POST /contacts/{id}/tags`
|
|
206
|
+
#
|
|
207
|
+
# Batch correlation. Unknown tag keys in `add` are created in the tag dictionary.
|
|
208
|
+
#
|
|
209
|
+
# @param id [String] Contact ID (UUID).
|
|
210
|
+
# @param add [Array<String>, nil] (corpo) Keys to add.
|
|
211
|
+
# @param remove [Array<String>, nil] (corpo) Keys to remove.
|
|
212
|
+
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
213
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
214
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
215
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
216
|
+
# @raise [ArgumentError] parâmetro de caminho vazio, "." ou "..".
|
|
217
|
+
def mutate_contact_tags(id, add: UNSET, remove: UNSET, idempotency_key: nil, timeout: nil)
|
|
218
|
+
payload = compact(
|
|
219
|
+
"add" => add,
|
|
220
|
+
"remove" => remove
|
|
221
|
+
)
|
|
222
|
+
request("POST",
|
|
223
|
+
"/contacts/#{segment(id, "id")}/tags",
|
|
224
|
+
body: payload,
|
|
225
|
+
idempotency_key: idempotency_key,
|
|
226
|
+
timeout: timeout)
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
# Add/remove contact groups on the contact. `POST /contacts/{id}/groups`
|
|
230
|
+
#
|
|
231
|
+
# Batch correlation with contact groups (NOT WhatsApp groups). Unknown group keys in `add` are
|
|
232
|
+
# created.
|
|
233
|
+
#
|
|
234
|
+
# @param id [String] Contact ID (UUID).
|
|
235
|
+
# @param add [Array<String>, nil] (corpo) Keys to add.
|
|
236
|
+
# @param remove [Array<String>, nil] (corpo) Keys to remove.
|
|
237
|
+
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
238
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
239
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
240
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
241
|
+
# @raise [ArgumentError] parâmetro de caminho vazio, "." ou "..".
|
|
242
|
+
def mutate_contact_groups(id, add: UNSET, remove: UNSET, idempotency_key: nil, timeout: nil)
|
|
243
|
+
payload = compact(
|
|
244
|
+
"add" => add,
|
|
245
|
+
"remove" => remove
|
|
246
|
+
)
|
|
247
|
+
request("POST",
|
|
248
|
+
"/contacts/#{segment(id, "id")}/groups",
|
|
249
|
+
body: payload,
|
|
250
|
+
idempotency_key: idempotency_key,
|
|
251
|
+
timeout: timeout)
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
# Opt the contact out (LGPD). `POST /contacts/{id}/optout`
|
|
255
|
+
#
|
|
256
|
+
# Marks the contact as opted out (status `opted_out`, sets `opted_out_at`) and adds it to the
|
|
257
|
+
# suppression list. Sends to this contact are blocked afterwards.
|
|
258
|
+
#
|
|
259
|
+
# @param id [String] Contact ID (UUID).
|
|
260
|
+
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
261
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
262
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
263
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
264
|
+
# @raise [ArgumentError] parâmetro de caminho vazio, "." ou "..".
|
|
265
|
+
def opt_out_contact(id, idempotency_key: nil, timeout: nil)
|
|
266
|
+
request("POST",
|
|
267
|
+
"/contacts/#{segment(id, "id")}/optout",
|
|
268
|
+
idempotency_key: idempotency_key,
|
|
269
|
+
timeout: timeout)
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
# Manually suppress the contact. `POST /contacts/{id}/suppress`
|
|
273
|
+
#
|
|
274
|
+
# Manual block — sets status `blocked` and adds a suppression entry so the contact stops
|
|
275
|
+
# receiving sends. Distinct from `/contacts/{jid}/block`, which blocks a number at the WhatsApp
|
|
276
|
+
# level.
|
|
277
|
+
#
|
|
278
|
+
# @param id [String] Contact ID (UUID).
|
|
279
|
+
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
280
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
281
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
282
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
283
|
+
# @raise [ArgumentError] parâmetro de caminho vazio, "." ou "..".
|
|
284
|
+
def suppress_contact(id, idempotency_key: nil, timeout: nil)
|
|
285
|
+
request("POST",
|
|
286
|
+
"/contacts/#{segment(id, "id")}/suppress",
|
|
287
|
+
idempotency_key: idempotency_key,
|
|
288
|
+
timeout: timeout)
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
# Opt the contact back in (remove suppression). `POST /contacts/{id}/optin`
|
|
292
|
+
#
|
|
293
|
+
# Removes the suppression (opt-out/manual) and reactivates the contact (status `active`).
|
|
294
|
+
#
|
|
295
|
+
# @param id [String] Contact ID (UUID).
|
|
296
|
+
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
297
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
298
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
299
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
300
|
+
# @raise [ArgumentError] parâmetro de caminho vazio, "." ou "..".
|
|
301
|
+
def opt_in_contact(id, idempotency_key: nil, timeout: nil)
|
|
302
|
+
request("POST",
|
|
303
|
+
"/contacts/#{segment(id, "id")}/optin",
|
|
304
|
+
idempotency_key: idempotency_key,
|
|
305
|
+
timeout: timeout)
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
# List the tag dictionary. `GET /tags`
|
|
309
|
+
#
|
|
310
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
311
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
312
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
313
|
+
def list_tags(timeout: nil)
|
|
314
|
+
request("GET", "/tags", timeout: timeout)
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
# Create a tag. `POST /tags`
|
|
318
|
+
#
|
|
319
|
+
# @param key [String] (corpo) Stable slug (unique in the dictionary). Posting an existing key
|
|
320
|
+
# updates it.
|
|
321
|
+
# @param name [String, nil] (corpo)
|
|
322
|
+
# @param color [String, nil] (corpo)
|
|
323
|
+
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
324
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
325
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
326
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
327
|
+
def create_tag(key:, name: UNSET, color: UNSET, idempotency_key: nil, timeout: nil)
|
|
328
|
+
payload = compact(
|
|
329
|
+
"key" => key,
|
|
330
|
+
"name" => name,
|
|
331
|
+
"color" => color
|
|
332
|
+
)
|
|
333
|
+
request("POST", "/tags", body: payload, idempotency_key: idempotency_key, timeout: timeout)
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
# Delete a tag. `DELETE /tags/{id}`
|
|
337
|
+
#
|
|
338
|
+
# Removes the tag from the dictionary and unlinks it from every contact.
|
|
339
|
+
#
|
|
340
|
+
# @param id [String] Contact ID (UUID).
|
|
341
|
+
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
342
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
343
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
344
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
345
|
+
# @raise [ArgumentError] parâmetro de caminho vazio, "." ou "..".
|
|
346
|
+
def delete_tag(id, idempotency_key: nil, timeout: nil)
|
|
347
|
+
request("DELETE",
|
|
348
|
+
"/tags/#{segment(id, "id")}",
|
|
349
|
+
idempotency_key: idempotency_key,
|
|
350
|
+
timeout: timeout)
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
# List the contact-group dictionary. `GET /contact-groups`
|
|
354
|
+
#
|
|
355
|
+
# Contact groups (CRM segments) — NOT WhatsApp groups (see `/groups`). Bulk correlation happens
|
|
356
|
+
# via the `groups`/`tags` fields on message sends.
|
|
357
|
+
#
|
|
358
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
359
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
360
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
361
|
+
def list_contact_groups(timeout: nil)
|
|
362
|
+
request("GET", "/contact-groups", timeout: timeout)
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
# Create a contact group. `POST /contact-groups`
|
|
366
|
+
#
|
|
367
|
+
# @param key [String] (corpo) Stable slug (unique in the dictionary). Posting an existing key
|
|
368
|
+
# updates it.
|
|
369
|
+
# @param name [String, nil] (corpo)
|
|
370
|
+
# @param color [String, nil] (corpo)
|
|
371
|
+
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
372
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
373
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
374
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
375
|
+
def create_contact_group(key:, name: UNSET, color: UNSET, idempotency_key: nil, timeout: nil)
|
|
376
|
+
payload = compact(
|
|
377
|
+
"key" => key,
|
|
378
|
+
"name" => name,
|
|
379
|
+
"color" => color
|
|
380
|
+
)
|
|
381
|
+
request("POST",
|
|
382
|
+
"/contact-groups",
|
|
383
|
+
body: payload,
|
|
384
|
+
idempotency_key: idempotency_key,
|
|
385
|
+
timeout: timeout)
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
# Delete a contact group. `DELETE /contact-groups/{id}`
|
|
389
|
+
#
|
|
390
|
+
# Removes the contact group from the dictionary and unlinks it from every contact.
|
|
391
|
+
#
|
|
392
|
+
# @param id [String] Contact ID (UUID).
|
|
393
|
+
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
394
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
395
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
396
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
397
|
+
# @raise [ArgumentError] parâmetro de caminho vazio, "." ou "..".
|
|
398
|
+
def delete_contact_group(id, idempotency_key: nil, timeout: nil)
|
|
399
|
+
request("DELETE",
|
|
400
|
+
"/contact-groups/#{segment(id, "id")}",
|
|
401
|
+
idempotency_key: idempotency_key,
|
|
402
|
+
timeout: timeout)
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
# List the suppression list. `GET /suppressions`
|
|
406
|
+
#
|
|
407
|
+
# Contacts that must not receive sends (opt-out, manual, bounce, etc.).
|
|
408
|
+
#
|
|
409
|
+
# @param limit [Integer, nil] (query)
|
|
410
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
411
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
412
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
413
|
+
def list_suppressions(limit: nil, timeout: nil)
|
|
414
|
+
query = {
|
|
415
|
+
"limit" => limit
|
|
416
|
+
}
|
|
417
|
+
request("GET", "/suppressions", query: query, timeout: timeout)
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
# Add a number to the suppression list. `POST /suppressions`
|
|
421
|
+
#
|
|
422
|
+
# @param phone [String] (corpo) +DDIdigits (E.164 without spaces).
|
|
423
|
+
# @param reason [String, nil] (corpo)
|
|
424
|
+
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
425
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
426
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
427
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
428
|
+
def create_suppression(phone:, reason: UNSET, idempotency_key: nil, timeout: nil)
|
|
429
|
+
payload = compact(
|
|
430
|
+
"phone" => phone,
|
|
431
|
+
"reason" => reason
|
|
432
|
+
)
|
|
433
|
+
request("POST",
|
|
434
|
+
"/suppressions",
|
|
435
|
+
body: payload,
|
|
436
|
+
idempotency_key: idempotency_key,
|
|
437
|
+
timeout: timeout)
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
# Remove a number from the suppression list. `DELETE /suppressions`
|
|
441
|
+
#
|
|
442
|
+
# Un-suppresses the number identified by the `phone` query param.
|
|
443
|
+
#
|
|
444
|
+
# @param phone [String] (query) +DDIdigits (E.164 without spaces).
|
|
445
|
+
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
446
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
447
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
448
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
449
|
+
def delete_suppression(phone:, idempotency_key: nil, timeout: nil)
|
|
450
|
+
query = {
|
|
451
|
+
"phone" => phone
|
|
452
|
+
}
|
|
453
|
+
request("DELETE",
|
|
454
|
+
"/suppressions",
|
|
455
|
+
query: query,
|
|
456
|
+
idempotency_key: idempotency_key,
|
|
457
|
+
timeout: timeout)
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
# Check whether numbers are on WhatsApp (IsOnWhatsApp). `POST /contacts/check`
|
|
461
|
+
#
|
|
462
|
+
# @param instance_id [String] (corpo)
|
|
463
|
+
# @param phones [Array<String>] (corpo)
|
|
464
|
+
# @param idempotency_key [String, nil] chave de idempotência (senão a SDK gera uma).
|
|
465
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
466
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
467
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
468
|
+
def contacts_check(instance_id:, phones:, idempotency_key: nil, timeout: nil)
|
|
469
|
+
payload = compact(
|
|
470
|
+
"instance_id" => instance_id,
|
|
471
|
+
"phones" => phones
|
|
472
|
+
)
|
|
473
|
+
request("POST",
|
|
474
|
+
"/contacts/check",
|
|
475
|
+
body: payload,
|
|
476
|
+
idempotency_key: idempotency_key,
|
|
477
|
+
timeout: timeout)
|
|
478
|
+
end
|
|
479
|
+
end
|
|
480
|
+
end
|
|
481
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# GERADO por script/generate.rb a partir de packages/sdk/openapi.yaml — não edite à mão.
|
|
4
|
+
|
|
5
|
+
module Bzapper
|
|
6
|
+
module Resources
|
|
7
|
+
# Conversas (inbox) e histórico — `client.conversations`.
|
|
8
|
+
class Conversations < Base
|
|
9
|
+
# List inbox threads (all numbers, or one with instance_id). `GET /conversations`
|
|
10
|
+
#
|
|
11
|
+
# @param instance_id [String, nil] (query) Restrict to one number. Omit for the unified inbox
|
|
12
|
+
# across all numbers.
|
|
13
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
14
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
15
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
16
|
+
def list_conversations(instance_id: nil, timeout: nil)
|
|
17
|
+
query = {
|
|
18
|
+
"instance_id" => instance_id
|
|
19
|
+
}
|
|
20
|
+
request("GET", "/conversations", query: query, timeout: timeout)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Paginated history of a chat. `GET /conversations/{jid}/messages`
|
|
24
|
+
#
|
|
25
|
+
# @param jid [String] chat_jid of the contact/group.
|
|
26
|
+
# @param instance_id [String, nil] (query) Restrict to one number. Omit for the history across
|
|
27
|
+
# all numbers.
|
|
28
|
+
# @param before [Time, String, nil] (query) Returns messages before this instant (RFC3339).
|
|
29
|
+
# @param limit [Integer, nil] (query)
|
|
30
|
+
# @param timeout [Numeric, nil] segundos por tentativa (padrão: o do cliente).
|
|
31
|
+
# @return [Hash, Array, nil] o JSON da resposta, inteiro (nil em 204).
|
|
32
|
+
# @raise [Bzapper::Error] resposta fora de 2xx ou falha de rede.
|
|
33
|
+
# @raise [ArgumentError] parâmetro de caminho vazio, "." ou "..".
|
|
34
|
+
def conversation_history(jid, instance_id: nil, before: nil, limit: nil, timeout: nil)
|
|
35
|
+
query = {
|
|
36
|
+
"instance_id" => instance_id,
|
|
37
|
+
"before" => before,
|
|
38
|
+
"limit" => limit
|
|
39
|
+
}
|
|
40
|
+
request("GET",
|
|
41
|
+
"/conversations/#{segment(jid, "jid")}/messages",
|
|
42
|
+
query: query,
|
|
43
|
+
timeout: timeout)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|