gupshup_whatsapp 0.2.0 → 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: 79ae49e29751763184e3d263e89473c527a714e4423078e4c541fa8fc7599c98
4
- data.tar.gz: a4755fb47759f6841d6ef00e98e9ffcf1a0f5f5e8b1ba8082620900691ef0c71
3
+ metadata.gz: 867b3245809517cd0ad0a548710c4979338572f4c28ed73133d73fff2c1a02c4
4
+ data.tar.gz: d46a4709e762c51dfdbb0edc77176e99dff91b3c9a9771e929bcd421d3500167
5
5
  SHA512:
6
- metadata.gz: 2505087bbacde3e5f058666680d0fc4269923a7d92d88ee252015307a129a42671b783c92ef2b44ff6c87501707abe955ae29ef95aafcd750c6f9e4962bd9ea2
7
- data.tar.gz: a65d6488ba5d91541e697c0a764e99852da50d052e8dc0bdca7b73181a83fe61b45c2b0ade45f1cba9a2a902f25dbb3fbeb16b4d7fe36ffe1af4fa5c7c52d761
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,4 +9,4 @@ gem "rspec", "~> 3.0"
9
9
 
10
10
  gem 'faraday'
11
11
  gem 'json'
12
- gem 'uuidtools'
12
+ gem 'uuid'
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,13 +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 API. For more instructions, refer to the source code README.md. "
10
11
  spec.homepage = "https://rubygems.org/"
11
12
  spec.license = "MIT"
12
13
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
14
 
14
15
  spec.metadata["homepage_uri"] = spec.homepage
15
- spec.metadata["source_code_uri"] = "https://gitlab.com/thundersparkf/gupshup_whatsapp.git"
16
- 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"
17
18
 
18
19
  # Specify which files should be added to the gem when it is released.
19
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
@@ -1,4 +1,4 @@
1
1
 
2
2
  module GupshupRuby
3
- VERSION = '0.2.0'.freeze
3
+ VERSION = '1.0.0'.freeze
4
4
  end
metadata CHANGED
@@ -1,42 +1,44 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gupshup_whatsapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
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
- description:
13
+ description: 'This is a simple open source implementation of the Ruby wrapper for
14
+ Gupshup WhatsApp API. For more instructions, refer to the source code README.md. '
14
15
  email:
15
16
  - devagastya0@gmail.com
16
17
  executables: []
17
18
  extensions: []
18
19
  extra_rdoc_files: []
19
20
  files:
20
- - ".DS_Store"
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
28
+ - Gemfile.lock
27
29
  - LICENSE.txt
28
30
  - README.md
29
31
  - Rakefile
30
32
  - bin/console
31
33
  - bin/setup
32
- - gupshup_ruby.gemspec
34
+ - gupshup_whatsapp.gemspec
33
35
  - lib/gupshup_whatsapp.rb
34
36
  - lib/gupshup_whatsapp/framework/error.rb
35
37
  - lib/gupshup_whatsapp/framework/request.rb
36
38
  - lib/gupshup_whatsapp/framework/response.rb
37
39
  - lib/gupshup_whatsapp/http/http.rb
38
- - lib/gupshup_whatsapp/rest/whatsapp/message/incoming_message.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/
@@ -44,9 +46,8 @@ licenses:
44
46
  - MIT
45
47
  metadata:
46
48
  homepage_uri: https://rubygems.org/
47
- source_code_uri: https://gitlab.com/thundersparkf/gupshup_whatsapp.git
48
- changelog_uri: https://gitlab.com/thundersparkf/gupshup_whatsapp/-/blob/21dc7da6a580d24af1280e7bfb8e22a7e644ddd7/CHANGELOG
49
- post_install_message:
49
+ source_code_uri: https://gitlab.com/thundersparkf/gupshup-whatsapp-sdk.git
50
+ post_install_message:
50
51
  rdoc_options: []
51
52
  require_paths:
52
53
  - lib
@@ -61,8 +62,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
62
  - !ruby/object:Gem::Version
62
63
  version: '0'
63
64
  requirements: []
64
- rubygems_version: 3.1.4
65
- signing_key:
65
+ rubygems_version: 3.2.22
66
+ signing_key:
66
67
  specification_version: 4
67
68
  summary: Ruby Wrapper for Gupshup Whatsapp API
68
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