warb 0.1.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -12
  3. data/README.md +9 -32
  4. data/Rakefile +3 -3
  5. data/docs/README.md +1 -4
  6. data/docs/components/README.md +1 -4
  7. data/docs/messages/README.md +1 -2
  8. data/docs/messages/interactive_call_to_action_url.md +9 -9
  9. data/docs/messages/interactive_list.md +2 -2
  10. data/docs/messages/interactive_reply_button.md +9 -9
  11. data/examples/audio.rb +10 -10
  12. data/examples/document.rb +34 -34
  13. data/examples/image.rb +22 -22
  14. data/examples/interactive_call_to_action_url.rb +46 -46
  15. data/examples/interactive_list.rb +61 -61
  16. data/examples/interactive_reply_button.rb +43 -43
  17. data/examples/location.rb +32 -32
  18. data/examples/location_request.rb +11 -11
  19. data/examples/message.rb +8 -8
  20. data/examples/sticker.rb +10 -10
  21. data/examples/video.rb +22 -22
  22. data/examples/webhook.rb +42 -44
  23. data/lib/warb/client.rb +5 -7
  24. data/lib/warb/components/action.rb +8 -12
  25. data/lib/warb/configuration.rb +1 -4
  26. data/lib/warb/connection.rb +9 -15
  27. data/lib/warb/dispatcher.rb +3 -4
  28. data/lib/warb/dispatcher_concern.rb +0 -6
  29. data/lib/warb/indicator_dispatcher.rb +4 -4
  30. data/lib/warb/media_dispatcher.rb +10 -10
  31. data/lib/warb/resources/audio.rb +1 -1
  32. data/lib/warb/resources/contact.rb +20 -22
  33. data/lib/warb/resources/document.rb +1 -1
  34. data/lib/warb/resources/flow.rb +8 -10
  35. data/lib/warb/resources/image.rb +1 -1
  36. data/lib/warb/resources/interactive_call_to_action_url.rb +8 -10
  37. data/lib/warb/resources/interactive_list.rb +5 -7
  38. data/lib/warb/resources/interactive_reply_button.rb +8 -10
  39. data/lib/warb/resources/location.rb +1 -11
  40. data/lib/warb/resources/location_request.rb +3 -5
  41. data/lib/warb/resources/reaction.rb +1 -1
  42. data/lib/warb/resources/resource.rb +4 -12
  43. data/lib/warb/resources/sticker.rb +1 -1
  44. data/lib/warb/resources/text.rb +3 -21
  45. data/lib/warb/resources/video.rb +1 -1
  46. data/lib/warb/utils.rb +1 -3
  47. data/lib/warb/version.rb +1 -1
  48. data/lib/warb.rb +31 -50
  49. metadata +3 -29
  50. data/docs/components/button.md +0 -61
  51. data/docs/components/copy_code_button.md +0 -57
  52. data/docs/components/url_button.md +0 -57
  53. data/docs/messages/template.md +0 -327
  54. data/docs/resources/currency.md +0 -22
  55. data/docs/resources/date_time.md +0 -11
  56. data/docs/resources/index.md +0 -14
  57. data/docs/resources/text.md +0 -9
  58. data/lib/warb/components/button.rb +0 -29
  59. data/lib/warb/components/component.rb +0 -19
  60. data/lib/warb/components/copy_code_button.rb +0 -30
  61. data/lib/warb/components/quick_reply_button.rb +0 -15
  62. data/lib/warb/components/url_button.rb +0 -30
  63. data/lib/warb/components/voice_call_button.rb +0 -15
  64. data/lib/warb/errors.rb +0 -27
  65. data/lib/warb/language.rb +0 -8
  66. data/lib/warb/resources/currency.rb +0 -47
  67. data/lib/warb/resources/date_time.rb +0 -34
  68. data/lib/warb/resources/template.rb +0 -167
  69. data/lib/warb/response.rb +0 -33
  70. data/lib/warb/response_error_handler.rb +0 -42
  71. data/lib/warb/template_dispatcher.rb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09b6db5e1307ca21155dce0d4c3e01b466a84b8a2a7447531f58bb1adf89a9a5'
4
- data.tar.gz: 2a543f87fc02cbf6af376cffad0d6da61168e5440520b3ed582671401919fadc
3
+ metadata.gz: 58ff4cfa4904a9a820c4b5906b947b6f5dcbd3e5a3afa76a9e88ed3f83488bb8
4
+ data.tar.gz: 1edcbcef65fd5f128cb0cf475f4b5c6ae8e4e285a4b57335b80818e0487f874a
5
5
  SHA512:
6
- metadata.gz: 271e9e372bdf2ea0874aba10408fda74e31ba4709cc051ff914d3fa6b4f91ee0d75c2192e06063004a96a61698cc6366727bc8b097fa741e4f755377ec324a6f
7
- data.tar.gz: 2fa9c539be381d1d877d4cff6f78145c402ea7620578a9f4181cee2a8069312ced9d04219db2a3a30038614a1f112d7bfbe560415978c080f1b7dfff125267da
6
+ metadata.gz: 43cabbb2bcd395dbbc32eacf0f170e00c5fa913f9edbe4543b9b19f81278648ccae955ac64601182fc468ab02ae81cdb81ae1c07d4601f793dd1645cad28a698
7
+ data.tar.gz: f7ef031988f7c39be607047ebab9e56d627b848527fce0baa5043f1108a93e378e4e7b6d7df853240bcdba9ccb46b0c0c8ba135833fc31fbccaf01175dab9ba6
data/.rubocop.yml CHANGED
@@ -1,15 +1,8 @@
1
- plugins:
2
- - rubocop-rspec
3
-
4
1
  AllCops:
5
2
  TargetRubyVersion: 3.1
6
- NewCops: enable
7
- SuggestExtensions: false
8
- Exclude:
9
- - examples/**/*
10
- - bin/*
11
- Style/Documentation:
12
- Enabled: false
13
3
 
14
- RSpec/NestedGroups:
15
- Enabled: false
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Style/StringLiteralsInInterpolation:
8
+ EnforcedStyle: double_quotes
data/README.md CHANGED
@@ -9,16 +9,18 @@ A Ruby Gem focused on wrap all the functionalities and use cases of the WhatsApp
9
9
 
10
10
  ## Installation
11
11
 
12
- Add `warb` to your bundle
12
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
13
13
 
14
- ```ruby
15
- bundle add warb
14
+ Install the gem and add to the application's Gemfile by executing:
15
+
16
+ ```bash
17
+ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
16
18
  ```
17
19
 
18
- or add it manually to your Gemfile if you prefer.
20
+ If bundler is not being used to manage dependencies, install the gem by executing:
19
21
 
20
- ```ruby
21
- gem 'warb'
22
+ ```bash
23
+ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
22
24
  ```
23
25
 
24
26
  ## Configuration
@@ -88,26 +90,9 @@ Warb.message.dispatch(recipient_number) do |builder|
88
90
  end
89
91
  ```
90
92
 
91
- ### What types of messages can I send?
92
-
93
- Warb implements the main types of WhatsApp messages, you can follow the message types [`here`](docs/messages/README.md#messages-types)
94
-
95
- examples:
96
-
97
- ```ruby
98
-
99
- warb = Warb.new(...)
100
-
101
- warb.message.dispatch(...)
102
- warb.audio.dispatch(...)
103
- warb.video.dispatch(...)
104
- warb.image.dispatch(...)
105
- ...
106
- ```
107
-
108
93
  ### Find all usage examples
109
94
 
110
- We suggest heading to the [`examples`](examples) directory, where you'll find documentation files with plenty of usage examples, organized by **Resources** (**Resources** are the types of messages you can send via WhatsApp using Warb).
95
+ We suggest heading to the `examples/` directory, where you'll find documentation files with plenty of usage examples, organized by **Resources** (**Resources** are the types of messages you can send via WhatsApp using Warb).
111
96
 
112
97
  You can also check the [`docs`](docs/README.md) for a more structured overview of the available resources and their usage.
113
98
 
@@ -124,14 +109,6 @@ To enable this kind of flow, you’ll need to know **when** a message is receive
124
109
  > ⚠️ **Note:** This gem **does not** provide built-in support for webhooks.
125
110
  > 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
111
 
127
- ## Deploy
128
-
129
- ```
130
- git tag v0.0.2
131
- git push origin main --tags
132
- ```
133
-
134
-
135
112
  ## Development
136
113
 
137
114
  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
 
data/docs/README.md CHANGED
@@ -10,7 +10,4 @@ Refer to [webhook](webhook.md) for more details on how to setup a webhook to get
10
10
  Refer to [messages](./messages/README.md) for more details on how to send messages using Warb.
11
11
 
12
12
  ## Components
13
- Refer to [components](./components/README.md) for more details on how Warb components work.
14
-
15
- ## Resources
16
- Refer to [resources](./resources/README.md) for more details on resources.
13
+ Refer to [components](./components/README.md) for more details on how Warb components work.
@@ -18,7 +18,4 @@ Here is a table of available components, and where they can be used:
18
18
  | `Warb::Components::ReplyButtonAction` | [Interactive Reply Button](../messages/interactive_reply_button.md) | [Reply Button Action](./reply_button_action) |
19
19
  | `Warb::Components::Row` | [Interactive List](../messages/interactive_list.md) | [Row](./row.md) |
20
20
  | `Warb::Components::ListAction` | [Interactive List](../messages/interactive_list.md) | [List Action](./list_action.md) |
21
- | `Warb::Components::Section` | [Interactive List](../messages/interactive_list.md) | [Section](./section.md) |
22
- | `Warb::Components::Button` | [Template](../messages/template.md) | [Button](./button.md) |
23
- | `Warb::Components::UrlButton` | [Template](../messages/template.md) | [UrlButton](./url_button.md) |
24
- | `Warb::Components::CopyCodeButton` | [Template](../messages/template.md) | [CopyCodeButton](./copy_code_button.md) |
21
+ | `Warb::Components::Section` | [Interactive List](../messages/interactive_list.md) | [Section](./section.md) |
@@ -71,10 +71,9 @@ Messages are sent using a helper dispatcher and its resource class. Here is a li
71
71
  | Video | `Warb::Resources::Video` | `video` | [Video Message](./video.md) |
72
72
  | Special Dispatchers |
73
73
  | Indicator | `Warb::Resources::Indicator` | `indicator` | [Indicator Message](./indicator.md) |
74
- | Template | `Warb::Resources::Template` | `template` | [Template Message](./template.md) |
75
74
 
76
75
  > Simple Dispatcher doesn't offer any additional functionality, they just send messages.
77
76
 
78
77
  > Media Dispatchers, aside from sending messages, also provide methods to upload and download media files.
79
78
 
80
- > Special Dispatchers are used for specific purposes, such as sending indicators, reactions or templates.
79
+ > Special Dispatchers are used for specific purposes, such as sending indicators or reactions.
@@ -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.add_text_header("Check this out!")
31
+ message.set_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, `add_image_header`, `add_video_header`, and `add_document_header`.
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`.
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.add_image_header(link: "https://example.com/image.jpg")
50
+ message.set_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.add_document_header(link: "https://example.com/document.pdf", filename: "document.pdf")
71
+ message.set_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
- | `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` |
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` |
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.add_text_header("Language Selection")
80
+ message.set_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.add_text_header("Language Selection")
111
+ message.set_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.add_image_header(media_id: "1341834336894773")
26
+ message.set_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.add_text_header(content: "Options")
41
+ message.set_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, `add_video_header` and `add_document_header`.
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`.
49
49
 
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.
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.
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
- | `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` |
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` |
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.
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