whatsapp_sdk 0.6.1 → 0.7.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 +10 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +15 -1
- data/README.md +27 -1
- data/example.rb +17 -0
- data/lib/whatsapp_sdk/api/business_profile.rb +56 -0
- data/lib/whatsapp_sdk/api/client.rb +24 -4
- data/lib/whatsapp_sdk/api/messages.rb +58 -10
- data/lib/whatsapp_sdk/api/request.rb +2 -2
- data/lib/whatsapp_sdk/api/response.rb +1 -0
- data/lib/whatsapp_sdk/api/responses/business_profile_data_response.rb +56 -0
- data/lib/whatsapp_sdk/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7cfa077303348e47c90cfcbda06cd977a1ccbd60680cc3dcbdfe609109b4570
|
4
|
+
data.tar.gz: 9a9d46ee397b70538e41f6489f5b0a72fc44054e154164d3fa383cccba5acdfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b08d94c4c773906cac506abb473f46281bfa233a9d56b5d6eaf294dfd53afca2c0cf4f70fb7f4019f6d1581697c43b54ff6556c1c50bfd95854cda54cf682952
|
7
|
+
data.tar.gz: 19ab26c648687e6ef2f7872ce0fa85b259b0fe2a91d6a41e2686d0b6cfe6bd6bf2e1727dd3daa84abd36de8b1d6dc19d1abaaaab7b5046f7af6ad06c80357f85
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
# unreleased
|
2
|
+
|
3
|
+
# v 0.7.0
|
4
|
+
Add message reaction @sanchezpaco [#58](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/58)
|
5
|
+
Add Business update API @sahilbansal17 [#56](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/56)
|
6
|
+
Fix Sorbet bug BusinessAPI [#60](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/60)
|
7
|
+
|
8
|
+
# v 0.6.2
|
9
|
+
Add Business Profiles API @sahilbansal17 [#53](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/53)
|
10
|
+
|
1
11
|
# v 0.6.1
|
2
12
|
Add raw_response to response [#47](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/46)
|
3
13
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
whatsapp_sdk (0.
|
4
|
+
whatsapp_sdk (0.7.0)
|
5
5
|
faraday (>= 2.3.0)
|
6
6
|
faraday-multipart (~> 1.0.4)
|
7
7
|
oj (~> 3.13.13)
|
@@ -12,8 +12,12 @@ PATH
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
+
addressable (2.8.1)
|
16
|
+
public_suffix (>= 2.0.2, < 6.0)
|
15
17
|
ast (2.4.2)
|
16
18
|
coderay (1.1.3)
|
19
|
+
crack (0.4.5)
|
20
|
+
rexml
|
17
21
|
diff-lcs (1.5.0)
|
18
22
|
faraday (2.5.2)
|
19
23
|
faraday-net_http (>= 2.0, < 3.1)
|
@@ -21,6 +25,7 @@ GEM
|
|
21
25
|
faraday-multipart (1.0.4)
|
22
26
|
multipart-post (~> 2)
|
23
27
|
faraday-net_http (3.0.0)
|
28
|
+
hashdiff (1.0.1)
|
24
29
|
method_source (1.0.0)
|
25
30
|
minitest (5.16.1)
|
26
31
|
mocha (1.14.0)
|
@@ -35,6 +40,7 @@ GEM
|
|
35
40
|
method_source (~> 1.0)
|
36
41
|
pry-nav (1.0.0)
|
37
42
|
pry (>= 0.9.10, < 0.15)
|
43
|
+
public_suffix (5.0.0)
|
38
44
|
rainbow (3.1.1)
|
39
45
|
rake (13.0.6)
|
40
46
|
rbi (0.0.15)
|
@@ -66,6 +72,7 @@ GEM
|
|
66
72
|
sorbet-static (= 0.5.10346)
|
67
73
|
sorbet-runtime (0.5.10346)
|
68
74
|
sorbet-static (0.5.10346-universal-darwin-21)
|
75
|
+
sorbet-static (0.5.10346-x86_64-linux)
|
69
76
|
sorbet-static-and-runtime (0.5.10346)
|
70
77
|
sorbet (= 0.5.10346)
|
71
78
|
sorbet-runtime (= 0.5.10346)
|
@@ -88,6 +95,10 @@ GEM
|
|
88
95
|
unparser (0.6.5)
|
89
96
|
diff-lcs (~> 1.3)
|
90
97
|
parser (>= 3.1.0)
|
98
|
+
webmock (3.18.1)
|
99
|
+
addressable (>= 2.8.0)
|
100
|
+
crack (>= 0.3.2)
|
101
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
91
102
|
webrick (1.7.0)
|
92
103
|
yard (0.9.28)
|
93
104
|
webrick (~> 1.7.0)
|
@@ -97,7 +108,9 @@ GEM
|
|
97
108
|
zeitwerk (2.6.0)
|
98
109
|
|
99
110
|
PLATFORMS
|
111
|
+
arm64-darwin-21
|
100
112
|
x86_64-darwin-21
|
113
|
+
x86_64-linux
|
101
114
|
|
102
115
|
DEPENDENCIES
|
103
116
|
bundler (~> 2.3)
|
@@ -116,6 +129,7 @@ DEPENDENCIES
|
|
116
129
|
sorbet-runtime
|
117
130
|
spoom
|
118
131
|
tapioca
|
132
|
+
webmock
|
119
133
|
whatsapp_sdk!
|
120
134
|
zeitwerk (>= 2.6.0)
|
121
135
|
|
data/README.md
CHANGED
@@ -4,11 +4,14 @@
|
|
4
4
|
<a href="https://codeclimate.com/github/ignacio-chiazzo/ruby_whatsapp_sdk/maintainability"><img src="https://api.codeclimate.com/v1/badges/169cce95450272e4ad7d/maintainability" /></a>
|
5
5
|
|
6
6
|
The SDK provides a set of operations and classes to use the Whatsapp API.
|
7
|
-
Send stickers, messages, audio, videos,
|
7
|
+
Send stickers, messages, audio, videos, locations, react to messages or just ask for the phone numbers through this library in a few steps!
|
8
8
|
|
9
9
|
|
10
|
+
## Demo
|
11
|
+
|
10
12
|
https://user-images.githubusercontent.com/11672878/173238826-6fc0a6f8-d0ee-4eae-8947-7dfd3b8b3446.mov
|
11
13
|
|
14
|
+
**Check the [Ruby on Rails Whatsapp example repository](https://github.com/ignacio-chiazzo/ruby_on_rails_whatsapp_example)** that uses this library to send messages.
|
12
15
|
|
13
16
|
## Installation
|
14
17
|
|
@@ -119,12 +122,27 @@ First, create the client and then create an instance `WhatsappSdk::Api::Messages
|
|
119
122
|
messages_api = WhatsappSdk::Api::Messages.new
|
120
123
|
phone_numbers_api = WhatsappSdk::Api::PhoneNumbers.new
|
121
124
|
medias_api = WhatsappSdk::Api::Medias.new
|
125
|
+
business_profile_api = WhatsappSdk::Api::BusinessProfile.new
|
122
126
|
```
|
123
127
|
|
124
128
|
Note: Remember to initialize the client first!
|
125
129
|
|
126
130
|
## APIs
|
127
131
|
|
132
|
+
### Business Profile API
|
133
|
+
<details>
|
134
|
+
|
135
|
+
Get the details of your business
|
136
|
+
```ruby
|
137
|
+
business_profile = business_profile_api.details(123456)
|
138
|
+
```
|
139
|
+
|
140
|
+
Update the details of your business
|
141
|
+
```ruby
|
142
|
+
business_profile_api.update(phone_number_id: SENDER_ID, params: { about: "A very cool business" } )
|
143
|
+
```
|
144
|
+
</details>
|
145
|
+
|
128
146
|
### Phone numbers API
|
129
147
|
|
130
148
|
<details>
|
@@ -181,6 +199,14 @@ messages_api.read_message(sender_id: 1234, message_id: "wamid.HBgLMTM0M123456789
|
|
181
199
|
|
182
200
|
Note: To get the `message_id` you can set up [Webhooks](https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components) that will listen and fire an event when a message is received.
|
183
201
|
|
202
|
+
**Send a reaction to message**
|
203
|
+
To send a reaction to a message, you need to obtain the mssage id and look for the emoji's unicode you want to use.
|
204
|
+
|
205
|
+
```ruby
|
206
|
+
messages_api.send_reaction(sender_id: 123_123, recipient_number: 56_789, message_id: "12345", emoji: "\u{1f550}")
|
207
|
+
|
208
|
+
messages_api.send_reaction(sender_id: 123_123, recipient_number: 56_789, message_id: "12345", emoji: "⛄️")
|
209
|
+
```
|
184
210
|
|
185
211
|
**Send a location message**
|
186
212
|
|
data/example.rb
CHANGED
@@ -28,6 +28,11 @@ RECIPIENT_NUMBER = "<TODO replace>"
|
|
28
28
|
BUSINESS_ID = "<TODO replace>"
|
29
29
|
IMAGE_LINK = "<TODO replace>"
|
30
30
|
|
31
|
+
if ACCESS_TOKEN == "<TODO replace>"
|
32
|
+
puts "\n\n**** Please update the ACCESS_TOKEN constant in this file. ****\n\n"
|
33
|
+
exit
|
34
|
+
end
|
35
|
+
|
31
36
|
################# Initialize Client #################
|
32
37
|
WhatsappSdk.configure do |config|
|
33
38
|
config.access_token = ACCESS_TOKEN
|
@@ -46,10 +51,16 @@ end
|
|
46
51
|
medias_api = WhatsappSdk::Api::Medias.new
|
47
52
|
messages_api = WhatsappSdk::Api::Messages.new
|
48
53
|
phone_numbers_api = WhatsappSdk::Api::PhoneNumbers.new
|
54
|
+
business_profile_api = WhatsappSdk::Api::BusinessProfile.new
|
55
|
+
|
56
|
+
############################## Business API ##############################
|
57
|
+
business_profile = business_profile_api.details(SENDER_ID)
|
58
|
+
business_profile_api.update(phone_number_id: SENDER_ID, params: { about: "A very cool business" } )
|
49
59
|
|
50
60
|
############################## Phone Numbers API ##############################
|
51
61
|
registered_number = phone_numbers_api.registered_number(SENDER_ID)
|
52
62
|
registered_numbers = phone_numbers_api.registered_numbers(BUSINESS_ID)
|
63
|
+
|
53
64
|
############################## Media API ##############################
|
54
65
|
|
55
66
|
# upload a media
|
@@ -76,6 +87,12 @@ message_sent = messages_api.send_text(sender_id: SENDER_ID, recipient_number: RE
|
|
76
87
|
message: "Hey there! it's Whatsapp Ruby SDK")
|
77
88
|
print_message_sent(message_sent)
|
78
89
|
|
90
|
+
######### React to a message
|
91
|
+
message_id = message_sent.data.messages.first.id
|
92
|
+
messages_api.send_reaction(sender_id: SENDER_ID, recipient_number: RECIPIENT_NUMBER, message_id: message_id, emoji: "\u{1f550}")
|
93
|
+
messages_api.send_reaction(sender_id: SENDER_ID, recipient_number: RECIPIENT_NUMBER, message_id: message_id, emoji: "⛄️")
|
94
|
+
|
95
|
+
######### Send location
|
79
96
|
location_sent = messages_api.send_location(
|
80
97
|
sender_id: SENDER_ID, recipient_number: RECIPIENT_NUMBER,
|
81
98
|
longitude: -75.6898604, latitude: 45.4192206, name: "Ignacio", address: "My house"
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# typed: strict
|
3
|
+
|
4
|
+
require_relative "request"
|
5
|
+
require_relative "response"
|
6
|
+
|
7
|
+
module WhatsappSdk
|
8
|
+
module Api
|
9
|
+
class BusinessProfile < Request
|
10
|
+
DEFAULT_FIELDS = 'about,address,description,email,profile_picture_url,websites,vertical'
|
11
|
+
|
12
|
+
# Get the details of business profile.
|
13
|
+
#
|
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) }
|
17
|
+
def details(phone_number_id)
|
18
|
+
response = send_request(
|
19
|
+
http_method: "get",
|
20
|
+
endpoint: "#{phone_number_id}/whatsapp_business_profile?fields=#{DEFAULT_FIELDS}"
|
21
|
+
)
|
22
|
+
|
23
|
+
WhatsappSdk::Api::Response.new(
|
24
|
+
response: response,
|
25
|
+
data_class_type: WhatsappSdk::Api::Responses::BusinessProfileDataResponse
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Update the details of business profile.
|
30
|
+
#
|
31
|
+
# @param phone_number_id [Integer] Phone Number Id.
|
32
|
+
# @param params [Hash] Params to update.
|
33
|
+
# @return [WhatsappSdk::Api::Response] Response object.
|
34
|
+
sig do
|
35
|
+
params(
|
36
|
+
phone_number_id: Integer, params: T::Hash[T.untyped, T.untyped]
|
37
|
+
).returns(WhatsappSdk::Api::Response)
|
38
|
+
end
|
39
|
+
def update(phone_number_id:, params:)
|
40
|
+
# this is a required field
|
41
|
+
params[:messaging_product] = 'whatsapp'
|
42
|
+
|
43
|
+
response = send_request(
|
44
|
+
http_method: "post",
|
45
|
+
endpoint: "#{phone_number_id}/whatsapp_business_profile",
|
46
|
+
params: params
|
47
|
+
)
|
48
|
+
|
49
|
+
WhatsappSdk::Api::Response.new(
|
50
|
+
response: response,
|
51
|
+
data_class_type: WhatsappSdk::Api::Responses::SuccessResponse
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
# typed: strict
|
3
3
|
|
4
4
|
require "faraday"
|
5
|
+
require "faraday/multipart"
|
5
6
|
require "oj"
|
6
7
|
|
7
8
|
module WhatsappSdk
|
@@ -19,13 +20,20 @@ module WhatsappSdk
|
|
19
20
|
|
20
21
|
sig do
|
21
22
|
params(
|
22
|
-
endpoint: String,
|
23
|
-
|
23
|
+
endpoint: String,
|
24
|
+
full_url: T.nilable(String),
|
25
|
+
http_method: String,
|
26
|
+
params: T::Hash[T.untyped, T.untyped],
|
27
|
+
headers: T::Hash[T.untyped, T.untyped]
|
28
|
+
).returns(T.nilable(T::Hash[T.untyped, T.untyped]))
|
24
29
|
end
|
25
|
-
def send_request(endpoint: "", full_url: nil, http_method: "post", params: {})
|
30
|
+
def send_request(endpoint: "", full_url: nil, http_method: "post", params: {}, headers: {})
|
26
31
|
url = full_url || API_CLIENT
|
27
32
|
|
28
|
-
|
33
|
+
faraday_request = T.unsafe(faraday(url))
|
34
|
+
|
35
|
+
response = faraday_request.public_send(http_method, endpoint, request_params(params, headers), headers)
|
36
|
+
|
29
37
|
Oj.load(response.body)
|
30
38
|
end
|
31
39
|
|
@@ -47,6 +55,18 @@ module WhatsappSdk
|
|
47
55
|
|
48
56
|
private
|
49
57
|
|
58
|
+
sig do
|
59
|
+
params(
|
60
|
+
params: T::Hash[T.untyped, T.untyped],
|
61
|
+
headers: T::Hash[T.untyped, T.untyped]
|
62
|
+
).returns(T.any(T::Hash[T.untyped, T.untyped], String))
|
63
|
+
end
|
64
|
+
def request_params(params, headers)
|
65
|
+
return params.to_json if params.is_a?(Hash) && headers['Content-Type'] == 'application/json'
|
66
|
+
|
67
|
+
params
|
68
|
+
end
|
69
|
+
|
50
70
|
sig { params(url: String).returns(Faraday::Connection) }
|
51
71
|
def faraday(url)
|
52
72
|
::Faraday.new(url) do |client|
|
@@ -9,6 +9,8 @@ module WhatsappSdk
|
|
9
9
|
class Messages < Request
|
10
10
|
extend T::Sig
|
11
11
|
|
12
|
+
DEFAULT_HEADERS = T.let({ 'Content-Type' => 'application/json' }, Hash)
|
13
|
+
|
12
14
|
class MissingArgumentError < StandardError
|
13
15
|
extend T::Sig
|
14
16
|
|
@@ -40,7 +42,8 @@ module WhatsappSdk
|
|
40
42
|
|
41
43
|
response = send_request(
|
42
44
|
endpoint: endpoint(sender_id),
|
43
|
-
params: params
|
45
|
+
params: params,
|
46
|
+
headers: DEFAULT_HEADERS
|
44
47
|
)
|
45
48
|
|
46
49
|
WhatsappSdk::Api::Response.new(
|
@@ -80,7 +83,8 @@ module WhatsappSdk
|
|
80
83
|
|
81
84
|
response = send_request(
|
82
85
|
endpoint: endpoint(sender_id),
|
83
|
-
params: params
|
86
|
+
params: params,
|
87
|
+
headers: DEFAULT_HEADERS
|
84
88
|
)
|
85
89
|
|
86
90
|
WhatsappSdk::Api::Response.new(
|
@@ -120,7 +124,8 @@ module WhatsappSdk
|
|
120
124
|
|
121
125
|
response = send_request(
|
122
126
|
endpoint: endpoint(sender_id),
|
123
|
-
params: params
|
127
|
+
params: params,
|
128
|
+
headers: DEFAULT_HEADERS
|
124
129
|
)
|
125
130
|
|
126
131
|
WhatsappSdk::Api::Response.new(
|
@@ -154,7 +159,8 @@ module WhatsappSdk
|
|
154
159
|
|
155
160
|
response = send_request(
|
156
161
|
endpoint: endpoint(sender_id),
|
157
|
-
params: params
|
162
|
+
params: params,
|
163
|
+
headers: DEFAULT_HEADERS
|
158
164
|
)
|
159
165
|
|
160
166
|
WhatsappSdk::Api::Response.new(
|
@@ -194,7 +200,8 @@ module WhatsappSdk
|
|
194
200
|
|
195
201
|
response = send_request(
|
196
202
|
endpoint: endpoint(sender_id),
|
197
|
-
params: params
|
203
|
+
params: params,
|
204
|
+
headers: DEFAULT_HEADERS
|
198
205
|
)
|
199
206
|
|
200
207
|
WhatsappSdk::Api::Response.new(
|
@@ -234,7 +241,8 @@ module WhatsappSdk
|
|
234
241
|
|
235
242
|
response = send_request(
|
236
243
|
endpoint: endpoint(sender_id),
|
237
|
-
params: params
|
244
|
+
params: params,
|
245
|
+
headers: DEFAULT_HEADERS
|
238
246
|
)
|
239
247
|
|
240
248
|
WhatsappSdk::Api::Response.new(
|
@@ -268,7 +276,8 @@ module WhatsappSdk
|
|
268
276
|
|
269
277
|
response = send_request(
|
270
278
|
endpoint: endpoint(sender_id),
|
271
|
-
params: params
|
279
|
+
params: params,
|
280
|
+
headers: DEFAULT_HEADERS
|
272
281
|
)
|
273
282
|
|
274
283
|
WhatsappSdk::Api::Response.new(
|
@@ -302,7 +311,8 @@ module WhatsappSdk
|
|
302
311
|
|
303
312
|
response = send_request(
|
304
313
|
endpoint: endpoint(sender_id),
|
305
|
-
params: params
|
314
|
+
params: params,
|
315
|
+
headers: DEFAULT_HEADERS
|
306
316
|
)
|
307
317
|
|
308
318
|
WhatsappSdk::Api::Response.new(
|
@@ -338,7 +348,8 @@ module WhatsappSdk
|
|
338
348
|
|
339
349
|
response = send_request(
|
340
350
|
endpoint: endpoint(sender_id),
|
341
|
-
params: params
|
351
|
+
params: params,
|
352
|
+
headers: DEFAULT_HEADERS
|
342
353
|
)
|
343
354
|
|
344
355
|
WhatsappSdk::Api::Response.new(
|
@@ -385,7 +396,44 @@ module WhatsappSdk
|
|
385
396
|
|
386
397
|
response = send_request(
|
387
398
|
endpoint: endpoint(sender_id),
|
388
|
-
params: params
|
399
|
+
params: params,
|
400
|
+
headers: DEFAULT_HEADERS
|
401
|
+
)
|
402
|
+
|
403
|
+
WhatsappSdk::Api::Response.new(
|
404
|
+
response: response,
|
405
|
+
data_class_type: WhatsappSdk::Api::Responses::MessageDataResponse
|
406
|
+
)
|
407
|
+
end
|
408
|
+
|
409
|
+
# Send reaction
|
410
|
+
#
|
411
|
+
# @param sender_id [Integer] Sender' phone number.
|
412
|
+
# @param recipient_number [Integer] Recipient' Phone number.
|
413
|
+
# @param message_id [String] the id of the message to reaction.
|
414
|
+
# @param emoji [String] unicode of the emoji to send.
|
415
|
+
# @return [WhatsappSdk::Api::Response] Response object.
|
416
|
+
sig do
|
417
|
+
params(
|
418
|
+
sender_id: Integer, recipient_number: Integer, message_id: String, emoji: T.any(String, Integer)
|
419
|
+
).returns(WhatsappSdk::Api::Response)
|
420
|
+
end
|
421
|
+
def send_reaction(sender_id:, recipient_number:, message_id:, emoji:)
|
422
|
+
params = {
|
423
|
+
messaging_product: "whatsapp",
|
424
|
+
recipient_type: "individual",
|
425
|
+
to: recipient_number,
|
426
|
+
type: "reaction",
|
427
|
+
reaction: {
|
428
|
+
message_id: message_id,
|
429
|
+
emoji: emoji
|
430
|
+
}
|
431
|
+
}
|
432
|
+
|
433
|
+
response = send_request(
|
434
|
+
endpoint: endpoint(sender_id),
|
435
|
+
params: params,
|
436
|
+
headers: DEFAULT_HEADERS
|
389
437
|
)
|
390
438
|
|
391
439
|
WhatsappSdk::Api::Response.new(
|
@@ -14,9 +14,9 @@ module WhatsappSdk
|
|
14
14
|
@client.download_file(url, path_to_file_name)
|
15
15
|
end
|
16
16
|
|
17
|
-
def send_request(endpoint: nil, full_url: nil, http_method: "post", params: {})
|
17
|
+
def send_request(endpoint: nil, full_url: nil, http_method: "post", params: {}, headers: {})
|
18
18
|
@client.send_request(
|
19
|
-
http_method: http_method, full_url: full_url, endpoint: endpoint, params: params
|
19
|
+
http_method: http_method, full_url: full_url, endpoint: endpoint, params: params, headers: headers
|
20
20
|
)
|
21
21
|
end
|
22
22
|
end
|
@@ -6,6 +6,7 @@ require_relative "responses/phone_number_data_response"
|
|
6
6
|
require_relative "responses/phone_numbers_data_response"
|
7
7
|
require_relative "responses/read_message_data_response"
|
8
8
|
require_relative "responses/message_error_response"
|
9
|
+
require_relative "responses/business_profile_data_response"
|
9
10
|
|
10
11
|
module WhatsappSdk
|
11
12
|
module Api
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# typed: strict
|
3
|
+
|
4
|
+
require_relative "data_response"
|
5
|
+
|
6
|
+
module WhatsappSdk
|
7
|
+
module Api
|
8
|
+
module Responses
|
9
|
+
class BusinessProfileDataResponse < DataResponse
|
10
|
+
sig { returns(T.nilable(String)) }
|
11
|
+
attr_accessor :about
|
12
|
+
|
13
|
+
sig { returns(T.nilable(String)) }
|
14
|
+
attr_accessor :address
|
15
|
+
|
16
|
+
sig { returns(T.nilable(String)) }
|
17
|
+
attr_accessor :description
|
18
|
+
|
19
|
+
sig { returns(T.nilable(String)) }
|
20
|
+
attr_accessor :email
|
21
|
+
|
22
|
+
sig { returns(T.nilable(String)) }
|
23
|
+
attr_accessor :messaging_product
|
24
|
+
|
25
|
+
sig { returns(T.nilable(String)) }
|
26
|
+
attr_accessor :profile_picture_url
|
27
|
+
|
28
|
+
sig { returns(T.nilable(String)) }
|
29
|
+
attr_accessor :vertical
|
30
|
+
|
31
|
+
sig { returns(T::Array[String]) }
|
32
|
+
attr_accessor :websites
|
33
|
+
|
34
|
+
sig { params(response: T::Hash[T.untyped, T.untyped]).void }
|
35
|
+
def initialize(response)
|
36
|
+
@about = T.let(response["data"][0]["about"], T.nilable(String))
|
37
|
+
@address = T.let(response["data"][0]["address"], T.nilable(String))
|
38
|
+
@description = T.let(response["data"][0]["description"], T.nilable(String))
|
39
|
+
@email = T.let(response["data"][0]["email"], T.nilable(String))
|
40
|
+
@messaging_product = T.let(response["data"][0]["messaging_product"], T.nilable(String))
|
41
|
+
@profile_picture_url = T.let(response["data"][0]["profile_picture_url"], T.nilable(String))
|
42
|
+
@vertical = T.let(response["data"][0]["vertical"], T.nilable(String))
|
43
|
+
@websites = T.let(response["data"][0]["websites"], T.nilable(T::Array[String]))
|
44
|
+
super(response)
|
45
|
+
end
|
46
|
+
|
47
|
+
sig { override.params(response: T::Hash[T.untyped, T.untyped]).returns(T.nilable(BusinessProfileDataResponse)) }
|
48
|
+
def self.build_from_response(response:)
|
49
|
+
return nil if response['error']
|
50
|
+
|
51
|
+
new(response)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/whatsapp_sdk/version.rb
CHANGED
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.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ignacio-chiazzo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -166,12 +166,14 @@ files:
|
|
166
166
|
- bin/tapioca
|
167
167
|
- example.rb
|
168
168
|
- lib/whatsapp_sdk.rb
|
169
|
+
- lib/whatsapp_sdk/api/business_profile.rb
|
169
170
|
- lib/whatsapp_sdk/api/client.rb
|
170
171
|
- lib/whatsapp_sdk/api/medias.rb
|
171
172
|
- lib/whatsapp_sdk/api/messages.rb
|
172
173
|
- lib/whatsapp_sdk/api/phone_numbers.rb
|
173
174
|
- lib/whatsapp_sdk/api/request.rb
|
174
175
|
- lib/whatsapp_sdk/api/response.rb
|
176
|
+
- lib/whatsapp_sdk/api/responses/business_profile_data_response.rb
|
175
177
|
- lib/whatsapp_sdk/api/responses/data_response.rb
|
176
178
|
- lib/whatsapp_sdk/api/responses/error_response.rb
|
177
179
|
- lib/whatsapp_sdk/api/responses/media_data_response.rb
|