warb 0.1.3 → 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.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -12
- data/README.md +9 -32
- data/Rakefile +3 -3
- data/docs/README.md +1 -4
- data/docs/components/README.md +1 -4
- data/docs/messages/README.md +1 -2
- data/docs/messages/interactive_call_to_action_url.md +9 -9
- data/docs/messages/interactive_list.md +2 -2
- data/docs/messages/interactive_reply_button.md +9 -9
- data/examples/audio.rb +10 -10
- data/examples/document.rb +34 -34
- data/examples/image.rb +22 -22
- data/examples/interactive_call_to_action_url.rb +46 -46
- data/examples/interactive_list.rb +61 -61
- data/examples/interactive_reply_button.rb +43 -43
- data/examples/location.rb +32 -32
- data/examples/location_request.rb +11 -11
- data/examples/message.rb +8 -8
- data/examples/sticker.rb +10 -10
- data/examples/video.rb +22 -22
- data/examples/webhook.rb +42 -44
- data/lib/warb/client.rb +5 -7
- data/lib/warb/components/action.rb +8 -12
- data/lib/warb/configuration.rb +1 -4
- data/lib/warb/connection.rb +9 -15
- data/lib/warb/dispatcher.rb +3 -4
- data/lib/warb/dispatcher_concern.rb +0 -6
- data/lib/warb/indicator_dispatcher.rb +4 -4
- data/lib/warb/media_dispatcher.rb +10 -10
- data/lib/warb/resources/audio.rb +1 -1
- data/lib/warb/resources/contact.rb +20 -22
- data/lib/warb/resources/document.rb +1 -1
- data/lib/warb/resources/flow.rb +8 -10
- data/lib/warb/resources/image.rb +1 -1
- data/lib/warb/resources/interactive_call_to_action_url.rb +8 -10
- data/lib/warb/resources/interactive_list.rb +5 -7
- data/lib/warb/resources/interactive_reply_button.rb +8 -10
- data/lib/warb/resources/location.rb +1 -11
- data/lib/warb/resources/location_request.rb +3 -5
- data/lib/warb/resources/reaction.rb +1 -1
- data/lib/warb/resources/resource.rb +4 -12
- data/lib/warb/resources/sticker.rb +1 -1
- data/lib/warb/resources/text.rb +3 -21
- data/lib/warb/resources/video.rb +1 -1
- data/lib/warb/utils.rb +1 -3
- data/lib/warb/version.rb +1 -1
- data/lib/warb.rb +31 -50
- metadata +3 -29
- data/docs/components/button.md +0 -61
- data/docs/components/copy_code_button.md +0 -57
- data/docs/components/url_button.md +0 -57
- data/docs/messages/template.md +0 -327
- data/docs/resources/currency.md +0 -22
- data/docs/resources/date_time.md +0 -11
- data/docs/resources/index.md +0 -14
- data/docs/resources/text.md +0 -9
- data/lib/warb/components/button.rb +0 -29
- data/lib/warb/components/component.rb +0 -19
- data/lib/warb/components/copy_code_button.rb +0 -30
- data/lib/warb/components/quick_reply_button.rb +0 -15
- data/lib/warb/components/url_button.rb +0 -30
- data/lib/warb/components/voice_call_button.rb +0 -15
- data/lib/warb/errors.rb +0 -27
- data/lib/warb/language.rb +0 -8
- data/lib/warb/resources/currency.rb +0 -47
- data/lib/warb/resources/date_time.rb +0 -34
- data/lib/warb/resources/template.rb +0 -167
- data/lib/warb/response.rb +0 -33
- data/lib/warb/response_error_handler.rb +0 -42
- data/lib/warb/template_dispatcher.rb +0 -12
data/lib/warb.rb
CHANGED
|
@@ -1,57 +1,38 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require_relative
|
|
6
|
-
require_relative
|
|
7
|
-
require_relative
|
|
8
|
-
require_relative
|
|
9
|
-
require_relative
|
|
10
|
-
require_relative
|
|
11
|
-
require_relative
|
|
12
|
-
require_relative
|
|
13
|
-
require_relative
|
|
14
|
-
require_relative
|
|
15
|
-
require_relative
|
|
16
|
-
require_relative
|
|
17
|
-
require_relative
|
|
18
|
-
require_relative
|
|
19
|
-
require_relative
|
|
20
|
-
require_relative
|
|
21
|
-
require_relative
|
|
22
|
-
require_relative
|
|
23
|
-
require_relative
|
|
24
|
-
require_relative
|
|
25
|
-
require_relative
|
|
26
|
-
require_relative
|
|
27
|
-
require_relative
|
|
28
|
-
require_relative
|
|
29
|
-
require_relative 'warb/resources/date_time'
|
|
30
|
-
require_relative 'warb/resources/flow'
|
|
31
|
-
require_relative 'warb/dispatcher'
|
|
32
|
-
require_relative 'warb/media_dispatcher'
|
|
33
|
-
require_relative 'warb/template_dispatcher'
|
|
34
|
-
require_relative 'warb/indicator_dispatcher'
|
|
35
|
-
require_relative 'warb/utils'
|
|
36
|
-
require_relative 'warb/components/component'
|
|
37
|
-
require_relative 'warb/components/button'
|
|
38
|
-
require_relative 'warb/components/quick_reply_button'
|
|
39
|
-
require_relative 'warb/components/url_button'
|
|
40
|
-
require_relative 'warb/components/copy_code_button'
|
|
41
|
-
require_relative 'warb/components/voice_call_button'
|
|
42
|
-
require_relative 'warb/components/action'
|
|
3
|
+
require "faraday"
|
|
4
|
+
require "faraday/multipart"
|
|
5
|
+
require_relative "warb/version"
|
|
6
|
+
require_relative "warb/configuration"
|
|
7
|
+
require_relative "warb/dispatcher_concern"
|
|
8
|
+
require_relative "warb/client"
|
|
9
|
+
require_relative "warb/resources/resource"
|
|
10
|
+
require_relative "warb/resources/text"
|
|
11
|
+
require_relative "warb/resources/image"
|
|
12
|
+
require_relative "warb/resources/video"
|
|
13
|
+
require_relative "warb/resources/sticker"
|
|
14
|
+
require_relative "warb/resources/audio"
|
|
15
|
+
require_relative "warb/resources/document"
|
|
16
|
+
require_relative "warb/resources/location"
|
|
17
|
+
require_relative "warb/resources/reaction"
|
|
18
|
+
require_relative "warb/resources/location_request"
|
|
19
|
+
require_relative "warb/resources/interactive_reply_button"
|
|
20
|
+
require_relative "warb/resources/interactive_list"
|
|
21
|
+
require_relative "warb/resources/interactive_call_to_action_url"
|
|
22
|
+
require_relative "warb/resources/contact"
|
|
23
|
+
require_relative "warb/resources/flow"
|
|
24
|
+
require_relative "warb/dispatcher"
|
|
25
|
+
require_relative "warb/media_dispatcher"
|
|
26
|
+
require_relative "warb/indicator_dispatcher"
|
|
27
|
+
require_relative "warb/utils"
|
|
28
|
+
require_relative "warb/components/action"
|
|
43
29
|
|
|
44
30
|
module Warb
|
|
45
|
-
MESSAGING_PRODUCT =
|
|
46
|
-
RECIPIENT_TYPE =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
403 => Forbidden,
|
|
51
|
-
404 => NotFound,
|
|
52
|
-
500 => InternalServerError,
|
|
53
|
-
503 => ServiceUnavailable
|
|
54
|
-
}.freeze
|
|
31
|
+
MESSAGING_PRODUCT = "whatsapp"
|
|
32
|
+
RECIPIENT_TYPE = "individual"
|
|
33
|
+
|
|
34
|
+
class Error < StandardError; end
|
|
35
|
+
# Your code goes here...
|
|
55
36
|
|
|
56
37
|
class << self
|
|
57
38
|
include DispatcherConcern
|
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.
|
|
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:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: faraday
|
|
@@ -53,8 +52,6 @@ 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
57
|
- docs/components/list_action.md
|
|
@@ -65,7 +62,6 @@ files:
|
|
|
65
62
|
- docs/components/row.md
|
|
66
63
|
- docs/components/section.md
|
|
67
64
|
- docs/components/url.md
|
|
68
|
-
- docs/components/url_button.md
|
|
69
65
|
- docs/images/contact-with-wa_id.png
|
|
70
66
|
- docs/images/contact-without-wa_id.png
|
|
71
67
|
- docs/messages/README.md
|
|
@@ -82,13 +78,8 @@ files:
|
|
|
82
78
|
- docs/messages/location_request.md
|
|
83
79
|
- docs/messages/reaction.md
|
|
84
80
|
- docs/messages/sticker.md
|
|
85
|
-
- docs/messages/template.md
|
|
86
81
|
- docs/messages/text.md
|
|
87
82
|
- docs/messages/video.md
|
|
88
|
-
- docs/resources/currency.md
|
|
89
|
-
- docs/resources/date_time.md
|
|
90
|
-
- docs/resources/index.md
|
|
91
|
-
- docs/resources/text.md
|
|
92
83
|
- docs/setup.md
|
|
93
84
|
- docs/webhook.md
|
|
94
85
|
- examples/audio.rb
|
|
@@ -107,29 +98,19 @@ files:
|
|
|
107
98
|
- lib/warb/client.rb
|
|
108
99
|
- lib/warb/components/action.rb
|
|
109
100
|
- lib/warb/components/address.rb
|
|
110
|
-
- lib/warb/components/button.rb
|
|
111
|
-
- lib/warb/components/component.rb
|
|
112
|
-
- lib/warb/components/copy_code_button.rb
|
|
113
101
|
- lib/warb/components/email.rb
|
|
114
102
|
- lib/warb/components/name.rb
|
|
115
103
|
- lib/warb/components/org.rb
|
|
116
104
|
- lib/warb/components/phone.rb
|
|
117
|
-
- lib/warb/components/quick_reply_button.rb
|
|
118
105
|
- lib/warb/components/url.rb
|
|
119
|
-
- lib/warb/components/url_button.rb
|
|
120
|
-
- lib/warb/components/voice_call_button.rb
|
|
121
106
|
- lib/warb/configuration.rb
|
|
122
107
|
- lib/warb/connection.rb
|
|
123
108
|
- lib/warb/dispatcher.rb
|
|
124
109
|
- lib/warb/dispatcher_concern.rb
|
|
125
|
-
- lib/warb/errors.rb
|
|
126
110
|
- lib/warb/indicator_dispatcher.rb
|
|
127
|
-
- lib/warb/language.rb
|
|
128
111
|
- lib/warb/media_dispatcher.rb
|
|
129
112
|
- lib/warb/resources/audio.rb
|
|
130
113
|
- lib/warb/resources/contact.rb
|
|
131
|
-
- lib/warb/resources/currency.rb
|
|
132
|
-
- lib/warb/resources/date_time.rb
|
|
133
114
|
- lib/warb/resources/document.rb
|
|
134
115
|
- lib/warb/resources/flow.rb
|
|
135
116
|
- lib/warb/resources/image.rb
|
|
@@ -141,12 +122,8 @@ files:
|
|
|
141
122
|
- lib/warb/resources/reaction.rb
|
|
142
123
|
- lib/warb/resources/resource.rb
|
|
143
124
|
- lib/warb/resources/sticker.rb
|
|
144
|
-
- lib/warb/resources/template.rb
|
|
145
125
|
- lib/warb/resources/text.rb
|
|
146
126
|
- lib/warb/resources/video.rb
|
|
147
|
-
- lib/warb/response.rb
|
|
148
|
-
- lib/warb/response_error_handler.rb
|
|
149
|
-
- lib/warb/template_dispatcher.rb
|
|
150
127
|
- lib/warb/utils.rb
|
|
151
128
|
- lib/warb/version.rb
|
|
152
129
|
- sig/warb.rbs
|
|
@@ -156,8 +133,6 @@ metadata:
|
|
|
156
133
|
homepage_uri: https://github.com/Rebase-BR/warb
|
|
157
134
|
source_code_uri: https://github.com/Rebase-BR/warb
|
|
158
135
|
changelog_uri: https://github.com/Rebase-BR/warb/blob/main/CHANGELOG.md?ref_type=heads
|
|
159
|
-
rubygems_mfa_required: 'true'
|
|
160
|
-
post_install_message:
|
|
161
136
|
rdoc_options: []
|
|
162
137
|
require_paths:
|
|
163
138
|
- lib
|
|
@@ -172,8 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
172
147
|
- !ruby/object:Gem::Version
|
|
173
148
|
version: '0'
|
|
174
149
|
requirements: []
|
|
175
|
-
rubygems_version: 3.
|
|
176
|
-
signing_key:
|
|
150
|
+
rubygems_version: 3.6.7
|
|
177
151
|
specification_version: 4
|
|
178
152
|
summary: A simple yet powerfull whatsapp api wrapper
|
|
179
153
|
test_files: []
|
data/docs/components/button.md
DELETED
|
@@ -1,61 +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
|
-
|
|
21
|
-
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.
|
|
22
|
-
|
|
23
|
-
## Examples
|
|
24
|
-
|
|
25
|
-
### Quick Reply button
|
|
26
|
-
```ruby
|
|
27
|
-
quick_reply = Warb::Components::Button.new(index: 0, sub_type: "quick_reply")
|
|
28
|
-
quick_reply.to_h
|
|
29
|
-
=> {
|
|
30
|
-
type: "button",
|
|
31
|
-
sub_type: "quick_reply",
|
|
32
|
-
index: 0
|
|
33
|
-
}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### Voice Call button
|
|
37
|
-
```ruby
|
|
38
|
-
voice_call = Warb::Components::Button.new(index: 1, sub_type: "voice_call")
|
|
39
|
-
voice_call.to_h
|
|
40
|
-
=> {
|
|
41
|
-
type: "button",
|
|
42
|
-
sub_type: "voice_call",
|
|
43
|
-
index: 1
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Usage in Templates
|
|
48
|
-
|
|
49
|
-
Buttons are typically used within template messages. Here's how to add them:
|
|
50
|
-
|
|
51
|
-
```ruby
|
|
52
|
-
template = Warb::Resources::Template.new(name: "my_template", language: "en_US")
|
|
53
|
-
|
|
54
|
-
# Add a quick reply button
|
|
55
|
-
template.add_quick_reply_button(index: 0)
|
|
56
|
-
|
|
57
|
-
# Add a voice call button
|
|
58
|
-
template.add_voice_call_button(index: 1)
|
|
59
|
-
|
|
60
|
-
# The buttons will be included in the template's build_payload (as components)
|
|
61
|
-
```
|
|
@@ -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,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
|
-
```
|