whatsapp_sdk 1.1.0 → 2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/Gemfile.lock +9 -8
- data/README.md +192 -0
- data/lib/whatsapp_sdk/api/business_account.rb +15 -0
- data/lib/whatsapp_sdk/api/client.rb +118 -17
- data/lib/whatsapp_sdk/api/flows.rb +95 -0
- data/lib/whatsapp_sdk/api/medias.rb +46 -0
- data/lib/whatsapp_sdk/api/messages.rb +123 -34
- data/lib/whatsapp_sdk/api/phone_numbers.rb +83 -2
- data/lib/whatsapp_sdk/api/request.rb +4 -2
- data/lib/whatsapp_sdk/api/responses/generic_error_response.rb +4 -0
- data/lib/whatsapp_sdk/api/responses/message_data_response.rb +4 -2
- data/lib/whatsapp_sdk/api/templates.rb +9 -2
- data/lib/whatsapp_sdk/configuration.rb +34 -4
- data/lib/whatsapp_sdk/resource/business_account.rb +36 -0
- data/lib/whatsapp_sdk/resource/contact_response.rb +7 -2
- data/lib/whatsapp_sdk/resource/errors.rb +3 -0
- data/lib/whatsapp_sdk/resource/message.rb +5 -1
- data/lib/whatsapp_sdk/resource/parameter_object.rb +4 -0
- data/lib/whatsapp_sdk/resource/template_analytic.rb +18 -0
- data/lib/whatsapp_sdk/version.rb +1 -1
- data/whatsapp_sdk.gemspec +1 -1
- metadata +6 -8
|
@@ -2,11 +2,43 @@
|
|
|
2
2
|
|
|
3
3
|
module WhatsappSdk
|
|
4
4
|
module Resource
|
|
5
|
+
# WhatsApp Business Account fields returned by Graph.
|
|
6
|
+
# Values are retained without conversion; fields omitted from the response are nil.
|
|
5
7
|
class BusinessAccount
|
|
8
|
+
# @!attribute [rw] id
|
|
9
|
+
# @return [String, nil] Business account ID.
|
|
10
|
+
# @!attribute [rw] name
|
|
11
|
+
# @return [String, nil] Business account name.
|
|
12
|
+
# @!attribute [rw] timezone_id
|
|
13
|
+
# @return [String, nil] Graph time zone identifier.
|
|
14
|
+
# @!attribute [rw] message_template_namespace
|
|
15
|
+
# @return [String, nil] Namespace used by the account's message templates.
|
|
16
|
+
# @!attribute [rw] account_review_status
|
|
17
|
+
# @return [String, nil] Account review status.
|
|
18
|
+
# @!attribute [rw] business_verification_status
|
|
19
|
+
# @return [String, nil] Business verification status.
|
|
20
|
+
# @!attribute [rw] country
|
|
21
|
+
# @return [String, nil] Account country code.
|
|
22
|
+
# @!attribute [rw] ownership_type
|
|
23
|
+
# @return [String, nil] Account ownership type.
|
|
24
|
+
# @!attribute [rw] primary_business_location
|
|
25
|
+
# @return [String, nil] Primary business location returned by Graph.
|
|
26
|
+
# @!attribute [rw] analytics
|
|
27
|
+
# @return [Hash, nil] Messaging analytics, when requested and returned.
|
|
28
|
+
# @!attribute [rw] conversation_analytics
|
|
29
|
+
# @return [Hash, nil] Conversation analytics, when requested and returned.
|
|
30
|
+
# @!attribute [rw] pricing_analytics
|
|
31
|
+
# @return [Hash, nil] Pricing analytics, when requested and returned.
|
|
32
|
+
# @!attribute [rw] call_analytics
|
|
33
|
+
# @return [Hash, nil] Call analytics, when requested and returned.
|
|
6
34
|
attr_accessor :id, :name, :timezone_id, :message_template_namespace, :account_review_status,
|
|
7
35
|
:business_verification_status, :country, :ownership_type, :primary_business_location,
|
|
8
36
|
:analytics, :conversation_analytics, :pricing_analytics, :call_analytics
|
|
9
37
|
|
|
38
|
+
# Build an account from a Graph response without converting field values.
|
|
39
|
+
#
|
|
40
|
+
# @param hash [Hash{String => Object}] Account fields keyed by their Graph names.
|
|
41
|
+
# @return [BusinessAccount] Account with nil for any missing fields.
|
|
10
42
|
def self.from_hash(hash)
|
|
11
43
|
business_account = BusinessAccount.new
|
|
12
44
|
business_account.id = hash["id"]
|
|
@@ -26,6 +58,10 @@ module WhatsappSdk
|
|
|
26
58
|
business_account
|
|
27
59
|
end
|
|
28
60
|
|
|
61
|
+
# Compare account details, excluding analytics fields.
|
|
62
|
+
#
|
|
63
|
+
# @param other [Object] Object to compare with this account.
|
|
64
|
+
# @return [Boolean] Whether the other account has the same core fields.
|
|
29
65
|
def ==(other)
|
|
30
66
|
return false unless other.is_a?(WhatsappSdk::Resource::BusinessAccount)
|
|
31
67
|
|
|
@@ -3,11 +3,16 @@
|
|
|
3
3
|
module WhatsappSdk
|
|
4
4
|
module Resource
|
|
5
5
|
class ContactResponse
|
|
6
|
-
|
|
6
|
+
# @!attribute [rw] user_id
|
|
7
|
+
# Business-scoped user ID, populated only when Graph includes contacts[].user_id.
|
|
8
|
+
# May be present alongside wa_id; nil when omitted from the response.
|
|
9
|
+
# @return [String, nil] Business-scoped user ID returned by Graph.
|
|
10
|
+
attr_accessor :wa_id, :input, :user_id
|
|
7
11
|
|
|
8
|
-
def initialize(input:, wa_id:)
|
|
12
|
+
def initialize(input:, wa_id: nil, user_id: nil)
|
|
9
13
|
@input = input
|
|
10
14
|
@wa_id = wa_id
|
|
15
|
+
@user_id = user_id
|
|
11
16
|
end
|
|
12
17
|
end
|
|
13
18
|
end
|
|
@@ -50,9 +50,12 @@ module WhatsappSdk
|
|
|
50
50
|
|
|
51
51
|
class InvalidInteractiveFooter < Error; end
|
|
52
52
|
|
|
53
|
+
# Raised when a template parameter format is neither "named" nor "positional".
|
|
53
54
|
class InvalidParameterFormatError < StandardError
|
|
55
|
+
# @return [Object] Rejected parameter format, retained without conversion.
|
|
54
56
|
attr_reader :format
|
|
55
57
|
|
|
58
|
+
# @param format [Object] Rejected value supplied as the template's parameter_format.
|
|
56
59
|
def initialize(format:)
|
|
57
60
|
@format = format
|
|
58
61
|
|
|
@@ -5,8 +5,12 @@ module WhatsappSdk
|
|
|
5
5
|
class Message
|
|
6
6
|
attr_reader :id
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
# @return [String, nil] Message acceptance/pacing status, only when returned by Meta.
|
|
9
|
+
attr_reader :message_status
|
|
10
|
+
|
|
11
|
+
def initialize(id:, message_status: nil)
|
|
9
12
|
@id = id
|
|
13
|
+
@message_status = message_status
|
|
10
14
|
end
|
|
11
15
|
end
|
|
12
16
|
end
|
|
@@ -51,6 +51,10 @@ module WhatsappSdk
|
|
|
51
51
|
POSITIONAL
|
|
52
52
|
].freeze
|
|
53
53
|
|
|
54
|
+
# Check whether a template parameter format is supported.
|
|
55
|
+
#
|
|
56
|
+
# @param format [Object] Value to check against the supported string formats.
|
|
57
|
+
# @return [Boolean] Whether format is exactly "named" or "positional".
|
|
54
58
|
def self.valid?(format)
|
|
55
59
|
FORMATS.include?(format)
|
|
56
60
|
end
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
module WhatsappSdk
|
|
4
4
|
module Resource
|
|
5
|
+
# Template analytics for one aggregation interval and product type.
|
|
6
|
+
# Metric data points are retained as raw Graph hashes without conversion.
|
|
5
7
|
class TemplateAnalytic
|
|
6
8
|
module Granularity
|
|
7
9
|
DAILY = "DAILY"
|
|
@@ -34,14 +36,30 @@ module WhatsappSdk
|
|
|
34
36
|
end
|
|
35
37
|
end
|
|
36
38
|
|
|
39
|
+
# @!attribute [rw] granularity
|
|
40
|
+
# @return [String, nil] Aggregation interval, such as DAILY.
|
|
41
|
+
# @!attribute [rw] product_type
|
|
42
|
+
# @return [String, nil] Messaging product, such as cloud_api.
|
|
43
|
+
# @!attribute [rw] data_points
|
|
44
|
+
# @return [Array<Hash>, nil] Raw per-template metrics and time ranges.
|
|
37
45
|
attr_accessor :granularity, :product_type, :data_points
|
|
38
46
|
|
|
47
|
+
# Construct an analytics record without validating or converting its fields.
|
|
48
|
+
#
|
|
49
|
+
# @param granularity [String, nil] Aggregation interval returned by Graph.
|
|
50
|
+
# @param product_type [String, nil] Messaging product returned by Graph.
|
|
51
|
+
# @param data_points [Array<Hash>, nil] Raw per-template metrics and time ranges.
|
|
52
|
+
# @return [TemplateAnalytic] Analytics record containing the supplied values.
|
|
39
53
|
def initialize(granularity:, product_type:, data_points:)
|
|
40
54
|
@granularity = granularity
|
|
41
55
|
@product_type = product_type
|
|
42
56
|
@data_points = data_points
|
|
43
57
|
end
|
|
44
58
|
|
|
59
|
+
# Build an analytics record from a Graph response.
|
|
60
|
+
#
|
|
61
|
+
# @param hash [Hash{String => Object}] Analytics fields keyed by their Graph names.
|
|
62
|
+
# @return [TemplateAnalytic] Analytics record with nil for any missing fields.
|
|
45
63
|
def self.from_hash(hash)
|
|
46
64
|
new(
|
|
47
65
|
granularity: hash["granularity"],
|
data/lib/whatsapp_sdk/version.rb
CHANGED
data/whatsapp_sdk.gemspec
CHANGED
|
@@ -42,7 +42,7 @@ Gem::Specification.new do |spec|
|
|
|
42
42
|
|
|
43
43
|
spec.add_development_dependency("bundler", "~> 2.3")
|
|
44
44
|
spec.add_development_dependency("minitest", "~> 5.0")
|
|
45
|
-
spec.add_development_dependency("rake", "~>
|
|
45
|
+
spec.add_development_dependency("rake", "~> 13.0")
|
|
46
46
|
|
|
47
47
|
spec.add_dependency("faraday", "~> 2.0", "> 2.0.1")
|
|
48
48
|
spec.add_dependency("faraday-multipart", "~> 1")
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: whatsapp_sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ignacio-chiazzo
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: bundler
|
|
@@ -44,14 +43,14 @@ dependencies:
|
|
|
44
43
|
requirements:
|
|
45
44
|
- - "~>"
|
|
46
45
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
46
|
+
version: '13.0'
|
|
48
47
|
type: :development
|
|
49
48
|
prerelease: false
|
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
50
|
requirements:
|
|
52
51
|
- - "~>"
|
|
53
52
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
53
|
+
version: '13.0'
|
|
55
54
|
- !ruby/object:Gem::Dependency
|
|
56
55
|
name: faraday
|
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -137,6 +136,7 @@ files:
|
|
|
137
136
|
- lib/whatsapp_sdk/api/business_account.rb
|
|
138
137
|
- lib/whatsapp_sdk/api/business_profile.rb
|
|
139
138
|
- lib/whatsapp_sdk/api/client.rb
|
|
139
|
+
- lib/whatsapp_sdk/api/flows.rb
|
|
140
140
|
- lib/whatsapp_sdk/api/medias.rb
|
|
141
141
|
- lib/whatsapp_sdk/api/messages.rb
|
|
142
142
|
- lib/whatsapp_sdk/api/phone_numbers.rb
|
|
@@ -196,7 +196,6 @@ metadata:
|
|
|
196
196
|
source_code_uri: https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk
|
|
197
197
|
changelog_uri: https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/blob/main/CHANGELOG.md
|
|
198
198
|
rubygems_mfa_required: 'true'
|
|
199
|
-
post_install_message:
|
|
200
199
|
rdoc_options: []
|
|
201
200
|
require_paths:
|
|
202
201
|
- lib
|
|
@@ -211,8 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
211
210
|
- !ruby/object:Gem::Version
|
|
212
211
|
version: '0'
|
|
213
212
|
requirements: []
|
|
214
|
-
rubygems_version:
|
|
215
|
-
signing_key:
|
|
213
|
+
rubygems_version: 4.0.20
|
|
216
214
|
specification_version: 4
|
|
217
215
|
summary: Use the Ruby Whatsapp SDK to communicate with Whatsapp API using the Cloud
|
|
218
216
|
API
|