warb 0.1.0 → 0.1.3

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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +12 -5
  3. data/README.md +8 -0
  4. data/Rakefile +3 -3
  5. data/docs/messages/interactive_call_to_action_url.md +9 -9
  6. data/docs/messages/interactive_list.md +2 -2
  7. data/docs/messages/interactive_reply_button.md +9 -9
  8. data/docs/messages/template.md +13 -13
  9. data/examples/audio.rb +10 -10
  10. data/examples/document.rb +34 -34
  11. data/examples/image.rb +22 -22
  12. data/examples/interactive_call_to_action_url.rb +46 -46
  13. data/examples/interactive_list.rb +61 -61
  14. data/examples/interactive_reply_button.rb +43 -43
  15. data/examples/location.rb +32 -32
  16. data/examples/location_request.rb +11 -11
  17. data/examples/message.rb +8 -8
  18. data/examples/sticker.rb +10 -10
  19. data/examples/video.rb +22 -22
  20. data/examples/webhook.rb +44 -42
  21. data/lib/warb/client.rb +7 -5
  22. data/lib/warb/components/action.rb +12 -8
  23. data/lib/warb/components/button.rb +2 -2
  24. data/lib/warb/components/component.rb +1 -1
  25. data/lib/warb/components/copy_code_button.rb +4 -4
  26. data/lib/warb/components/quick_reply_button.rb +1 -1
  27. data/lib/warb/components/url_button.rb +4 -4
  28. data/lib/warb/components/voice_call_button.rb +1 -1
  29. data/lib/warb/configuration.rb +4 -1
  30. data/lib/warb/connection.rb +15 -9
  31. data/lib/warb/dispatcher.rb +3 -2
  32. data/lib/warb/dispatcher_concern.rb +2 -0
  33. data/lib/warb/errors.rb +27 -0
  34. data/lib/warb/indicator_dispatcher.rb +4 -4
  35. data/lib/warb/language.rb +2 -2
  36. data/lib/warb/media_dispatcher.rb +10 -10
  37. data/lib/warb/resources/audio.rb +1 -1
  38. data/lib/warb/resources/contact.rb +22 -20
  39. data/lib/warb/resources/currency.rb +6 -4
  40. data/lib/warb/resources/date_time.rb +1 -1
  41. data/lib/warb/resources/document.rb +1 -1
  42. data/lib/warb/resources/flow.rb +10 -8
  43. data/lib/warb/resources/image.rb +1 -1
  44. data/lib/warb/resources/interactive_call_to_action_url.rb +10 -8
  45. data/lib/warb/resources/interactive_list.rb +7 -5
  46. data/lib/warb/resources/interactive_reply_button.rb +10 -8
  47. data/lib/warb/resources/location.rb +1 -1
  48. data/lib/warb/resources/location_request.rb +5 -3
  49. data/lib/warb/resources/reaction.rb +1 -1
  50. data/lib/warb/resources/resource.rb +4 -4
  51. data/lib/warb/resources/sticker.rb +1 -1
  52. data/lib/warb/resources/template.rb +30 -29
  53. data/lib/warb/resources/text.rb +4 -4
  54. data/lib/warb/resources/video.rb +1 -1
  55. data/lib/warb/response.rb +33 -0
  56. data/lib/warb/response_error_handler.rb +42 -0
  57. data/lib/warb/template_dispatcher.rb +4 -2
  58. data/lib/warb/utils.rb +3 -1
  59. data/lib/warb/version.rb +1 -1
  60. data/lib/warb.rb +50 -42
  61. metadata +10 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae3d5993ad731dab7a7aeb08130e76aff0872f4f4420680c8724613241043966
4
- data.tar.gz: c1fa725f65ad1f69dd37abee564a9864b8cb96b224bc2e098d6ffee183fa33a6
3
+ metadata.gz: 2f9ae7b1519b693fce17eb562569b49d110f18e57faf6fe1608880af08e40bcd
4
+ data.tar.gz: 931fb4cb412c47e0756eb05f21ff84b0126ef154ed9274ea83c3bd4f303f086b
5
5
  SHA512:
6
- metadata.gz: 30e29c7d31ea2d88bb844c1d50c727cbecf7a32d08d4eb5b6b0114a7d756eb16a103c8e4ca3e32c9532d0a834d0524e8d4d90ba536de8560bb2523dc3dd0c34a
7
- data.tar.gz: 765c7adf8cefc2a3eb53dfacfa847f1e29ffddbfd512273a6af8ae09a8f247259b4d6f4465a3c9ea46f83621781c94fa24176c1158589b9e0bda7e9e37c6e355
6
+ metadata.gz: 7aedabac7a6c7c74932b4ff243faf3ba06b7596c3c6c77114e65db6fd74e809833d2fb76d4e592eb738d156881d2efdf016c59236607f7ab300afc592e6ee501
7
+ data.tar.gz: d91b0667879f1e192d1cdc6e23048eba6326519df997546335b36df709cdddbbe8eb81605dfdd304b060e4a89da8792d0388cd62e13cf1a59773aecd3cd5c062
data/.rubocop.yml CHANGED
@@ -1,8 +1,15 @@
1
+ plugins:
2
+ - rubocop-rspec
3
+
1
4
  AllCops:
2
5
  TargetRubyVersion: 3.1
6
+ NewCops: enable
7
+ SuggestExtensions: false
8
+ Exclude:
9
+ - examples/**/*
10
+ - bin/*
11
+ Style/Documentation:
12
+ Enabled: false
3
13
 
4
- Style/StringLiterals:
5
- EnforcedStyle: double_quotes
6
-
7
- Style/StringLiteralsInInterpolation:
8
- EnforcedStyle: double_quotes
14
+ RSpec/NestedGroups:
15
+ Enabled: false
data/README.md CHANGED
@@ -124,6 +124,14 @@ To enable this kind of flow, you’ll need to know **when** a message is receive
124
124
  > ⚠️ **Note:** This gem **does not** provide built-in support for webhooks.
125
125
  > However, you can look at [`examples/webhook.rb`](examples/webhook.rb) for a starting point on how to implement it. Also, check the [official documentation](https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/payload-examples) for more details if you get stuck.
126
126
 
127
+ ## Deploy
128
+
129
+ ```
130
+ git tag v0.0.2
131
+ git push origin main --tags
132
+ ```
133
+
134
+
127
135
  ## Development
128
136
 
129
137
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/Rakefile CHANGED
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- require "rubocop/rake_task"
8
+ require 'rubocop/rake_task'
9
9
 
10
10
  RuboCop::RakeTask.new
11
11
 
@@ -28,7 +28,7 @@ Warb.interactive_call_to_action_url.dispatch(recipient_number) do |message|
28
28
  message.footer = "footer"
29
29
 
30
30
  # for header, there's a helper method to create a text header
31
- message.set_text_header("Check this out!")
31
+ message.add_text_header("Check this out!")
32
32
 
33
33
  # and for action, you can use the build_action method to create a CTA action`
34
34
  message.build_action(button_text: "Click Here") do |action|
@@ -37,7 +37,7 @@ Warb.interactive_call_to_action_url.dispatch(recipient_number) do |message|
37
37
  end
38
38
  ```
39
39
 
40
- Aside from the text header, you can also set an image, video, or document as header using the respective methods, `set_image_header`, `set_video_header`, and `set_document_header`.
40
+ Aside from the text header, you can also set an image, video, or document as header using the respective methods, `add_image_header`, `add_video_header`, and `add_document_header`.
41
41
 
42
42
  Here is an example of using an image as header:
43
43
 
@@ -47,7 +47,7 @@ Warb.interactive_call_to_action_url.dispatch(recipient_number) do |message|
47
47
  message.footer = "footer"
48
48
 
49
49
  # set an image as header
50
- message.set_image_header(link: "https://example.com/image.jpg")
50
+ message.add_image_header(link: "https://example.com/image.jpg")
51
51
 
52
52
  # the build_action method also returns the built action
53
53
  action = message.build_action do |action|
@@ -68,7 +68,7 @@ Warb.interactive_call_to_action_url.dispatch(recipient_number) do |message|
68
68
 
69
69
  # set a document as header
70
70
  # for documents, you can also pass a filename. its extension will be used to determine the MIME type
71
- message.set_document_header(link: "https://example.com/document.pdf", filename: "document.pdf")
71
+ message.add_document_header(link: "https://example.com/document.pdf", filename: "document.pdf")
72
72
 
73
73
  message.build_action(url: "https://example.com", button_text: "Click here")
74
74
  end
@@ -86,11 +86,11 @@ Here is a summary of the fields you can set in the `dispatch` method of the `int
86
86
  For header, as seen above, you can set it using the following instance methods:
87
87
  | Method | Named Parameters | Positional Parameters | Respective Resource Class |
88
88
  |-----------------------|--------------------|------------------------|-----------------------------|
89
- | `set_text_header` | - | the content header | `Warb::Resources::Text` |
90
- | `set_image_header` | `link` | - | `Warb::Resources::Image` |
91
- | `set_video_header` | `link` | - | `Warb::Resources::Video` |
92
- | `set_document_header` | `link`, `filename` | - | `Warb::Resources::Document` |
89
+ | `add_text_header` | - | the content header | `Warb::Resources::Text` |
90
+ | `add_image_header` | `link` | - | `Warb::Resources::Image` |
91
+ | `add_video_header` | `link` | - | `Warb::Resources::Video` |
92
+ | `add_document_header` | `link`, `filename` | - | `Warb::Resources::Document` |
93
93
 
94
94
  Under the hood, the set header methods will create the respective resource object and call its `build_header` method to prepare the header for sending.
95
95
 
96
- For the action, the `build_action` instance method will create a `Warb::Components::CTAAction` and return it
96
+ For the action, the `build_action` instance method will create a `Warb::Components::CTAAction` and return it
@@ -77,7 +77,7 @@ Warb.interactive_list.dispatch(recipient_number) do |message|
77
77
  message.body = "Choose your preferred language"
78
78
  message.footer = "You can change it later"
79
79
 
80
- message.set_text_header("Language Selection")
80
+ message.add_text_header("Language Selection")
81
81
 
82
82
  message.build_action(button_text: "Select") do |action|
83
83
  section = action.add_section(title: nil)
@@ -108,7 +108,7 @@ Warb.interactive_list.dispatch(recipient_number) do |message|
108
108
  message.body = "Choose your preferred language"
109
109
  message.footer = "You can change it later"
110
110
 
111
- message.set_text_header("Language Selection")
111
+ message.add_text_header("Language Selection")
112
112
 
113
113
  message.build_action(button_text: "Select") do |action|
114
114
  action.add_section(title: "American Languages") do |american_section|
@@ -23,7 +23,7 @@ Or you can use the block building strategy to simplify the process:
23
23
 
24
24
  ```ruby
25
25
  Warb.interactive_reply_button.dispatch(recipient_number) do |message|
26
- message.set_image_header(media_id: "1341834336894773")
26
+ message.add_image_header(media_id: "1341834336894773")
27
27
 
28
28
  message.body = "Select a Language:"
29
29
  message.footer = nil
@@ -38,23 +38,23 @@ or you can build the action with the buttons texts directly, passing them to the
38
38
 
39
39
  ```ruby
40
40
  Warb.interactive_reply_button.dispatch(recipient_number, action: action) do |message|
41
- message.set_text_header(content: "Options")
41
+ message.add_text_header(content: "Options")
42
42
  message.body = "Select a Language:"
43
43
  message.footer = nil
44
44
  message.build_action(buttons_texts: ["Português", "English", "Español"])
45
45
  end
46
46
  ```
47
47
 
48
- Aside from text and image headers, you can also set a video or document as header using the respective methods, `set_video_header` and `set_document_header`.
48
+ Aside from text and image headers, you can also set a video or document as header using the respective methods, `add_video_header` and `add_document_header`.
49
49
 
50
- For text header, `set_text_header` receives a string, while for image, video, and document headers, you can pass a `media_id` or a `link` to the media file.
50
+ For text header, `add_text_header` receives a string, while for image, video, and document headers, you can pass a `media_id` or a `link` to the media file.
51
51
  For header, as seen above, you can set it using the following instance methods:
52
52
  | Method | Named Parameters | Positional Parameters | Respective Resource Class |
53
53
  |-----------------------|--------------------------------|------------------------|-----------------------------|
54
- | `set_text_header` | - | the content header | `Warb::Resources::Text` |
55
- | `set_image_header` | `link`, `media_id` | - | `Warb::Resources::Image` |
56
- | `set_video_header` | `link`, `media_id` | - | `Warb::Resources::Video` |
57
- | `set_document_header` | `link`, `media_id`, `filename` | - | `Warb::Resources::Document` |
54
+ | `add_text_header` | - | the content header | `Warb::Resources::Text` |
55
+ | `add_image_header` | `link`, `media_id` | - | `Warb::Resources::Image` |
56
+ | `add_video_header` | `link`, `media_id` | - | `Warb::Resources::Video` |
57
+ | `add_document_header` | `link`, `media_id`, `filename` | - | `Warb::Resources::Document` |
58
58
 
59
59
  Either `link` or `media_id` can be used, but not both at the same time.
60
60
 
@@ -64,4 +64,4 @@ If you're using a `media_id`, it must be obtained from a previous upload using t
64
64
 
65
65
  The `filename` for the document header is optional, but if provided, it will be used to determine the MIME type of the document.
66
66
 
67
- For the `action` of the message, you can use the [`Warb::Components::ReplyButtonAction`](../components/reply_button_action.md) class to build the action with the buttons texts.
67
+ For the `action` of the message, you can use the [`Warb::Components::ReplyButtonAction`](../components/reply_button_action.md) class to build the action with the buttons texts.
@@ -216,18 +216,18 @@ end
216
216
  If your template has any media header, you can set it as follow:
217
217
  | Header Type | Template Instance Method | Params |
218
218
  |----------------|-----------------------------|------------------------------------------------|
219
- | `image` | `set_image_header` | `media_id` or `link` |
220
- | `video` | `set_video_header` | `media_id` or `link` |
221
- | `document` | `set_document_header` | `media_id` or `link`, `filename` |
222
- | `location` | `set_location_header` | `latitude`, `longitude`, `name`, and `address` |
223
- | `text` | `set_text_header` | `content`, `parameter_name` |
219
+ | `image` | `add_image_header` | `media_id` or `link` |
220
+ | `video` | `add_video_header` | `media_id` or `link` |
221
+ | `document` | `add_document_header` | `media_id` or `link`, `filename` |
222
+ | `location` | `add_location_header` | `latitude`, `longitude`, `name`, and `address` |
223
+ | `text` | `add_text_header` | `content`, `parameter_name` |
224
224
 
225
- Every time a call is made to any `set_header` method, a new header will be set, overwriting the previous one.
225
+ Every time a call is made to any `add_header` method, a new header will be set, overwriting the previous one.
226
226
 
227
- If you just want to change one attribute or another, `set_header` methods return the related resource, so it is possible to set the values if you keep a hold of such instance
227
+ If you just want to change one attribute or another, `add_header` methods return the related resource, so it is possible to set the values if you keep a hold of such instance
228
228
  ```ruby
229
229
  Warb.template.dispatch(recipient_number) do |template|
230
- header = template.set_image_header(media_id: "wrong_media_id")
230
+ header = template.add_image_header(media_id: "wrong_media_id")
231
231
 
232
232
  header.media_id = "correct_media_id"
233
233
  end
@@ -243,18 +243,18 @@ For the `document` header, `filename` is important because its extension will de
243
243
 
244
244
  For the `location` header, at least `latitude` and `longitude` must be provided.
245
245
 
246
- `set_header` methods will simply instatiate the corresponding resource class with the given parameters, and then, set it as the header attribute.
246
+ `add_header` methods will simply instatiate the corresponding resource class with the given parameters, and then, set it as the header attribute.
247
247
 
248
248
  For `text` header, note that, due to how the WhatsApp Business Platform works, you can't set the entire content for it (the same that happens with the body of the message).
249
249
 
250
- In this case, `set_text_header`, will simply use whatever was given to it as parameter to build the final header in the WhatsApp Business Platform.
250
+ In this case, `add_text_header`, will simply use whatever was given to it as parameter to build the final header in the WhatsApp Business Platform.
251
251
 
252
- So, for example, if your tamplate header was created with `Hello, {{1}}!`, then the text passed to `set_text_header` will simply be substituted in that `{{1}}`.
252
+ So, for example, if your tamplate header was created with `Hello, {{1}}!`, then the text passed to `add_text_header` will simply be substituted in that `{{1}}`.
253
253
 
254
- If your template was defined using named parameters instead (something like `Hello, {{customer_name}}!`), then you must pass the name of the paramter to `set_text_header` as follow:
254
+ If your template was defined using named parameters instead (something like `Hello, {{customer_name}}!`), then you must pass the name of the paramter to `add_text_header` as follow:
255
255
  ```ruby
256
256
  Warb.template.dispatch(recipient_number) do |template|
257
- template.set_text_header(content: "John", parameter_name: "customer_name")
257
+ template.add_text_header(content: "John", parameter_name: "customer_name")
258
258
  end
259
259
  ```
260
260
 
data/examples/audio.rb CHANGED
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../lib/warb"
3
+ require_relative '../lib/warb'
4
4
 
5
5
  # Configure your variables here
6
6
 
7
- access_token = ""
8
- business_id = ""
9
- sender_id = ""
10
- recipient_number = ""
7
+ access_token = ''
8
+ business_id = ''
9
+ sender_id = ''
10
+ recipient_number = ''
11
11
 
12
- audio_link = ""
12
+ audio_link = ''
13
13
 
14
14
  # We recommend testing one section at a time, as it can be overwhelming to see all the messages at once.
15
15
  # So you can comment out the sections you don't want to test.
@@ -25,8 +25,8 @@ warb_from_setup = Warb.setup do |config|
25
25
  end
26
26
 
27
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
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
30
  # allow values for file_type: audio/aac, audio/amr, audio/mpeg, audio/mp4 or audio/ogg
31
31
  audio_id = warb_from_setup.audio.upload(file_path: file_path, file_type: file_type)
32
32
  # if you already have an audio id, you can simply replace the above line with such id
@@ -53,8 +53,8 @@ warb_from_new = Warb.new(
53
53
  )
54
54
 
55
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
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
58
  # allow values for file_type: audio/aac, audio/amr, audio/mpeg, audio/mp4 or audio/ogg
59
59
  audio_id = warb_from_setup.audio.upload(file_path: file_path, file_type: file_type)
60
60
  # if you already have an audio id, you can simply replace the above line with such id
data/examples/document.rb CHANGED
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../lib/warb"
3
+ require_relative '../lib/warb'
4
4
 
5
5
  # Configure your variables here
6
6
 
7
- access_token = ""
8
- business_id = ""
9
- sender_id = ""
10
- recipient_number = ""
7
+ access_token = ''
8
+ business_id = ''
9
+ sender_id = ''
10
+ recipient_number = ''
11
11
 
12
- document_link = ""
12
+ document_link = ''
13
13
 
14
14
  # We recommend testing one section at a time, as it can be overwhelming to see all the messages at once.
15
15
  # So you can comment out the sections you don't want to test.
@@ -25,8 +25,8 @@ warb_from_setup = Warb.setup do |config|
25
25
  end
26
26
 
27
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
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
30
  # allow values for file_type:
31
31
  # text/plain, application/vnd.ms-excel, application/msword
32
32
  # application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-powerpoint,
@@ -35,22 +35,22 @@ document_id = warb_from_setup.document.upload(file_path: file_path, file_type: f
35
35
  # if you already have a document id, you can simply replace the above line with such id
36
36
 
37
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")
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
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")
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
43
 
44
44
  warb_from_setup.document.dispatch(recipient_number) do |builder|
45
45
  builder.media_id = document_id
46
- builder.filename = "optional_name.pdf"
47
- builder.caption = "OPTIONAL - Document caption"
46
+ builder.filename = 'optional_name.pdf'
47
+ builder.caption = 'OPTIONAL - Document caption'
48
48
  end
49
49
 
50
50
  warb_from_setup.document.dispatch(recipient_number) do |builder|
51
51
  builder.link = document_link
52
- builder.filename = "optional_name.pdf"
53
- builder.caption = "OPTIONAL - Document caption"
52
+ builder.filename = 'optional_name.pdf'
53
+ builder.caption = 'OPTIONAL - Document caption'
54
54
  end
55
55
 
56
56
  # ############################################ #
@@ -64,8 +64,8 @@ warb_from_new = Warb.new(
64
64
  )
65
65
 
66
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
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
69
  # allow values for file_type:
70
70
  # text/plain, application/vnd.ms-excel, application/msword
71
71
  # application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-powerpoint,
@@ -74,22 +74,22 @@ document_id = warb_from_setup.document.upload(file_path: file_path, file_type: f
74
74
  # if you already have a document id, you can simply replace the above line with such id
75
75
 
76
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")
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
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")
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
82
 
83
83
  warb_from_new.document.dispatch(recipient_number) do |builder|
84
84
  builder.media_id = document_id
85
- builder.filename = "optional_name.pdf"
86
- builder.caption = "OPTIONAL - Document caption"
85
+ builder.filename = 'optional_name.pdf'
86
+ builder.caption = 'OPTIONAL - Document caption'
87
87
  end
88
88
 
89
89
  warb_from_new.document.dispatch(recipient_number) do |builder|
90
90
  builder.link = document_link
91
- builder.filename = "optional_name.pdf"
92
- builder.caption = "OPTIONAL - Document caption"
91
+ builder.filename = 'optional_name.pdf'
92
+ builder.caption = 'OPTIONAL - Document caption'
93
93
  end
94
94
 
95
95
  # ################################################# #
@@ -97,20 +97,20 @@ end
97
97
  # ################################################# #
98
98
 
99
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")
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
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")
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
105
 
106
106
  Warb.document.dispatch(recipient_number) do |builder|
107
107
  builder.media_id = document_id
108
- builder.filename = "optional_name.pdf"
109
- builder.caption = "OPTIONAL - Document caption"
108
+ builder.filename = 'optional_name.pdf'
109
+ builder.caption = 'OPTIONAL - Document caption'
110
110
  end
111
111
 
112
112
  Warb.document.dispatch(recipient_number) do |builder|
113
113
  builder.link = document_link
114
- builder.filename = "optional_name.pdf"
115
- builder.caption = "OPTIONAL - Document caption"
114
+ builder.filename = 'optional_name.pdf'
115
+ builder.caption = 'OPTIONAL - Document caption'
116
116
  end
data/examples/image.rb CHANGED
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../lib/warb"
3
+ require_relative '../lib/warb'
4
4
 
5
5
  # Configure your variables here
6
6
 
7
- access_token = ""
8
- business_id = ""
9
- sender_id = ""
10
- recipient_number = ""
7
+ access_token = ''
8
+ business_id = ''
9
+ sender_id = ''
10
+ recipient_number = ''
11
11
 
12
- image_link = ""
12
+ image_link = ''
13
13
 
14
14
  # We recommend testing one section at a time, as it can be overwhelming to see all the messages at once.
15
15
  # So you can comment out the sections you don't want to test.
@@ -25,25 +25,25 @@ warb_from_setup = Warb.setup do |config|
25
25
  end
26
26
 
27
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")
28
+ warb_from_setup.image.dispatch(recipient_number, link: image_link, caption: 'OPTIONAL - Image caption')
29
29
 
30
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"
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
33
  image_id = warb_from_setup.image.upload(file_path: file_path, file_type: file_type)
34
34
  # if you already have an image id, you can simply replace the above line with such id
35
35
 
36
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")
37
+ warb_from_setup.image.dispatch(recipient_number, media_id: image_id, caption: 'OPTIONAL - Image caption')
38
38
 
39
39
  warb_from_setup.image.dispatch(recipient_number) do |builder|
40
40
  builder.media_id = image_id
41
- builder.caption = "OPTIONAL - Image caption"
41
+ builder.caption = 'OPTIONAL - Image caption'
42
42
  end
43
43
 
44
44
  warb_from_setup.image.dispatch(recipient_number) do |builder|
45
45
  builder.link = image_link
46
- builder.caption = "OPTIONAL - Image caption"
46
+ builder.caption = 'OPTIONAL - Image caption'
47
47
  end
48
48
 
49
49
  # ############################################ #
@@ -57,24 +57,24 @@ warb_from_new = Warb.new(
57
57
  )
58
58
 
59
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"
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
62
  image_id = warb_from_new.image.upload(file_path: file_path, file_type: file_type)
63
63
  # if you already have an image id, you can simply replace the above line with such id
64
64
 
65
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")
66
+ warb_from_new.image.dispatch(recipient_number, media_id: image_id, caption: 'OPTIONAL - Image caption')
67
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")
68
+ warb_from_new.image.dispatch(recipient_number, link: image_link, caption: 'OPTIONAL - Image caption')
69
69
 
70
70
  warb_from_new.image.dispatch(recipient_number) do |builder|
71
71
  builder.media_id = image_id
72
- builder.caption = "OPTIONAL - Image caption"
72
+ builder.caption = 'OPTIONAL - Image caption'
73
73
  end
74
74
 
75
75
  warb_from_new.image.dispatch(recipient_number) do |builder|
76
76
  builder.link = image_link
77
- builder.caption = "OPTIONAL - Image caption"
77
+ builder.caption = 'OPTIONAL - Image caption'
78
78
  end
79
79
 
80
80
  # ################################################# #
@@ -82,16 +82,16 @@ end
82
82
  # ################################################# #
83
83
 
84
84
  Warb.image.dispatch(recipient_number, media_id: image_id)
85
- Warb.image.dispatch(recipient_number, media_id: image_id, caption: "OPTIONAL - Image caption")
85
+ Warb.image.dispatch(recipient_number, media_id: image_id, caption: 'OPTIONAL - Image caption')
86
86
  Warb.image.dispatch(recipient_number, link: image_link)
87
- Warb.image.dispatch(recipient_number, link: image_link, caption: "OPTIONAL - Image caption")
87
+ Warb.image.dispatch(recipient_number, link: image_link, caption: 'OPTIONAL - Image caption')
88
88
 
89
89
  Warb.image.dispatch(recipient_number) do |builder|
90
90
  builder.media_id = image_id
91
- builder.caption = "OPTIONAL - Image caption"
91
+ builder.caption = 'OPTIONAL - Image caption'
92
92
  end
93
93
 
94
94
  Warb.image.dispatch(recipient_number) do |builder|
95
95
  builder.link = image_link
96
- builder.caption = "OPTIONAL - Image caption"
96
+ builder.caption = 'OPTIONAL - Image caption'
97
97
  end