whatsapp_sdk 0.12.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cursorrules +53 -0
- data/.github/workflows/codeql-analysis.yml +8 -6
- data/.gitignore +1 -0
- data/.rubocop.yml +0 -3
- data/CHANGELOG.md +19 -7
- data/Gemfile +1 -4
- data/Gemfile.lock +9 -23
- data/README.md +148 -223
- data/SECURITY.md +21 -0
- data/example.rb +217 -125
- data/lib/whatsapp_sdk/api/api_configuration.rb +2 -5
- data/lib/whatsapp_sdk/api/business_profile.rb +12 -26
- data/lib/whatsapp_sdk/api/client.rb +31 -43
- data/lib/whatsapp_sdk/api/medias.rb +31 -46
- data/lib/whatsapp_sdk/api/messages.rb +28 -142
- data/lib/whatsapp_sdk/api/phone_numbers.rb +32 -36
- data/lib/whatsapp_sdk/api/request.rb +2 -2
- data/lib/whatsapp_sdk/api/responses/generic_error_response.rb +12 -30
- data/lib/whatsapp_sdk/api/responses/http_response_error.rb +18 -0
- data/lib/whatsapp_sdk/api/responses/id_response.rb +15 -0
- data/lib/whatsapp_sdk/api/responses/message_data_response.rb +18 -37
- data/lib/whatsapp_sdk/api/responses/pagination_records.rb +17 -0
- data/lib/whatsapp_sdk/api/responses/success_response.rb +3 -20
- data/lib/whatsapp_sdk/api/templates.rb +30 -63
- data/lib/whatsapp_sdk/configuration.rb +2 -24
- data/lib/whatsapp_sdk/error.rb +0 -1
- data/lib/whatsapp_sdk/resource/address.rb +1 -30
- data/lib/whatsapp_sdk/resource/address_type.rb +3 -8
- data/lib/whatsapp_sdk/resource/business_profile.rb +28 -3
- data/lib/whatsapp_sdk/resource/button_parameter.rb +4 -20
- data/lib/whatsapp_sdk/resource/component.rb +12 -43
- data/lib/whatsapp_sdk/resource/contact.rb +1 -30
- data/lib/whatsapp_sdk/resource/contact_response.rb +1 -9
- data/lib/whatsapp_sdk/resource/currency.rb +0 -8
- data/lib/whatsapp_sdk/resource/date_time.rb +0 -6
- data/lib/whatsapp_sdk/resource/email.rb +1 -10
- data/lib/whatsapp_sdk/resource/errors.rb +3 -17
- data/lib/whatsapp_sdk/resource/interactive.rb +6 -27
- data/lib/whatsapp_sdk/resource/interactive_action.rb +10 -24
- data/lib/whatsapp_sdk/resource/interactive_action_reply_button.rb +5 -19
- data/lib/whatsapp_sdk/resource/interactive_action_section.rb +1 -11
- data/lib/whatsapp_sdk/resource/interactive_action_section_row.rb +0 -11
- data/lib/whatsapp_sdk/resource/interactive_body.rb +0 -10
- data/lib/whatsapp_sdk/resource/interactive_footer.rb +0 -10
- data/lib/whatsapp_sdk/resource/interactive_header.rb +25 -53
- data/lib/whatsapp_sdk/resource/location.rb +44 -0
- data/lib/whatsapp_sdk/resource/media.rb +28 -114
- data/lib/whatsapp_sdk/resource/media_component.rb +89 -0
- data/lib/whatsapp_sdk/resource/media_types.rb +0 -3
- data/lib/whatsapp_sdk/resource/message.rb +0 -5
- data/lib/whatsapp_sdk/resource/message_template_namespace.rb +17 -0
- data/lib/whatsapp_sdk/resource/name.rb +1 -28
- data/lib/whatsapp_sdk/resource/org.rb +1 -13
- data/lib/whatsapp_sdk/resource/parameter_object.rb +71 -74
- data/lib/whatsapp_sdk/resource/phone_number.rb +40 -22
- data/lib/whatsapp_sdk/resource/phone_number_component.rb +25 -0
- data/lib/whatsapp_sdk/resource/template.rb +43 -36
- data/lib/whatsapp_sdk/resource/url.rb +1 -10
- data/lib/whatsapp_sdk/version.rb +1 -2
- data/lib/whatsapp_sdk.rb +0 -4
- data/whatsapp_sdk.gemspec +1 -4
- metadata +13 -62
- data/lib/whatsapp_sdk/api/response.rb +0 -51
- data/lib/whatsapp_sdk/api/responses/business_profile_data_response.rb +0 -56
- data/lib/whatsapp_sdk/api/responses/data_response.rb +0 -26
- data/lib/whatsapp_sdk/api/responses/error_response.rb +0 -32
- data/lib/whatsapp_sdk/api/responses/media_data_response.rb +0 -48
- data/lib/whatsapp_sdk/api/responses/message_error_response.rb +0 -13
- data/lib/whatsapp_sdk/api/responses/message_template_namespace_data_response.rb +0 -37
- data/lib/whatsapp_sdk/api/responses/phone_number_data_response.rb +0 -60
- data/lib/whatsapp_sdk/api/responses/phone_numbers_data_response.rb +0 -39
- data/lib/whatsapp_sdk/api/responses/read_message_data_response.rb +0 -34
- data/lib/whatsapp_sdk/api/responses/template_data_response.rb +0 -51
- data/lib/whatsapp_sdk/api/responses/templates_data_response.rb +0 -39
- data/sorbet/config +0 -6
- data/sorbet/rbi/annotations/faraday.rbi +0 -17
- data/sorbet/rbi/annotations/mocha.rbi +0 -34
- data/sorbet/rbi/annotations/rainbow.rbi +0 -269
- data/sorbet/rbi/gems/faraday-multipart@1.0.4.rbi +0 -270
- data/sorbet/rbi/gems/faraday-net_http@2.0.3.rbi +0 -182
- data/sorbet/rbi/gems/faraday@2.3.0.rbi +0 -2494
- data/sorbet/rbi/gems/method_source@1.0.0.rbi +0 -272
- data/sorbet/rbi/gems/minitest@5.16.1.rbi +0 -1459
- data/sorbet/rbi/gems/mocha@1.14.0.rbi +0 -60
- data/sorbet/rbi/gems/multipart-post@2.2.3.rbi +0 -239
- data/sorbet/rbi/gems/netrc@0.11.0.rbi +0 -150
- data/sorbet/rbi/gems/oj@3.13.14.rbi +0 -589
- data/sorbet/rbi/gems/zeitwerk@2.6.0.rbi +0 -867
- data/sorbet/rbi/todo.rbi +0 -8
- data/sorbet/shims/request.rbi +0 -10
- data/sorbet/tapioca/config.yml +0 -13
- data/sorbet/tapioca/require.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b916f88ff7d75987b2173c55eb05efa2761951667f5d09daa2d6febba5e2ad63
|
4
|
+
data.tar.gz: 9c1974df055bdab421285fb4095f205b4713a22ca5363841737157c3f5ddf40a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74f451bf6122b298a40aebae35806e49ad630ed1a7e54ca021b2179c3339361366190594dfe5327a575964203a49c0064cf4f0d14a6772a2b70ff0e9a1ea1d78
|
7
|
+
data.tar.gz: 28766015d65c3e7bac47cbc50bef0dd2e509bb326d20d360ed3e2cb9993c60adebe3059af882f8b9c01519485a868db7c7ca3ca2590e7e44cae3ae7b3a6e7eb6
|
data/.cursorrules
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
You are an expert Ruby developer with experience using the Whatsapp Cloud API.
|
2
|
+
|
3
|
+
# WhatsApp Cloud API Ruby SDK Development Guidelines
|
4
|
+
|
5
|
+
## Language and Frameworks used
|
6
|
+
language: ruby
|
7
|
+
Test: minitest
|
8
|
+
Linter: rubocop
|
9
|
+
|
10
|
+
## File Structure
|
11
|
+
source_files: `lib/**/*.rb`
|
12
|
+
test_files: `test/**/*_test.rb`
|
13
|
+
example_files: `example.rb`
|
14
|
+
|
15
|
+
## Dependencies
|
16
|
+
gemfile: Gemfile
|
17
|
+
|
18
|
+
## Documentation
|
19
|
+
docs:
|
20
|
+
- README.md
|
21
|
+
- CONTRIBUTING.MD
|
22
|
+
- CHANGELOG.MD
|
23
|
+
|
24
|
+
# Main API classes (lib/whatsapp_sdk/api/)
|
25
|
+
api_classes:
|
26
|
+
- Messages
|
27
|
+
- Medias
|
28
|
+
- PhoneNumbers
|
29
|
+
- BusinessProfile
|
30
|
+
- Templates
|
31
|
+
|
32
|
+
## Code Style and Structure
|
33
|
+
- Write concise, idiomatic Ruby code with accurate examples.
|
34
|
+
- Follow Ruby conventions and best practices.
|
35
|
+
- Use object-oriented and functional programming patterns as appropriate.
|
36
|
+
- Follow the Ruby Style Guide (https://rubystyle.guide/)
|
37
|
+
|
38
|
+
|
39
|
+
## Code Style and Structure
|
40
|
+
- Write concise, idiomatic Ruby code with accurate examples
|
41
|
+
- Follow Ruby conventions and best practices
|
42
|
+
- Use object-oriented and functional programming patterns as appropriate
|
43
|
+
- Adhere to the Ruby Style Guide (https://rubystyle.guide/)
|
44
|
+
- Implement proper error logging and user-friendly messages
|
45
|
+
|
46
|
+
## Development Guidelines
|
47
|
+
1. Ensure comprehensive test coverage for all API classes
|
48
|
+
2. Document public methods and classes using YARD syntax
|
49
|
+
3. Keep the SDK modular and extensible for future WhatsApp API updates
|
50
|
+
4. Implement robust error handling and provide clear error messages
|
51
|
+
5. Use semantic versioning for releases
|
52
|
+
6. Maintain backwards compatibility when possible
|
53
|
+
|
@@ -39,29 +39,31 @@ jobs:
|
|
39
39
|
steps:
|
40
40
|
- name: Checkout repository
|
41
41
|
uses: actions/checkout@v3
|
42
|
+
with:
|
43
|
+
node-version: '20'
|
42
44
|
|
43
45
|
# Initializes the CodeQL tools for scanning.
|
44
46
|
- name: Initialize CodeQL
|
45
|
-
uses: github/codeql-action/init@
|
47
|
+
uses: github/codeql-action/init@v3
|
46
48
|
with:
|
47
49
|
languages: ${{ matrix.language }}
|
48
50
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
49
51
|
# By default, queries listed here will override any specified in a config file.
|
50
52
|
# Prefix the list here with "+" to use these queries and those in the config file.
|
51
|
-
|
53
|
+
|
52
54
|
# 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
55
|
# queries: security-extended,security-and-quality
|
54
56
|
|
55
|
-
|
57
|
+
|
56
58
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
57
59
|
# If this step fails, then you should remove it and run the build manually (see below)
|
58
60
|
- name: Autobuild
|
59
|
-
uses: github/codeql-action/autobuild@
|
61
|
+
uses: github/codeql-action/autobuild@v3
|
60
62
|
|
61
63
|
# ℹ️ Command-line programs to run using the OS shell.
|
62
64
|
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
63
65
|
|
64
|
-
# If the Autobuild fails above, remove it and uncomment the following three lines.
|
66
|
+
# If the Autobuild fails above, remove it and uncomment the following three lines.
|
65
67
|
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
|
66
68
|
|
67
69
|
# - run: |
|
@@ -69,4 +71,4 @@ jobs:
|
|
69
71
|
# ./location_of_script_within_repo/buildscript.sh
|
70
72
|
|
71
73
|
- name: Perform CodeQL Analysis
|
72
|
-
uses: github/codeql-action/analyze@
|
74
|
+
uses: github/codeql-action/analyze@v3
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require:
|
2
2
|
- rubocop-minitest
|
3
3
|
- rubocop-performance
|
4
|
-
- rubocop-sorbet
|
5
4
|
|
6
5
|
AllCops:
|
7
6
|
NewCops: enable
|
@@ -53,6 +52,4 @@ Gemspec/RequiredRubyVersion:
|
|
53
52
|
Minitest/MultipleAssertions:
|
54
53
|
Enabled: false
|
55
54
|
|
56
|
-
Style/AccessorGrouping: # disabled so that we can use sorbet signatures for each attr
|
57
|
-
Enabled: false
|
58
55
|
|
data/CHANGELOG.md
CHANGED
@@ -1,15 +1,27 @@
|
|
1
1
|
# Unreleased
|
2
2
|
|
3
|
+
# v 1.0.0
|
4
|
+
- Implement a Better response API [159](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/156)
|
5
|
+
- Implement a Better API for calling the Cloud API [156](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/156)
|
6
|
+
- Used [VCR gem]() for tests @igacio-chiazzo [153](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/153)
|
7
|
+
- Added support for API v20.0 and v21.0 @guizaols [152](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/152)
|
8
|
+
- Increased minimum required Ruby version to 2.7.0 @ignacio-chiazzo [151](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/151)
|
9
|
+
|
10
|
+
# v 0.13.0
|
11
|
+
|
12
|
+
- Remove sorbet dependency @ignacio-chiazzo [148](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/148)
|
13
|
+
- Added the ability to specify the `filename` [via the document](https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages) API. @sahilas [#137](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/137)
|
14
|
+
|
3
15
|
# v 0.12.1
|
4
|
-
- Fix bug using client/api_versions @mgruner [#134](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/134)
|
16
|
+
- Fix bug using `client/api_versions` @mgruner [#134](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/134)
|
5
17
|
|
6
18
|
# v 0.12.0
|
7
19
|
- Added ability to specify logger @chahmedejaz [#129](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/129)
|
8
20
|
- Allow download of unsupported media types @dvuckovic [#128](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/128)
|
9
21
|
- Allow users to specify the API version. @conr [#126](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/126)
|
10
|
-
- Use
|
22
|
+
- Use HTTP multipart only when needed. @ignacio-chiazzo [#123](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/123)
|
11
23
|
- Validate Vertical on BusinessProfile update API. @ignacio-chiazzo [#120](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/120)
|
12
|
-
- Added ability to specify fields param in the
|
24
|
+
- Added ability to specify fields param in the business profile API. @ignacio-chiazzo [#119](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/119)
|
13
25
|
|
14
26
|
# v 0.11.0
|
15
27
|
- Bumped API version to v19. @paulomcnally https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/116
|
@@ -68,7 +80,7 @@ Remove warnings [#41](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/
|
|
68
80
|
Require Faraday [#40](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/40)
|
69
81
|
|
70
82
|
# v 0.4.0
|
71
|
-
- Make the gem
|
83
|
+
- Make the gem strictly 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)
|
72
84
|
- Object IDs are Strings in development [#37](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/37)
|
73
85
|
|
74
86
|
# v 0.3.2
|
@@ -82,12 +94,12 @@ Require Faraday [#40](https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/pull/
|
|
82
94
|
|
83
95
|
# v 0.2.0
|
84
96
|
- Added Media API
|
85
|
-
- Added error and
|
86
|
-
- Added faraday-
|
97
|
+
- Added error and successful responses
|
98
|
+
- Added faraday-multipart as part of the library
|
87
99
|
|
88
100
|
# v 0.1.0
|
89
101
|
- Added Message Template API.
|
90
|
-
- Added Currency and
|
102
|
+
- Added Currency and DateTime resources.
|
91
103
|
- Added Media resource.
|
92
104
|
- Added Component and ParameterObject resource.
|
93
105
|
- Fixed bug in recipient_number in Messages API.
|
data/Gemfile
CHANGED
@@ -10,16 +10,13 @@ group(:test) do
|
|
10
10
|
gem('rubocop', require: false)
|
11
11
|
gem('rubocop-minitest', require: false)
|
12
12
|
gem('rubocop-performance', require: false)
|
13
|
-
gem('
|
13
|
+
gem('vcr')
|
14
14
|
gem('webmock')
|
15
15
|
end
|
16
16
|
|
17
17
|
group(:development) do
|
18
18
|
gem('pry')
|
19
19
|
gem('pry-nav')
|
20
|
-
gem('sorbet')
|
21
|
-
gem('spoom')
|
22
|
-
gem('tapioca', require: false)
|
23
20
|
end
|
24
21
|
|
25
22
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
whatsapp_sdk (0.
|
4
|
+
whatsapp_sdk (1.0.0)
|
5
5
|
faraday (~> 2)
|
6
6
|
faraday-multipart (~> 1)
|
7
|
-
sorbet-runtime (~> 0.5)
|
8
7
|
zeitwerk (~> 2)
|
9
8
|
|
10
9
|
GEM
|
@@ -28,7 +27,7 @@ GEM
|
|
28
27
|
method_source (1.0.0)
|
29
28
|
minitest (5.16.1)
|
30
29
|
mocha (1.14.0)
|
31
|
-
multipart-post (2.4.
|
30
|
+
multipart-post (2.4.1)
|
32
31
|
parallel (1.22.1)
|
33
32
|
parser (3.1.2.0)
|
34
33
|
ast (~> 2.4.1)
|
@@ -41,7 +40,8 @@ GEM
|
|
41
40
|
rainbow (3.1.1)
|
42
41
|
rake (12.3.3)
|
43
42
|
regexp_parser (2.5.0)
|
44
|
-
rexml (3.
|
43
|
+
rexml (3.3.6)
|
44
|
+
strscan
|
45
45
|
rubocop (1.30.1)
|
46
46
|
parallel (~> 1.10)
|
47
47
|
parser (>= 3.1.0.0)
|
@@ -58,28 +58,17 @@ GEM
|
|
58
58
|
rubocop-performance (1.14.2)
|
59
59
|
rubocop (>= 1.7.0, < 2.0)
|
60
60
|
rubocop-ast (>= 0.4.0)
|
61
|
-
rubocop-sorbet (0.7.0)
|
62
|
-
rubocop (>= 0.90.0)
|
63
61
|
ruby-progressbar (1.11.0)
|
64
62
|
ruby2_keywords (0.0.5)
|
65
|
-
|
66
|
-
sorbet-static (= 0.5.10346)
|
67
|
-
sorbet-runtime (0.5.10346)
|
68
|
-
sorbet-static (0.5.10346-universal-darwin-19)
|
69
|
-
sorbet-static (0.5.10346-universal-darwin-21)
|
70
|
-
sorbet-static (0.5.10346-x86_64-linux)
|
71
|
-
spoom (1.1.12)
|
72
|
-
sorbet (>= 0.5.9204)
|
73
|
-
sorbet-runtime (>= 0.5.9204)
|
74
|
-
thor (>= 0.19.2)
|
75
|
-
tapioca (0.0.1)
|
76
|
-
thor (1.2.1)
|
63
|
+
strscan (3.1.0)
|
77
64
|
unicode-display_width (2.2.0)
|
65
|
+
vcr (6.3.1)
|
66
|
+
base64
|
78
67
|
webmock (3.18.1)
|
79
68
|
addressable (>= 2.8.0)
|
80
69
|
crack (>= 0.3.2)
|
81
70
|
hashdiff (>= 0.4.0, < 2.0.0)
|
82
|
-
zeitwerk (2.6.
|
71
|
+
zeitwerk (2.6.18)
|
83
72
|
|
84
73
|
PLATFORMS
|
85
74
|
arm64-darwin-21
|
@@ -97,10 +86,7 @@ DEPENDENCIES
|
|
97
86
|
rubocop
|
98
87
|
rubocop-minitest
|
99
88
|
rubocop-performance
|
100
|
-
|
101
|
-
sorbet
|
102
|
-
spoom
|
103
|
-
tapioca
|
89
|
+
vcr
|
104
90
|
webmock
|
105
91
|
whatsapp_sdk!
|
106
92
|
|