gupshup_whatsapp 0.2.5 → 1.0.0

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: db9b5533ae12ad81eee67d6afa9efb69e469176c37d47eec4d1deaff5ff2a303
4
- data.tar.gz: 96fc488d2d56f4df699a4b6cbaf5287d333a5375adc4f6d5cb2c22cc29114068
3
+ metadata.gz: 867b3245809517cd0ad0a548710c4979338572f4c28ed73133d73fff2c1a02c4
4
+ data.tar.gz: d46a4709e762c51dfdbb0edc77176e99dff91b3c9a9771e929bcd421d3500167
5
5
  SHA512:
6
- metadata.gz: b9445724381d32fc03b0018603b6290c79d9793fc42509b22e7beb9714289710b71ca1b5b1ea4beafdc30d860e1f1322a34e7091dce74da4da94d93fadba008a
7
- data.tar.gz: 5c2472757a44e95e7fb6709c39a50b04b16fa651239606454bb5a4c1071c15d7630d36f2a2a4b9fa37dc9aa3ff7c13d5478ce70aabe474f9733768fe674b4c4e
6
+ metadata.gz: bcf008e35cdb2d3ead4936d98627092bbdc83deef7e79b13a432253d130bcf69c243bd12db5d6b306721628537ee697f16f7a53e9a47b5f55f70db922cece356
7
+ data.tar.gz: 2b12170a5434ee2b0b343dea7e92815c6e322007cc645c7dcd03878060f58e98cd911ca0f01090824cabb5623d52eee3b36f1bdd7e711acc747000d78830532d
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
@@ -0,0 +1,9 @@
1
+ # CHANGELOG
2
+
3
+ [1.0.0] - 2021-09-11
4
+ Full functionality and all message types supported
5
+ ## Added
6
+ - Support for lists, quick replies and stickers
7
+
8
+ ## Fixed
9
+ - Tests with updated sample URLs
data/Gemfile CHANGED
@@ -9,3 +9,4 @@ gem "rspec", "~> 3.0"
9
9
 
10
10
  gem 'faraday'
11
11
  gem 'json'
12
+ gem 'uuid'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gupshup_whatsapp (0.2.4)
4
+ gupshup_whatsapp (1.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -21,6 +21,8 @@ GEM
21
21
  faraday-net_http (1.0.1)
22
22
  faraday-net_http_persistent (1.1.0)
23
23
  json (2.5.1)
24
+ macaddr (1.7.2)
25
+ systemu (~> 2.6.5)
24
26
  multipart-post (2.1.1)
25
27
  rake (12.3.3)
26
28
  rspec (3.10.0)
@@ -37,6 +39,9 @@ GEM
37
39
  rspec-support (~> 3.10.0)
38
40
  rspec-support (3.10.2)
39
41
  ruby2_keywords (0.0.4)
42
+ systemu (2.6.5)
43
+ uuid (2.3.9)
44
+ macaddr (~> 1.0)
40
45
 
41
46
  PLATFORMS
42
47
  ruby
@@ -47,6 +52,7 @@ DEPENDENCIES
47
52
  json
48
53
  rake (~> 12.0)
49
54
  rspec (~> 3.0)
55
+ uuid
50
56
 
51
57
  BUNDLED WITH
52
58
  2.1.4
File without changes
@@ -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
@@ -1,4 +1,4 @@
1
1
 
2
2
  module GupshupRuby
3
- VERSION = '0.2.5'.freeze
3
+ VERSION = '1.0.0'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gupshup_whatsapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 1.0.0
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-07-02 00:00:00.000000000 Z
11
+ date: 2021-09-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'This is a simple open source implementation of the Ruby wrapper for
14
14
  Gupshup WhatsApp API. For more instructions, refer to the source code README.md. '
@@ -19,9 +19,10 @@ extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
21
  - ".gitignore"
22
+ - ".gitlab-ci.yml"
22
23
  - ".rspec"
23
24
  - ".travis.yml"
24
- - CHANGELOG
25
+ - CHANGELOG.md
25
26
  - CODE_OF_CONDUCT.md
26
27
  - Gemfile
27
28
  - Gemfile.lock
@@ -30,13 +31,14 @@ files:
30
31
  - Rakefile
31
32
  - bin/console
32
33
  - bin/setup
33
- - gupshup_ruby.gemspec
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
40
  - lib/gupshup_whatsapp/rest/whatsapp/message/outbound_message.rb
41
+ - lib/gupshup_whatsapp/rest/whatsapp/user-event/user-event.rb
40
42
  - lib/gupshup_whatsapp/rest/whatsapp/whatsapp.rb
41
43
  - lib/gupshup_whatsapp/version.rb
42
44
  homepage: https://rubygems.org/
@@ -45,7 +47,7 @@ licenses:
45
47
  metadata:
46
48
  homepage_uri: https://rubygems.org/
47
49
  source_code_uri: https://gitlab.com/thundersparkf/gupshup-whatsapp-sdk.git
48
- post_install_message:
50
+ post_install_message:
49
51
  rdoc_options: []
50
52
  require_paths:
51
53
  - lib
@@ -60,8 +62,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
62
  - !ruby/object:Gem::Version
61
63
  version: '0'
62
64
  requirements: []
63
- rubygems_version: 3.1.4
64
- signing_key:
65
+ rubygems_version: 3.2.22
66
+ signing_key:
65
67
  specification_version: 4
66
68
  summary: Ruby Wrapper for Gupshup Whatsapp API
67
69
  test_files: []
data/CHANGELOG DELETED
File without changes