whatsapp_sdk 0.9.1 → 0.10.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 (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -1
  3. data/Gemfile +0 -6
  4. data/Gemfile.lock +16 -16
  5. data/README.md +32 -9
  6. data/example.rb +67 -1
  7. data/lib/whatsapp_sdk/api/business_profile.rb +8 -8
  8. data/lib/whatsapp_sdk/api/medias.rb +18 -18
  9. data/lib/whatsapp_sdk/api/messages.rb +67 -71
  10. data/lib/whatsapp_sdk/api/phone_numbers.rb +16 -16
  11. data/lib/whatsapp_sdk/api/response.rb +4 -4
  12. data/lib/whatsapp_sdk/api/responses/generic_error_response.rb +49 -0
  13. data/lib/whatsapp_sdk/api/responses/message_data_response.rb +8 -8
  14. data/lib/whatsapp_sdk/api/responses/message_error_response.rb +2 -38
  15. data/lib/whatsapp_sdk/api/responses/message_template_namespace_data_response.rb +37 -0
  16. data/lib/whatsapp_sdk/api/responses/template_data_response.rb +51 -0
  17. data/lib/whatsapp_sdk/api/responses/templates_data_response.rb +39 -0
  18. data/lib/whatsapp_sdk/api/templates.rb +201 -0
  19. data/lib/whatsapp_sdk/configuration.rb +2 -2
  20. data/lib/whatsapp_sdk/resource/component.rb +2 -2
  21. data/lib/whatsapp_sdk/resource/errors.rb +68 -0
  22. data/lib/whatsapp_sdk/resource/interactive_action.rb +5 -5
  23. data/lib/whatsapp_sdk/resource/interactive_action_reply_button.rb +2 -2
  24. data/lib/whatsapp_sdk/resource/interactive_action_section.rb +2 -2
  25. data/lib/whatsapp_sdk/resource/interactive_action_section_row.rb +5 -5
  26. data/lib/whatsapp_sdk/resource/interactive_body.rb +1 -1
  27. data/lib/whatsapp_sdk/resource/interactive_footer.rb +1 -1
  28. data/lib/whatsapp_sdk/resource/interactive_header.rb +1 -1
  29. data/lib/whatsapp_sdk/resource/languages.rb +86 -0
  30. data/lib/whatsapp_sdk/resource/media_types.rb +2 -1
  31. data/lib/whatsapp_sdk/resource/parameter_object.rb +2 -2
  32. data/lib/whatsapp_sdk/resource/template.rb +64 -0
  33. data/lib/whatsapp_sdk/version.rb +1 -1
  34. data/whatsapp_sdk.gemspec +8 -8
  35. metadata +22 -15
  36. data/lib/whatsapp_sdk/resource/error.rb +0 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d6eccb61d3c648fa1c8a2a7e56512c1887b1aad9eb99f2569927f810b1754f8
4
- data.tar.gz: 5cada724227ef568c36ec56a2a206752e170946e8890acefe504b24f821e9ab6
3
+ metadata.gz: fa0d6e4b9794168087c75aab57f48d377184850652b7cf7b9ffee57879a38c82
4
+ data.tar.gz: 25fc304e0f05d91b00897dc8c30b27040da480b78de38f3ec277119c610cdc7c
5
5
  SHA512:
6
- metadata.gz: d9b534bc13fb8fad31fc31245417cf508537c4edd851b1d9cc6e546f50fbede19dd8bccbbe636194f49c1a40bbe721307b2dd8c1f0c4ea21cdc8ec643423d2db
7
- data.tar.gz: 5f99f8a13ce068bd9667a719c7cdebcc87de874fb8b0cc7b06f6b0e1c857d888241ea6188ac6c9c9155a4184059effaade3c6255969a59b4a72cfa17d3c7abfc
6
+ metadata.gz: 2105c7f9a2a777dce4e486c3e8a1eef8e65b0888e06bd4f01d11822532e7162a5183c07606e96af4aa8ffdfd0c14a10a52b23cffd4a51f869aa9e8435ce0a210
7
+ data.tar.gz: 655c3432bf4088c9a408b297761e18a996beffda0ff72fc3516fb6988bbd024f0239b0b89cbf351ee30972375f6c1f5f181c4b45eeae9c973592e93766f78ae6
data/CHANGELOG.md CHANGED
@@ -1,4 +1,14 @@
1
- # Unreleased
1
+ # Unreleased
2
+
3
+ # v 0.10.0
4
+ - Implement Templates API @emersonu, @ignacio-chiazzo [#90](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/90)
5
+ - Using compatible Gem versions instead of fixed dependency versions @nbluis [#108](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/108)
6
+ - [Breaking Change] Rename `error` module with `errors`. @ignacio-chiazzo [#101](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/101)
7
+
8
+ If you are calling an error using `WhatsappSdk::Resource::Error`, you should update it to `WhatsappSdk::Resource::Errors`, e.g. `WhatsappSdk::Resource::Errors::MissingArgumentError`
9
+
10
+ # v 0.9.2
11
+ - Add Support to image/webp sticker media. @renatovico [#94](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/issues/94)
2
12
 
3
13
  # v 0.9.1
4
14
  - Invalidate unsupported and invalid media types @ignacio-chiazzo [#89](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/89)
data/Gemfile CHANGED
@@ -5,12 +5,6 @@ source "https://rubygems.org"
5
5
 
6
6
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
7
7
 
8
- gem("faraday")
9
- gem("faraday-multipart")
10
- gem("rake", ">= 12.3.3")
11
- gem('sorbet-runtime')
12
- gem("zeitwerk", ">= 2.6.0")
13
-
14
8
  group(:test) do
15
9
  gem('mocha')
16
10
  gem('rubocop', require: false)
data/Gemfile.lock CHANGED
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- whatsapp_sdk (0.9.1)
5
- faraday (~> 2.3.0)
6
- faraday-multipart (~> 1.0.4)
7
- sorbet-runtime (~> 0.5.1)
8
- zeitwerk (~> 2.6.0)
4
+ whatsapp_sdk (0.10.0)
5
+ faraday (~> 2)
6
+ faraday-multipart (~> 1)
7
+ sorbet-runtime (~> 0.5)
8
+ zeitwerk (~> 2)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
@@ -13,21 +13,23 @@ GEM
13
13
  addressable (2.8.1)
14
14
  public_suffix (>= 2.0.2, < 6.0)
15
15
  ast (2.4.2)
16
+ base64 (0.2.0)
16
17
  coderay (1.1.3)
17
18
  crack (0.4.5)
18
19
  rexml
19
20
  diff-lcs (1.5.0)
20
- faraday (2.3.0)
21
- faraday-net_http (~> 2.0)
21
+ faraday (2.7.12)
22
+ base64
23
+ faraday-net_http (>= 2.0, < 3.1)
22
24
  ruby2_keywords (>= 0.0.4)
23
25
  faraday-multipart (1.0.4)
24
26
  multipart-post (~> 2)
25
- faraday-net_http (2.1.0)
27
+ faraday-net_http (3.0.2)
26
28
  hashdiff (1.0.1)
27
29
  method_source (1.0.0)
28
30
  minitest (5.16.1)
29
31
  mocha (1.14.0)
30
- multipart-post (2.2.3)
32
+ multipart-post (2.3.0)
31
33
  netrc (0.11.0)
32
34
  parallel (1.22.1)
33
35
  parser (3.1.2.0)
@@ -39,7 +41,7 @@ GEM
39
41
  pry (>= 0.9.10, < 0.15)
40
42
  public_suffix (5.0.0)
41
43
  rainbow (3.1.1)
42
- rake (13.0.6)
44
+ rake (12.3.3)
43
45
  rbi (0.0.15)
44
46
  ast
45
47
  parser (>= 2.6.4.0)
@@ -70,6 +72,7 @@ GEM
70
72
  sorbet (0.5.10346)
71
73
  sorbet-static (= 0.5.10346)
72
74
  sorbet-runtime (0.5.10346)
75
+ sorbet-static (0.5.10346-universal-darwin-19)
73
76
  sorbet-static (0.5.10346-universal-darwin-21)
74
77
  sorbet-static (0.5.10346-x86_64-linux)
75
78
  sorbet-static-and-runtime (0.5.10346)
@@ -104,33 +107,30 @@ GEM
104
107
  yard-sorbet (0.7.0)
105
108
  sorbet-runtime (>= 0.5)
106
109
  yard (>= 0.9)
107
- zeitwerk (2.6.0)
110
+ zeitwerk (2.6.12)
108
111
 
109
112
  PLATFORMS
110
113
  arm64-darwin-21
114
+ x86_64-darwin-19
111
115
  x86_64-darwin-21
112
116
  x86_64-linux
113
117
 
114
118
  DEPENDENCIES
115
119
  bundler (~> 2.3)
116
- faraday
117
- faraday-multipart
118
120
  minitest (~> 5.0)
119
121
  mocha
120
122
  pry
121
123
  pry-nav
122
- rake (>= 12.3.3)
124
+ rake (~> 12.3)
123
125
  rubocop
124
126
  rubocop-minitest
125
127
  rubocop-performance
126
128
  rubocop-sorbet
127
129
  sorbet
128
- sorbet-runtime
129
130
  spoom
130
131
  tapioca
131
132
  webmock
132
133
  whatsapp_sdk!
133
- zeitwerk (>= 2.6.0)
134
134
 
135
135
  BUNDLED WITH
136
136
  2.3.22
data/README.md CHANGED
@@ -31,25 +31,26 @@ Or install it yourself as:
31
31
 
32
32
  ## Quick Start
33
33
 
34
- There are three primary resources, `Messages`, `Media` and `PhoneNumbers`. `Messages` allows users to send any kind of message (text, audio, location, video, image, etc.). `Media` allows users to manage media, and `Phone Numbers` enable clients to query the associated phone numbers.
34
+ There are three primary resources, `Messages`, `Media` and `PhoneNumbers`. `Messages` allows users to send any message (text, audio, location, video, image, etc.). `Media` allows users to manage media, and `Phone Numbers` enable clients to query the associated phone numbers.
35
35
 
36
- To use `Messages`, `Media` or `PhoneNumbers`, you need to initialize the `Client` that contains auth information. There are two ways to do it
36
+ To use `Messages`, `Media` or `PhoneNumbers`, you need to initialize the `Client` that contains auth information. There are two ways to do it.
37
37
 
38
- 1) Using an initializer
38
+ 1) Use an initializer
39
39
 
40
40
  ```ruby
41
+ # config/initializers/whatsapp_sdk.rb
41
42
  WhatsappSdk.configure do |config|
42
43
  config.access_token = ACCESS_TOKEN
43
44
  end
44
45
  ```
45
- OR 2) creating a `Client` instance and pass it to the `Messages`, `Medias` or `PhoneNumbers` instance like this:
46
+ OR 2) Create a `Client` instance and pass it to the `Messages`, `Medias` or `PhoneNumbers` instance like this:
46
47
 
47
48
  ```ruby
48
49
  client = WhatsappSdk::Api::Client.new("<ACCESS TOKEN>") # replace this with a valid access token
49
50
  messages_api = WhatsappSdk::Api::Messages.new(client)
50
51
  ```
51
52
 
52
- Each API operation returns a `WhatsappSdk::Api::Response` that contains `data` and `error` and a couple of helpful functions such as `ok?` and `error?`. There are three types of response `WhatsappSdk::Api::MessageDataResponse`, `WhatsappSdk::Api::PhoneNumberDataResponse` and `WhatsappSdk::Api::PhoneNumbersDataResponse`. Each of them contains different attributes.
53
+ Each API operation returns a `WhatsappSdk::Api::Response` that contains `data` and `error` and a couple of helpful functions such as `ok?` and `error?`. There are three types of responses `WhatsappSdk::Api::MessageDataResponse`, `WhatsappSdk::Api::PhoneNumberDataResponse` and `WhatsappSdk::Api::PhoneNumbersDataResponse`. Each of them contains different attributes.
53
54
 
54
55
  ## Set up a Meta app
55
56
 
@@ -123,12 +124,31 @@ messages_api = WhatsappSdk::Api::Messages.new
123
124
  phone_numbers_api = WhatsappSdk::Api::PhoneNumbers.new
124
125
  medias_api = WhatsappSdk::Api::Medias.new
125
126
  business_profile_api = WhatsappSdk::Api::BusinessProfile.new
127
+ templates_api = WhatsappSdk::Api::Templates.new
126
128
  ```
127
129
 
128
130
  Note: Remember to initialize the client first!
129
131
 
130
132
  ## APIs
131
133
 
134
+ ### Templates
135
+ <details>
136
+
137
+ ```ruby
138
+ # Get list of templates
139
+ templates_api.templates(business_id: BUSINESS_ID)
140
+
141
+ # Create a template
142
+ new_template = templates_api.create(
143
+ business_id: BUSINESS_ID, name: "seasonal_promotion", language: "en_US", category: "MARKETING",
144
+ components_json: components_json, allow_category_change: true
145
+ )
146
+
147
+ # Delete a template
148
+ templates_api.delete(business_id: BUSINESS_ID, name: "my_name") # delete by name
149
+ ```
150
+ </details>
151
+
132
152
  ### Business Profile API
133
153
  <details>
134
154
 
@@ -480,17 +500,17 @@ Visit [the example file](/example.rb) with examples to call the API in a single
480
500
 
481
501
  ## Troubleshooting
482
502
 
483
- - If the API response is `success`, but the message is not delivered, ensure the device you're sending the message to is using a supported Whatsapp version. [Check documentation](https://developers.facebook.com/docs/whatsapp/cloud-api/support/troubleshooting#message-not-delivered). Try also replying a message to the number your registered on your Whatsapp.
503
+ - If the API response is `success`, but the message is not delivered, ensure the device you're sending the message to is using a supported Whatsapp version. [Check documentation](https://developers.facebook.com/docs/whatsapp/cloud-api/support/troubleshooting#message-not-delivered). Try also replying a message to the number you are registered on your Whatsapp.
484
504
  - Ensure your Meta App uses an API version greater than or equal to `v.14`.
485
- - Ensure that the Panel in the Facebook dashboard doesn't display any error.
505
+ - Ensure that the Panel in the Facebook dashboard doesn't display any errors.
486
506
 
487
- Note: Sometimes the messages are delayed, see [Meta documentation](https://developers.facebook.com/docs/whatsapp/on-premises/guides/send-message-performance#delays).
507
+ Note: Sometimes the messages are delayed; see [Meta documentation](https://developers.facebook.com/docs/whatsapp/on-premises/guides/send-message-performance#delays).
488
508
 
489
509
  ## Development
490
510
 
491
511
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests.
492
512
 
493
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
513
+ Run ' bundle exec rake install ' to install this gem onto your local machine. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
494
514
 
495
515
  ### Run all the tests
496
516
  - **Unit tests:** Run `rake test`
@@ -506,6 +526,9 @@ Bug reports and pull requests are welcome on GitHub at [https://github.com/ignac
506
526
 
507
527
  If you want a feature to be implemented in the gem, please, open an issue and we will take a look as soon as we can.
508
528
 
529
+
530
+ Do you want to contribute and are unsure where to start? Ping me on Twitter, and I will help you!
531
+
509
532
  ## License
510
533
 
511
534
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/example.rb CHANGED
@@ -48,10 +48,76 @@ def print_message_sent(message_response)
48
48
  end
49
49
  ##################################################
50
50
 
51
+
51
52
  medias_api = WhatsappSdk::Api::Medias.new
52
53
  messages_api = WhatsappSdk::Api::Messages.new
53
54
  phone_numbers_api = WhatsappSdk::Api::PhoneNumbers.new
54
55
  business_profile_api = WhatsappSdk::Api::BusinessProfile.new
56
+ templates_api = WhatsappSdk::Api::Templates.new
57
+
58
+ ############################## Templates API ##############################
59
+
60
+ ## Get list of templates
61
+ templates_api.templates(business_id: BUSINESS_ID)
62
+
63
+ ## Get message templates namespace
64
+ templates_api.get_message_template_namespace(business_id: BUSINESS_ID)
65
+
66
+ # Create a template
67
+ components_json = [
68
+ {
69
+ "type": "BODY",
70
+ "text": "Thank you for your order, {{1}}! Your confirmation number is {{2}}. If you have any questions, please use the buttons below to contact support. Thank you for being a customer!",
71
+ "example": {
72
+ "body_text": [
73
+ [
74
+ "Ignacio","860198-230332"
75
+ ]
76
+ ]
77
+ }
78
+ },
79
+ {
80
+ "type": "BUTTONS",
81
+ "buttons": [
82
+ {
83
+ "type": "PHONE_NUMBER",
84
+ "text": "Call",
85
+ "phone_number": "59898400766"
86
+ },
87
+ {
88
+ "type": "URL",
89
+ "text": "Contact Support",
90
+ "url": "https://www.luckyshrub.com/support"
91
+ }
92
+ ]
93
+ }
94
+ ]
95
+
96
+ new_template = templates_api.create(
97
+ business_id: BUSINESS_ID, name: "seasonal_promotion", language: "ka", category: "MARKETING",
98
+ components_json: components_json, allow_category_change: true
99
+ )
100
+
101
+ # Update a template
102
+ components_json = [
103
+ {
104
+ "type" => "header",
105
+ "parameters" => [
106
+ {
107
+ "type" => "image",
108
+ "image" => {
109
+ "link" => "https://www.google.com/imgres?imgurl=https%3A%2F%2Fqph.cf2.quoracdn.net%2Fmain-qimg-6d977408fdd90a09a1fee7ba9e2f777c-lq&imgrefurl=https%3A%2F%2Fwww.quora.com%2FHow-can-I-find-my-WhatsApp-ID&tbnid=lDAx1vzXwqCakM&vet=12ahUKEwjKupLviJX4AhVrrHIEHQpGD9MQMygAegUIARC9AQ..i&docid=s-DNQVCrZmhJYM&w=602&h=339&q=example%20whatsapp%20image%20id&ved=2ahUKEwjKupLviJX4AhVrrHIEHQpGD9MQMygAegUIARC9AQ"
110
+ }
111
+ }
112
+ ]
113
+ }
114
+ ]
115
+ templates_api.update(template_id: "1624560287967996", category: "UTILITY")
116
+
117
+ ## Delete a template
118
+ templates_api.delete(business_id: BUSINESS_ID, name: "seasonal_promotion") # delete by name
119
+ # templates_api.delete(business_id: BUSINESS_ID, name: "name2", hsm_id: "243213188351928") # delete by name and id
120
+
55
121
  ############################## Business API ##############################
56
122
  business_profile = business_profile_api.details(SENDER_ID)
57
123
  business_profile_api.update(phone_number_id: SENDER_ID, params: { about: "A very cool business" } )
@@ -107,7 +173,7 @@ message_id = message_sent.data.messages.first.id
107
173
  messages_api.send_reaction(sender_id: SENDER_ID, recipient_number: RECIPIENT_NUMBER, message_id: message_id, emoji: "\u{1f550}")
108
174
  messages_api.send_reaction(sender_id: SENDER_ID, recipient_number: RECIPIENT_NUMBER, message_id: message_id, emoji: "⛄️")
109
175
 
110
- ######### Reply to a message
176
+ ######### Reply to a message
111
177
  message_to_reply_id = message_sent.data.messages.first.id
112
178
  reply = messages_api.send_text(sender_id: SENDER_ID, recipient_number: RECIPIENT_NUMBER, message: "I'm a reply", message_id: message_to_reply_id)
113
179
  print_message_sent(reply)
@@ -12,17 +12,17 @@ module WhatsappSdk
12
12
  # Get the details of business profile.
13
13
  #
14
14
  # @param phone_number_id [Integer] Phone Number Id.
15
- # @return [WhatsappSdk::Api::Response] Response object.
16
- sig { params(phone_number_id: Integer).returns(WhatsappSdk::Api::Response) }
15
+ # @return [Api::Response] Response object.
16
+ sig { params(phone_number_id: Integer).returns(Api::Response) }
17
17
  def details(phone_number_id)
18
18
  response = send_request(
19
19
  http_method: "get",
20
20
  endpoint: "#{phone_number_id}/whatsapp_business_profile?fields=#{DEFAULT_FIELDS}"
21
21
  )
22
22
 
23
- WhatsappSdk::Api::Response.new(
23
+ Api::Response.new(
24
24
  response: response,
25
- data_class_type: WhatsappSdk::Api::Responses::BusinessProfileDataResponse
25
+ data_class_type: Api::Responses::BusinessProfileDataResponse
26
26
  )
27
27
  end
28
28
 
@@ -30,11 +30,11 @@ module WhatsappSdk
30
30
  #
31
31
  # @param phone_number_id [Integer] Phone Number Id.
32
32
  # @param params [Hash] Params to update.
33
- # @return [WhatsappSdk::Api::Response] Response object.
33
+ # @return [Api::Response] Response object.
34
34
  sig do
35
35
  params(
36
36
  phone_number_id: Integer, params: T::Hash[T.untyped, T.untyped]
37
- ).returns(WhatsappSdk::Api::Response)
37
+ ).returns(Api::Response)
38
38
  end
39
39
  def update(phone_number_id:, params:)
40
40
  # this is a required field
@@ -46,9 +46,9 @@ module WhatsappSdk
46
46
  params: params
47
47
  )
48
48
 
49
- WhatsappSdk::Api::Response.new(
49
+ Api::Response.new(
50
50
  response: response,
51
- data_class_type: WhatsappSdk::Api::Responses::SuccessResponse
51
+ data_class_type: Api::Responses::SuccessResponse
52
52
  )
53
53
  end
54
54
  end
@@ -46,17 +46,17 @@ module WhatsappSdk
46
46
  # Get Media by ID.
47
47
  #
48
48
  # @param media_id [String] Media Id.
49
- # @return [WhatsappSdk::Api::Response] Response object.
50
- sig { params(media_id: String).returns(WhatsappSdk::Api::Response) }
49
+ # @return [Api::Response] Response object.
50
+ sig { params(media_id: String).returns(Api::Response) }
51
51
  def media(media_id:)
52
52
  response = send_request(
53
53
  http_method: "get",
54
54
  endpoint: "/#{media_id}"
55
55
  )
56
56
 
57
- WhatsappSdk::Api::Response.new(
57
+ Api::Response.new(
58
58
  response: response,
59
- data_class_type: WhatsappSdk::Api::Responses::MediaDataResponse
59
+ data_class_type: Api::Responses::MediaDataResponse
60
60
  )
61
61
  end
62
62
 
@@ -66,8 +66,8 @@ module WhatsappSdk
66
66
  # @param file_path [String] The file_path to download the media e.g. "tmp/downloaded_image.png".
67
67
  # @param media_type [String] The media type e.g. "audio/mp4". See the supported types in the official
68
68
  # documentation https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media#supported-media-types.
69
- # @return [WhatsappSdk::Api::Response] Response object.
70
- sig { params(url: String, file_path: String, media_type: String).returns(WhatsappSdk::Api::Response) }
69
+ # @return [Api::Response] Response object.
70
+ sig { params(url: String, file_path: String, media_type: String).returns(Api::Response) }
71
71
  def download(url:, file_path:, media_type:)
72
72
  raise InvalidMediaTypeError.new(media_type: media_type) unless valid_media_type?(media_type)
73
73
 
@@ -80,10 +80,10 @@ module WhatsappSdk
80
80
  { "error" => true, "status" => response.code }
81
81
  end
82
82
 
83
- WhatsappSdk::Api::Response.new(
83
+ Api::Response.new(
84
84
  response: response,
85
- data_class_type: WhatsappSdk::Api::Responses::SuccessResponse,
86
- error_class_type: WhatsappSdk::Api::Responses::ErrorResponse
85
+ data_class_type: Api::Responses::SuccessResponse,
86
+ error_class_type: Api::Responses::ErrorResponse
87
87
  )
88
88
  end
89
89
 
@@ -93,8 +93,8 @@ module WhatsappSdk
93
93
  # @param type [String] Media type e.g. text/plain, video/3gp, image/jpeg, image/png. For more information,
94
94
  # see the official documentation https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media#supported-media-types.
95
95
  #
96
- # @return [WhatsappSdk::Api::Response] Response object.
97
- sig { params(sender_id: Integer, file_path: String, type: String).returns(WhatsappSdk::Api::Response) }
96
+ # @return [Api::Response] Response object.
97
+ sig { params(sender_id: Integer, file_path: String, type: String).returns(Api::Response) }
98
98
  def upload(sender_id:, file_path:, type:)
99
99
  raise FileNotFoundError.new(file_path: file_path) unless File.file?(file_path)
100
100
 
@@ -106,26 +106,26 @@ module WhatsappSdk
106
106
 
107
107
  response = send_request(http_method: "post", endpoint: "#{sender_id}/media", params: params)
108
108
 
109
- WhatsappSdk::Api::Response.new(
109
+ Api::Response.new(
110
110
  response: response,
111
- data_class_type: WhatsappSdk::Api::Responses::MediaDataResponse
111
+ data_class_type: Api::Responses::MediaDataResponse
112
112
  )
113
113
  end
114
114
 
115
115
  # Delete a Media by ID.
116
116
  #
117
117
  # @param media_id [String] Media Id.
118
- # @return [WhatsappSdk::Api::Response] Response object.
119
- sig { params(media_id: String).returns(WhatsappSdk::Api::Response) }
118
+ # @return [Api::Response] Response object.
119
+ sig { params(media_id: String).returns(Api::Response) }
120
120
  def delete(media_id:)
121
121
  response = send_request(
122
122
  http_method: "delete",
123
123
  endpoint: "/#{media_id}"
124
124
  )
125
125
 
126
- WhatsappSdk::Api::Response.new(
126
+ Api::Response.new(
127
127
  response: response,
128
- data_class_type: WhatsappSdk::Api::Responses::SuccessResponse
128
+ data_class_type: Api::Responses::SuccessResponse
129
129
  )
130
130
  end
131
131
 
@@ -140,7 +140,7 @@ module WhatsappSdk
140
140
  end
141
141
 
142
142
  def valid_media_type?(media_type)
143
- WhatsappSdk::Resource::MediaTypes::SUPPORTED_MEDIA_TYPES.include?(media_type)
143
+ Resource::MediaTypes::SUPPORTED_MEDIA_TYPES.include?(media_type)
144
144
  end
145
145
  end
146
146
  end