gupshup_whatsapp 1.0.4 → 1.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3502c7561440269a2de2e9f3b581fd5580b91ba1da095062015e4110d023335
4
- data.tar.gz: 11af5e984de551c0aabde0dab6b536cda4c76e44c99ab3781c58d4f22df2c066
3
+ metadata.gz: 8061c5b019b240b7a5ab3ea331a7b4e009d75d6f402d9640fef694016c5cfe90
4
+ data.tar.gz: 70c89c1ced81c7c93de714cb61c0d0473921df830793703d5a00f664dbfaf197
5
5
  SHA512:
6
- metadata.gz: cb7f1dff869bf378a15198f93a32a0c547dae44d743dc327074f4dc181cd753f13139bf2879eaf3f779a6a0cf96d6fa60587860d7d87d6177fca248e82361fb3
7
- data.tar.gz: 74c00d1615cb06e68aefa1f689e5b985639a2514241b124e7469ec0023a7b254d3d4cb0775718b358cf6a08d4cf0452dac9e607d4924d0f505731b8670edcde0
6
+ metadata.gz: e2f41516bceef0aabe5cb27815eb28b91603c480ca8358ed771011f1e499745aa1c4f082df72d7a29f09ffe4f9a867f5a30460763d11c4d1b2f3bada15f46245
7
+ data.tar.gz: 4d20952dbce737d46c74e192f3a150fe93bdf207c58db59a320d924c175c42e1ce9e6dde6e0462884f88bbd23b1aa0eb8be1bab9e28a50ae5fa49d4ded89cb24
data/.gitignore CHANGED
@@ -1,11 +1,291 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
1
+ # Created by https://www.toptal.com/developers/gitignore/api/ruby,rubymine+iml,rubymine,rubymine+all
2
+ # Edit at https://www.toptal.com/developers/gitignore?templates=ruby,rubymine+iml,rubymine,rubymine+all
3
+
4
+ ### Ruby ###
5
+ *.gem
6
+ *.rbc
7
+ /.config
4
8
  /coverage/
5
- /doc/
9
+ /InstalledFiles
6
10
  /pkg/
7
11
  /spec/reports/
12
+ /spec/examples.txt
13
+ /test/tmp/
14
+ /test/version_tmp/
8
15
  /tmp/
9
16
 
10
- # rspec failure tracking
11
- .rspec_status
17
+ # Used by dotenv library to load environment variables.
18
+ # .env
19
+
20
+ # Ignore Byebug command history file.
21
+ .byebug_history
22
+
23
+ ## Specific to RubyMotion:
24
+ .dat*
25
+ .repl_history
26
+ build/
27
+ *.bridgesupport
28
+ build-iPhoneOS/
29
+ build-iPhoneSimulator/
30
+
31
+ ## Specific to RubyMotion (use of CocoaPods):
32
+ #
33
+ # We recommend against adding the Pods directory to your .gitignore. However
34
+ # you should judge for yourself, the pros and cons are mentioned at:
35
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
36
+ # vendor/Pods/
37
+
38
+ ## Documentation cache and generated files:
39
+ /.yardoc/
40
+ /_yardoc/
41
+ /doc/
42
+ /rdoc/
43
+
44
+ ## Environment normalization:
45
+ /.bundle/
46
+ /vendor/bundle
47
+ /lib/bundler/man/
48
+
49
+ # for a library or gem, you might want to ignore these files since the code is
50
+ # intended to run in multiple environments; otherwise, check them in:
51
+ # Gemfile.lock
52
+ # .ruby-version
53
+ # .ruby-gemset
54
+
55
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
56
+ .rvmrc
57
+
58
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
59
+ # .rubocop-https?--*
60
+
61
+ ### RubyMine ###
62
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
63
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
64
+
65
+ # User-specific stuff
66
+ .idea/**/workspace.xml
67
+ .idea/**/tasks.xml
68
+ .idea/**/usage.statistics.xml
69
+ .idea/**/dictionaries
70
+ .idea/**/shelf
71
+
72
+ # AWS User-specific
73
+ .idea/**/aws.xml
74
+
75
+ # Generated files
76
+ .idea/**/contentModel.xml
77
+
78
+ # Sensitive or high-churn files
79
+ .idea/**/dataSources/
80
+ .idea/**/dataSources.ids
81
+ .idea/**/dataSources.local.xml
82
+ .idea/**/sqlDataSources.xml
83
+ .idea/**/dynamic.xml
84
+ .idea/**/uiDesigner.xml
85
+ .idea/**/dbnavigator.xml
86
+
87
+ # Gradle
88
+ .idea/**/gradle.xml
89
+ .idea/**/libraries
90
+
91
+ # Gradle and Maven with auto-import
92
+ # When using Gradle or Maven with auto-import, you should exclude module files,
93
+ # since they will be recreated, and may cause churn. Uncomment if using
94
+ # auto-import.
95
+ # .idea/artifacts
96
+ # .idea/compiler.xml
97
+ # .idea/jarRepositories.xml
98
+ # .idea/modules.xml
99
+ # .idea/*.iml
100
+ # .idea/modules
101
+ # *.iml
102
+ # *.ipr
103
+
104
+ # CMake
105
+ cmake-build-*/
106
+
107
+ # Mongo Explorer plugin
108
+ .idea/**/mongoSettings.xml
109
+
110
+ # File-based project format
111
+ *.iws
112
+
113
+ # IntelliJ
114
+ out/
115
+
116
+ # mpeltonen/sbt-idea plugin
117
+ .idea_modules/
118
+
119
+ # JIRA plugin
120
+ atlassian-ide-plugin.xml
121
+
122
+ # Cursive Clojure plugin
123
+ .idea/replstate.xml
124
+
125
+ # SonarLint plugin
126
+ .idea/sonarlint/
127
+
128
+ # Crashlytics plugin (for Android Studio and IntelliJ)
129
+ com_crashlytics_export_strings.xml
130
+ crashlytics.properties
131
+ crashlytics-build.properties
132
+ fabric.properties
133
+
134
+ # Editor-based Rest Client
135
+ .idea/httpRequests
136
+
137
+ # Android studio 3.1+ serialized cache file
138
+ .idea/caches/build_file_checksums.ser
139
+
140
+ ### RubyMine Patch ###
141
+ # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
142
+
143
+ # *.iml
144
+ # modules.xml
145
+ # .idea/misc.xml
146
+ # *.ipr
147
+
148
+ # Sonarlint plugin
149
+ # https://plugins.jetbrains.com/plugin/7973-sonarlint
150
+ .idea/**/sonarlint/
151
+
152
+ # SonarQube Plugin
153
+ # https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
154
+ .idea/**/sonarIssues.xml
155
+
156
+ # Markdown Navigator plugin
157
+ # https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
158
+ .idea/**/markdown-navigator.xml
159
+ .idea/**/markdown-navigator-enh.xml
160
+ .idea/**/markdown-navigator/
161
+
162
+ # Cache file creation bug
163
+ # See https://youtrack.jetbrains.com/issue/JBR-2257
164
+ .idea/$CACHE_FILE$
165
+
166
+ # CodeStream plugin
167
+ # https://plugins.jetbrains.com/plugin/12206-codestream
168
+ .idea/codestream.xml
169
+
170
+ # Azure Toolkit for IntelliJ plugin
171
+ # https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
172
+ .idea/**/azureSettings.xml
173
+
174
+ ### RubyMine+all ###
175
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
176
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
177
+
178
+ # User-specific stuff
179
+
180
+ # AWS User-specific
181
+
182
+ # Generated files
183
+
184
+ # Sensitive or high-churn files
185
+
186
+ # Gradle
187
+
188
+ # Gradle and Maven with auto-import
189
+ # When using Gradle or Maven with auto-import, you should exclude module files,
190
+ # since they will be recreated, and may cause churn. Uncomment if using
191
+ # auto-import.
192
+ # .idea/artifacts
193
+ # .idea/compiler.xml
194
+ # .idea/jarRepositories.xml
195
+ # .idea/modules.xml
196
+ # .idea/*.iml
197
+ # .idea/modules
198
+ # *.iml
199
+ # *.ipr
200
+
201
+ # CMake
202
+
203
+ # Mongo Explorer plugin
204
+
205
+ # File-based project format
206
+
207
+ # IntelliJ
208
+
209
+ # mpeltonen/sbt-idea plugin
210
+
211
+ # JIRA plugin
212
+
213
+ # Cursive Clojure plugin
214
+
215
+ # SonarLint plugin
216
+
217
+ # Crashlytics plugin (for Android Studio and IntelliJ)
218
+
219
+ # Editor-based Rest Client
220
+
221
+ # Android studio 3.1+ serialized cache file
222
+
223
+ ### RubyMine+all Patch ###
224
+ # Ignore everything but code style settings and run configurations
225
+ # that are supposed to be shared within teams.
226
+
227
+ .idea/*
228
+
229
+ !.idea/codeStyles
230
+ !.idea/runConfigurations
231
+
232
+ ### RubyMine+iml ###
233
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
234
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
235
+
236
+ # User-specific stuff
237
+
238
+ # AWS User-specific
239
+
240
+ # Generated files
241
+
242
+ # Sensitive or high-churn files
243
+
244
+ # Gradle
245
+
246
+ # Gradle and Maven with auto-import
247
+ # When using Gradle or Maven with auto-import, you should exclude module files,
248
+ # since they will be recreated, and may cause churn. Uncomment if using
249
+ # auto-import.
250
+ # .idea/artifacts
251
+ # .idea/compiler.xml
252
+ # .idea/jarRepositories.xml
253
+ # .idea/modules.xml
254
+ # .idea/*.iml
255
+ # .idea/modules
256
+ # *.iml
257
+ # *.ipr
258
+
259
+ # CMake
260
+
261
+ # Mongo Explorer plugin
262
+
263
+ # File-based project format
264
+
265
+ # IntelliJ
266
+
267
+ # mpeltonen/sbt-idea plugin
268
+
269
+ # JIRA plugin
270
+
271
+ # Cursive Clojure plugin
272
+
273
+ # SonarLint plugin
274
+
275
+ # Crashlytics plugin (for Android Studio and IntelliJ)
276
+
277
+ # Editor-based Rest Client
278
+
279
+ # Android studio 3.1+ serialized cache file
280
+
281
+ ### RubyMine+iml Patch ###
282
+ # Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
283
+
284
+ *.iml
285
+ modules.xml
286
+ .idea/misc.xml
287
+ *.ipr
288
+
289
+ # End of https://www.toptal.com/developers/gitignore/api/ruby,rubymine+iml,rubymine,rubymine+all
290
+ .envrc
291
+
data/.gitlab-ci.yml CHANGED
@@ -1,11 +1,48 @@
1
1
  image: ruby
2
2
 
3
- run:
4
- before_script:
5
- - mkdir ~/.gem
6
- - mv $RUBY_GEM_CREDS ~/.gem/credentials
7
- - chmod 0600 ~/.gem/credentials # rubygems requires 0600 permissions on the credentials file
8
- script:
9
- - gem build gupshup_whatsapp
10
- - gem push *.gem
11
- - rm gupshup_whatsapp*.gem
3
+ stages:
4
+ - docs
5
+ - test
6
+ - push
7
+
8
+ pages:
9
+ stage: docs
10
+ script:
11
+ - mkdir .public
12
+ - gem install yard
13
+ - yard -q
14
+ - cp -r ./doc/* .public
15
+ - rm -rf public
16
+ - mv .public public
17
+ artifacts:
18
+ paths:
19
+ - public
20
+ rules:
21
+ - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
22
+
23
+ test:
24
+ stage: test
25
+ script:
26
+ #Temporary version only for testing
27
+ - export GEM_VERSION="1.0.0"
28
+ - export GEM_HOST_API_KEY="$GEM_HOST_API_KEY"
29
+ - echo $GEM_HOST_API_KEY
30
+ - bundle install
31
+ - rspec --format doc
32
+
33
+ publish:
34
+ stage: push
35
+ script:
36
+ - export
37
+ - echo "releasing $CI_COMMIT_TAG"
38
+ - export GEM_VERSION="$CI_COMMIT_TAG"
39
+ - gem build gupshup_whatsapp
40
+ - echo "$GEM_API_KEY"
41
+ - GEM_HOST_API_KEY="$GEM_API_KEY" gem push -V *.gem
42
+ - rm gupshup_whatsapp*.gem
43
+ rules:
44
+ - if: $CI_COMMIT_TAG
45
+
46
+
47
+
48
+
data/.rspec_status ADDED
@@ -0,0 +1,12 @@
1
+ example_id | status | run_time |
2
+ --------------------------------- | ------ | --------------- |
3
+ ./spec/gupshup_ruby_spec.rb[1:1] | passed | 0.00047 seconds |
4
+ ./spec/gupshup_ruby_spec.rb[1:2] | passed | 0.08943 seconds |
5
+ ./spec/gupshup_ruby_spec.rb[1:3] | passed | 0.07458 seconds |
6
+ ./spec/gupshup_ruby_spec.rb[1:4] | passed | 0.07847 seconds |
7
+ ./spec/gupshup_ruby_spec.rb[1:5] | passed | 0.07556 seconds |
8
+ ./spec/gupshup_ruby_spec.rb[1:6] | passed | 0.08539 seconds |
9
+ ./spec/gupshup_ruby_spec.rb[1:7] | passed | 0.08631 seconds |
10
+ ./spec/gupshup_ruby_spec.rb[1:8] | passed | 0.08138 seconds |
11
+ ./spec/gupshup_ruby_spec.rb[1:9] | passed | 0.07846 seconds |
12
+ ./spec/gupshup_ruby_spec.rb[1:10] | passed | 0.07963 seconds |
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.3.6
data/Gemfile CHANGED
@@ -5,8 +5,9 @@ gemspec
5
5
 
6
6
  gem "rake", "~> 12.0"
7
7
  gem "rspec", "~> 3.0"
8
+ gem "yard"
8
9
 
9
10
 
10
11
  gem 'faraday'
11
12
  gem 'json'
12
- gem 'uuid'
13
+ gem 'uuid'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gupshup_whatsapp (1.0.1)
4
+ gupshup_whatsapp (1.0.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -42,6 +42,7 @@ GEM
42
42
  systemu (2.6.5)
43
43
  uuid (2.3.9)
44
44
  macaddr (~> 1.0)
45
+ yard (0.9.37)
45
46
 
46
47
  PLATFORMS
47
48
  ruby
@@ -53,6 +54,7 @@ DEPENDENCIES
53
54
  rake (~> 12.0)
54
55
  rspec (~> 3.0)
55
56
  uuid
57
+ yard
56
58
 
57
59
  BUNDLED WITH
58
60
  2.4.17
data/README.md CHANGED
@@ -44,14 +44,91 @@ payload = {
44
44
  }
45
45
  ```
46
46
 
47
+ #### List Payload
48
+
49
+ ```
50
+ payload = {
51
+ :isHSM => false,
52
+ :type => "text",
53
+ :text => 'Hi Hello'
54
+ }
55
+ ```
56
+
57
+ #### Sticker Payload
58
+
59
+ ```
60
+ payload = {
61
+ 'type': 'sticker',
62
+ 'url': url
63
+ }
64
+ ```
65
+
66
+ #### Videos Payload
67
+
68
+ ```
69
+ payload = {
70
+ :isHSM => false,
71
+ :type => "text",
72
+ :text => 'Hi Hello'
73
+ }
74
+ ```
75
+
76
+ #### Files Payload
77
+
78
+ ```
79
+ payload = {
80
+ :isHSM => false,
81
+ :type => "text",
82
+ :text => 'Hi Hello'
83
+ }
84
+ ```
85
+
86
+ #### Text Payload
87
+
88
+ ```
89
+ payload = {
90
+ :isHSM => false,
91
+ :type => "text",
92
+ :text => 'Hi Hello'
93
+ }
94
+ ```
95
+
96
+ #### Audio Payload
97
+
98
+ ```
99
+ payload = {
100
+ :isHSM => false,
101
+ :type => "text",
102
+ :text => 'Hi Hello'
103
+ }
104
+ ```
105
+
106
+ #### Location Payload
107
+
108
+ ```
109
+ payload = {
110
+ :isHSM => false,
111
+ :type => "text",
112
+ :text => 'Hi Hello'
113
+ }
114
+ ```
115
+
47
116
  After this, run the following commands in your code after replacing the credentials and phone number:
48
117
  ```
49
118
  g = Gupshup::WhatsApp.new(app, apikey, phone_number, version='2')
50
119
  g.send('916383467769', payload)
51
120
  ```
52
121
  ## <a name="testing"></a>Testing
53
- To run tests, configure your gupshup credentials in the `spec/gupshup_ruby_spec.rb`, and run
122
+ To run tests, set the following environmental variables:
123
+
124
+ ```shell
125
+ export GUPSHUP_DESTINATION_PHONE=
126
+ export GUPSHUP_APP=
127
+ export GUPSHUP_APP_APIKEY=
128
+ export GUPSHUP_API_VERSION=2
54
129
  ```
130
+ And the run:
131
+ ```shell
55
132
  rspec --format doc
56
133
  ```
57
134
  ## Development
@@ -2,19 +2,19 @@ require_relative 'lib/gupshup_whatsapp/version'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "gupshup_whatsapp"
5
- spec.version = "1.0.4"
5
+ spec.version = ENV["GEM_VERSION"]
6
6
  spec.authors = ["thundersparkf"]
7
7
  spec.email = ["devagastya0@gmail.com"]
8
8
 
9
9
  spec.summary = "Ruby Wrapper for Gupshup Whatsapp API"
10
- spec.description = "This is a simple open source implementation of the Ruby wrapper for Gupshup WhatsApp API. For more instructions, refer to the source code README.md. For message structure, please refer to https://docs.gupshup.io/docs/whatsapp-message-type-outbound-free-form for the structure."
10
+ spec.description = "This is a simple open source implementation of the Ruby wrapper for Gupshup WhatsApp API. For more instructions, refer to the source code README.md. For message structure, please refer to https://docs.gupshup.io/reference/msg for the structure."
11
11
  spec.homepage = "https://rubygems.org/"
12
12
  spec.license = "MIT"
13
13
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
14
 
15
15
  spec.metadata["homepage_uri"] = spec.homepage
16
16
  spec.metadata["source_code_uri"] = "https://gitlab.com/thundersparkf/gupshup-whatsapp-sdk.git"
17
- spec.metadata["documentation_uri"] ="https://docs.gupshup.io/docs/whatsapp-message-type-outbound-free-form"
17
+ spec.metadata["documentation_uri"] ="https://thundersparkf.gitlab.io/gupshup-whatsapp-sdk/"
18
18
  spec.metadata["bug_tracker_uri"] = "https://gitlab.com/thundersparkf/gupshup-whatsapp-sdk/-/issues"
19
19
  # spec.metadata["changelog_uri"] = "https://gitlab.com/thundersparkf/gupshup_whatsapp/-/blob/21dc7da6a580d24af1280e7bfb8e22a7e644ddd7/CHANGELOG"
20
20
 
@@ -11,16 +11,14 @@ class OutboundMessage < Gupshup::REST::WhatsApp
11
11
  @headers = { 'Content-type' => @content_type, 'apikey' => @apikey }
12
12
  end
13
13
 
14
-
15
-
16
14
  def send(destination, message_params)
17
15
  # Exception handling for parameters to be added
18
16
  case message_params[:type]
19
17
  when 'text'
20
18
  if message_params[:isHSM]
21
- send_text_message(destination, message_params[:text], isHSM = true)
19
+ send_text_message(destination, message_params[:text], is_hsm = true)
22
20
  else
23
- send_text_message(destination, message_params[:text], isHSM = false)
21
+ send_text_message(destination, message_params[:text], is_hsm = false)
24
22
  end
25
23
  when 'sticker'
26
24
  send_sticker(destination, message_params[:url])
@@ -43,9 +41,12 @@ class OutboundMessage < Gupshup::REST::WhatsApp
43
41
  end
44
42
  end
45
43
 
46
- # @param [Object] destination
47
- def send_text_message(destination, message, isHSM=false)
48
- payload = {'isHSM' => isHSM,
44
+ # Sends a text
45
+ # @param destination [String] destination phone number
46
+ # @param message [String] text message
47
+ # @param is_hsm [Boolean] specifies whether message is a template.
48
+ def send_text_message(destination, message, is_hsm=false)
49
+ payload = {'isHSM' => is_hsm,
49
50
  'type' => 'text',
50
51
  'text' => message }.to_json
51
52
  data = { 'channel' => @channel,
@@ -57,9 +58,16 @@ class OutboundMessage < Gupshup::REST::WhatsApp
57
58
  r.request(host = base_uri, port = 443, method = 'POST', url = path, data = data, headers = @headers)
58
59
  end
59
60
 
60
- def send_image(destination, imageUrl, previewUrl, caption)
61
- payload = {'type' => 'image', 'originalUrl' => imageUrl,
62
- 'previewUrl' => previewUrl, 'caption' => caption }.to_json
61
+
62
+ # Sends an image
63
+ # @param destination [String] destination phone number
64
+ # @param image_url [String] url of the image(publicly available) to send
65
+ # @param preview_url [String] url of the preview image(publicly available) to be displayed before the download of
66
+ # the image
67
+ # @param caption [String] caption text for the image
68
+ def send_image(destination, image_url, preview_url, caption)
69
+ payload = { 'type' => 'image', 'originalUrl' => image_url,
70
+ 'previewUrl' => preview_url, 'caption' => caption }.to_json
63
71
  data = { 'channel' => @channel, 'destination' => destination.to_s,
64
72
  'source' => @source, 'src.name' => @app,
65
73
  'message' => payload }
@@ -67,6 +75,10 @@ class OutboundMessage < Gupshup::REST::WhatsApp
67
75
  r = Gupshup::HTTP::Client.new
68
76
  r.request(host = base_uri, port = 443, method = 'POST', url = path, data = data, headers = @headers)
69
77
  end
78
+
79
+ # Sends a Whatsapp Sticker
80
+ # @param destination [String] destination phone number
81
+ # @param url [String] url of the sticker to send
70
82
  def send_sticker(destination, url)
71
83
  payload = {
72
84
  'type': 'sticker',
@@ -81,6 +93,11 @@ class OutboundMessage < Gupshup::REST::WhatsApp
81
93
  r = Gupshup::HTTP::Client.new
82
94
  r.request(host = base_uri, port = 443, method = 'POST', url = path, data = data, headers = @headers)
83
95
  end
96
+
97
+ # Sends a video
98
+ # @param destination [String] destination phone number
99
+ # @param url [String] url of the video(publicly available) to send
100
+ # @param caption [String] caption text for the video
84
101
  def send_video(destination, url, caption)
85
102
  payload = {'url' => url,
86
103
  'type' => 'video',
@@ -95,6 +112,10 @@ class OutboundMessage < Gupshup::REST::WhatsApp
95
112
  r.request(host = base_uri, port = 443, method = 'POST', url = path, data = data, headers = @headers)
96
113
  end
97
114
 
115
+ # Sends a file
116
+ # @param destination [String] destination phone number
117
+ # @param url [String] url of the video(publicly available) to send
118
+ # @param filename [String] name of the file to be displayed in the chat
98
119
  def send_file(destination, url, filename)
99
120
  payload = {'url' => url,
100
121
  'type' => 'file',
@@ -109,6 +130,9 @@ class OutboundMessage < Gupshup::REST::WhatsApp
109
130
  r.request(host = base_uri, port = 443, method = 'POST', url = path, data = data, headers = @headers)
110
131
  end
111
132
 
133
+ # Sends an audio
134
+ # @param destination [String] destination phone number
135
+ # @param url [String] url of the audio(publicly available) to send
112
136
  def send_audio(destination, url)
113
137
  payload = {'url' => url,
114
138
  'type' => 'audio' }.to_json
@@ -122,6 +146,12 @@ class OutboundMessage < Gupshup::REST::WhatsApp
122
146
  r.request(host = base_uri, port = 443, method = 'POST', url = path, data = data, headers = @headers)
123
147
  end
124
148
 
149
+ # Sends a location
150
+ # @param destination [String] destination phone number
151
+ # @param longitude [String] longitude
152
+ # @param latitude [String] latitude
153
+ # @param name [String] name of the location to be displayed in the message
154
+ # @param address [String] address displayed as a caption to the location attachment in the message
125
155
  def send_location(destination, longitude, latitude, name, address)
126
156
  payload = { "type": 'location',
127
157
  "longitude": longitude, "latitude": latitude,
@@ -136,10 +166,16 @@ class OutboundMessage < Gupshup::REST::WhatsApp
136
166
  r.request(host = base_uri, port = 443, method = 'POST', url = path, data = data, headers = @headers)
137
167
  end
138
168
 
139
- def send_list(destination, title, body, globalButtons, items)
169
+ # Sends a list
170
+ # @param destination [String] destination phone number
171
+ # @param title [String] longitude
172
+ # @param body [String] latitude
173
+ # @param global_buttons [Array<String, String>] Buttons type(valid value: text) and Title of the button. [{"type": "text", "title": "Button title"}].
174
+ # @param items [Array<String, String>] list items. Refer to https://docs.gupshup.io/docs/whatsapp-message-type-outbound-free-form#lists for format
175
+ def send_list(destination, title, body, global_buttons, items)
140
176
  uuid = UUID.new
141
177
  payload = { "type": 'list', "title": title, "body": body, "msgid": uuid.generate ,
142
- "globalButtons": [{ "type": globalButtons[0][:type], "title": globalButtons[0][:title] }],
178
+ "globalButtons": [{ "type": global_buttons[0][:type], "title": global_buttons[0][:title] }],
143
179
  "items": items }.to_json
144
180
  data = { 'channel' => @channel,
145
181
  'destination' => destination.to_s,
@@ -151,6 +187,10 @@ class OutboundMessage < Gupshup::REST::WhatsApp
151
187
  r.request(host = base_uri, port = 443, method = 'POST', url = path, data = data, headers = @headers)
152
188
  end
153
189
 
190
+ # Sends a button/quick reply
191
+ # @param destination [String] destination phone number
192
+ # @param content [String] message content
193
+ # @param options [Array<String, String>] list of options with title text and message text.
154
194
  def send_button(destination, content, options)
155
195
  uuid = UUID.new
156
196
  payload = { "type": 'quick_reply', "content": content, "msgid": uuid.generate,
metadata CHANGED
@@ -1,19 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gupshup_whatsapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - thundersparkf
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-16 00:00:00.000000000 Z
11
+ date: 2024-11-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This is a simple open source implementation of the Ruby wrapper for Gupshup
14
14
  WhatsApp API. For more instructions, refer to the source code README.md. For message
15
- structure, please refer to https://docs.gupshup.io/docs/whatsapp-message-type-outbound-free-form
16
- for the structure.
15
+ structure, please refer to https://docs.gupshup.io/reference/msg for the structure.
17
16
  email:
18
17
  - devagastya0@gmail.com
19
18
  executables: []
@@ -23,6 +22,8 @@ files:
23
22
  - ".gitignore"
24
23
  - ".gitlab-ci.yml"
25
24
  - ".rspec"
25
+ - ".rspec_status"
26
+ - ".ruby-version"
26
27
  - ".travis.yml"
27
28
  - CHANGELOG.md
28
29
  - CODE_OF_CONDUCT.md
@@ -49,7 +50,7 @@ licenses:
49
50
  metadata:
50
51
  homepage_uri: https://rubygems.org/
51
52
  source_code_uri: https://gitlab.com/thundersparkf/gupshup-whatsapp-sdk.git
52
- documentation_uri: https://docs.gupshup.io/docs/whatsapp-message-type-outbound-free-form
53
+ documentation_uri: https://thundersparkf.gitlab.io/gupshup-whatsapp-sdk/
53
54
  bug_tracker_uri: https://gitlab.com/thundersparkf/gupshup-whatsapp-sdk/-/issues
54
55
  post_install_message:
55
56
  rdoc_options: []
@@ -66,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
67
  - !ruby/object:Gem::Version
67
68
  version: '0'
68
69
  requirements: []
69
- rubygems_version: 3.5.11
70
+ rubygems_version: 3.5.22
70
71
  signing_key:
71
72
  specification_version: 4
72
73
  summary: Ruby Wrapper for Gupshup Whatsapp API