warb 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 +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +8 -0
- data/CHANGELOG.md +25 -0
- data/README.md +120 -0
- data/Rakefile +12 -0
- data/docs/README.md +13 -0
- data/docs/components/README.md +21 -0
- data/docs/components/address.md +68 -0
- data/docs/components/cta_action.md +13 -0
- data/docs/components/email.md +40 -0
- data/docs/components/list_action.md +29 -0
- data/docs/components/name.md +49 -0
- data/docs/components/org.md +42 -0
- data/docs/components/phone.md +57 -0
- data/docs/components/reply_button_action.md +32 -0
- data/docs/components/row.md +13 -0
- data/docs/components/section.md +30 -0
- data/docs/components/url.md +40 -0
- data/docs/images/contact-with-wa_id.png +0 -0
- data/docs/images/contact-without-wa_id.png +0 -0
- data/docs/messages/README.md +79 -0
- data/docs/messages/audio.md +119 -0
- data/docs/messages/contact.md +134 -0
- data/docs/messages/document.md +122 -0
- data/docs/messages/flow.md +12 -0
- data/docs/messages/image.md +116 -0
- data/docs/messages/indicator.md +39 -0
- data/docs/messages/interactive_call_to_action_url.md +96 -0
- data/docs/messages/interactive_list.md +159 -0
- data/docs/messages/interactive_reply_button.md +67 -0
- data/docs/messages/location.md +34 -0
- data/docs/messages/location_request.md +21 -0
- data/docs/messages/reaction.md +23 -0
- data/docs/messages/sticker.md +116 -0
- data/docs/messages/text.md +47 -0
- data/docs/messages/video.md +116 -0
- data/docs/setup.md +46 -0
- data/docs/webhook.md +24 -0
- data/examples/audio.rb +86 -0
- data/examples/document.rb +116 -0
- data/examples/image.rb +97 -0
- data/examples/interactive_call_to_action_url.rb +177 -0
- data/examples/interactive_list.rb +201 -0
- data/examples/interactive_reply_button.rb +174 -0
- data/examples/location.rb +85 -0
- data/examples/location_request.rb +55 -0
- data/examples/message.rb +61 -0
- data/examples/sticker.rb +86 -0
- data/examples/video.rb +96 -0
- data/examples/webhook.rb +144 -0
- data/lib/warb/client.rb +46 -0
- data/lib/warb/components/action.rb +121 -0
- data/lib/warb/components/address.rb +31 -0
- data/lib/warb/components/email.rb +21 -0
- data/lib/warb/components/name.rb +29 -0
- data/lib/warb/components/org.rb +23 -0
- data/lib/warb/components/phone.rb +23 -0
- data/lib/warb/components/url.rb +21 -0
- data/lib/warb/configuration.rb +13 -0
- data/lib/warb/connection.rb +47 -0
- data/lib/warb/dispatcher.rb +16 -0
- data/lib/warb/dispatcher_concern.rb +69 -0
- data/lib/warb/indicator_dispatcher.rb +31 -0
- data/lib/warb/media_dispatcher.rb +46 -0
- data/lib/warb/resources/audio.rb +19 -0
- data/lib/warb/resources/contact.rb +89 -0
- data/lib/warb/resources/document.rb +32 -0
- data/lib/warb/resources/flow.rb +34 -0
- data/lib/warb/resources/image.rb +31 -0
- data/lib/warb/resources/interactive_call_to_action_url.rb +48 -0
- data/lib/warb/resources/interactive_list.rb +36 -0
- data/lib/warb/resources/interactive_reply_button.rb +48 -0
- data/lib/warb/resources/location.rb +21 -0
- data/lib/warb/resources/location_request.rb +24 -0
- data/lib/warb/resources/reaction.rb +19 -0
- data/lib/warb/resources/resource.rb +51 -0
- data/lib/warb/resources/sticker.rb +19 -0
- data/lib/warb/resources/text.rb +29 -0
- data/lib/warb/resources/video.rb +31 -0
- data/lib/warb/utils.rb +5 -0
- data/lib/warb/version.rb +5 -0
- data/lib/warb.rb +58 -0
- data/sig/warb.rbs +4 -0
- metadata +153 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../lib/warb"
|
|
4
|
+
|
|
5
|
+
# Configure your variables here
|
|
6
|
+
|
|
7
|
+
access_token = ""
|
|
8
|
+
business_id = ""
|
|
9
|
+
sender_id = ""
|
|
10
|
+
recipient_number = ""
|
|
11
|
+
|
|
12
|
+
# You can use Resources to create headers for your messages.
|
|
13
|
+
text_header = Warb::Resources::Text.as_header("OPTIONAL - Header")
|
|
14
|
+
image_header = Warb::Resources::Image.as_header(media_id: image_id)
|
|
15
|
+
video_header = Warb::Resources::Video.as_header(link: image_url)
|
|
16
|
+
|
|
17
|
+
# You can use Action Components to create actions for your messages.
|
|
18
|
+
action_component = Warb::Components::ReplyButtonAction.new(["button 1", "button 2", "button 3"])
|
|
19
|
+
|
|
20
|
+
# We recommend testing one section at a time, as it can be overwhelming to see all the messages at once.
|
|
21
|
+
# So you can comment out the sections you don't want to test.
|
|
22
|
+
|
|
23
|
+
# ############################################## #
|
|
24
|
+
# ============== Using Warb.setup ============== #
|
|
25
|
+
# ############################################## #
|
|
26
|
+
|
|
27
|
+
warb_from_setup = Warb.setup do |config|
|
|
28
|
+
config.access_token = access_token
|
|
29
|
+
config.business_id = business_id
|
|
30
|
+
config.sender_id = sender_id
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
warb_from_setup.interactive_list.dispatch(
|
|
34
|
+
recipient_number,
|
|
35
|
+
header: text_header,
|
|
36
|
+
body: "body",
|
|
37
|
+
footer: "footer",
|
|
38
|
+
action: action_component
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
warb_from_setup.interactive_list.dispatch(
|
|
42
|
+
recipient_number,
|
|
43
|
+
header: image_header,
|
|
44
|
+
body: "body",
|
|
45
|
+
footer: "footer",
|
|
46
|
+
action: action_component
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
warb_from_setup.interactive_list.dispatch(
|
|
50
|
+
recipient_number,
|
|
51
|
+
header: video_header,
|
|
52
|
+
body: "body",
|
|
53
|
+
footer: "footer",
|
|
54
|
+
action: action_component
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
warb_from_setup.interactive_list.dispatch(recipient_number) do |builder|
|
|
58
|
+
# OPTIONAL Headers: you can choose between text, image, or video headers.
|
|
59
|
+
|
|
60
|
+
builder.set_text_header("Text Header")
|
|
61
|
+
|
|
62
|
+
# If you want to use an image header, uncomment the line below and provide a valid or Media ID or Link.
|
|
63
|
+
# builder.set_image_header(media_id: image_id) # or builder.set_image_header(link: image_link)
|
|
64
|
+
|
|
65
|
+
# If you want to use a video header, uncomment the line below and provide a valid Media ID or Link.
|
|
66
|
+
# builder.set_video_header(media_id: video_id) # or builder.set_video_header(link: video_link)
|
|
67
|
+
|
|
68
|
+
builder.body = "body"
|
|
69
|
+
builder.footer = "footer"
|
|
70
|
+
|
|
71
|
+
builder.build_action do |action|
|
|
72
|
+
action.button_text = "Action button text"
|
|
73
|
+
|
|
74
|
+
section = action.add_section
|
|
75
|
+
section.title = "Title"
|
|
76
|
+
section.rows = [Warb::Components::Row.new(title: "S #0 R #0")]
|
|
77
|
+
section.add_row title: "Second Row", description: "Who knows?"
|
|
78
|
+
|
|
79
|
+
section = action.add_section title: "Second Section"
|
|
80
|
+
row = section.add_row title: "KeK"
|
|
81
|
+
row.description = "Description"
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# ############################################ #
|
|
86
|
+
# ============== Using Warb.new ============== #
|
|
87
|
+
# ############################################ #
|
|
88
|
+
|
|
89
|
+
warb_from_new = Warb.new(
|
|
90
|
+
access_token: access_token,
|
|
91
|
+
business_id: business_id,
|
|
92
|
+
sender_id: sender_id
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
warb_from_new.interactive_list.dispatch(
|
|
96
|
+
recipient_number,
|
|
97
|
+
header: text_header,
|
|
98
|
+
body: "body",
|
|
99
|
+
footer: "footer",
|
|
100
|
+
action: action_component
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
warb_from_new.interactive_list.dispatch(
|
|
104
|
+
recipient_number,
|
|
105
|
+
header: image_header,
|
|
106
|
+
body: "body",
|
|
107
|
+
footer: "footer",
|
|
108
|
+
action: action_component
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
warb_from_new.interactive_list.dispatch(
|
|
112
|
+
recipient_number,
|
|
113
|
+
header: video_header,
|
|
114
|
+
body: "body",
|
|
115
|
+
footer: "footer",
|
|
116
|
+
action: action_component
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
warb_from_new.interactive_list.dispatch(recipient_number) do |builder|
|
|
120
|
+
# OPTIONAL Headers: you can choose between text, image, or video headers.
|
|
121
|
+
|
|
122
|
+
builder.set_text_header("Text Header")
|
|
123
|
+
|
|
124
|
+
# If you want to use an image header, uncomment the line below and provide a valid or Media ID or Link.
|
|
125
|
+
# builder.set_image_header(media_id: image_id) # or builder.set_image_header(link: image_link)
|
|
126
|
+
|
|
127
|
+
# If you want to use a video header, uncomment the line below and provide a valid Media ID or Link.
|
|
128
|
+
# builder.set_video_header(media_id: video_id) # or builder.set_video_header(link: video_link)
|
|
129
|
+
|
|
130
|
+
builder.body = "body"
|
|
131
|
+
builder.footer = "footer"
|
|
132
|
+
|
|
133
|
+
builder.build_action do |action|
|
|
134
|
+
action.button_text = "Action button text"
|
|
135
|
+
|
|
136
|
+
section = action.add_section
|
|
137
|
+
section.title = "Title"
|
|
138
|
+
section.rows = [Warb::Components::Row.new(title: "S #0 R #0")]
|
|
139
|
+
section.add_row title: "Second Row", description: "Who knows?"
|
|
140
|
+
|
|
141
|
+
section = action.add_section title: "Second Section"
|
|
142
|
+
row = section.add_row title: "KeK"
|
|
143
|
+
row.description = "Description"
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# ################################################# #
|
|
148
|
+
# ============== Using Warb directly ============== #
|
|
149
|
+
# ################################################# #
|
|
150
|
+
|
|
151
|
+
Warb.interactive_list.dispatch(
|
|
152
|
+
recipient_number,
|
|
153
|
+
header: text_header,
|
|
154
|
+
body: "body",
|
|
155
|
+
footer: "footer",
|
|
156
|
+
action: action_component
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
Warb.interactive_list.dispatch(
|
|
160
|
+
recipient_number,
|
|
161
|
+
header: image_header,
|
|
162
|
+
body: "body",
|
|
163
|
+
footer: "footer",
|
|
164
|
+
action: action_component
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
Warb.interactive_list.dispatch(
|
|
168
|
+
recipient_number,
|
|
169
|
+
header: video_header,
|
|
170
|
+
body: "body",
|
|
171
|
+
footer: "footer",
|
|
172
|
+
action: action_component
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
Warb.interactive_list.dispatch(recipient_number) do |builder|
|
|
176
|
+
# OPTIONAL Headers: you can choose between text, image, or video headers.
|
|
177
|
+
|
|
178
|
+
builder.set_text_header("Text Header")
|
|
179
|
+
|
|
180
|
+
# If you want to use an image header, uncomment the line below and provide a valid or Media ID or Link.
|
|
181
|
+
# builder.set_image_header(media_id: image_id) # or builder.set_image_header(link: image_link)
|
|
182
|
+
|
|
183
|
+
# If you want to use a video header, uncomment the line below and provide a valid Media ID or Link.
|
|
184
|
+
# builder.set_video_header(media_id: video_id) # or builder.set_video_header(link: video_link)
|
|
185
|
+
|
|
186
|
+
builder.body = "body"
|
|
187
|
+
builder.footer = "footer"
|
|
188
|
+
|
|
189
|
+
builder.build_action do |action|
|
|
190
|
+
action.button_text = "Action button text"
|
|
191
|
+
|
|
192
|
+
section = action.add_section
|
|
193
|
+
section.title = "Title"
|
|
194
|
+
section.rows = [Warb::Components::Row.new(title: "S #0 R #0")]
|
|
195
|
+
section.add_row title: "Second Row", description: "Who knows?"
|
|
196
|
+
|
|
197
|
+
section = action.add_section title: "Second Section"
|
|
198
|
+
row = section.add_row title: "KeK"
|
|
199
|
+
row.description = "Description"
|
|
200
|
+
end
|
|
201
|
+
end
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../lib/warb"
|
|
4
|
+
|
|
5
|
+
# Configure your variables here
|
|
6
|
+
|
|
7
|
+
access_token = ""
|
|
8
|
+
business_id = ""
|
|
9
|
+
sender_id = ""
|
|
10
|
+
recipient_number = ""
|
|
11
|
+
|
|
12
|
+
# You can use Resources to create headers for your messages.
|
|
13
|
+
text_header = Warb::Resources::Text.as_header("OPTIONAL - Header")
|
|
14
|
+
image_header = Warb::Resources::Image.as_header(media_id: image_id)
|
|
15
|
+
video_header = Warb::Resources::Video.as_header(link: image_url)
|
|
16
|
+
|
|
17
|
+
# You can use Action Components to create actions for your messages.
|
|
18
|
+
action_component = Warb::Components::ReplyButtonAction.new(["button 1", "button 2", "button 3"])
|
|
19
|
+
|
|
20
|
+
# We recommend testing one section at a time, as it can be overwhelming to see all the messages at once.
|
|
21
|
+
# So you can comment out the sections you don't want to test.
|
|
22
|
+
|
|
23
|
+
# ############################################## #
|
|
24
|
+
# ============== Using Warb.setup ============== #
|
|
25
|
+
# ############################################## #
|
|
26
|
+
|
|
27
|
+
warb_from_setup = Warb.setup do |config|
|
|
28
|
+
config.access_token = access_token
|
|
29
|
+
config.business_id = business_id
|
|
30
|
+
config.sender_id = sender_id
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
warb_from_setup.interactive_reply_button.dispatch(
|
|
34
|
+
recipient_number,
|
|
35
|
+
header: text_header,
|
|
36
|
+
body: "body",
|
|
37
|
+
footer: "footer",
|
|
38
|
+
action: action_component
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
warb_from_setup.interactive_reply_button.dispatch(
|
|
42
|
+
recipient_number,
|
|
43
|
+
header: image_header,
|
|
44
|
+
body: "body",
|
|
45
|
+
footer: "footer",
|
|
46
|
+
action: action_component
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
warb_from_setup.interactive_reply_button.dispatch(
|
|
50
|
+
recipient_number,
|
|
51
|
+
header: video_header,
|
|
52
|
+
body: "body",
|
|
53
|
+
footer: "footer",
|
|
54
|
+
action: action_component
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
warb_from_setup.interactive_reply_button.dispatch(recipient_number) do |builder|
|
|
58
|
+
# OPTIONAL Headers: you can choose between text, image, or video headers.
|
|
59
|
+
|
|
60
|
+
builder.set_text_header("Text Header")
|
|
61
|
+
|
|
62
|
+
# If you want to use an image header, uncomment the line below and provide a valid or Media ID or Link.
|
|
63
|
+
# builder.set_image_header(media_id: image_id) # or builder.set_image_header(link: image_link)
|
|
64
|
+
|
|
65
|
+
# If you want to use a video header, uncomment the line below and provide a valid Media ID or Link.
|
|
66
|
+
# builder.set_video_header(media_id: video_id) # or builder.set_video_header(link: video_link)
|
|
67
|
+
|
|
68
|
+
builder.body = "body"
|
|
69
|
+
builder.footer = "footer"
|
|
70
|
+
|
|
71
|
+
builder.build_action do |action|
|
|
72
|
+
action.buttons_texts = ["button 1", "button 2", "button 3"]
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# ############################################ #
|
|
77
|
+
# ============== Using Warb.new ============== #
|
|
78
|
+
# ############################################ #
|
|
79
|
+
|
|
80
|
+
warb_from_new = Warb.new(
|
|
81
|
+
access_token: access_token,
|
|
82
|
+
business_id: business_id,
|
|
83
|
+
sender_id: sender_id
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
warb_from_new.interactive_reply_button.dispatch(
|
|
87
|
+
recipient_number,
|
|
88
|
+
header: text_header,
|
|
89
|
+
body: "body",
|
|
90
|
+
footer: "footer",
|
|
91
|
+
action: action_component
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
warb_from_new.interactive_reply_button.dispatch(
|
|
95
|
+
recipient_number,
|
|
96
|
+
header: image_header,
|
|
97
|
+
body: "body",
|
|
98
|
+
footer: "footer",
|
|
99
|
+
action: action_component
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
warb_from_new.interactive_reply_button.dispatch(
|
|
103
|
+
recipient_number,
|
|
104
|
+
header: video_header,
|
|
105
|
+
body: "body",
|
|
106
|
+
footer: "footer",
|
|
107
|
+
action: action_component
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
warb_from_new.interactive_reply_button.dispatch(recipient_number) do |builder|
|
|
111
|
+
# OPTIONAL Headers: you can choose between text, image, or video headers.
|
|
112
|
+
|
|
113
|
+
builder.set_text_header("Text Header")
|
|
114
|
+
|
|
115
|
+
# If you want to use an image header, uncomment the line below and provide a valid or Media ID or Link.
|
|
116
|
+
# builder.set_image_header(media_id: image_id) # or builder.set_image_header(link: image_link)
|
|
117
|
+
|
|
118
|
+
# If you want to use a video header, uncomment the line below and provide a valid Media ID or Link.
|
|
119
|
+
# builder.set_video_header(media_id: video_id) # or builder.set_video_header(link: video_link)
|
|
120
|
+
|
|
121
|
+
builder.body = "body"
|
|
122
|
+
builder.footer = "footer"
|
|
123
|
+
|
|
124
|
+
builder.build_action do |action|
|
|
125
|
+
action.buttons_texts = ["button 1", "button 2", "button 3"]
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# ################################################# #
|
|
130
|
+
# ============== Using Warb directly ============== #
|
|
131
|
+
# ################################################# #
|
|
132
|
+
|
|
133
|
+
Warb.interactive_reply_button.dispatch(
|
|
134
|
+
recipient_number,
|
|
135
|
+
header: text_header,
|
|
136
|
+
body: "body",
|
|
137
|
+
footer: "footer",
|
|
138
|
+
action: action_component
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
Warb.interactive_reply_button.dispatch(
|
|
142
|
+
recipient_number,
|
|
143
|
+
header: image_header,
|
|
144
|
+
body: "body",
|
|
145
|
+
footer: "footer",
|
|
146
|
+
action: action_component
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
Warb.interactive_reply_button.dispatch(
|
|
150
|
+
recipient_number,
|
|
151
|
+
header: video_header,
|
|
152
|
+
body: "body",
|
|
153
|
+
footer: "footer",
|
|
154
|
+
action: action_component
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
Warb.interactive_reply_button.dispatch(recipient_number) do |builder|
|
|
158
|
+
# OPTIONAL Headers: you can choose between text, image, or video headers.
|
|
159
|
+
|
|
160
|
+
builder.set_text_header("Text Header")
|
|
161
|
+
|
|
162
|
+
# If you want to use an image header, uncomment the line below and provide a valid or Media ID or Link.
|
|
163
|
+
# builder.set_image_header(media_id: image_id) # or builder.set_image_header(link: image_link)
|
|
164
|
+
|
|
165
|
+
# If you want to use a video header, uncomment the line below and provide a valid Media ID or Link.
|
|
166
|
+
# builder.set_video_header(media_id: video_id) # or builder.set_video_header(link: video_link)
|
|
167
|
+
|
|
168
|
+
builder.body = "body"
|
|
169
|
+
builder.footer = "footer"
|
|
170
|
+
|
|
171
|
+
builder.build_action do |action|
|
|
172
|
+
action.buttons_texts = ["button 1", "button 2", "button 3"]
|
|
173
|
+
end
|
|
174
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../lib/warb"
|
|
4
|
+
|
|
5
|
+
# Configure your variables here
|
|
6
|
+
|
|
7
|
+
access_token = ""
|
|
8
|
+
business_id = ""
|
|
9
|
+
sender_id = ""
|
|
10
|
+
recipient_number = ""
|
|
11
|
+
|
|
12
|
+
# We recommend testing one section at a time, as it can be overwhelming to see all the messages at once.
|
|
13
|
+
# So you can comment out the sections you don't want to test.
|
|
14
|
+
|
|
15
|
+
# ############################################## #
|
|
16
|
+
# ============== Using Warb.setup ============== #
|
|
17
|
+
# ############################################## #
|
|
18
|
+
|
|
19
|
+
warb_from_setup = Warb.setup do |config|
|
|
20
|
+
config.access_token = access_token
|
|
21
|
+
config.business_id = business_id
|
|
22
|
+
config.sender_id = sender_id
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
warb_from_setup.location.dispatch(recipient_number, latitude: "37.44216251868683", longitude: "-122.16153582049394")
|
|
26
|
+
warb_from_setup.location.dispatch(
|
|
27
|
+
recipient_number,
|
|
28
|
+
latitude: "37.44216251868683",
|
|
29
|
+
longitude: "-122.16153582049394",
|
|
30
|
+
name: "OPTIONAL - Location Name",
|
|
31
|
+
address: "OPTIONAL - Location Address"
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
warb_from_setup.location.dispatch(recipient_number) do |builder|
|
|
35
|
+
builder.latitude = "37.44216251868683"
|
|
36
|
+
builder.longitude = "-122.16153582049394"
|
|
37
|
+
builder.name = "OPTIONAL - Location Name"
|
|
38
|
+
builder.address = "OPTIONAL - Location Address"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# ############################################ #
|
|
42
|
+
# ============== Using Warb.new ============== #
|
|
43
|
+
# ############################################ #
|
|
44
|
+
|
|
45
|
+
warb_from_new = Warb.new(
|
|
46
|
+
access_token: access_token,
|
|
47
|
+
business_id: business_id,
|
|
48
|
+
sender_id: sender_id
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
warb_from_new.location.dispatch(recipient_number, latitude: "37.44216251868683", longitude: "-122.16153582049394")
|
|
52
|
+
warb_from_new.location.dispatch(
|
|
53
|
+
recipient_number,
|
|
54
|
+
latitude: "37.44216251868683",
|
|
55
|
+
longitude: "-122.16153582049394",
|
|
56
|
+
name: "OPTIONAL - Location Name",
|
|
57
|
+
address: "OPTIONAL - Location Address"
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
warb_from_new.location.dispatch(recipient_number) do |builder|
|
|
61
|
+
builder.latitude = "37.44216251868683"
|
|
62
|
+
builder.longitude = "-122.16153582049394"
|
|
63
|
+
builder.name = "OPTIONAL - Location Name"
|
|
64
|
+
builder.address = "OPTIONAL - Location Address"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# ################################################# #
|
|
68
|
+
# ============== Using Warb directly ============== #
|
|
69
|
+
# ################################################# #
|
|
70
|
+
|
|
71
|
+
Warb.location.dispatch(recipient_number, latitude: "37.44216251868683", longitude: "-122.16153582049394")
|
|
72
|
+
Warb.location.dispatch(
|
|
73
|
+
recipient_number,
|
|
74
|
+
latitude: "37.44216251868683",
|
|
75
|
+
longitude: "-122.16153582049394",
|
|
76
|
+
name: "OPTIONAL - Location Name",
|
|
77
|
+
address: "OPTIONAL - Location Address"
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
Warb.location.dispatch(recipient_number) do |builder|
|
|
81
|
+
builder.latitude = "37.44216251868683"
|
|
82
|
+
builder.longitude = "-122.16153582049394"
|
|
83
|
+
builder.name = "OPTIONAL - Location Name"
|
|
84
|
+
builder.address = "OPTIONAL - Location Address"
|
|
85
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../lib/warb"
|
|
4
|
+
|
|
5
|
+
# Configure your variables here
|
|
6
|
+
|
|
7
|
+
access_token = ""
|
|
8
|
+
business_id = ""
|
|
9
|
+
sender_id = ""
|
|
10
|
+
recipient_number = ""
|
|
11
|
+
|
|
12
|
+
# We recommend testing one section at a time, as it can be overwhelming to see all the messages at once.
|
|
13
|
+
# So you can comment out the sections you don't want to test.
|
|
14
|
+
|
|
15
|
+
# ############################################## #
|
|
16
|
+
# ============== Using Warb.setup ============== #
|
|
17
|
+
# ############################################## #
|
|
18
|
+
|
|
19
|
+
warb_from_setup = Warb.setup do |config|
|
|
20
|
+
config.access_token = access_token
|
|
21
|
+
config.business_id = business_id
|
|
22
|
+
config.sender_id = sender_id
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
warb_from_setup.location_request.dispatch(recipient_number, body_text: "Location request body text")
|
|
26
|
+
|
|
27
|
+
warb_from_setup.location_request.dispatch(recipient_number) do |builder|
|
|
28
|
+
builder.body_text = "Location request body text"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# ############################################ #
|
|
32
|
+
# ============== Using Warb.new ============== #
|
|
33
|
+
# ############################################ #
|
|
34
|
+
|
|
35
|
+
warb_from_new = Warb.new(
|
|
36
|
+
access_token: access_token,
|
|
37
|
+
business_id: business_id,
|
|
38
|
+
sender_id: sender_id
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
warb_from_new.location_request.dispatch(recipient_number, body_text: "Location request body text")
|
|
42
|
+
|
|
43
|
+
warb_from_new.location_request.dispatch(recipient_number) do |builder|
|
|
44
|
+
builder.body_text = "Location request body text"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# ################################################# #
|
|
48
|
+
# ============== Using Warb directly ============== #
|
|
49
|
+
# ################################################# #
|
|
50
|
+
|
|
51
|
+
Warb.location_request.dispatch(recipient_number, body_text: "Location request body text")
|
|
52
|
+
|
|
53
|
+
Warb.location_request.dispatch(recipient_number) do |builder|
|
|
54
|
+
builder.body_text = "Location request body text"
|
|
55
|
+
end
|
data/examples/message.rb
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../lib/warb"
|
|
4
|
+
|
|
5
|
+
# Configure your variables here
|
|
6
|
+
|
|
7
|
+
access_token = ""
|
|
8
|
+
business_id = ""
|
|
9
|
+
sender_id = ""
|
|
10
|
+
recipient_number = ""
|
|
11
|
+
|
|
12
|
+
# We recommend testing one section at a time, as it can be overwhelming to see all the messages at once.
|
|
13
|
+
# So you can comment out the sections you don't want to test.
|
|
14
|
+
|
|
15
|
+
# ############################################## #
|
|
16
|
+
# ============== Using Warb.setup ============== #
|
|
17
|
+
# ############################################## #
|
|
18
|
+
|
|
19
|
+
warb_from_setup = Warb.setup do |config|
|
|
20
|
+
config.access_token = access_token
|
|
21
|
+
config.business_id = business_id
|
|
22
|
+
config.sender_id = sender_id
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
warb_from_setup.message.dispatch(recipient_number, content: 'Hello from warb! Message sent with "content" key')
|
|
26
|
+
warb_from_setup.message.dispatch(recipient_number, message: 'Hello from warb! Message sent with "message" key')
|
|
27
|
+
warb_from_setup.message.dispatch(recipient_number, text: 'Hello from warb! Message sent with "text" key')
|
|
28
|
+
|
|
29
|
+
warb_from_setup.message.dispatch(recipient_number) do |builder|
|
|
30
|
+
builder.content = "Hello from warb! Message sent with block builder"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# ############################################ #
|
|
34
|
+
# ============== Using Warb.new ============== #
|
|
35
|
+
# ############################################ #
|
|
36
|
+
|
|
37
|
+
warb_from_new = Warb.new(
|
|
38
|
+
access_token: access_token,
|
|
39
|
+
business_id: business_id,
|
|
40
|
+
sender_id: sender_id
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
warb_from_new.message.dispatch(recipient_number, content: 'Hello from warb! Message sent with "content" key')
|
|
44
|
+
warb_from_new.message.dispatch(recipient_number, message: 'Hello from warb! Message sent with "message" key')
|
|
45
|
+
warb_from_new.message.dispatch(recipient_number, text: 'Hello from warb! Message sent with "text" key')
|
|
46
|
+
|
|
47
|
+
warb_from_new.message.dispatch(recipient_number) do |builder|
|
|
48
|
+
builder.content = "Hello from warb! Message sent with block builder"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# ################################################# #
|
|
52
|
+
# ============== Using Warb directly ============== #
|
|
53
|
+
# ################################################# #
|
|
54
|
+
|
|
55
|
+
Warb.message.dispatch(recipient_number, content: 'Hello from warb! Message sent with "content" key')
|
|
56
|
+
Warb.message.dispatch(recipient_number, message: 'Hello from warb! Message sent with "message" key')
|
|
57
|
+
Warb.message.dispatch(recipient_number, text: 'Hello from warb! Message sent with "text" key')
|
|
58
|
+
|
|
59
|
+
Warb.message.dispatch(recipient_number) do |builder|
|
|
60
|
+
builder.content = "Hello from warb! Message sent with block builder"
|
|
61
|
+
end
|
data/examples/sticker.rb
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../lib/warb"
|
|
4
|
+
|
|
5
|
+
# Configure your variables here
|
|
6
|
+
|
|
7
|
+
access_token = ""
|
|
8
|
+
business_id = ""
|
|
9
|
+
sender_id = ""
|
|
10
|
+
recipient_number = ""
|
|
11
|
+
|
|
12
|
+
image_link = ""
|
|
13
|
+
|
|
14
|
+
# We recommend testing one section at a time, as it can be overwhelming to see all the messages at once.
|
|
15
|
+
# So you can comment out the sections you don't want to test.
|
|
16
|
+
|
|
17
|
+
# ############################################## #
|
|
18
|
+
# ============== Using Warb.setup ============== #
|
|
19
|
+
# ############################################## #
|
|
20
|
+
|
|
21
|
+
warb_from_setup = Warb.setup do |config|
|
|
22
|
+
config.access_token = access_token
|
|
23
|
+
config.business_id = business_id
|
|
24
|
+
config.sender_id = sender_id
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# To send sticker using its ID, you may need to retrieve it first, which can be retrieved this way
|
|
28
|
+
file_path = "" # fill this in with the file path pointing to wherever the sticker is located
|
|
29
|
+
file_type = "image/webp" # fill this in with the mimetype of the sticker to be uploaded
|
|
30
|
+
# only image/webp is allowed for sticker file type
|
|
31
|
+
image_id = warb_from_setup.sticker.upload(file_path: file_path, file_type: file_type)
|
|
32
|
+
# if you already have an sticker id, you can simply replace the above line with such id
|
|
33
|
+
|
|
34
|
+
warb_from_setup.sticker.dispatch(recipient_number, media_id: image_id)
|
|
35
|
+
warb_from_setup.sticker.dispatch(recipient_number, link: image_link)
|
|
36
|
+
|
|
37
|
+
warb_from_setup.sticker.dispatch(recipient_number) do |builder|
|
|
38
|
+
builder.media_id = image_id
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
warb_from_setup.sticker.dispatch(recipient_number) do |builder|
|
|
42
|
+
builder.link = image_link
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# ############################################ #
|
|
46
|
+
# ============== Using Warb.new ============== #
|
|
47
|
+
# ############################################ #
|
|
48
|
+
|
|
49
|
+
warb_from_new = Warb.new(
|
|
50
|
+
access_token: access_token,
|
|
51
|
+
business_id: business_id,
|
|
52
|
+
sender_id: sender_id
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
# Same as stated above, if you need a sticker id, you can upload it this way
|
|
56
|
+
file_path = "" # fill this in with the file path pointing to wherever the sticker is located
|
|
57
|
+
file_type = "" # fill this in with the mimetype of the sticker to be uploaded
|
|
58
|
+
# allow values for file_type: sticker/aac, sticker/amr, sticker/mpeg, sticker/mp4 or sticker/ogg
|
|
59
|
+
image_id = warb_from_setup.sticker.upload(file_path: file_path, file_type: file_type)
|
|
60
|
+
# if you already have a sticker id, you can simply replace the above line with such id
|
|
61
|
+
|
|
62
|
+
warb_from_new.sticker.dispatch(recipient_number, media_id: image_id)
|
|
63
|
+
warb_from_new.sticker.dispatch(recipient_number, link: image_link)
|
|
64
|
+
|
|
65
|
+
warb_from_new.sticker.dispatch(recipient_number) do |builder|
|
|
66
|
+
builder.media_id = image_id
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
warb_from_new.sticker.dispatch(recipient_number) do |builder|
|
|
70
|
+
builder.link = image_link
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# ################################################# #
|
|
74
|
+
# ============== Using Warb directly ============== #
|
|
75
|
+
# ################################################# #
|
|
76
|
+
|
|
77
|
+
Warb.sticker.dispatch(recipient_number, media_id: image_id)
|
|
78
|
+
Warb.sticker.dispatch(recipient_number, link: image_link)
|
|
79
|
+
|
|
80
|
+
Warb.sticker.dispatch(recipient_number) do |builder|
|
|
81
|
+
builder.media_id = image_id
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
Warb.sticker.dispatch(recipient_number) do |builder|
|
|
85
|
+
builder.link = image_link
|
|
86
|
+
end
|