direct7 0.0.12 → 0.0.14

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: 61fdb33e63e088d25da99d77b92118459a0bd2b5cc619f5196adc63cb58b714c
4
- data.tar.gz: 53cd5530d34ce0f08f509cbf1e33dee77f44eb2c5671fda40129c94a6f49c5c3
3
+ metadata.gz: bee476d4776b5658c0cccabd7dd102ea3fc5956adc3d50119ae3bbeaab617769
4
+ data.tar.gz: d11ff34f0be945a802476d210c024caaac57448f991430ca2bdee9b7c501e155
5
5
  SHA512:
6
- metadata.gz: b5d564a1af80f826b257091fda2b7a225ef64cd34f73ffa52d4eda8d51564be5af0fcb2b54a307592c269ad76d00427798c89efffb2132c68a472473f1a58ed8
7
- data.tar.gz: 5c120cc6918ed365ac4639d7d777d74d0295fa9dc33428b010ad224dc8483d846346d711fa3dcaba75a8f0ff149ac84903a9e5c0de0a667ca160a872cf86cd60
6
+ metadata.gz: bc867e763b692dfd5bd5e75a59cd5bad98ff36f811dd9ca08ed8e1bcc8cbabcbbfae59809c77c6d99d7b77528381801d124f3044f9aff4dd92be049533ab09c7
7
+ data.tar.gz: 258dcc9a516516302352e372f60835dc365e3819fa86517c739b5659fceb7676db6a19b9597009bf046a7a82d00a86737d973ed29a8b7f63d6245c140955900e
data/README.md CHANGED
@@ -8,7 +8,7 @@ The SDK is available on RubyGems and can be installed using two methods:
8
8
  Add this line to your application's Gemfile:
9
9
 
10
10
  ```bash
11
- gem 'direct7', '~> 0.0.12'
11
+ gem 'direct7', '~> 0.0.14'
12
12
  ```
13
13
 
14
14
  And then execute:
@@ -171,7 +171,7 @@ require 'direct7'
171
171
 
172
172
  client = Direct7::Client.new('Your API token')
173
173
 
174
- client.whatsapp.send_whatsapp_freeform_message(originator="91906152XXXX", recipient="91906152XXXX", message_type="CONTACTS", first_name="Amal", last_name="Anu", display_name="Amal Anu", phone="91906152XXXX", email = "amal@gmail.com")
174
+ client.whatsapp.send_whatsapp_freeform_message(originator="91906152XXXX", recipient="91906152XXXX", message_type="CONTACTS", first_name="Amal", last_name="Anu", formatted_name="Amal Anu", phones=["91906152XXXX", "91906152XXXX"], emails = ["amal@gmail.com", "amal@gmail.com"])
175
175
  ```
176
176
 
177
177
  ### Send Whatsapp Templated Message.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.12
1
+ 0.0.14
Binary file
Binary file
data/direct7.gemspec CHANGED
@@ -4,7 +4,7 @@ require "direct7/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "direct7"
7
- spec.version = "0.0.12"
7
+ spec.version = "0.0.14"
8
8
  spec.authors = ["Direct7 Networks"]
9
9
  spec.email = ["support@d7networks.com"]
10
10
  spec.summary = "Ruby SDK for Direct7 Platform REST API"
@@ -10,12 +10,7 @@ module Direct7
10
10
  @log = Logger.new(STDOUT) # You can customize the log destination as needed
11
11
  end
12
12
 
13
- def send_whatsapp_freeform_message(originator, recipient, message_type, message_text= nil, first_name= nil,
14
- last_name= nil, display_name= nil, phone= nil,
15
- email= nil, url= nil, latitude= nil, longitude= nil,
16
- location_name= nil, location_address= nil,
17
- attachment_type= nil, attachment_url= nil,
18
- attachment_caption= nil)
13
+ def send_whatsapp_freeform_message(originator, recipient, message_type, body=nil, first_name=nil, last_name=nil, formatted_name=nil, phones=nil, emails=nil, urls=nil, latitude=nil, longitude=nil, name=nil, address=nil, type=nil, url=nil, caption=nil)
19
14
  message = {
20
15
  'originator' => originator,
21
16
  'recipients' => [{'recipient' => recipient}],
@@ -26,40 +21,44 @@ module Direct7
26
21
 
27
22
  case message_type
28
23
  when 'CONTACTS'
29
- message['content']['contact'] = {
30
- 'first_name' => first_name,
31
- 'last_name' => last_name,
32
- 'display_name' => display_name,
33
- 'phone' => phone,
34
- 'email' => email,
35
- 'url' => url
36
- }
24
+ message['content']['contacts'] = [{
25
+ 'name' => {
26
+ 'first_name' => first_name,
27
+ 'last_name' => last_name,
28
+ 'formatted_name' => formatted_name,
29
+ },
30
+ 'phones' => (phones.map { |phone| { 'phone' => phone } } if phones),
31
+ 'emails' => (emails.map { |email| { 'email' => email } } if emails),
32
+ 'urls' => (urls.map { |url| { 'url' => url } } if urls),
33
+ }]
37
34
  when 'LOCATION'
38
35
  message['content']['location'] = {
39
36
  'latitude' => latitude,
40
37
  'longitude' => longitude,
41
- 'name' => location_name,
42
- 'address' => location_address
38
+ 'name' => name,
39
+ 'address' => address,
43
40
  }
44
41
  when 'ATTACHMENT'
45
42
  message['content']['attachment'] = {
46
- 'attachment_type' => attachment_type,
47
- 'attachment_url' => attachment_url,
48
- 'attachment_caption' => attachment_caption
43
+ 'type' => type,
44
+ 'url' => url,
45
+ 'caption' => caption,
49
46
  }
50
47
  when 'TEXT'
51
- message['content']['message_text'] = message_text
48
+ message['content']['text'] = {
49
+ 'body' => body,
50
+ }
52
51
  end
53
- puts message
54
- response = @client.post(@client.host, '/whatsapp/v1/send', true, params= { 'messages' => [message] })
52
+
53
+ response = @client.post(@client.host, '/whatsapp/v2/send', params: { 'messages' => [message] })
55
54
  @log.info('Message sent successfully.')
56
55
  response
57
56
  end
58
57
 
59
58
  def send_whatsapp_templated_message(originator, recipient, template_id,
60
- body_parameter_values, media_type= nil, media_url= nil,
61
- latitude= nil, longitude= nil, location_name= nil,
62
- location_address= nil)
59
+ body_parameter_values, media_type=nil, media_url=nil,
60
+ latitude=nil, longitude=nil, location_name=nil,
61
+ location_address=nil,lto_expiration_time_ms=nil, coupon_code=nil, quick_replies= nil, actions= nil, carousel_cards=nil)
63
62
  message = {
64
63
  'originator' => originator,
65
64
  'recipients' => [{'recipient' => recipient}],
@@ -87,8 +86,44 @@ module Direct7
87
86
  message['content']['template']['media'] = { 'media_type' => media_type, 'media_url' => media_url }
88
87
  end
89
88
  end
90
-
91
- response = @client.post(@client.host, '/whatsapp/v1/send', true, params= { 'messages' => [message] })
89
+
90
+ if lto_expiration_time_ms
91
+ message['content']['template']['limited_time_offer'] = {
92
+ 'expiration_time_ms' => 'lto_expiration_time_ms',
93
+ }
94
+ end
95
+
96
+ if coupon_code
97
+ message['content']['template']['buttons'] = {
98
+ 'coupon_code' => [
99
+ {
100
+ "index"=> 0,
101
+ "type"=> "copy_code",
102
+ "coupon_code"=> coupon_code
103
+ }
104
+ ]
105
+ }
106
+ end
107
+
108
+ if quick_replies
109
+ message['content']['template']['buttons'] = {
110
+ 'quick_replies' => actquick_repliesions,
111
+ }
112
+ end
113
+
114
+ if actions
115
+ message['content']['template']['buttons'] = {
116
+ 'actions' => actions,
117
+ }
118
+ end
119
+
120
+ if carousel_cards
121
+ message['content']['template']['carousel'] = {
122
+ 'cards' => carousel_cards,
123
+ }
124
+ end
125
+
126
+ response = @client.post(@client.host, '/whatsapp/v2/send', true, params: { 'messages' => [message] })
92
127
  @log.info('Message sent successfully.')
93
128
  response
94
129
  end
data/test/test.rb CHANGED
@@ -5,7 +5,7 @@ require_relative '../lib/direct7/client'
5
5
 
6
6
  class TestSERVICES < Test::Unit::TestCase
7
7
  def setup
8
- @client = Direct7::Client.new('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiOTM2M2FmNTUtYWRmMS00Y2YzLWJhNjEtNGRjNWIxOTE4NGUwIn0.rctBTKBUO2FERmv_j75ItWACpUDQ7NG14v1PeXlM1ks')
8
+ @client = Direct7::Client.new('API TOKEN')
9
9
  end
10
10
 
11
11
  def test_send_message
@@ -13,54 +13,79 @@ class TestSERVICES < Test::Unit::TestCase
13
13
  originator='SignOTP',
14
14
  report_url='https://the_url_to_recieve_delivery_report.com',
15
15
  schedule_time=nil,
16
- { recipients: ['+918086757074'], content: 'Greetings from D7 API', unicode: false }
16
+ { recipients: ['+991999999XXXX'], content: 'Greetings from D7 API', unicode: false }
17
17
  )
18
18
  puts response1
19
- # response2 = @client.sms.get_status(request_id= '001a1a4e-0221-4cb7-a524-a2a5b337cbe8')
20
- # puts response2
19
+ response2 = @client.sms.get_status(request_id= '001a1a4e-0221-4cb7-a524-a2a5b337cbe8')
20
+ puts response2
21
21
  end
22
- # def test_slack_send_message
23
- # response1 = @client.slack.send_slack_message(content="Greetings from D7 API", work_space_name="WorkSpaceName", channel_name="ChannelName", report_url="https://the_url_to_recieve_delivery_report.com" )
24
- # puts response1
25
- # response2 = @client.slack.get_status(request_id= '002599bf-e53d-46ad-b784-34f8fd5b6cf3')
26
- # puts response2
27
- # end
28
- #
29
- # def test_send_viber_message
30
- # response1 = @client.viber.send_viber_message(recipients=["+91999999XXXX"], content="Greetings from D7 API", label="PROMOTION", originator="SignOTP", call_back_url="https://the_url_to_recieve_delivery_report.com")
31
- # puts response1
32
- # response2 = @client.viber.get_status(request_id= 'd1319cc5-7183-43ff-8d98-0c18c5a62f1b')
33
- # puts response2
34
- # end
35
- #
36
- # def test_search_number_details
37
- # response = @client.number_lookup.search_number_details(recipients="+91999999XXXX")
38
- # puts response
39
- # end
40
- #
41
- # def test_send_otp
42
- # response = @client.verify.send_otp(originator="SignOTP", recipient="+91999999XXXX", content="Greetings from D7 API, your mobile verification code is: {}", data_coding="text", expiry=600)
43
- # puts response
44
- # response = @client.verify.resend_otp(otp_id="bb0e35ea-b094-40c6-9dda-06e37e801446")
45
- # puts response
46
- # response = @client.verify.verify_otp(otp_id="bb0e35ea-b094-40c6-9dda-06e37e801446", otp_code="022089")
47
- # puts response
48
- # response = @client.verify.get_status(otp_id="bb0e35ea-b094-40c6-9dda-06e37e801446")
49
- # puts response
50
- # end
51
- #
52
- # def test_send_whatsapp_templated_message
53
- # response = @client.whatsapp.send_whatsapp_templated_message(originator="919061525574", recipient="91999999XXXX",
54
- # template_id="marketing_media_image", body_parameter_values={"0": "Customer"}, media_type="image",
55
- # media_url="https://d7networks.com/static/resources/css/img/favicon.d27f70e6ebd0.png"
56
- # )
57
- # puts response
58
- # response = @client.whatsapp.send_whatsapp_freeform_message(
59
- # originator= "91906154XXXX",
60
- # recipient= "+91999999XXXX",
61
- # message_type="CONTACTS", first_name="Amal", last_name="Anu", display_name="Amal Anu", phone="91906152XXXX", email = "amal@gmail.com"
62
- # )
63
- # response = @client.whatsapp.get_status(request_id="81eca535-8131-4866-be18-b3d933604069")
64
- # puts response
22
+ def test_slack_send_message
23
+ response1 = @client.slack.send_slack_message(content="Greetings from D7 API", work_space_name="WorkSpaceName", channel_name="ChannelName", report_url="https://the_url_to_recieve_delivery_report.com" )
24
+ puts response1
25
+ response2 = @client.slack.get_status(request_id= '002599bf-e53d-46ad-b784-34f8fd5b6cf3')
26
+ puts response2
27
+ end
28
+
29
+ def test_send_viber_message
30
+ response1 = @client.viber.send_viber_message(recipients=["+91999999XXXX"], content="Greetings from D7 API", label="PROMOTION", originator="SignOTP", call_back_url="https://the_url_to_recieve_delivery_report.com")
31
+ puts response1
32
+ response2 = @client.viber.get_status(request_id= 'd1319cc5-7183-43ff-8d98-0c18c5a62f1b')
33
+ puts response2
34
+ end
35
+
36
+ def test_search_number_details
37
+ response = @client.number_lookup.search_number_details(recipients="+91999999XXXX")
38
+ puts response
39
+ end
40
+
41
+ def test_send_otp
42
+ response = @client.verify.send_otp(originator="SignOTP", recipient="+91999999XXXX", content="Greetings from D7 API, your mobile verification code is: {}", data_coding="text", expiry=600)
43
+ puts response
44
+ response = @client.verify.resend_otp(otp_id="bb0e35ea-b094-40c6-9dda-06e37e801446")
45
+ puts response
46
+ response = @client.verify.verify_otp(otp_id="bb0e35ea-b094-40c6-9dda-06e37e801446", otp_code="022089")
47
+ puts response
48
+ response = @client.verify.get_status(otp_id="bb0e35ea-b094-40c6-9dda-06e37e801446")
49
+ puts response
50
+ end
51
+
52
+ def test_send_whatsapp_templated_message
53
+ response = @client.whatsapp.send_whatsapp_templated_message(originator="919061525574", recipient="91999999XXXX",
54
+ template_id="marketing_media_image", body_parameter_values={"0": "Customer"}, media_type="image",
55
+ media_url="https://d7networks.com/static/resources/css/img/favicon.d27f70e6ebd0.png"
56
+ )
57
+ puts response
58
+ end
59
+ def test_send_whatsapp_freeform_contact
60
+ # freeform contacts
61
+ response = @client.whatsapp.send_whatsapp_freeform_message(
62
+ originator= "XXXXXXXXXXXX",
63
+ recipient= "+XXXXXXXXXXXX",
64
+ message_type="CONTACTS", first_name="Amal", last_name="Anu", formatted_name="Amal Anu", phones=["91906152XXXX"], emails = ["amal@gmail.com"]
65
+ )
66
+ response = @client.whatsapp.get_status(request_id="81eca535-8131-4866-be18-b3d933604069")
67
+ puts response
68
+ end
69
+
70
+ def test_send_whatsapp_freeform_message_text
71
+ response = @client.whatsapp.send_whatsapp_freeform_message(
72
+ originator= "+XXXXXXXXXXXX",
73
+ recipient= "XXXXXXXXXXX",
74
+ message_type= "TEXT",
75
+ body= "Hi",
76
+ )
77
+ puts response
78
+ end
79
+
80
+ def test_send_whatsapp_freeform_message_attachment
81
+ response = @client.whatsapp.send_whatsapp_freeform_message(
82
+ originator= "+XXXXXXXXXXXX",
83
+ recipient= "XXXXXXXXXXX",
84
+ message_type= "ATTACHMENT",
85
+ type= "image",
86
+ url= "https=//upload.wikimedia.org",
87
+ caption= "Tet"
88
+ )
89
+ puts response
65
90
  # end
66
91
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: direct7
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Direct7 Networks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-05 00:00:00.000000000 Z
11
+ date: 2024-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -128,6 +128,8 @@ files:
128
128
  - VERSION
129
129
  - direct7-0.0.10.gem
130
130
  - direct7-0.0.11.gem
131
+ - direct7-0.0.12.gem
132
+ - direct7-0.0.13.gem
131
133
  - direct7.gemspec
132
134
  - doc/Direct7.html
133
135
  - doc/Direct7/AuthenticationError.html
@@ -2215,7 +2217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
2215
2217
  - !ruby/object:Gem::Version
2216
2218
  version: '0'
2217
2219
  requirements: []
2218
- rubygems_version: 3.4.22
2220
+ rubygems_version: 3.3.5
2219
2221
  signing_key:
2220
2222
  specification_version: 4
2221
2223
  summary: Ruby SDK for Direct7 Platform REST API