whatsapp_sdk 0.4.0 → 0.5.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/Gemfile.lock +1 -1
- data/README.md +23 -14
- data/example.rb +9 -7
- data/lib/{version.rb → whatsapp_sdk/version.rb} +3 -1
- data/lib/whatsapp_sdk.rb +3 -2
- data/whatsapp_sdk.gemspec +3 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ed72c3c8b37576bd66fd20d2cb4b1057118b164a7dfd1beee06d3ea9e643baa
|
4
|
+
data.tar.gz: 82629ab66d2b098d4b3d4b3a5dd201182444769448e8259625f04de4370a1bc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e2624a444b24964b9d4254dcbb2baa0e99bfaa5300dd3e03cdc2ec4870b73f04084562bdb0a9f9cbbdd2877afbe8face27e297700f9c0a27118851459ec33c9
|
7
|
+
data.tar.gz: dbd91d2753ddddebd117984dd10b301bccb0805ced290ce5d01578e237e70d340a4db0ef02ce9aff8396d554e8cafa57659f6f1e885388960cb492c0b9c54a05
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
#
|
1
|
+
# v 0.5.1
|
2
|
+
Remove warnings [#41](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/41)
|
3
|
+
|
4
|
+
# v 0.5.0
|
5
|
+
Require Faraday [#40](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/40)
|
6
|
+
|
7
|
+
# v 0.4.0
|
2
8
|
- Make the gem stricly typed using Sorbet [#34](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/34), [#35](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/35), [#37](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/37)
|
3
9
|
- Object IDs are Strings in development [#37](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/37)
|
4
10
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -48,17 +48,6 @@ messages_api = WhatsappSdk::Api::Messages.new(client)
|
|
48
48
|
|
49
49
|
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.
|
50
50
|
|
51
|
-
## Operations
|
52
|
-
First, create the client and then create an instance `WhatsappSdk::Api::Messages` that requires a client as a param like this:
|
53
|
-
|
54
|
-
```ruby
|
55
|
-
messages_api = WhatsappSdk::Api::Messages.new
|
56
|
-
phone_numbers_api = WhatsappSdk::Api::PhoneNumbers.new
|
57
|
-
medias_api = WhatsappSdk::Api::Medias.new
|
58
|
-
```
|
59
|
-
|
60
|
-
Note: Remember to initialize the client first!
|
61
|
-
|
62
51
|
## Set up a Meta app
|
63
52
|
|
64
53
|
<details><summary>1) Create a Meta Business app </summary>
|
@@ -123,10 +112,23 @@ Check the [example.rb file](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk
|
|
123
112
|
|
124
113
|
</details>
|
125
114
|
|
115
|
+
## Operations
|
116
|
+
First, create the client and then create an instance `WhatsappSdk::Api::Messages` that requires a client as a param like this:
|
126
117
|
|
118
|
+
```ruby
|
119
|
+
messages_api = WhatsappSdk::Api::Messages.new
|
120
|
+
phone_numbers_api = WhatsappSdk::Api::PhoneNumbers.new
|
121
|
+
medias_api = WhatsappSdk::Api::Medias.new
|
122
|
+
```
|
127
123
|
|
124
|
+
Note: Remember to initialize the client first!
|
125
|
+
|
126
|
+
## APIs
|
128
127
|
|
129
128
|
### Phone numbers API
|
129
|
+
|
130
|
+
<details>
|
131
|
+
|
130
132
|
Get the list of phone numbers registered
|
131
133
|
```ruby
|
132
134
|
phone_numbers_api.registered_numbers(123456) # accepts a business_id
|
@@ -136,8 +138,10 @@ Get the a phone number by id
|
|
136
138
|
```ruby
|
137
139
|
phone_numbers_api.registered_numbers(123456) # accepts a phone_number_id
|
138
140
|
```
|
141
|
+
</details>
|
139
142
|
|
140
143
|
### Media API
|
144
|
+
<details>
|
141
145
|
|
142
146
|
Upload a media
|
143
147
|
```ruby
|
@@ -159,7 +163,10 @@ Delete a media
|
|
159
163
|
medias_api.delete(media_id: MEDIA_ID)
|
160
164
|
```
|
161
165
|
|
166
|
+
</details>
|
167
|
+
|
162
168
|
### Messages API
|
169
|
+
<details>
|
163
170
|
|
164
171
|
**Send a text message**
|
165
172
|
|
@@ -300,12 +307,12 @@ Alernative, you could pass a plain json like this:
|
|
300
307
|
```ruby
|
301
308
|
@messages_api.send_template(sender_id: 12_345, recipient_number: 12345678, name: "hello_world", language: "en_US", components_json: [{...}])
|
302
309
|
```
|
310
|
+
</details>
|
303
311
|
|
304
|
-
##
|
312
|
+
## Examples
|
305
313
|
|
306
314
|
Visit [the example file](/example.rb) with examples to call the API in a single file.
|
307
315
|
|
308
|
-
|
309
316
|
## Whatsapp Cloud API
|
310
317
|
|
311
318
|
- See the [official documentation](https://developers.facebook.com/docs/whatsapp/cloud-api) for the Whatsapp Cloud API.
|
@@ -313,7 +320,9 @@ Visit [the example file](/example.rb) with examples to call the API in a single
|
|
313
320
|
|
314
321
|
## Troubleshooting
|
315
322
|
|
316
|
-
- If the API response is `success
|
323
|
+
- 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.
|
324
|
+
- Ensure your Meta App uses an API version greater than or equal to `v.14`.
|
325
|
+
- Ensure that the Panel in the Facebook dashboard doesn't display any error.
|
317
326
|
|
318
327
|
## Development
|
319
328
|
|
data/example.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
# 1) Copy this code into a file and save it `example.rb`
|
@@ -11,7 +12,7 @@ gemfile(true) do
|
|
11
12
|
|
12
13
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
13
14
|
|
14
|
-
gem "whatsapp_sdk"
|
15
|
+
gem "whatsapp_sdk", path: "/Users/ignaciochiazzo/src/whatsapp_sdk" # "~> 0.5.0"
|
15
16
|
gem "pry"
|
16
17
|
gem "pry-nav"
|
17
18
|
end
|
@@ -21,12 +22,12 @@ require "pry"
|
|
21
22
|
require "pry-nav"
|
22
23
|
|
23
24
|
################# UPDATE CONSTANTS #################
|
25
|
+
ACCESS_TOKEN = "EAAZAvvr0DZBs0BAHyg1bIPxEVV8dfI6woMaCxGNdjEEWYbZAkrMDuSqJcwXuIX10AmUW5TQLMEQCHM07dYzpGW5rTbZCZAoDt0aixPyZBB2nKFCTGhd3OnyZCZCzAxEdZBbZC4IY9uYkYbC9KCSLfOpAdgBU1dLGCTR2brwAvpWZAosgjXwgQZBLwrOSEpblsMVTGDkNaxAbi8zZBLijYRi6gsaSK" # replace this with a valid access_token # TODO replace
|
26
|
+
BUSINESS_ID = 102261539298487
|
27
|
+
SENDER_ID = 111591145018464
|
28
|
+
RECIPIENT_NUMBER = 13437772910
|
24
29
|
|
25
|
-
|
26
|
-
SENDER_ID = "<TODO replace>"
|
27
|
-
RECIPIENT_NUMBER = "<TODO replace>"
|
28
|
-
BUSINESS_ID = "<TODO replace>"
|
29
|
-
IMAGE_LINK = "<TODO replace>"
|
30
|
+
IMAGE_LINK = "https://ignaciochiazzo.com/static/4c403819b9750c8ad8b20a75308f2a8a/876d5/profile-pic.avif"
|
30
31
|
|
31
32
|
################# Initialize Client #################
|
32
33
|
WhatsappSdk.configure do |config|
|
@@ -46,6 +47,7 @@ end
|
|
46
47
|
medias_api = WhatsappSdk::Api::Medias.new
|
47
48
|
messages_api = WhatsappSdk::Api::Messages.new
|
48
49
|
phone_numbers_api = WhatsappSdk::Api::PhoneNumbers.new
|
50
|
+
binding.pry
|
49
51
|
|
50
52
|
############################## Phone Numbers API ##############################
|
51
53
|
registered_number = phone_numbers_api.registered_number(SENDER_ID)
|
@@ -88,7 +90,7 @@ print_message_sent(location_sent)
|
|
88
90
|
######### SEND AN IMAGE
|
89
91
|
# Send an image with a link
|
90
92
|
image_sent = messages_api.send_image(
|
91
|
-
sender_id: SENDER_ID, recipient_number: RECIPIENT_NUMBER, link: media.url, caption: "
|
93
|
+
sender_id: SENDER_ID, recipient_number: RECIPIENT_NUMBER, link: media.url, caption: "Testing"
|
92
94
|
)
|
93
95
|
print_message_sent(image_sent)
|
94
96
|
|
data/lib/whatsapp_sdk.rb
CHANGED
@@ -2,12 +2,13 @@
|
|
2
2
|
# typed: true
|
3
3
|
|
4
4
|
require "zeitwerk"
|
5
|
+
require "faraday"
|
6
|
+
require "faraday/multipart"
|
7
|
+
require "sorbet-runtime"
|
5
8
|
|
6
9
|
loader = Zeitwerk::Loader.for_gem
|
7
10
|
loader.setup
|
8
11
|
|
9
|
-
require "sorbet-runtime"
|
10
|
-
|
11
12
|
module WhatsappSdk
|
12
13
|
class << self
|
13
14
|
extend T::Sig
|
data/whatsapp_sdk.gemspec
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
# typed: true
|
3
3
|
|
4
|
+
require_relative 'lib/whatsapp_sdk/version'
|
5
|
+
|
4
6
|
lib = File.expand_path('lib', __dir__)
|
5
7
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
-
require "version"
|
7
8
|
|
8
9
|
Gem::Specification.new do |spec|
|
9
10
|
spec.name = "whatsapp_sdk"
|
10
|
-
spec.version = WhatsappSdk::VERSION
|
11
|
+
spec.version = WhatsappSdk::Version::VERSION
|
11
12
|
spec.authors = ["ignacio-chiazzo"]
|
12
13
|
spec.email = ["ignaciochiazzo@gmail.com"]
|
13
14
|
spec.summary = "Use the Ruby Whatsapp SDK to comunicate with Whatsapp API using the Cloud API"
|
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.5.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: 2022-09-
|
11
|
+
date: 2022-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -165,7 +165,6 @@ files:
|
|
165
165
|
- bin/setup
|
166
166
|
- bin/tapioca
|
167
167
|
- example.rb
|
168
|
-
- lib/version.rb
|
169
168
|
- lib/whatsapp_sdk.rb
|
170
169
|
- lib/whatsapp_sdk/api/client.rb
|
171
170
|
- lib/whatsapp_sdk/api/medias.rb
|
@@ -200,6 +199,7 @@ files:
|
|
200
199
|
- lib/whatsapp_sdk/resource/parameter_object.rb
|
201
200
|
- lib/whatsapp_sdk/resource/phone_number.rb
|
202
201
|
- lib/whatsapp_sdk/resource/url.rb
|
202
|
+
- lib/whatsapp_sdk/version.rb
|
203
203
|
- sorbet/config
|
204
204
|
- sorbet/rbi/annotations/faraday.rbi
|
205
205
|
- sorbet/rbi/annotations/mocha.rbi
|