vatio-sdk 0.8.0 → 0.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c921c47af7fe3fc6252679275a7717a2c3df5651c2772af28bb99202a8d11bb
4
- data.tar.gz: 243719a522e1007183c248e847067f975ac727063edba7d561b85c941aecc596
3
+ metadata.gz: 8fc024c85ca67669f7b0971a9fafbd65c0932f1608e7e2ffdc8a8714088d5e5c
4
+ data.tar.gz: 4801d1b1efe265284e53ae3c2d29ae09cda61016e85c66c33547f1fe2723ae81
5
5
  SHA512:
6
- metadata.gz: 733e344de538c7430bbb5c85f51152aa87949a0fa70e0ac0bc01dd2fdffc29bb620887105c3e00e2c604b75506e44bc4bc606e361e7713f095bf5aee1f6393e5
7
- data.tar.gz: 344d942247e4a56f60fd2a601a917eb4305668d628d40ac8c658b02f092d234c179ad6506b61d40cb4a8cb924b44603fe729f912391c7ce5e4a3553c8c315791
6
+ metadata.gz: 5105ee83825f513850f5e0196af8c6af66dd9aa5a500e0cc9f1be60f47a1be04fd055532e432f5ee394144790d3f1186ac427686e10a5778f6605fac32d6eff8
7
+ data.tar.gz: 600c732a95c860429fab141eb4ae4a70cd945a477c1a20f1c63609a6916c7bc99334c0fed9fc8a7d679dd70b80af6e16064dd6259db816355f866646e3ee172c
data/README.md CHANGED
@@ -242,6 +242,17 @@ you:
242
242
  template: offer.with_params("Ana").merge(buttons: [{ index: 0, params: [offer.code] }])
243
243
  ```
244
244
 
245
+ Anything else a template takes (a media or text header, named
246
+ parameters, a coupon code) goes as Meta's own send components, as each
247
+ template's `example` shows:
248
+
249
+ ```ruby
250
+ template: { name: "ati_offer", language: "es", components: [
251
+ { type: "header", parameters: [{ type: "image", image: { link: photo_url } }] },
252
+ { type: "body", parameters: [{ type: "text", parameter_name: "name", text: "Ana" }] }
253
+ ] }
254
+ ```
255
+
245
256
  The response only says it is queued: the agent's turn and Meta's delivery
246
257
  both happen after it. `Vatio::Server.message_status(id)` reads it back,
247
258
  with `content` (what reached the phone) once it is sent, and
@@ -301,7 +312,7 @@ end
301
312
  | `OutsideWindow` | `outside_window`, with `last_inbound_at` |
302
313
  | `OptedOut` | `opted_out` |
303
314
  | `HumanAnswering` | `human_takeover`, `handoff_pending` |
304
- | `TemplateError` | `template_not_found` (often created in Meta a minute ago: Vatio is syncing, retry shortly), `template_not_approved`, `template_params`, `template_buttons`, `template_required` |
315
+ | `TemplateError` | `template_not_found` (often created in Meta a minute ago: Vatio is syncing, retry shortly), `template_not_approved`, `template_params`, `template_buttons`, `template_components`, `template_required` |
305
316
  | `InvalidRequest` | Any other 422: `invalid_recipient`, `content_required`, `invalid_identity`, `not_a_test_phone`… |
306
317
  | `Unauthorized` | 401 / 403: the key is wrong, revoked, or another workspace's |
307
318
  | `Conflict` | Any other 409: `idempotency_conflict` (`details["message_id"]`), `identity_conflict`, `whatsapp_not_connected`, `whatsapp_paused`, `whatsapp_number_unhealthy` (Meta refuses every send from the number; `details["issue"]` says why and the fix) |
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Vatio
4
4
  module Identity
5
- VERSION = "0.8.0"
5
+ VERSION = "0.9.0"
6
6
  end
7
7
  end
@@ -38,7 +38,9 @@ module Vatio
38
38
  # template: { name:, language:, params: [], buttons: [{ index:, params: [] }] },
39
39
  # used only when the 24-hour window is closed -- send it too
40
40
  # to always reach the person. `buttons` fills URL buttons
41
- # whose link ends in {{1}}.
41
+ # whose link ends in {{1}}. Or { name:, language:, components: [] }
42
+ # with Meta's own send components, for anything else a
43
+ # template takes (a header, named parameters, a coupon code).
42
44
  # An authentication template takes `code:` instead of params,
43
45
  # with no brief or text, and is sent whatever the window.
44
46
  #
@@ -150,6 +152,10 @@ module Vatio
150
152
  # Accepts a Hash with symbol or string keys, or anything with `to_h`.
151
153
  def normalize_template(template)
152
154
  hash = template.to_h.transform_keys(&:to_s)
155
+ if hash.key?("components")
156
+ return { name: hash["name"], language: hash["language"], components: Array(hash["components"]) }
157
+ end
158
+
153
159
  { name: hash["name"], language: hash["language"], params: Array(hash["params"]).map(&:to_s),
154
160
  code: hash["code"]&.to_s, buttons: normalize_buttons(hash["buttons"]) }.compact
155
161
  end
@@ -13,9 +13,15 @@ module Vatio
13
13
  #
14
14
  # template: offer.with_params("Ana").merge(buttons: [{ index: 0, params: ["ABC123"] }])
15
15
  #
16
+ # Anything else it takes (a header, named parameters, a coupon code) goes
17
+ # as Meta's own send components; `example` shows them:
18
+ #
19
+ # template: { name: t.name, language: t.language, components: [...] }
20
+ #
16
21
  # Empty on a preview key: the preview number's templates are Vatio's.
17
22
  Template = Struct.new(
18
- :name, :language, :category, :status, :rejected_reason, :body, :parameter_count, :buttons, :example,
23
+ :name, :language, :category, :status, :rejected_reason, :body, :parameter_count, :parameter_format, :buttons,
24
+ :components, :example,
19
25
  keyword_init: true
20
26
  ) do
21
27
  def self.from(hash) = Value.build(self, hash)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vatio-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Urcalab