gupshup_whatsapp 0.2.1 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +11 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +58 -0
- data/{gupshup_ruby.gemspec → gupshup_whatsapp.gemspec} +3 -3
- data/lib/gupshup_whatsapp/rest/whatsapp/message/outbound_message.rb +51 -2
- data/lib/gupshup_whatsapp/rest/whatsapp/user-event/user-event.rb +22 -0
- data/lib/gupshup_whatsapp/version.rb +1 -1
- metadata +13 -13
- data/.DS_Store +0 -0
- data/CHANGELOG +0 -0
- data/lib/gupshup_whatsapp/rest/whatsapp/message/incoming_message.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad2e44e98e09cac92d7fa1d5c5ddb729b262310fe9db3167df412c3abd45fb80
|
4
|
+
data.tar.gz: 78ce7fa3473afb35931a7f95b5933e80d3bd39bdf287cc941e0eb91f9622734f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a054a7f89523b670531f0e921097884da40ec8dd913b4c5ed07bde82e71364833e1d7d47edc33a2055a0da20beeaad6dcc32404994137754ff98577fb8d55712
|
7
|
+
data.tar.gz: 6b56435cdad8c3fa16db07e5d1e92a1682564f1abb8392e330c7fe3beffb94d8aaebfa591f6e6fa4824c4afcc15908be89c9d0943fa1d16789159f30181f469e
|
data/.gitlab-ci.yml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
image: ruby
|
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
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
gupshup_whatsapp (1.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.4.4)
|
10
|
+
faraday (1.4.3)
|
11
|
+
faraday-em_http (~> 1.0)
|
12
|
+
faraday-em_synchrony (~> 1.0)
|
13
|
+
faraday-excon (~> 1.1)
|
14
|
+
faraday-net_http (~> 1.0)
|
15
|
+
faraday-net_http_persistent (~> 1.1)
|
16
|
+
multipart-post (>= 1.2, < 3)
|
17
|
+
ruby2_keywords (>= 0.0.4)
|
18
|
+
faraday-em_http (1.0.0)
|
19
|
+
faraday-em_synchrony (1.0.0)
|
20
|
+
faraday-excon (1.1.0)
|
21
|
+
faraday-net_http (1.0.1)
|
22
|
+
faraday-net_http_persistent (1.1.0)
|
23
|
+
json (2.5.1)
|
24
|
+
macaddr (1.7.2)
|
25
|
+
systemu (~> 2.6.5)
|
26
|
+
multipart-post (2.1.1)
|
27
|
+
rake (12.3.3)
|
28
|
+
rspec (3.10.0)
|
29
|
+
rspec-core (~> 3.10.0)
|
30
|
+
rspec-expectations (~> 3.10.0)
|
31
|
+
rspec-mocks (~> 3.10.0)
|
32
|
+
rspec-core (3.10.1)
|
33
|
+
rspec-support (~> 3.10.0)
|
34
|
+
rspec-expectations (3.10.1)
|
35
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
+
rspec-support (~> 3.10.0)
|
37
|
+
rspec-mocks (3.10.2)
|
38
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
+
rspec-support (~> 3.10.0)
|
40
|
+
rspec-support (3.10.2)
|
41
|
+
ruby2_keywords (0.0.4)
|
42
|
+
systemu (2.6.5)
|
43
|
+
uuid (2.3.9)
|
44
|
+
macaddr (~> 1.0)
|
45
|
+
|
46
|
+
PLATFORMS
|
47
|
+
ruby
|
48
|
+
|
49
|
+
DEPENDENCIES
|
50
|
+
faraday
|
51
|
+
gupshup_whatsapp!
|
52
|
+
json
|
53
|
+
rake (~> 12.0)
|
54
|
+
rspec (~> 3.0)
|
55
|
+
uuid
|
56
|
+
|
57
|
+
BUNDLED WITH
|
58
|
+
2.1.4
|
@@ -7,14 +7,14 @@ Gem::Specification.new do |spec|
|
|
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
|
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. "
|
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
|
-
spec.metadata["source_code_uri"] = "https://gitlab.com/thundersparkf/
|
17
|
-
spec.metadata["changelog_uri"] = "https://gitlab.com/thundersparkf/gupshup_whatsapp/-/blob/21dc7da6a580d24af1280e7bfb8e22a7e644ddd7/CHANGELOG"
|
16
|
+
spec.metadata["source_code_uri"] = "https://gitlab.com/thundersparkf/gupshup-whatsapp-sdk.git"
|
17
|
+
# spec.metadata["changelog_uri"] = "https://gitlab.com/thundersparkf/gupshup_whatsapp/-/blob/21dc7da6a580d24af1280e7bfb8e22a7e644ddd7/CHANGELOG"
|
18
18
|
|
19
19
|
# Specify which files should be added to the gem when it is released.
|
20
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
require_relative '../whatsapp'
|
3
2
|
module Gupshup
|
4
3
|
module REST
|
@@ -12,6 +11,8 @@ class OutboundMessage < Gupshup::REST::WhatsApp
|
|
12
11
|
@headers = { 'Content-type' => @content_type, 'apikey' => @apikey }
|
13
12
|
end
|
14
13
|
|
14
|
+
|
15
|
+
|
15
16
|
def send(destination, message_params)
|
16
17
|
# Exception handling for parameters to be added
|
17
18
|
case message_params[:type]
|
@@ -21,6 +22,8 @@ class OutboundMessage < Gupshup::REST::WhatsApp
|
|
21
22
|
else
|
22
23
|
send_text_message(destination, message_params[:text], isHSM = false)
|
23
24
|
end
|
25
|
+
when 'sticker'
|
26
|
+
send_sticker(destination, message_params[:url])
|
24
27
|
when 'image'
|
25
28
|
send_image(destination, message_params[:originalUrl], message_params[:previewUrl], message_params[:caption])
|
26
29
|
when 'video'
|
@@ -31,6 +34,10 @@ class OutboundMessage < Gupshup::REST::WhatsApp
|
|
31
34
|
send_file(destination, message_params[:url], message_params[:filename])
|
32
35
|
when 'location'
|
33
36
|
send_location(destination, message_params[:longitude], message_params[:latitude], message_params[:name], message_params[:address])
|
37
|
+
when 'list'
|
38
|
+
send_list(destination, message_params[:title], message_params[:body], message_params[:globalButtons], message_params[:items])
|
39
|
+
when 'quick_reply'
|
40
|
+
send_button(destination, message_params[:content], message_params[:options])
|
34
41
|
else
|
35
42
|
puts 'Done'
|
36
43
|
end
|
@@ -41,7 +48,6 @@ class OutboundMessage < Gupshup::REST::WhatsApp
|
|
41
48
|
payload = {'isHSM' => isHSM,
|
42
49
|
'type' => 'text',
|
43
50
|
'text' => message }.to_json
|
44
|
-
|
45
51
|
data = { 'channel' => @channel,
|
46
52
|
'destination' => destination.to_s,
|
47
53
|
'source' => @source,
|
@@ -57,10 +63,24 @@ class OutboundMessage < Gupshup::REST::WhatsApp
|
|
57
63
|
data = { 'channel' => @channel, 'destination' => destination.to_s,
|
58
64
|
'source' => @source, 'src.name' => @app,
|
59
65
|
'message' => payload }
|
66
|
+
puts payload
|
60
67
|
r = Gupshup::HTTP::Client.new
|
61
68
|
r.request(host = base_uri, port = 443, method = 'POST', url = path, data = data, headers = @headers)
|
62
69
|
end
|
70
|
+
def send_sticker(destination, url)
|
71
|
+
payload = {
|
72
|
+
'type': 'sticker',
|
73
|
+
'url': url
|
74
|
+
}.to_json
|
63
75
|
|
76
|
+
data = { 'channel' => @channel,
|
77
|
+
'destination' => destination.to_s,
|
78
|
+
'source' => @source,
|
79
|
+
'src.name' => @app,
|
80
|
+
'message' => payload }
|
81
|
+
r = Gupshup::HTTP::Client.new
|
82
|
+
r.request(host = base_uri, port = 443, method = 'POST', url = path, data = data, headers = @headers)
|
83
|
+
end
|
64
84
|
def send_video(destination, url, caption)
|
65
85
|
payload = {'url' => url,
|
66
86
|
'type' => 'video',
|
@@ -115,6 +135,35 @@ class OutboundMessage < Gupshup::REST::WhatsApp
|
|
115
135
|
r = Gupshup::HTTP::Client.new
|
116
136
|
r.request(host = base_uri, port = 443, method = 'POST', url = path, data = data, headers = @headers)
|
117
137
|
end
|
138
|
+
|
139
|
+
def send_list(destination, title, body, globalButtons, items)
|
140
|
+
uuid = UUID.new
|
141
|
+
payload = { "type": 'list', "title": title, "body": body, "msgid": uuid.generate ,
|
142
|
+
"globalButtons": [{ "type": globalButtons[0][:type], "title": globalButtons[0][:title] }],
|
143
|
+
"items": items }.to_json
|
144
|
+
data = { 'channel' => @channel,
|
145
|
+
'destination' => destination.to_s,
|
146
|
+
'source' => @source,
|
147
|
+
'src.name' => @app,
|
148
|
+
'message' => payload }
|
149
|
+
|
150
|
+
r = Gupshup::HTTP::Client.new
|
151
|
+
r.request(host = base_uri, port = 443, method = 'POST', url = path, data = data, headers = @headers)
|
152
|
+
end
|
153
|
+
|
154
|
+
def send_button(destination, content, options)
|
155
|
+
uuid = UUID.new
|
156
|
+
payload = { "type": 'quick_reply', "content": content, "msgid": uuid.generate,
|
157
|
+
"options": options}.to_json
|
158
|
+
data = { 'channel' => @channel,
|
159
|
+
'destination' => destination.to_s,
|
160
|
+
'source' => @source,
|
161
|
+
'src.name' => @app,
|
162
|
+
'message' => payload }
|
163
|
+
r = Gupshup::HTTP::Client.new
|
164
|
+
r.request(host = base_uri, port = 443, method = 'POST', url = path, data = data, headers = @headers)
|
165
|
+
end
|
166
|
+
|
118
167
|
end
|
119
168
|
end
|
120
169
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
require_relative '../whatsapp'
|
3
|
+
|
4
|
+
module Gupshup
|
5
|
+
module REST
|
6
|
+
class UserEvents < Gupshup::REST::WhatsApp
|
7
|
+
attr_accessor :app, :base_uri, :apikey, :version, :content_type, :headers
|
8
|
+
|
9
|
+
def initialize(app, apikey, version = '2')
|
10
|
+
super
|
11
|
+
@headers = { 'apikey' => @apikey }
|
12
|
+
end
|
13
|
+
|
14
|
+
def send
|
15
|
+
r = Gupshup::HTTP::Client.new
|
16
|
+
r = r.request(host = base_uri, port = 443, method = 'GET', url = "/sm/api/v1/users/#{app}", headers = @headers)
|
17
|
+
puts r.inspect
|
18
|
+
r
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,43 +1,44 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gupshup_whatsapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thundersparkf
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'This is a simple open source implementation of the Ruby wrapper for
|
14
|
-
Gupshup WhatsApp
|
14
|
+
Gupshup WhatsApp API. For more instructions, refer to the source code README.md. '
|
15
15
|
email:
|
16
16
|
- devagastya0@gmail.com
|
17
17
|
executables: []
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
-
- ".DS_Store"
|
22
21
|
- ".gitignore"
|
22
|
+
- ".gitlab-ci.yml"
|
23
23
|
- ".rspec"
|
24
24
|
- ".travis.yml"
|
25
|
-
- CHANGELOG
|
25
|
+
- CHANGELOG.md
|
26
26
|
- CODE_OF_CONDUCT.md
|
27
27
|
- Gemfile
|
28
|
+
- Gemfile.lock
|
28
29
|
- LICENSE.txt
|
29
30
|
- README.md
|
30
31
|
- Rakefile
|
31
32
|
- bin/console
|
32
33
|
- bin/setup
|
33
|
-
-
|
34
|
+
- gupshup_whatsapp.gemspec
|
34
35
|
- lib/gupshup_whatsapp.rb
|
35
36
|
- lib/gupshup_whatsapp/framework/error.rb
|
36
37
|
- lib/gupshup_whatsapp/framework/request.rb
|
37
38
|
- lib/gupshup_whatsapp/framework/response.rb
|
38
39
|
- lib/gupshup_whatsapp/http/http.rb
|
39
|
-
- lib/gupshup_whatsapp/rest/whatsapp/message/incoming_message.rb
|
40
40
|
- lib/gupshup_whatsapp/rest/whatsapp/message/outbound_message.rb
|
41
|
+
- lib/gupshup_whatsapp/rest/whatsapp/user-event/user-event.rb
|
41
42
|
- lib/gupshup_whatsapp/rest/whatsapp/whatsapp.rb
|
42
43
|
- lib/gupshup_whatsapp/version.rb
|
43
44
|
homepage: https://rubygems.org/
|
@@ -45,9 +46,8 @@ licenses:
|
|
45
46
|
- MIT
|
46
47
|
metadata:
|
47
48
|
homepage_uri: https://rubygems.org/
|
48
|
-
source_code_uri: https://gitlab.com/thundersparkf/
|
49
|
-
|
50
|
-
post_install_message:
|
49
|
+
source_code_uri: https://gitlab.com/thundersparkf/gupshup-whatsapp-sdk.git
|
50
|
+
post_install_message:
|
51
51
|
rdoc_options: []
|
52
52
|
require_paths:
|
53
53
|
- lib
|
@@ -62,8 +62,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '0'
|
64
64
|
requirements: []
|
65
|
-
rubygems_version: 3.
|
66
|
-
signing_key:
|
65
|
+
rubygems_version: 3.2.22
|
66
|
+
signing_key:
|
67
67
|
specification_version: 4
|
68
68
|
summary: Ruby Wrapper for Gupshup Whatsapp API
|
69
69
|
test_files: []
|
data/.DS_Store
DELETED
Binary file
|
data/CHANGELOG
DELETED
File without changes
|
@@ -1,16 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'uuidtools'
|
3
|
-
require 'securerandom'
|
4
|
-
require_relative '../whatsapp'
|
5
|
-
module WhatsApp
|
6
|
-
class IncomingMessage < Gupshup::REST::WhatsApp
|
7
|
-
def initialize(app, apikey, version = '2')
|
8
|
-
super
|
9
|
-
@type = 'message'
|
10
|
-
end
|
11
|
-
|
12
|
-
def sendMessage(message, type)
|
13
|
-
payload = {'id': SecureRandom.hex, }
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|