warb 0.1.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 (104) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +8 -0
  4. data/CHANGELOG.md +25 -0
  5. data/README.md +135 -0
  6. data/Rakefile +12 -0
  7. data/docs/README.md +16 -0
  8. data/docs/components/README.md +24 -0
  9. data/docs/components/address.md +68 -0
  10. data/docs/components/button.md +61 -0
  11. data/docs/components/copy_code_button.md +57 -0
  12. data/docs/components/cta_action.md +13 -0
  13. data/docs/components/email.md +40 -0
  14. data/docs/components/list_action.md +29 -0
  15. data/docs/components/name.md +49 -0
  16. data/docs/components/org.md +42 -0
  17. data/docs/components/phone.md +57 -0
  18. data/docs/components/reply_button_action.md +32 -0
  19. data/docs/components/row.md +13 -0
  20. data/docs/components/section.md +30 -0
  21. data/docs/components/url.md +40 -0
  22. data/docs/components/url_button.md +57 -0
  23. data/docs/images/contact-with-wa_id.png +0 -0
  24. data/docs/images/contact-without-wa_id.png +0 -0
  25. data/docs/messages/README.md +80 -0
  26. data/docs/messages/audio.md +119 -0
  27. data/docs/messages/contact.md +134 -0
  28. data/docs/messages/document.md +122 -0
  29. data/docs/messages/flow.md +12 -0
  30. data/docs/messages/image.md +116 -0
  31. data/docs/messages/indicator.md +39 -0
  32. data/docs/messages/interactive_call_to_action_url.md +96 -0
  33. data/docs/messages/interactive_list.md +159 -0
  34. data/docs/messages/interactive_reply_button.md +67 -0
  35. data/docs/messages/location.md +34 -0
  36. data/docs/messages/location_request.md +21 -0
  37. data/docs/messages/reaction.md +23 -0
  38. data/docs/messages/sticker.md +116 -0
  39. data/docs/messages/template.md +327 -0
  40. data/docs/messages/text.md +47 -0
  41. data/docs/messages/video.md +116 -0
  42. data/docs/resources/currency.md +22 -0
  43. data/docs/resources/date_time.md +11 -0
  44. data/docs/resources/index.md +14 -0
  45. data/docs/resources/text.md +9 -0
  46. data/docs/setup.md +46 -0
  47. data/docs/webhook.md +24 -0
  48. data/examples/audio.rb +86 -0
  49. data/examples/document.rb +116 -0
  50. data/examples/image.rb +97 -0
  51. data/examples/interactive_call_to_action_url.rb +177 -0
  52. data/examples/interactive_list.rb +201 -0
  53. data/examples/interactive_reply_button.rb +174 -0
  54. data/examples/location.rb +85 -0
  55. data/examples/location_request.rb +55 -0
  56. data/examples/message.rb +61 -0
  57. data/examples/sticker.rb +86 -0
  58. data/examples/video.rb +96 -0
  59. data/examples/webhook.rb +144 -0
  60. data/lib/warb/client.rb +46 -0
  61. data/lib/warb/components/action.rb +121 -0
  62. data/lib/warb/components/address.rb +31 -0
  63. data/lib/warb/components/button.rb +29 -0
  64. data/lib/warb/components/component.rb +19 -0
  65. data/lib/warb/components/copy_code_button.rb +30 -0
  66. data/lib/warb/components/email.rb +21 -0
  67. data/lib/warb/components/name.rb +29 -0
  68. data/lib/warb/components/org.rb +23 -0
  69. data/lib/warb/components/phone.rb +23 -0
  70. data/lib/warb/components/quick_reply_button.rb +15 -0
  71. data/lib/warb/components/url.rb +21 -0
  72. data/lib/warb/components/url_button.rb +30 -0
  73. data/lib/warb/components/voice_call_button.rb +15 -0
  74. data/lib/warb/configuration.rb +13 -0
  75. data/lib/warb/connection.rb +47 -0
  76. data/lib/warb/dispatcher.rb +16 -0
  77. data/lib/warb/dispatcher_concern.rb +73 -0
  78. data/lib/warb/indicator_dispatcher.rb +31 -0
  79. data/lib/warb/language.rb +8 -0
  80. data/lib/warb/media_dispatcher.rb +46 -0
  81. data/lib/warb/resources/audio.rb +19 -0
  82. data/lib/warb/resources/contact.rb +89 -0
  83. data/lib/warb/resources/currency.rb +45 -0
  84. data/lib/warb/resources/date_time.rb +34 -0
  85. data/lib/warb/resources/document.rb +32 -0
  86. data/lib/warb/resources/flow.rb +34 -0
  87. data/lib/warb/resources/image.rb +31 -0
  88. data/lib/warb/resources/interactive_call_to_action_url.rb +48 -0
  89. data/lib/warb/resources/interactive_list.rb +36 -0
  90. data/lib/warb/resources/interactive_reply_button.rb +48 -0
  91. data/lib/warb/resources/location.rb +31 -0
  92. data/lib/warb/resources/location_request.rb +24 -0
  93. data/lib/warb/resources/reaction.rb +19 -0
  94. data/lib/warb/resources/resource.rb +59 -0
  95. data/lib/warb/resources/sticker.rb +19 -0
  96. data/lib/warb/resources/template.rb +166 -0
  97. data/lib/warb/resources/text.rb +47 -0
  98. data/lib/warb/resources/video.rb +31 -0
  99. data/lib/warb/template_dispatcher.rb +10 -0
  100. data/lib/warb/utils.rb +5 -0
  101. data/lib/warb/version.rb +5 -0
  102. data/lib/warb.rb +69 -0
  103. data/sig/warb.rbs +4 -0
  104. metadata +172 -0
data/examples/audio.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
+ audio_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 audio 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 audio is located
29
+ file_type = "" # fill this in with the mimetype of the audio to be uploaded
30
+ # allow values for file_type: audio/aac, audio/amr, audio/mpeg, audio/mp4 or audio/ogg
31
+ audio_id = warb_from_setup.audio.upload(file_path: file_path, file_type: file_type)
32
+ # if you already have an audio id, you can simply replace the above line with such id
33
+
34
+ warb_from_setup.audio.dispatch(recipient_number, media_id: audio_id)
35
+ warb_from_setup.audio.dispatch(recipient_number, link: audio_link)
36
+
37
+ warb_from_setup.audio.dispatch(recipient_number) do |builder|
38
+ builder.media_id = audio_id
39
+ end
40
+
41
+ warb_from_setup.audio.dispatch(recipient_number) do |builder|
42
+ builder.link = audio_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 an audio id, you can upload it this way
56
+ file_path = "" # fill this in with the file path pointing to wherever the audio is located
57
+ file_type = "" # fill this in with the mimetype of the audio to be uploaded
58
+ # allow values for file_type: audio/aac, audio/amr, audio/mpeg, audio/mp4 or audio/ogg
59
+ audio_id = warb_from_setup.audio.upload(file_path: file_path, file_type: file_type)
60
+ # if you already have an audio id, you can simply replace the above line with such id
61
+
62
+ warb_from_new.audio.dispatch(recipient_number, media_id: audio_id)
63
+ warb_from_new.audio.dispatch(recipient_number, link: audio_link)
64
+
65
+ warb_from_new.audio.dispatch(recipient_number) do |builder|
66
+ builder.media_id = audio_id
67
+ end
68
+
69
+ warb_from_new.audio.dispatch(recipient_number) do |builder|
70
+ builder.link = audio_link
71
+ end
72
+
73
+ # ################################################# #
74
+ # ============== Using Warb directly ============== #
75
+ # ################################################# #
76
+
77
+ Warb.audio.dispatch(recipient_number, media_id: audio_id)
78
+ Warb.audio.dispatch(recipient_number, link: audio_link)
79
+
80
+ Warb.audio.dispatch(recipient_number) do |builder|
81
+ builder.media_id = audio_id
82
+ end
83
+
84
+ Warb.audio.dispatch(recipient_number) do |builder|
85
+ builder.link = audio_link
86
+ end
@@ -0,0 +1,116 @@
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
+ document_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 document 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 document is located
29
+ file_type = "" # fill this in with the mimetype of the document to be uploaded
30
+ # allow values for file_type:
31
+ # text/plain, application/vnd.ms-excel, application/msword
32
+ # application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-powerpoint,
33
+ # application/vnd.openxmlformats-officedocument.presentationml.presentation or application/pdf
34
+ document_id = warb_from_setup.document.upload(file_path: file_path, file_type: file_type)
35
+ # if you already have a document id, you can simply replace the above line with such id
36
+
37
+ warb_from_setup.document.dispatch(recipient_number, media_id: document_id)
38
+ warb_from_setup.document.dispatch(recipient_number, media_id: document_id, filename: "optional_name.pdf")
39
+ warb_from_setup.document.dispatch(recipient_number, media_id: document_id, caption: "OPTIONAL - Document caption")
40
+ warb_from_setup.document.dispatch(recipient_number, link: document_link)
41
+ warb_from_setup.document.dispatch(recipient_number, link: document_link, filename: "optional_name.pdf")
42
+ warb_from_setup.document.dispatch(recipient_number, link: document_link, caption: "OPTIONAL - Document caption")
43
+
44
+ warb_from_setup.document.dispatch(recipient_number) do |builder|
45
+ builder.media_id = document_id
46
+ builder.filename = "optional_name.pdf"
47
+ builder.caption = "OPTIONAL - Document caption"
48
+ end
49
+
50
+ warb_from_setup.document.dispatch(recipient_number) do |builder|
51
+ builder.link = document_link
52
+ builder.filename = "optional_name.pdf"
53
+ builder.caption = "OPTIONAL - Document caption"
54
+ end
55
+
56
+ # ############################################ #
57
+ # ============== Using Warb.new ============== #
58
+ # ############################################ #
59
+
60
+ warb_from_new = Warb.new(
61
+ access_token: access_token,
62
+ business_id: business_id,
63
+ sender_id: sender_id
64
+ )
65
+
66
+ # Same as stated above, if you need a document id, you can upload it this way
67
+ file_path = "" # fill this in with the file path pointing to wherever the document is located
68
+ file_type = "" # fill this in with the mimetype of the document to be uploaded
69
+ # allow values for file_type:
70
+ # text/plain, application/vnd.ms-excel, application/msword
71
+ # application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-powerpoint,
72
+ # application/vnd.openxmlformats-officedocument.presentationml.presentation or application/pdf
73
+ document_id = warb_from_setup.document.upload(file_path: file_path, file_type: file_type)
74
+ # if you already have a document id, you can simply replace the above line with such id
75
+
76
+ warb_from_new.document.dispatch(recipient_number, media_id: document_id)
77
+ warb_from_new.document.dispatch(recipient_number, media_id: document_id, filename: "optional_name.pdf")
78
+ warb_from_new.document.dispatch(recipient_number, media_id: document_id, caption: "OPTIONAL - Document caption")
79
+ warb_from_new.document.dispatch(recipient_number, link: document_link)
80
+ warb_from_new.document.dispatch(recipient_number, link: document_link, filename: "optional_name.pdf")
81
+ warb_from_new.document.dispatch(recipient_number, link: document_link, caption: "OPTIONAL - Document caption")
82
+
83
+ warb_from_new.document.dispatch(recipient_number) do |builder|
84
+ builder.media_id = document_id
85
+ builder.filename = "optional_name.pdf"
86
+ builder.caption = "OPTIONAL - Document caption"
87
+ end
88
+
89
+ warb_from_new.document.dispatch(recipient_number) do |builder|
90
+ builder.link = document_link
91
+ builder.filename = "optional_name.pdf"
92
+ builder.caption = "OPTIONAL - Document caption"
93
+ end
94
+
95
+ # ################################################# #
96
+ # ============== Using Warb directly ============== #
97
+ # ################################################# #
98
+
99
+ Warb.document.dispatch(recipient_number, media_id: document_id)
100
+ Warb.document.dispatch(recipient_number, media_id: document_id, filename: "optional_name.pdf")
101
+ Warb.document.dispatch(recipient_number, media_id: document_id, caption: "OPTIONAL - Document caption")
102
+ Warb.document.dispatch(recipient_number, link: document_link)
103
+ Warb.document.dispatch(recipient_number, link: document_link, filename: "optional_name.pdf")
104
+ Warb.document.dispatch(recipient_number, link: document_link, caption: "OPTIONAL - Document caption")
105
+
106
+ Warb.document.dispatch(recipient_number) do |builder|
107
+ builder.media_id = document_id
108
+ builder.filename = "optional_name.pdf"
109
+ builder.caption = "OPTIONAL - Document caption"
110
+ end
111
+
112
+ Warb.document.dispatch(recipient_number) do |builder|
113
+ builder.link = document_link
114
+ builder.filename = "optional_name.pdf"
115
+ builder.caption = "OPTIONAL - Document caption"
116
+ end
data/examples/image.rb ADDED
@@ -0,0 +1,97 @@
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
+ warb_from_setup.image.dispatch(recipient_number, link: image_link)
28
+ warb_from_setup.image.dispatch(recipient_number, link: image_link, caption: "OPTIONAL - Image caption")
29
+
30
+ # To send image using its ID, you may need to retrieve it first, which can be retrieved this way
31
+ file_path = "" # fill this in with the file path pointing to wherever the image is located
32
+ file_type = "" # fill this in with the mimetype of the image to be uploaded. allowed values: "image/jpeg" or "image/png"
33
+ image_id = warb_from_setup.image.upload(file_path: file_path, file_type: file_type)
34
+ # if you already have an image id, you can simply replace the above line with such id
35
+
36
+ warb_from_setup.image.dispatch(recipient_number, media_id: image_id)
37
+ warb_from_setup.image.dispatch(recipient_number, media_id: image_id, caption: "OPTIONAL - Image caption")
38
+
39
+ warb_from_setup.image.dispatch(recipient_number) do |builder|
40
+ builder.media_id = image_id
41
+ builder.caption = "OPTIONAL - Image caption"
42
+ end
43
+
44
+ warb_from_setup.image.dispatch(recipient_number) do |builder|
45
+ builder.link = image_link
46
+ builder.caption = "OPTIONAL - Image caption"
47
+ end
48
+
49
+ # ############################################ #
50
+ # ============== Using Warb.new ============== #
51
+ # ############################################ #
52
+
53
+ warb_from_new = Warb.new(
54
+ access_token: access_token,
55
+ business_id: business_id,
56
+ sender_id: sender_id
57
+ )
58
+
59
+ # Same as stated above, if you need an image id, you can upload it this way
60
+ file_path = "" # fill this in with the file path pointing to wherever the image is located
61
+ file_type = "" # fill this in with the mimetype of the image to be uploaded. allowed values: "image/jpeg" or "image/png"
62
+ image_id = warb_from_new.image.upload(file_path: file_path, file_type: file_type)
63
+ # if you already have an image id, you can simply replace the above line with such id
64
+
65
+ warb_from_new.image.dispatch(recipient_number, media_id: image_id)
66
+ warb_from_new.image.dispatch(recipient_number, media_id: image_id, caption: "OPTIONAL - Image caption")
67
+ warb_from_new.image.dispatch(recipient_number, link: image_link)
68
+ warb_from_new.image.dispatch(recipient_number, link: image_link, caption: "OPTIONAL - Image caption")
69
+
70
+ warb_from_new.image.dispatch(recipient_number) do |builder|
71
+ builder.media_id = image_id
72
+ builder.caption = "OPTIONAL - Image caption"
73
+ end
74
+
75
+ warb_from_new.image.dispatch(recipient_number) do |builder|
76
+ builder.link = image_link
77
+ builder.caption = "OPTIONAL - Image caption"
78
+ end
79
+
80
+ # ################################################# #
81
+ # ============== Using Warb directly ============== #
82
+ # ################################################# #
83
+
84
+ Warb.image.dispatch(recipient_number, media_id: image_id)
85
+ Warb.image.dispatch(recipient_number, media_id: image_id, caption: "OPTIONAL - Image caption")
86
+ Warb.image.dispatch(recipient_number, link: image_link)
87
+ Warb.image.dispatch(recipient_number, link: image_link, caption: "OPTIONAL - Image caption")
88
+
89
+ Warb.image.dispatch(recipient_number) do |builder|
90
+ builder.media_id = image_id
91
+ builder.caption = "OPTIONAL - Image caption"
92
+ end
93
+
94
+ Warb.image.dispatch(recipient_number) do |builder|
95
+ builder.link = image_link
96
+ builder.caption = "OPTIONAL - Image caption"
97
+ end
@@ -0,0 +1,177 @@
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::CTAAction.new(button_text: "Action button text", url: "https://www.rebase.com.br")
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_call_to_action_url.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_call_to_action_url.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_call_to_action_url.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_call_to_action_url.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
+ action.url = "https://www.rebase.com.br"
74
+ end
75
+ end
76
+
77
+ # ############################################ #
78
+ # ============== Using Warb.new ============== #
79
+ # ############################################ #
80
+
81
+ warb_from_new = Warb.new(
82
+ access_token: access_token,
83
+ business_id: business_id,
84
+ sender_id: sender_id
85
+ )
86
+
87
+ warb_from_new.interactive_call_to_action_url.dispatch(
88
+ recipient_number,
89
+ header: text_header,
90
+ body: "body",
91
+ footer: "footer",
92
+ action: action_component
93
+ )
94
+
95
+ warb_from_new.interactive_call_to_action_url.dispatch(
96
+ recipient_number,
97
+ header: image_header,
98
+ body: "body",
99
+ footer: "footer",
100
+ action: action_component
101
+ )
102
+
103
+ warb_from_new.interactive_call_to_action_url.dispatch(
104
+ recipient_number,
105
+ header: video_header,
106
+ body: "body",
107
+ footer: "footer",
108
+ action: action_component
109
+ )
110
+
111
+ warb_from_new.interactive_call_to_action_url.dispatch(recipient_number) do |builder|
112
+ # Headers: you can choose between text, image, or video headers.
113
+
114
+ builder.set_text_header("Text Header")
115
+
116
+ # If you want to use an image header, uncomment the line below and provide a valid or Media ID or Link.
117
+ # builder.set_image_header(media_id: image_id) # or builder.set_image_header(link: image_link)
118
+
119
+ # If you want to use a video header, uncomment the line below and provide a valid Media ID or Link.
120
+ # builder.set_video_header(media_id: video_id) # or builder.set_video_header(link: video_link)
121
+
122
+ builder.body = "body"
123
+ builder.footer = "footer"
124
+
125
+ builder.build_action do |action|
126
+ action.button_text = "Action Button Text"
127
+ action.url = "https://www.rebase.com.br"
128
+ end
129
+ end
130
+
131
+ # ################################################# #
132
+ # ============== Using Warb directly ============== #
133
+ # ################################################# #
134
+
135
+ Warb.interactive_call_to_action_url.dispatch(
136
+ recipient_number,
137
+ header: text_header,
138
+ body: "body",
139
+ footer: "footer",
140
+ action: action_component
141
+ )
142
+
143
+ Warb.interactive_call_to_action_url.dispatch(
144
+ recipient_number,
145
+ header: image_header,
146
+ body: "body",
147
+ footer: "footer",
148
+ action: action_component
149
+ )
150
+
151
+ Warb.interactive_call_to_action_url.dispatch(
152
+ recipient_number,
153
+ header: video_header,
154
+ body: "body",
155
+ footer: "footer",
156
+ action: action_component
157
+ )
158
+
159
+ Warb.interactive_call_to_action_url.dispatch(recipient_number) do |builder|
160
+ # Headers: you can choose between text, image, or video headers.
161
+
162
+ builder.set_text_header("Text Header")
163
+
164
+ # If you want to use an image header, uncomment the line below and provide a valid or Media ID or Link.
165
+ # builder.set_image_header(media_id: image_id) # or builder.set_image_header(link: image_link)
166
+
167
+ # If you want to use a video header, uncomment the line below and provide a valid Media ID or Link.
168
+ # builder.set_video_header(media_id: video_id) # or builder.set_video_header(link: video_link)
169
+
170
+ builder.body = "body"
171
+ builder.footer = "footer"
172
+
173
+ builder.build_action do |action|
174
+ action.button_text = "Action Button Text"
175
+ action.url = "https://www.rebase.com.br"
176
+ end
177
+ end
@@ -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