warb 0.1.4 → 1.0.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.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -12
  3. data/README.md +9 -32
  4. data/Rakefile +3 -3
  5. data/docs/README.md +1 -4
  6. data/docs/components/README.md +1 -4
  7. data/docs/messages/README.md +1 -2
  8. data/docs/messages/flow.md +5 -241
  9. data/docs/messages/interactive_call_to_action_url.md +9 -9
  10. data/docs/messages/interactive_list.md +2 -2
  11. data/docs/messages/interactive_reply_button.md +9 -9
  12. data/docs/setup.md +1 -45
  13. data/examples/audio.rb +10 -10
  14. data/examples/document.rb +34 -34
  15. data/examples/image.rb +22 -22
  16. data/examples/interactive_call_to_action_url.rb +46 -46
  17. data/examples/interactive_list.rb +61 -61
  18. data/examples/interactive_reply_button.rb +43 -43
  19. data/examples/location.rb +32 -32
  20. data/examples/location_request.rb +11 -11
  21. data/examples/message.rb +8 -8
  22. data/examples/sticker.rb +10 -10
  23. data/examples/video.rb +22 -22
  24. data/examples/webhook.rb +43 -77
  25. data/lib/warb/client.rb +5 -7
  26. data/lib/warb/components/action.rb +8 -12
  27. data/lib/warb/configuration.rb +1 -4
  28. data/lib/warb/connection.rb +9 -15
  29. data/lib/warb/dispatcher.rb +3 -4
  30. data/lib/warb/dispatcher_concern.rb +0 -6
  31. data/lib/warb/indicator_dispatcher.rb +4 -4
  32. data/lib/warb/media_dispatcher.rb +10 -10
  33. data/lib/warb/resources/audio.rb +1 -1
  34. data/lib/warb/resources/contact.rb +20 -22
  35. data/lib/warb/resources/document.rb +1 -1
  36. data/lib/warb/resources/flow.rb +20 -82
  37. data/lib/warb/resources/image.rb +1 -1
  38. data/lib/warb/resources/interactive_call_to_action_url.rb +8 -10
  39. data/lib/warb/resources/interactive_list.rb +5 -7
  40. data/lib/warb/resources/interactive_reply_button.rb +8 -10
  41. data/lib/warb/resources/location.rb +1 -11
  42. data/lib/warb/resources/location_request.rb +3 -5
  43. data/lib/warb/resources/reaction.rb +1 -1
  44. data/lib/warb/resources/resource.rb +4 -14
  45. data/lib/warb/resources/sticker.rb +1 -1
  46. data/lib/warb/resources/text.rb +3 -31
  47. data/lib/warb/resources/video.rb +1 -1
  48. data/lib/warb/utils.rb +1 -3
  49. data/lib/warb/version.rb +1 -1
  50. data/lib/warb.rb +31 -67
  51. metadata +3 -34
  52. data/docs/components/button.md +0 -62
  53. data/docs/components/copy_code_button.md +0 -57
  54. data/docs/components/flow_button.md +0 -102
  55. data/docs/components/url_button.md +0 -57
  56. data/docs/messages/template.md +0 -373
  57. data/docs/resources/README.md +0 -14
  58. data/docs/resources/currency.md +0 -22
  59. data/docs/resources/date_time.md +0 -11
  60. data/docs/resources/text.md +0 -9
  61. data/lib/warb/category.rb +0 -8
  62. data/lib/warb/components/button.rb +0 -29
  63. data/lib/warb/components/component.rb +0 -19
  64. data/lib/warb/components/copy_code_button.rb +0 -30
  65. data/lib/warb/components/flow_button.rb +0 -32
  66. data/lib/warb/components/quick_reply_button.rb +0 -15
  67. data/lib/warb/components/url_button.rb +0 -30
  68. data/lib/warb/components/voice_call_button.rb +0 -15
  69. data/lib/warb/errors.rb +0 -27
  70. data/lib/warb/language.rb +0 -8
  71. data/lib/warb/resources/currency.rb +0 -47
  72. data/lib/warb/resources/date_time.rb +0 -34
  73. data/lib/warb/resources/helpers/header.rb +0 -35
  74. data/lib/warb/resources/template.rb +0 -163
  75. data/lib/warb/resources/validation.rb +0 -30
  76. data/lib/warb/response.rb +0 -33
  77. data/lib/warb/response_error_handler.rb +0 -42
  78. data/lib/warb/template_dispatcher.rb +0 -21
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rebase
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-09-15 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: faraday
@@ -53,11 +52,8 @@ files:
53
52
  - docs/README.md
54
53
  - docs/components/README.md
55
54
  - docs/components/address.md
56
- - docs/components/button.md
57
- - docs/components/copy_code_button.md
58
55
  - docs/components/cta_action.md
59
56
  - docs/components/email.md
60
- - docs/components/flow_button.md
61
57
  - docs/components/list_action.md
62
58
  - docs/components/name.md
63
59
  - docs/components/org.md
@@ -66,7 +62,6 @@ files:
66
62
  - docs/components/row.md
67
63
  - docs/components/section.md
68
64
  - docs/components/url.md
69
- - docs/components/url_button.md
70
65
  - docs/images/contact-with-wa_id.png
71
66
  - docs/images/contact-without-wa_id.png
72
67
  - docs/messages/README.md
@@ -83,13 +78,8 @@ files:
83
78
  - docs/messages/location_request.md
84
79
  - docs/messages/reaction.md
85
80
  - docs/messages/sticker.md
86
- - docs/messages/template.md
87
81
  - docs/messages/text.md
88
82
  - docs/messages/video.md
89
- - docs/resources/README.md
90
- - docs/resources/currency.md
91
- - docs/resources/date_time.md
92
- - docs/resources/text.md
93
83
  - docs/setup.md
94
84
  - docs/webhook.md
95
85
  - examples/audio.rb
@@ -105,37 +95,24 @@ files:
105
95
  - examples/video.rb
106
96
  - examples/webhook.rb
107
97
  - lib/warb.rb
108
- - lib/warb/category.rb
109
98
  - lib/warb/client.rb
110
99
  - lib/warb/components/action.rb
111
100
  - lib/warb/components/address.rb
112
- - lib/warb/components/button.rb
113
- - lib/warb/components/component.rb
114
- - lib/warb/components/copy_code_button.rb
115
101
  - lib/warb/components/email.rb
116
- - lib/warb/components/flow_button.rb
117
102
  - lib/warb/components/name.rb
118
103
  - lib/warb/components/org.rb
119
104
  - lib/warb/components/phone.rb
120
- - lib/warb/components/quick_reply_button.rb
121
105
  - lib/warb/components/url.rb
122
- - lib/warb/components/url_button.rb
123
- - lib/warb/components/voice_call_button.rb
124
106
  - lib/warb/configuration.rb
125
107
  - lib/warb/connection.rb
126
108
  - lib/warb/dispatcher.rb
127
109
  - lib/warb/dispatcher_concern.rb
128
- - lib/warb/errors.rb
129
110
  - lib/warb/indicator_dispatcher.rb
130
- - lib/warb/language.rb
131
111
  - lib/warb/media_dispatcher.rb
132
112
  - lib/warb/resources/audio.rb
133
113
  - lib/warb/resources/contact.rb
134
- - lib/warb/resources/currency.rb
135
- - lib/warb/resources/date_time.rb
136
114
  - lib/warb/resources/document.rb
137
115
  - lib/warb/resources/flow.rb
138
- - lib/warb/resources/helpers/header.rb
139
116
  - lib/warb/resources/image.rb
140
117
  - lib/warb/resources/interactive_call_to_action_url.rb
141
118
  - lib/warb/resources/interactive_list.rb
@@ -145,13 +122,8 @@ files:
145
122
  - lib/warb/resources/reaction.rb
146
123
  - lib/warb/resources/resource.rb
147
124
  - lib/warb/resources/sticker.rb
148
- - lib/warb/resources/template.rb
149
125
  - lib/warb/resources/text.rb
150
- - lib/warb/resources/validation.rb
151
126
  - lib/warb/resources/video.rb
152
- - lib/warb/response.rb
153
- - lib/warb/response_error_handler.rb
154
- - lib/warb/template_dispatcher.rb
155
127
  - lib/warb/utils.rb
156
128
  - lib/warb/version.rb
157
129
  - sig/warb.rbs
@@ -161,8 +133,6 @@ metadata:
161
133
  homepage_uri: https://github.com/Rebase-BR/warb
162
134
  source_code_uri: https://github.com/Rebase-BR/warb
163
135
  changelog_uri: https://github.com/Rebase-BR/warb/blob/main/CHANGELOG.md?ref_type=heads
164
- rubygems_mfa_required: 'true'
165
- post_install_message:
166
136
  rdoc_options: []
167
137
  require_paths:
168
138
  - lib
@@ -177,8 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
147
  - !ruby/object:Gem::Version
178
148
  version: '0'
179
149
  requirements: []
180
- rubygems_version: 3.4.10
181
- signing_key:
150
+ rubygems_version: 3.6.7
182
151
  specification_version: 4
183
152
  summary: A simple yet powerfull whatsapp api wrapper
184
153
  test_files: []
@@ -1,62 +0,0 @@
1
- # Button
2
-
3
- `Warb::Components::Button` is a component that represents a generic button used in template messages. It's part of the Components module, which contains reusable parts of complex structures.
4
-
5
- It represents a generic button, which can be set with the following attributes:
6
-
7
- ## Attributes
8
- | Attribute | Type | Required | Description |
9
- |--------------|-----------|----------|-----------------------------------------------|
10
- | `index` | `Integer` | Yes | An identifier or position for the button. |
11
- | `sub_type` | `String` | Yes | A more specific classification for the button |
12
-
13
- ## Common Button Types
14
- | Button Type | Template Instance Method | Params |
15
- |---------------|------------------------------|------------------------------------------|
16
- | `quick_reply` | `add_quick_reply_button` | `index` |
17
- | `voice_call` | `add_voice_call_button` | `index` |
18
- | `url` | `add_dynamic_url_button` | `index`, `text` |
19
- | `copy_code` | `add_copy_code_button` | `index`, `coupon_code` |
20
- | `flow` | `add_flow_button` | `index`, `flow_token`, `flow_action_data`|
21
-
22
- Please, refer to our [templates messaging documentation](../messages/template.md) for more info. You can check the methods to insert a button in the "Adding Buttons" section.
23
-
24
- ## Examples
25
-
26
- ### Quick Reply button
27
- ```ruby
28
- quick_reply = Warb::Components::Button.new(index: 0, sub_type: "quick_reply")
29
- quick_reply.to_h
30
- => {
31
- type: "button",
32
- sub_type: "quick_reply",
33
- index: 0
34
- }
35
- ```
36
-
37
- ### Voice Call button
38
- ```ruby
39
- voice_call = Warb::Components::Button.new(index: 1, sub_type: "voice_call")
40
- voice_call.to_h
41
- => {
42
- type: "button",
43
- sub_type: "voice_call",
44
- index: 1
45
- }
46
- ```
47
-
48
- ## Usage in Templates
49
-
50
- Buttons are typically used within template messages. Here's how to add them:
51
-
52
- ```ruby
53
- template = Warb::Resources::Template.new(name: "my_template", language: "en_US")
54
-
55
- # Add a quick reply button
56
- template.add_quick_reply_button(index: 0)
57
-
58
- # Add a voice call button
59
- template.add_voice_call_button(index: 1)
60
-
61
- # The buttons will be included in the template's build_payload (as components)
62
- ```
@@ -1,57 +0,0 @@
1
- # CopyCodeButton
2
-
3
- `Warb::Components::CopyCodeButton` is a component used in template messages for copy code buttons.
4
-
5
- ## Attributes
6
- | Attribute | Type | Required | Description |
7
- |----------------|-----------|----------|-----------------------------------------------|
8
- | `index` | `Integer` | Yes | An identifier or position for the button. |
9
- | `sub_type` | `String` | Yes | Always "copy_code" for this button type |
10
- | `coupon_code` | `String` | No | The coupon code to be copied when button is pressed |
11
-
12
- ## Examples
13
-
14
- ### Basic copy code button
15
- ```ruby
16
- copy_button = Warb::Components::CopyCodeButton.new(index: 0, sub_type: "copy_code", coupon_code: "SAVE20")
17
- copy_button.to_h
18
- => {
19
- type: "button",
20
- sub_type: "copy_code",
21
- index: 0,
22
- parameters: [
23
- {
24
- type: "coupon_code",
25
- coupon_code: "SAVE20"
26
- }
27
- ]
28
- }
29
- ```
30
-
31
- ### Copy code button without coupon code
32
- ```ruby
33
- copy_button = Warb::Components::CopyCodeButton.new(index: 1, sub_type: "copy_code")
34
- copy_button.to_h
35
- => {
36
- type: "button",
37
- sub_type: "copy_code",
38
- index: 1
39
- }
40
- ```
41
-
42
- ## Usage in Templates
43
-
44
- Copy code buttons are typically added to templates using the `add_copy_code_button` method:
45
-
46
- ```ruby
47
- template = Warb::Resources::Template.new(name: "my_template", language: "en_US")
48
-
49
- # Add a copy code button
50
- template.add_copy_code_button(index: 0, coupon_code: "SAVE20")
51
-
52
- # Or using a block for more complex configuration
53
- template.add_copy_code_button do |button|
54
- button.index = 0
55
- button.coupon_code = "SAVE20"
56
- end
57
- ```
@@ -1,102 +0,0 @@
1
- # FlowButton
2
-
3
- ```Warb::Components::FlowButton``` is a component used in template messages for flow buttons.
4
- This button type allows you to link a template directly with a WhatsApp Flow experience.
5
-
6
- ## Attributes
7
- | Attribute | Type | Required | Description |
8
- | ------------------ | --------- | -------- |-----------------------------------------------------------------|
9
- | `index` | `Integer` | Yes | An identifier or position for the button in the template. |
10
- | `sub_type` | `String` | Yes | Always `"flow"` for this button type. |
11
- | `flow_token` | `String` | No | If not set, the API defaults to `"unused"`. |
12
- | `flow_action_data` | `Hash` | No | A key-value payload passed to the flow as pre-filled form data. |
13
-
14
-
15
-
16
- ## Examples
17
- ###### Basic Flow button with token
18
- ```ruby
19
- flow_button = Warb::Components::FlowButton.new(
20
- index: 0,
21
- sub_type: "flow",
22
- flow_token: "TOKEN_123"
23
- )
24
-
25
- flow_button.to_h
26
- => {
27
- type: "button",
28
- sub_type: "flow",
29
- index: 0,
30
- parameters: [
31
- {
32
- type: "action",
33
- action: {
34
- flow_token: "TOKEN_123"
35
- }
36
- }
37
- ]
38
- }
39
- ```
40
-
41
- ##### Flow button with token and action data
42
- ```ruby
43
- flow_button = Warb::Components::FlowButton.new(
44
- index: 1,
45
- sub_type: "flow",
46
- flow_token: "TOKEN_ABC",
47
- flow_action_data: { name: "John", cpf: "11122233344" }
48
- )
49
-
50
- flow_button.to_h
51
- => {
52
- type: "button",
53
- sub_type: "flow",
54
- index: 1,
55
- parameters: [
56
- {
57
- type: "action",
58
- action: {
59
- flow_token: "TOKEN_ABC",
60
- flow_action_data: { name: "John", cpf: "11122233344" }
61
- }
62
- }
63
- ]
64
- }
65
- ```
66
-
67
- ##### Flow button without optional fields
68
- ```ruby
69
- flow_button = Warb::Components::FlowButton.new(index: 2, sub_type: "flow")
70
- flow_button.to_h
71
- => {
72
- type: "button",
73
- sub_type: "flow",
74
- index: 2,
75
- parameters: [
76
- {
77
- type: "action",
78
- action: {}
79
- }
80
- ]
81
- }
82
- ```
83
- ### Usage in Templates
84
-
85
- Flow buttons are typically added to templates using the add_flow_button method:
86
-
87
- ```ruby
88
- template = Warb::Resources::Template.new(name: "my_template", language: "en_US")
89
-
90
- # Add a flow button with token
91
- template.add_flow_button(index: 0, flow_token: "TOKEN_123")
92
-
93
- # Add a flow button with token and action data
94
- template.add_flow_button(index: 1, flow_token: "TOKEN_ABC", flow_action_data: { name: "Jane", dob: "1990-01-01" })
95
-
96
- # Or using a block for more complex configuration
97
- template.add_flow_button do |button|
98
- button.index = 0
99
- button.flow_token = "TOKEN_DYNAMIC"
100
- button.flow_action_data = { email: "user@example.com" }
101
- end
102
- ```
@@ -1,57 +0,0 @@
1
- # UrlButton
2
-
3
- `Warb::Components::UrlButton` is a component used in template messages, for dynamic url or auth code buttons.
4
-
5
- ## Attributes
6
- | Attribute | Type | Required | Description |
7
- |--------------|-----------|----------|-----------------------------------------------|
8
- | `index` | `Integer` | Yes | An identifier or position for the button. |
9
- | `sub_type` | `String` | Yes | Always "url" for this button type |
10
- | `text` | `String` | No | The URL suffix or text parameter for the button |
11
-
12
- ## Examples
13
-
14
- ### Basic URL button
15
- ```ruby
16
- url_button = Warb::Components::UrlButton.new(index: 0, sub_type: "url", text: "example.com")
17
- url_button.to_h
18
- => {
19
- type: "button",
20
- sub_type: "url",
21
- index: 0,
22
- parameters: [
23
- {
24
- type: "text",
25
- text: "example.com"
26
- }
27
- ]
28
- }
29
- ```
30
-
31
- ### URL button without text parameter
32
- ```ruby
33
- url_button = Warb::Components::UrlButton.new(index: 1, sub_type: "url")
34
- url_button.to_h
35
- => {
36
- type: "button",
37
- sub_type: "url",
38
- index: 1
39
- }
40
- ```
41
-
42
- ## Usage in Templates
43
-
44
- URL buttons are typically added to templates using the `add_dynamic_url_button` method:
45
-
46
- ```ruby
47
- template = Warb::Resources::Template.new(name: "my_template", language: "en_US")
48
-
49
- # Add a dynamic URL button
50
- template.add_dynamic_url_button(index: 0, text: "example.com")
51
-
52
- # Or using a block for more complex configuration
53
- template.add_dynamic_url_button do |button|
54
- button.index = 0
55
- button.text = "example.com"
56
- end
57
- ```