whatsapp_sdk 0.13.0 → 1.0.1

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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/.cursorrules +53 -0
  3. data/CHANGELOG.md +10 -0
  4. data/Gemfile +1 -0
  5. data/Gemfile.lock +21 -11
  6. data/README.md +115 -170
  7. data/example.rb +197 -113
  8. data/lib/whatsapp_sdk/api/business_profile.rb +12 -14
  9. data/lib/whatsapp_sdk/api/client.rb +26 -2
  10. data/lib/whatsapp_sdk/api/medias.rb +23 -31
  11. data/lib/whatsapp_sdk/api/messages.rb +24 -61
  12. data/lib/whatsapp_sdk/api/phone_numbers.rb +32 -22
  13. data/lib/whatsapp_sdk/api/request.rb +2 -0
  14. data/lib/whatsapp_sdk/api/responses/generic_error_response.rb +4 -4
  15. data/lib/whatsapp_sdk/api/responses/http_response_error.rb +18 -0
  16. data/lib/whatsapp_sdk/api/responses/{message_error_response.rb → id_response.rb} +6 -3
  17. data/lib/whatsapp_sdk/api/responses/message_data_response.rb +17 -20
  18. data/lib/whatsapp_sdk/api/responses/pagination_records.rb +17 -0
  19. data/lib/whatsapp_sdk/api/responses/success_response.rb +3 -16
  20. data/lib/whatsapp_sdk/api/templates.rb +27 -36
  21. data/lib/whatsapp_sdk/resource/business_profile.rb +28 -0
  22. data/lib/whatsapp_sdk/resource/errors.rb +2 -0
  23. data/lib/whatsapp_sdk/resource/media.rb +18 -68
  24. data/lib/whatsapp_sdk/resource/media_component.rb +89 -0
  25. data/lib/whatsapp_sdk/resource/message_template_namespace.rb +17 -0
  26. data/lib/whatsapp_sdk/resource/phone_number.rb +41 -11
  27. data/lib/whatsapp_sdk/resource/phone_number_component.rb +25 -0
  28. data/lib/whatsapp_sdk/resource/template.rb +20 -0
  29. data/lib/whatsapp_sdk/version.rb +1 -1
  30. data/whatsapp_sdk.gemspec +2 -2
  31. metadata +18 -17
  32. data/lib/whatsapp_sdk/api/response.rb +0 -32
  33. data/lib/whatsapp_sdk/api/responses/business_profile_data_response.rb +0 -33
  34. data/lib/whatsapp_sdk/api/responses/data_response.rb +0 -17
  35. data/lib/whatsapp_sdk/api/responses/error_response.rb +0 -25
  36. data/lib/whatsapp_sdk/api/responses/media_data_response.rb +0 -30
  37. data/lib/whatsapp_sdk/api/responses/message_template_namespace_data_response.rb +0 -27
  38. data/lib/whatsapp_sdk/api/responses/phone_number_data_response.rb +0 -42
  39. data/lib/whatsapp_sdk/api/responses/phone_numbers_data_response.rb +0 -32
  40. data/lib/whatsapp_sdk/api/responses/read_message_data_response.rb +0 -29
  41. data/lib/whatsapp_sdk/api/responses/template_data_response.rb +0 -46
  42. data/lib/whatsapp_sdk/api/responses/templates_data_response.rb +0 -32
@@ -1,12 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "request"
4
- require_relative "response"
5
- require_relative 'responses/success_response'
6
- require_relative 'responses/message_template_namespace_data_response'
7
- require_relative 'responses/generic_error_response'
8
- require_relative 'responses/template_data_response'
9
- require_relative 'responses/templates_data_response'
10
4
  require_relative "../resource/languages"
11
5
 
12
6
  module WhatsappSdk
@@ -36,7 +30,7 @@ module WhatsappSdk
36
30
  # @param allow_category_change [Boolean] Optional Allow category change.
37
31
  # Set to true to allow us to assign a category based on the template guidelines and the template's contents.
38
32
  # This can prevent your template from being rejected for miscategorization.
39
- # @return [Response] Response object.
33
+ # @return [Template] Template object.
40
34
  def create(
41
35
  business_id:, name:, category:, language:, components_json: nil, allow_category_change: nil
42
36
  )
@@ -63,19 +57,15 @@ module WhatsappSdk
63
57
  headers: DEFAULT_HEADERS
64
58
  )
65
59
 
66
- Response.new(
67
- response: response,
68
- data_class_type: Responses::TemplateDataResponse,
69
- error_class_type: Responses::GenericErrorResponse
70
- )
60
+ Resource::Template.from_hash(response)
71
61
  end
72
62
 
73
63
  # Get templates
74
64
  #
75
65
  # @param business_id [Integer] The business ID.
76
66
  # @param limit [Integer] Optional. Number of templates to return in a single page.
77
- # @return [Response] Response object.
78
- def templates(business_id:, limit: 100)
67
+ # @return [Template] Pagination Record containing an array of Template objects.
68
+ def list(business_id:, limit: 100)
79
69
  params = {}
80
70
  params["limit"] = limit if limit
81
71
 
@@ -85,18 +75,23 @@ module WhatsappSdk
85
75
  params: params
86
76
  )
87
77
 
88
- Response.new(
89
- response: response,
90
- data_class_type: Responses::TemplatesDataResponse,
91
- error_class_type: Responses::GenericErrorResponse
78
+ Api::Responses::PaginationRecords.new(
79
+ records: parse_templates(response['data']),
80
+ before: response['paging']['cursors']['before'],
81
+ after: response['paging']['cursors']['after']
92
82
  )
93
83
  end
94
84
 
85
+ def templates(business_id:)
86
+ warn "[DEPRECATION] `templates` is deprecated. Please use `list` instead."
87
+ list(business_id: business_id)
88
+ end
89
+
95
90
  # Get Message Template Namespace
96
91
  # The message template namespace is required to send messages using the message templates.
97
92
  #
98
93
  # @param business_id [Integer] The business ID.
99
- # @return [Response] Response object.
94
+ # @return [MessageTemplateNamespace] MessageTemplateNamespace object.
100
95
  def get_message_template_namespace(business_id:)
101
96
  response = send_request(
102
97
  endpoint: business_id.to_s,
@@ -104,11 +99,7 @@ module WhatsappSdk
104
99
  params: { "fields" => "message_template_namespace" }
105
100
  )
106
101
 
107
- Response.new(
108
- response: response,
109
- data_class_type: Responses::MessageTemplateNamespaceDataResponse,
110
- error_class_type: Responses::GenericErrorResponse
111
- )
102
+ WhatsappSdk::Resource::MessageTemplateNamespace.from_hash(response)
112
103
  end
113
104
 
114
105
  # Edit Template
@@ -120,7 +111,7 @@ module WhatsappSdk
120
111
  #
121
112
  # @param id [String] Required. The message_template-id.
122
113
  # @param components_json [Json] Components that make up the template..
123
- # return [Response] Response object.
114
+ # @return [Boolean] Whether the update was successful.
124
115
  def update(template_id:, category: nil, components_json: nil)
125
116
  if category && !WhatsappSdk::Resource::Template::Category.valid?(category)
126
117
  raise InvalidCategoryError.new(category: category)
@@ -137,11 +128,7 @@ module WhatsappSdk
137
128
  headers: { "Content-Type" => "application/json" }
138
129
  )
139
130
 
140
- Response.new(
141
- response: response,
142
- data_class_type: Responses::SuccessResponse,
143
- error_class_type: Responses::GenericErrorResponse
144
- )
131
+ Api::Responses::SuccessResponse.success_response?(response: response)
145
132
  end
146
133
 
147
134
  # Delete Template
@@ -155,7 +142,7 @@ module WhatsappSdk
155
142
  # @param name [String] Required. The template's name.
156
143
  # @param hsm_id [String] Optional. The template's id.
157
144
  #
158
- # @return [Response] Response object.
145
+ # @return [Boolean] Whether the deletion was successful.
159
146
  def delete(business_id:, name:, hsm_id: nil)
160
147
  params = { name: name }
161
148
  params[:hsm_id] = hsm_id if hsm_id
@@ -166,11 +153,15 @@ module WhatsappSdk
166
153
  params: params
167
154
  )
168
155
 
169
- Response.new(
170
- response: response,
171
- data_class_type: Responses::SuccessResponse,
172
- error_class_type: Responses::GenericErrorResponse
173
- )
156
+ Api::Responses::SuccessResponse.success_response?(response: response)
157
+ end
158
+
159
+ private
160
+
161
+ def parse_templates(templates_data)
162
+ templates_data.map do |template|
163
+ Resource::Template.from_hash(template)
164
+ end
174
165
  end
175
166
  end
176
167
  end
@@ -7,6 +7,34 @@ module WhatsappSdk
7
7
  UNDEFINED OTHER AUTO BEAUTY APPAREL EDU ENTERTAIN EVENT_PLAN FINANCE GROCERY
8
8
  GOVT HOTEL HEALTH NONPROFIT PROF_SERVICES RETAIL TRAVEL RESTAURANT NOT_A_BIZ
9
9
  ].freeze
10
+
11
+ attr_accessor :about, :address, :description, :email, :messaging_product,
12
+ :profile_picture_url, :vertical, :websites
13
+
14
+ def self.from_hash(hash)
15
+ business_profile = BusinessProfile.new
16
+ business_profile.about = hash["about"]
17
+ business_profile.address = hash["address"]
18
+ business_profile.description = hash["description"]
19
+ business_profile.email = hash["email"]
20
+ business_profile.messaging_product = hash["messaging_product"]
21
+ business_profile.profile_picture_url = hash["profile_picture_url"]
22
+ business_profile.vertical = hash["vertical"]
23
+ business_profile.websites = hash["websites"]
24
+
25
+ business_profile
26
+ end
27
+
28
+ def ==(other)
29
+ about == other.about &&
30
+ address == other.address &&
31
+ description == other.description &&
32
+ email == other.email &&
33
+ messaging_product == other.messaging_product &&
34
+ profile_picture_url == other.profile_picture_url &&
35
+ vertical == other.vertical &&
36
+ websites == other.websites
37
+ end
10
38
  end
11
39
  end
12
40
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "../error"
4
+
3
5
  module WhatsappSdk
4
6
  module Resource
5
7
  module Errors
@@ -3,21 +3,6 @@
3
3
  module WhatsappSdk
4
4
  module Resource
5
5
  class Media
6
- class InvalidMedia < StandardError
7
- attr_reader :field, :message
8
-
9
- def initialize(field, message)
10
- @field = field
11
- @message = message
12
- super(message)
13
- end
14
- end
15
-
16
- # Returns media id.
17
- #
18
- # @returns id [String].
19
- attr_accessor :id
20
-
21
6
  module Type
22
7
  AUDIO = 'audio'
23
8
  DOCUMENT = 'document'
@@ -26,61 +11,26 @@ module WhatsappSdk
26
11
  STICKER = 'sticker'
27
12
  end
28
13
 
29
- # @returns type [String]. Valid options ar audio, document, image, video and sticker.
30
- attr_accessor :type
31
-
32
- # The protocol and URL of the media to be sent. Use only with HTTP/HTTPS URLs.
33
- # Do not use this field when the message type is set to text.
34
- #
35
- # @returns link [String].
36
- attr_accessor :link
37
-
38
- # Describes the specified document or image media.
39
- #
40
- # @returns caption [String].
41
- attr_accessor :caption
42
-
43
- # Describes the filename for the specific document. Use only with document media.
44
- #
45
- # @returns filename [String].
46
- attr_accessor :filename
47
-
48
- def initialize(type:, id: nil, link: nil, caption: nil, filename: nil)
49
- @type = type
50
- @id = id
51
- @link = link
52
- @caption = caption
53
- @filename = filename
54
- validate_media
55
- end
56
-
57
- def to_json
58
- json = {}
59
- json[:id] = id unless id.nil?
60
- json[:link] = link unless link.nil?
61
- json[:caption] = caption unless caption.nil?
62
- json[:filename] = filename unless filename.nil?
63
- json
64
- end
65
-
66
- private
67
-
68
- def validate_media
69
- raise InvalidMedia.new(:filename, "filename can only be used with document") if filename && !supports_filename?
70
-
71
- if caption && !supports_caption?
72
- raise InvalidMedia.new(:caption, "caption can only be used with document or image")
73
- end
74
-
75
- true
76
- end
77
-
78
- def supports_filename?
79
- type == Type::DOCUMENT
14
+ attr_accessor :file_size, :id, :messaging_product, :mime_type, :sha256, :url
15
+
16
+ def self.from_hash(hash)
17
+ media = new
18
+ media.id = hash["id"]
19
+ media.file_size = hash["file_size"]
20
+ media.messaging_product = hash["messaging_product"]
21
+ media.mime_type = hash["mime_type"]
22
+ media.sha256 = hash["sha256"]
23
+ media.url = hash["url"]
24
+ media
80
25
  end
81
26
 
82
- def supports_caption?
83
- type == Type::DOCUMENT || type == Type::IMAGE
27
+ def ==(other)
28
+ id == other.id &&
29
+ file_size == other.file_size &&
30
+ messaging_product == other.messaging_product &&
31
+ mime_type == other.mime_type &&
32
+ sha256 == other.sha256 &&
33
+ url == other.url
84
34
  end
85
35
  end
86
36
  end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The media used by a component (button, header, body, footer) etc.
4
+
5
+ module WhatsappSdk
6
+ module Resource
7
+ class MediaComponent
8
+ class InvalidMedia < StandardError
9
+ attr_reader :field, :message
10
+
11
+ def initialize(field, message)
12
+ @field = field
13
+ @message = message
14
+ super(message)
15
+ end
16
+ end
17
+
18
+ # Returns media id.
19
+ #
20
+ # @returns id [String].
21
+ attr_accessor :id
22
+
23
+ module Type
24
+ AUDIO = 'audio'
25
+ DOCUMENT = 'document'
26
+ IMAGE = 'image'
27
+ VIDEO = 'video'
28
+ STICKER = 'sticker'
29
+ end
30
+
31
+ # @returns type [String]. Valid options ar audio, document, image, video and sticker.
32
+ attr_accessor :type
33
+
34
+ # The protocol and URL of the media to be sent. Use only with HTTP/HTTPS URLs.
35
+ # Do not use this field when the message type is set to text.
36
+ #
37
+ # @returns link [String].
38
+ attr_accessor :link
39
+
40
+ # Describes the specified document or image media.
41
+ #
42
+ # @returns caption [String].
43
+ attr_accessor :caption
44
+
45
+ # Describes the filename for the specific document. Use only with document media.
46
+ #
47
+ # @returns filename [String].
48
+ attr_accessor :filename
49
+
50
+ def initialize(type:, id: nil, link: nil, caption: nil, filename: nil)
51
+ @type = type
52
+ @id = id
53
+ @link = link
54
+ @caption = caption
55
+ @filename = filename
56
+ validate_media
57
+ end
58
+
59
+ def to_json
60
+ json = {}
61
+ json[:id] = id unless id.nil?
62
+ json[:link] = link unless link.nil?
63
+ json[:caption] = caption unless caption.nil?
64
+ json[:filename] = filename unless filename.nil?
65
+ json
66
+ end
67
+
68
+ private
69
+
70
+ def validate_media
71
+ raise InvalidMedia.new(:filename, "filename can only be used with document") if filename && !supports_filename?
72
+
73
+ if caption && !supports_caption?
74
+ raise InvalidMedia.new(:caption, "caption can only be used with document or image")
75
+ end
76
+
77
+ true
78
+ end
79
+
80
+ def supports_filename?
81
+ type == Type::DOCUMENT
82
+ end
83
+
84
+ def supports_caption?
85
+ type == Type::DOCUMENT || type == Type::IMAGE
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WhatsappSdk
4
+ module Resource
5
+ class MessageTemplateNamespace
6
+ attr_accessor :id, :message_template_namespace
7
+
8
+ def self.from_hash(hash)
9
+ message_template_namespace = new
10
+ message_template_namespace.id = hash["id"]
11
+ message_template_namespace.message_template_namespace = hash["message_template_namespace"]
12
+
13
+ message_template_namespace
14
+ end
15
+ end
16
+ end
17
+ end
@@ -3,21 +3,51 @@
3
3
  module WhatsappSdk
4
4
  module Resource
5
5
  class PhoneNumber
6
- attr_accessor :phone, :wa_id, :type
6
+ attr_accessor :id, :verified_name, :display_phone_number, :quality_rating, :is_pin_enabled,
7
+ :is_official_business_account, :account_mode, :certificate, :code_verification_status,
8
+ :eligibility_for_api_business_global_search, :name_status, :new_name_status, :status,
9
+ :search_visibility, :messaging_limit_tier # , :phone, :wa_id, :type
7
10
 
8
- def initialize(phone:, type:, wa_id:)
9
- @phone = phone
10
- @type = type
11
- @wa_id = wa_id
11
+ def self.from_hash(hash)
12
+ phone_number = PhoneNumber.new
13
+ phone_number.id = hash["id"]
14
+ phone_number.verified_name = hash["verified_name"]
15
+ phone_number.display_phone_number = hash["display_phone_number"]
16
+ phone_number.quality_rating = hash["quality_rating"]
17
+ phone_number.is_pin_enabled = hash["is_pin_enabled"]
18
+ phone_number.is_official_business_account = hash["is_official_business_account"]
19
+ phone_number.account_mode = hash["account_mode"]
20
+ phone_number.certificate = hash["certificate"]
21
+ phone_number.code_verification_status = hash["code_verification_status"]
22
+ phone_number.eligibility_for_api_business_global_search = hash["eligibility_for_api_business_global_search"]
23
+ phone_number.name_status = hash["name_status"]
24
+ phone_number.new_name_status = hash["new_name_status"]
25
+ phone_number.status = hash["status"]
26
+ phone_number.search_visibility = hash["search_visibility"]
27
+ phone_number.messaging_limit_tier = hash["messaging_limit_tier"]
28
+
29
+ phone_number
12
30
  end
13
31
 
14
- def to_h
15
- {
16
- phone: @phone,
17
- type: @type,
18
- wa_id: @wa_id
19
- }
32
+ # rubocop:disable Metrics/PerceivedComplexity
33
+ def ==(other)
34
+ id == other.id &&
35
+ verified_name == other.verified_name &&
36
+ display_phone_number == other.display_phone_number &&
37
+ quality_rating == other.quality_rating &&
38
+ is_pin_enabled == other.is_pin_enabled &&
39
+ is_official_business_account == other.is_official_business_account &&
40
+ account_mode == other.account_mode &&
41
+ certificate == other.certificate &&
42
+ code_verification_status == other.code_verification_status &&
43
+ eligibility_for_api_business_global_search == other.eligibility_for_api_business_global_search &&
44
+ name_status == other.name_status &&
45
+ new_name_status == other.new_name_status &&
46
+ status == other.status &&
47
+ search_visibility == other.search_visibility &&
48
+ messaging_limit_tier == other.messaging_limit_tier
20
49
  end
50
+ # rubocop:enable Metrics/PerceivedComplexity
21
51
  end
22
52
  end
23
53
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The media used by a component (button, header, body, footer) etc.
4
+
5
+ module WhatsappSdk
6
+ module Resource
7
+ class PhoneNumberComponent
8
+ attr_accessor :phone, :wa_id, :type
9
+
10
+ def initialize(phone:, type:, wa_id:)
11
+ @phone = phone
12
+ @type = type
13
+ @wa_id = wa_id
14
+ end
15
+
16
+ def to_h
17
+ {
18
+ phone: @phone,
19
+ type: @type,
20
+ wa_id: @wa_id
21
+ }
22
+ end
23
+ end
24
+ end
25
+ end
@@ -46,6 +46,26 @@ module WhatsappSdk
46
46
  @name = name
47
47
  @components_json = components_json
48
48
  end
49
+
50
+ def self.from_hash(hash)
51
+ new(
52
+ id: hash["id"],
53
+ status: hash["status"],
54
+ category: hash["category"],
55
+ language: hash["language"],
56
+ name: hash["name"],
57
+ components_json: hash["components"]
58
+ )
59
+ end
60
+
61
+ def ==(other)
62
+ id == other.id &&
63
+ status == other.status &&
64
+ category == other.category &&
65
+ language == other.language &&
66
+ name == other.name &&
67
+ components_json == other.components_json
68
+ end
49
69
  end
50
70
  end
51
71
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WhatsappSdk
4
- VERSION = "0.13.0"
4
+ VERSION = "1.0.1"
5
5
  end
data/whatsapp_sdk.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  DESCRIPTION
19
19
  spec.homepage = "https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk"
20
20
  spec.license = "MIT"
21
- spec.required_ruby_version = '>= 1.8.6'
21
+ spec.required_ruby_version = '>= 2.7.0'
22
22
 
23
23
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
24
24
  # to allow pushing to a single host or delete this section to allow pushing to any host.
@@ -44,7 +44,7 @@ Gem::Specification.new do |spec|
44
44
  spec.add_development_dependency("minitest", "~> 5.0")
45
45
  spec.add_development_dependency("rake", "~> 12.3")
46
46
 
47
- spec.add_dependency("faraday", "~> 2")
47
+ spec.add_dependency("faraday", "~> 2.0", "> 2.0.1")
48
48
  spec.add_dependency("faraday-multipart", "~> 1")
49
49
  spec.add_dependency("zeitwerk", "~> 2")
50
50
  spec.metadata['rubygems_mfa_required'] = 'true'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whatsapp_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ignacio-chiazzo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-19 00:00:00.000000000 Z
11
+ date: 2024-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,14 +58,20 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '2'
61
+ version: '2.0'
62
+ - - ">"
63
+ - !ruby/object:Gem::Version
64
+ version: 2.0.1
62
65
  type: :runtime
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
65
68
  requirements:
66
69
  - - "~>"
67
70
  - !ruby/object:Gem::Version
68
- version: '2'
71
+ version: '2.0'
72
+ - - ">"
73
+ - !ruby/object:Gem::Version
74
+ version: 2.0.1
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: faraday-multipart
71
77
  requirement: !ruby/object:Gem::Requirement
@@ -104,6 +110,7 @@ extensions: []
104
110
  extra_rdoc_files: []
105
111
  files:
106
112
  - ".circleci/config.yml"
113
+ - ".cursorrules"
107
114
  - ".github/ISSUE_TEMPLATE/bug_report.md"
108
115
  - ".github/ISSUE_TEMPLATE/feature_request.md"
109
116
  - ".github/workflows/codeql-analysis.yml"
@@ -133,21 +140,12 @@ files:
133
140
  - lib/whatsapp_sdk/api/messages.rb
134
141
  - lib/whatsapp_sdk/api/phone_numbers.rb
135
142
  - lib/whatsapp_sdk/api/request.rb
136
- - lib/whatsapp_sdk/api/response.rb
137
- - lib/whatsapp_sdk/api/responses/business_profile_data_response.rb
138
- - lib/whatsapp_sdk/api/responses/data_response.rb
139
- - lib/whatsapp_sdk/api/responses/error_response.rb
140
143
  - lib/whatsapp_sdk/api/responses/generic_error_response.rb
141
- - lib/whatsapp_sdk/api/responses/media_data_response.rb
144
+ - lib/whatsapp_sdk/api/responses/http_response_error.rb
145
+ - lib/whatsapp_sdk/api/responses/id_response.rb
142
146
  - lib/whatsapp_sdk/api/responses/message_data_response.rb
143
- - lib/whatsapp_sdk/api/responses/message_error_response.rb
144
- - lib/whatsapp_sdk/api/responses/message_template_namespace_data_response.rb
145
- - lib/whatsapp_sdk/api/responses/phone_number_data_response.rb
146
- - lib/whatsapp_sdk/api/responses/phone_numbers_data_response.rb
147
- - lib/whatsapp_sdk/api/responses/read_message_data_response.rb
147
+ - lib/whatsapp_sdk/api/responses/pagination_records.rb
148
148
  - lib/whatsapp_sdk/api/responses/success_response.rb
149
- - lib/whatsapp_sdk/api/responses/template_data_response.rb
150
- - lib/whatsapp_sdk/api/responses/templates_data_response.rb
151
149
  - lib/whatsapp_sdk/api/templates.rb
152
150
  - lib/whatsapp_sdk/configuration.rb
153
151
  - lib/whatsapp_sdk/error.rb
@@ -173,12 +171,15 @@ files:
173
171
  - lib/whatsapp_sdk/resource/languages.rb
174
172
  - lib/whatsapp_sdk/resource/location.rb
175
173
  - lib/whatsapp_sdk/resource/media.rb
174
+ - lib/whatsapp_sdk/resource/media_component.rb
176
175
  - lib/whatsapp_sdk/resource/media_types.rb
177
176
  - lib/whatsapp_sdk/resource/message.rb
177
+ - lib/whatsapp_sdk/resource/message_template_namespace.rb
178
178
  - lib/whatsapp_sdk/resource/name.rb
179
179
  - lib/whatsapp_sdk/resource/org.rb
180
180
  - lib/whatsapp_sdk/resource/parameter_object.rb
181
181
  - lib/whatsapp_sdk/resource/phone_number.rb
182
+ - lib/whatsapp_sdk/resource/phone_number_component.rb
182
183
  - lib/whatsapp_sdk/resource/template.rb
183
184
  - lib/whatsapp_sdk/resource/url.rb
184
185
  - lib/whatsapp_sdk/version.rb
@@ -200,7 +201,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
201
  requirements:
201
202
  - - ">="
202
203
  - !ruby/object:Gem::Version
203
- version: 1.8.6
204
+ version: 2.7.0
204
205
  required_rubygems_version: !ruby/object:Gem::Requirement
205
206
  requirements:
206
207
  - - ">="
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "responses/message_data_response"
4
- require_relative "responses/phone_number_data_response"
5
- require_relative "responses/phone_numbers_data_response"
6
- require_relative "responses/read_message_data_response"
7
- require_relative "responses/message_error_response"
8
- require_relative "responses/business_profile_data_response"
9
-
10
- module WhatsappSdk
11
- module Api
12
- class Response
13
- attr_accessor :error, :data, :raw_response
14
-
15
- def initialize(response:, data_class_type:, error_class_type: Responses::MessageErrorResponse)
16
- @raw_response = response
17
- @data = data_class_type.build_from_response(response: response)
18
- @error = error_class_type.build_from_response(response: response)
19
- end
20
-
21
- # @return [Boolean] Whether or not the response is successful.
22
- def ok?
23
- @error.nil?
24
- end
25
-
26
- # @return [Boolean] Whether or not the response has an error.
27
- def error?
28
- !!@error
29
- end
30
- end
31
- end
32
- end