whatsapp_sdk 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3dabd5d87a1a3988caaafc2a090c9b85bcea77cc764132a169227a5ca1c4b409
4
- data.tar.gz: 1ac41750e5e737fbf9a606e013015d796b68c328e3950241cad051c8eef6d674
3
+ metadata.gz: 309171f5666c8ab046ca3e386ea48486076ba6aa1412eb088b9a884e30d06bf3
4
+ data.tar.gz: 3bf929a941471762f0f35333b7179fc03c6c48c227a6fbd83246169f0739c505
5
5
  SHA512:
6
- metadata.gz: 183f8600f1e74a46b4a38f290c806f479a0e52a20ec7c6d836b2fe3ac8038e4c91620e83d8780810907a2395555169aa8911fd5385299adcd3830a3492bea9a7
7
- data.tar.gz: ce2cb90d04e06dc62d0294bcd395b3cf6cdffb2e60c24a8671539825de486299b11647eab9cf875007f290b8a35af350aadb7a985cad4bad2bcc415d85955cd3
6
+ metadata.gz: cb2485c108c4c8ec5fd431bb906fd6f82046fb12344fa2fdda23eea9dc2eac97753f47cf600871d7c81a043d1c14fdcfa518d20e9c5fa3363cb4c88224c0f179
7
+ data.tar.gz: 157afd0a17d5e310c803c7d7e36b88fcb7c8ea4d33d0bff2800aec57459442f08a2bb820b137e0184f4d5edf87177d2f3643f445bc07e0b1a3bd8f0fee954999
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+ 1. Go to '...'
16
+
17
+ **Expected behavior**
18
+ A clear and concise description of what you expected to happen.
19
+
20
+ **Additional context**
21
+ Add any other context about the problem here.
@@ -0,0 +1,14 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Additional context**
14
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,72 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ "main" ]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [ "main" ]
20
+ schedule:
21
+ - cron: '20 22 * * 6'
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+ permissions:
28
+ actions: read
29
+ contents: read
30
+ security-events: write
31
+
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ language: [ 'ruby' ]
36
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37
+ # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
38
+
39
+ steps:
40
+ - name: Checkout repository
41
+ uses: actions/checkout@v3
42
+
43
+ # Initializes the CodeQL tools for scanning.
44
+ - name: Initialize CodeQL
45
+ uses: github/codeql-action/init@v2
46
+ with:
47
+ languages: ${{ matrix.language }}
48
+ # If you wish to specify custom queries, you can do so here or in a config file.
49
+ # By default, queries listed here will override any specified in a config file.
50
+ # Prefix the list here with "+" to use these queries and those in the config file.
51
+
52
+ # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
53
+ # queries: security-extended,security-and-quality
54
+
55
+
56
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
57
+ # If this step fails, then you should remove it and run the build manually (see below)
58
+ - name: Autobuild
59
+ uses: github/codeql-action/autobuild@v2
60
+
61
+ # ℹ️ Command-line programs to run using the OS shell.
62
+ # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
63
+
64
+ # If the Autobuild fails above, remove it and uncomment the following three lines.
65
+ # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
66
+
67
+ # - run: |
68
+ # echo "Run, Build Application using script"
69
+ # ./location_of_script_within_repo/buildscript.sh
70
+
71
+ - name: Perform CodeQL Analysis
72
+ uses: github/codeql-action/analyze@v2
data/CHANGELOG.md CHANGED
@@ -1,11 +1,13 @@
1
1
  # Unreleased
2
2
 
3
+ # v 0.3.1
4
+ - Update Meta API to v14
5
+
3
6
  # v 0.3.0
4
7
  - Allow Apps to have a singleton global authentication client.
5
8
 
6
9
  # v 0.2.0
7
10
  - Added Media API
8
- - Update Facebook API to v14
9
11
  - Added error and sucess responses
10
12
  - Added faraday-multiplart as part of the library
11
13
 
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ gem("faraday")
8
8
  gem("faraday-multipart")
9
9
  gem("oj")
10
10
  gem("rake", ">= 12.3.3")
11
+ gem("zeitwerk", ">= 2.6.0")
11
12
 
12
13
  group(:test) do
13
14
  gem('mocha')
data/Gemfile.lock CHANGED
@@ -1,10 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- whatsapp_sdk (0.2.0)
4
+ whatsapp_sdk (0.3.0)
5
5
  faraday (~> 2.3.0)
6
6
  faraday-multipart (~> 1.0.4)
7
7
  oj (~> 3.13.13)
8
+ zeitwerk (~> 2.6.0)
8
9
 
9
10
  GEM
10
11
  remote: https://rubygems.org/
@@ -53,6 +54,7 @@ GEM
53
54
  ruby-progressbar (1.11.0)
54
55
  ruby2_keywords (0.0.5)
55
56
  unicode-display_width (2.2.0)
57
+ zeitwerk (2.6.0)
56
58
 
57
59
  PLATFORMS
58
60
  x86_64-darwin-21
@@ -71,6 +73,7 @@ DEPENDENCIES
71
73
  rubocop-minitest
72
74
  rubocop-performance
73
75
  whatsapp_sdk!
76
+ zeitwerk (>= 2.6.0)
74
77
 
75
78
  BUNDLED WITH
76
79
  2.3.9
data/README.md CHANGED
@@ -4,7 +4,7 @@
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, locations or just ask for the phone numbers through this library in a few steps!
7
+ Send stickers, messages, audio, videos, and locations or just ask for the phone numbers through this library in a few steps!
8
8
 
9
9
 
10
10
  https://user-images.githubusercontent.com/11672878/173238826-6fc0a6f8-d0ee-4eae-8947-7dfd3b8b3446.mov
@@ -28,9 +28,9 @@ Or install it yourself as:
28
28
 
29
29
  ## Quick Start
30
30
 
31
- There are three primary resources, `Messages`, `Media` and `PhoneNumbers`. The first one allows clients to send any kind of message (text, audio, location, video, image, etc.), and the latter will enable clients to query the phone numbers associated.
31
+ 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.
32
32
 
33
- To use `Messages`, `Media` or `PhoneNumbers` you need to initialize the `Client` that contain auth information. There are two ways to do it
33
+ To use `Messages`, `Media` or `PhoneNumbers`, you need to initialize the `Client` that contains auth information. There are two ways to do it
34
34
 
35
35
  1) Using an initializer
36
36
 
@@ -39,7 +39,7 @@ WhatsappSdk.configure do |config|
39
39
  config.access_token = ACCESS_TOKEN
40
40
  end
41
41
  ```
42
- OR creating an instance and pass it to the Messages or PhoneNumbers instance like this:
42
+ OR 2) creating a `Client` instance and pass it to the `Messages`, `Medias` or `PhoneNumbers` instance like this:
43
43
 
44
44
  ```ruby
45
45
  client = WhatsappSdk::Api::Client.new("<ACCESS TOKEN>") # replace this with a valid access token
@@ -244,7 +244,7 @@ Visit [the example file](/example.rb) with examples to call the API in a single
244
244
 
245
245
  ## Troubleshooting
246
246
 
247
- - If the API response is success but the message is not delivered, make sure 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)
247
+ - If the API response is `success` but the message is not delivered, make sure 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)
248
248
 
249
249
  ## Development
250
250
 
data/example.rb CHANGED
@@ -11,7 +11,7 @@ gemfile(true) do
11
11
 
12
12
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
13
13
 
14
- gem "whatsapp_sdk"
14
+ gem "whatsapp_sdk", path: "/Users/ignaciochiazzo/src/whatsapp_sdk"
15
15
  gem "pry"
16
16
  gem "pry-nav"
17
17
  end
@@ -22,11 +22,13 @@ require "pry-nav"
22
22
 
23
23
  ################# UPDATE CONSTANTS #################
24
24
 
25
- ACCESS_TOKEN = "<TODO replace>"
26
- SENDER_ID = "<TODO replace>"
27
- RECIPIENT_NUMBER = "<TODO replace>"
28
- BUSINESS_ID = "<TODO replace>"
29
- IMAGE_LINK = "<TODO replace>"
25
+ ACCESS_TOKEN = "EAAHwuHDNkqoBAOtjFZAw1MUOXsFOv4EMP8Hi2mtzvcHSPbYWD4HLLLRapjPIDQWagke3cF2IIZCbtlhMZCluO1sH7C594q0q9UqZAXwufTqBtebRlssZCLwKeC69l6Emdmt2gRYGDnhTJH0mrM7L5ivZAWezhjOvtzdnKJ7xBZALiQRKB6JrEAgAZBcnBMfBZC75xR0ZACXQUPoplhjN1a5FTA" # replace this with a valid access_token # TODO replace
26
+ SENDER_ID = 107_878_721_936_019
27
+ RECIPIENT_NUMBER = 13_437_772_910
28
+ BUSINESS_ID = 114_503_234_599_312
29
+ IMAGE_LINK = "https://ignaciochiazzo.com/static/4c403819b9750c8ad8b20a75308f2a8a/876d5/profile-pic.avif"
30
+ binding.pry
31
+ # message_sent = messages_api.send_text(sender_id: SENDER_ID, recipient_number: RECIPIENT_NUMBER, message: "holis")
30
32
 
31
33
  ################# Initialize Client #################
32
34
  WhatsappSdk.configure do |config|
@@ -57,6 +59,7 @@ uploaded_media = medias_api.upload(sender_id: SENDER_ID, file_path: "tmp/whatsap
57
59
  puts "Uploaded media id: #{uploaded_media.data&.id}"
58
60
 
59
61
  # get a media
62
+ uploaded_media = medias_api.upload(sender_id: SENDER_ID, file_path: "tmp/whatsapp.png", type: "image/png")
60
63
  media = medias_api.media(media_id: uploaded_media.data&.id).data
61
64
  puts "Media info: #{media.raw_data_response}"
62
65
 
@@ -64,9 +67,9 @@ puts "Media info: #{media.raw_data_response}"
64
67
  download_image = medias_api.download(url: media&.url, file_path: 'tmp/downloaded_whatsapp.png')
65
68
  puts "Downloaded: #{download_image.data.success?}"
66
69
 
67
- # delete a media
68
- deleted_media = medias_api.delete(media_id: media&.id)
69
- puts "Deleted: #{deleted_media.data.success?}"
70
+ # # delete a media
71
+ # deleted_media = medias_api.delete(media_id: media&.id)
72
+ # puts "Deleted: #{deleted_media.data.success?}"
70
73
 
71
74
  ############################## Messages API ##############################
72
75
 
@@ -205,3 +208,8 @@ response_with_json = messages_api.send_template(
205
208
  ]
206
209
  )
207
210
  puts response_with_json
211
+
212
+
213
+ # # delete a media
214
+ deleted_media = medias_api.delete(media_id: media&.id)
215
+ puts "Deleted: #{deleted_media.data.success?}"
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WhatsappSdk
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
@@ -3,7 +3,7 @@
3
3
  module WhatsappSdk
4
4
  module Api
5
5
  class Request
6
- API_VERSION = "v13.0"
6
+ API_VERSION = "v14.0"
7
7
  API_CLIENT = "https://graph.facebook.com/#{API_VERSION}/"
8
8
 
9
9
  def initialize(client = WhatsappSdk.configuration.client)
@@ -7,17 +7,6 @@ module WhatsappSdk
7
7
  # end
8
8
  #
9
9
  # The gem have access to the client through WhatsappSdk.configuration.client
10
-
11
- class << self
12
- def configuration
13
- @configuration ||= Configuration.new
14
- end
15
-
16
- def configure
17
- yield(configuration)
18
- end
19
- end
20
-
21
10
  class Configuration
22
11
  attr_accessor :access_token
23
12
 
data/lib/whatsapp_sdk.rb CHANGED
@@ -1,38 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Configuration
4
- require_relative "whatsapp_sdk/configuration"
3
+ require "zeitwerk"
4
+ loader = Zeitwerk::Loader.for_gem
5
+ loader.setup # ready!
5
6
 
6
- # APIs
7
- require_relative "whatsapp_sdk/api/phone_numbers"
8
- require_relative "whatsapp_sdk/api/messages"
9
- require_relative "whatsapp_sdk/api/medias"
10
- require_relative "whatsapp_sdk/api/client"
7
+ module WhatsappSdk
8
+ class << self
9
+ def configuration
10
+ @configuration ||= Configuration.new
11
+ end
11
12
 
12
- # APIs responses
13
- require_relative "whatsapp_sdk/api/responses/message_data_response"
14
- require_relative "whatsapp_sdk/api/responses/phone_number_data_response"
15
- require_relative "whatsapp_sdk/api/responses/phone_numbers_data_response"
16
- require_relative "whatsapp_sdk/api/responses/message_error_response"
17
- require_relative "whatsapp_sdk/api/responses/data_response"
18
- require_relative "whatsapp_sdk/api/responses/read_message_data_response"
19
- require_relative "whatsapp_sdk/api/responses/media_data_response"
20
- require_relative "whatsapp_sdk/api/responses/success_response"
21
- require_relative "whatsapp_sdk/api/responses/error_response"
22
-
23
- # Resources
24
- require_relative "whatsapp_sdk/resource/address"
25
- require_relative "whatsapp_sdk/resource/button_parameter"
26
- require_relative "whatsapp_sdk/resource/component"
27
- require_relative "whatsapp_sdk/resource/contact_response"
28
- require_relative "whatsapp_sdk/resource/contact"
29
- require_relative "whatsapp_sdk/resource/currency"
30
- require_relative "whatsapp_sdk/resource/date_time"
31
- require_relative "whatsapp_sdk/resource/email"
32
- require_relative "whatsapp_sdk/resource/media"
33
- require_relative "whatsapp_sdk/resource/message"
34
- require_relative "whatsapp_sdk/resource/name"
35
- require_relative "whatsapp_sdk/resource/org"
36
- require_relative "whatsapp_sdk/resource/parameter_object"
37
- require_relative "whatsapp_sdk/resource/phone_number"
38
- require_relative "whatsapp_sdk/resource/url"
13
+ def configure
14
+ yield(configuration)
15
+ end
16
+ end
17
+ end
data/whatsapp_sdk.gemspec CHANGED
@@ -45,5 +45,6 @@ Gem::Specification.new do |spec|
45
45
  spec.add_dependency("faraday", "~> 2.3.0")
46
46
  spec.add_dependency("faraday-multipart", "~> 1.0.4")
47
47
  spec.add_dependency("oj", "~> 3.13.13")
48
+ spec.add_dependency("zeitwerk", "~> 2.6.0")
48
49
  spec.metadata['rubygems_mfa_required'] = 'true'
49
50
  end
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.3.0
4
+ version: 0.3.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-06-27 00:00:00.000000000 Z
11
+ date: 2022-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 3.13.13
97
+ - !ruby/object:Gem::Dependency
98
+ name: zeitwerk
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 2.6.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 2.6.0
97
111
  description: |2
98
112
  Use the Ruby Whatsapp SDK to comunicate with Whatsapp API using the Cloud API.
99
113
  Create bots to send and receive messages using the Whatsapp SDK in a few minutes.
@@ -104,6 +118,9 @@ extensions: []
104
118
  extra_rdoc_files: []
105
119
  files:
106
120
  - ".circleci/config.yml"
121
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
122
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
123
+ - ".github/workflows/codeql-analysis.yml"
107
124
  - ".github/workflows/dependency-review.yml"
108
125
  - ".github/workflows/ruby.yml"
109
126
  - ".gitignore"