direct7 0.0.13 → 0.0.15

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: f8c128191bac6a5abb2d2dfed05e504a36df201d394d44fb05dde354bc4e3e16
4
- data.tar.gz: 0bd62c9782fa39cceebc1110bd68b68dc000d37e0548c11788fc882c48b2c0b0
3
+ metadata.gz: c0546e0b943b43bcc8e4c609055043703bd2265c0407389a2ed489683bdbbbba
4
+ data.tar.gz: d6b2d1e9d8b5ede3f6c4e293a7a67a137b98e13c73ecc24c7cd4636e34137471
5
5
  SHA512:
6
- metadata.gz: 34016259c47fa36daf4e3829897fb7a3a5cb38f1e4f82222d02d1eec093d36db4e10ec038276dfe238132b08bd62bb241eaf99def9fa020cebd038d9392f7f39
7
- data.tar.gz: 75564fd228ff33d129220c29961e20fc9e963d760c918b0331fc002218fc66122ae1172221238c0cbdd8f98f09f0e3c7eb395d6dd35bcdb0efc8af4beccde941
6
+ metadata.gz: b53723c34ea53b71e3366d7db46d3c73e9053887d255d261193a07be9a8fe03fb99edbd855de1ad351bbbe65b0bbdd0cdc0e150f7f07a1964d9ee7cd9e79e748
7
+ data.tar.gz: 258dcd2bc7648cae763f32e395cf308f476aeb3452a9c4bbb2e7004224affc609c745a8ccc2d8804d916cc238ea7750ae8022a52978a4ab1af162ec64563a3d5
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.13'
11
+ gem 'direct7', '~> 0.0.15'
12
12
  ```
13
13
 
14
14
  And then execute:
@@ -164,14 +164,23 @@ client = Direct7::Client.new('Your API token')
164
164
  client.number_lookup.search_number_details(recipient="+914257845XXXX")
165
165
  ```
166
166
 
167
- ### Send Whatsapp Free-form Message (Contact Details)
167
+ ### Send Whatsapp Free-form Message (Location Details)
168
168
 
169
169
  ```ruby
170
170
  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(
175
+ originator='{originator}',
176
+ recipient='{recipient}',
177
+ message_type='LOCATION',
178
+ body=nil, first_name=nil, last_name=nil, formatted_name=nil, middle_name=nil, suffix=nil, prefix=nil, birthday=nil, phones=nil, emails=nil, urls=nil,
179
+ latitude='12.93803129081362',
180
+ longitude='77.61088653615994',
181
+ name='Mobile Pvt Ltd',
182
+ address='Bengaluru, Karnataka 56009'
183
+ )
175
184
  ```
176
185
 
177
186
  ### Send Whatsapp Templated Message.
@@ -181,7 +190,39 @@ require 'direct7'
181
190
 
182
191
  client = Direct7::Client.new('Your API token')
183
192
 
184
- client.whatsapp.send_whatsapp_templated_message(originator="91906152XXXX", recipient="91906152XXXX", message_type="TEMPLATE", template_id="monthly_promotion", body_parameter_values={"0": "promotion"})
193
+ client.whatsapp.send_whatsapp_templated_message(
194
+ originator='{originator}',
195
+ recipient='{recipient}',
196
+ template_id="{template_id}",
197
+ language="en",
198
+ body_parameter_values=nil,
199
+ media_type="image",
200
+ text_header_title=nil,
201
+ media_url='https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg'
202
+ )
203
+ ```
204
+
205
+ ### Send Whatsapp Interactive Message: CTA.
206
+
207
+ ```ruby
208
+ require 'direct7'
209
+
210
+ client = Direct7::Client.new('Your API token')
211
+ parameters = {
212
+ "display_text": "Visit Us",
213
+ "url": "https://www.luckyshrub.com?clickID=kqDGWd24Q5TRwoEQTICY7W1JKoXvaZOXWAS7h1P76s0R7Paec4"
214
+ }
215
+ client.whatsapp.send_whatsapp_templated_message(
216
+ originator='{originator}',
217
+ recipient='{recipient}',
218
+ interactive_type= "cta_url",
219
+ header_type= "text",
220
+ header_text= "Payment$ for D7 Whatsapp Service",
221
+ header_link=nil, header_file_name=nil,
222
+ body_text= "Direct7 Networks is a messaging service provider that specializes in helping organizations efficiently communicate with their customers.",
223
+ footer_text= "Thank You",
224
+ parameters= parameters
225
+ )
185
226
  ```
186
227
 
187
228
  ### Get Request Status
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.13
1
+ 0.0.15
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.13"
7
+ spec.version = "0.0.15"
8
8
  spec.authors = ["Direct7 Networks"]
9
9
  spec.email = ["support@d7networks.com"]
10
10
  spec.summary = "Ruby SDK for Direct7 Platform REST API"
@@ -82,13 +82,13 @@ module Direct7
82
82
  puts "Client error: #{response.code} #{response.body.inspect}"
83
83
  case response.code.to_i
84
84
  when 400
85
- raise BadRequest, response.body.inspect
85
+ raise BadRequest, response.body
86
86
  when 404
87
- raise NotFoundError, response.body.inspect
87
+ raise NotFoundError, response.body
88
88
  when 402
89
- raise InsufficientCreditError, response.body.inspect
89
+ raise InsufficientCreditError, response.body
90
90
  when 422
91
- raise ValidationError, response.body.inspect
91
+ raise ValidationError, response.body
92
92
  else
93
93
  raise ClientError, "#{response.code} response from #{host}"
94
94
  end
@@ -10,7 +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, 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)
13
+ def send_whatsapp_freeform_message(originator, recipient, message_type, body=nil, first_name=nil, last_name=nil, formatted_name=nil, middle_name=nil, suffix=nil, prefix=nil, birthday=nil, phones=nil, emails=nil, urls=nil, latitude=nil, longitude=nil, name=nil, address=nil, type=nil, url=nil, caption=nil, filename=nil, message_id=nil, emoji=nil, contact_addresses=nil)
14
14
  message = {
15
15
  'originator' => originator,
16
16
  'recipients' => [{'recipient' => recipient}],
@@ -19,69 +19,108 @@ module Direct7
19
19
  }
20
20
  }
21
21
 
22
- case message_type
23
- when 'CONTACTS'
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
- }]
34
- when 'LOCATION'
35
- message['content']['location'] = {
36
- 'latitude' => latitude,
37
- 'longitude' => longitude,
38
- 'name' => name,
39
- 'address' => address,
40
- }
41
- when 'ATTACHMENT'
42
- message['content']['attachment'] = {
43
- 'type' => type,
44
- 'url' => url,
45
- 'caption' => caption,
46
- }
47
- when 'TEXT'
48
- message['content']['text'] = {
49
- 'body' => body,
50
- }
51
- end
22
+ if message_type
23
+ if message_type == 'CONTACTS'
24
+ message['content']['contacts'] = [{
25
+ 'name' => {
26
+ 'first_name' => first_name,
27
+ 'last_name' => last_name,
28
+ 'formatted_name' => formatted_name,
29
+ 'middle_name' => middle_name,
30
+ 'suffix' => suffix,
31
+ 'prefix' => prefix,
32
+ },
33
+ 'addresses' => contact_addresses,
34
+ 'birthday' => birthday,
35
+ 'phones' => phones,
36
+ 'emails' => emails,
37
+ 'urls' => urls
38
+ }]
39
+ end
52
40
 
53
- response = @client.post(@client.host, '/whatsapp/v2/send', params: { 'messages' => [message] })
41
+ if message_type == 'LOCATION'
42
+ message['content']['location'] = {
43
+ 'latitude' => latitude,
44
+ 'longitude' => longitude,
45
+ 'name' => name,
46
+ 'address' => address,
47
+ }
48
+ end
49
+ if message_type == 'ATTACHMENT'
50
+ if type
51
+ if type == "document"
52
+ message['content']['attachment'] = {
53
+ 'type' => type,
54
+ 'url' => url,
55
+ 'caption' => caption,
56
+ 'filename' => filename
57
+ }
58
+ else
59
+ message['content']['attachment'] = {
60
+ 'type' => type,
61
+ 'url' => url,
62
+ 'caption' => caption
63
+ }
64
+ end
65
+ end
66
+ end
67
+
68
+ if message_type == 'TEXT'
69
+ message['content']['text'] = {
70
+ 'body' => body,
71
+ }
72
+ end
73
+
74
+ if message_type == 'REACTION'
75
+ message['content']['reaction'] = {
76
+ 'message_id' => message_id,
77
+ 'emoji' => emoji
78
+ }
79
+ end
80
+ end
81
+ response = @client.post(@client.host, '/whatsapp/v2/send', true, params= {'messages' => [message]})
54
82
  @log.info('Message sent successfully.')
55
83
  response
56
84
  end
57
85
 
58
- def send_whatsapp_templated_message(originator, recipient, template_id,
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)
86
+ def send_whatsapp_templated_message(originator, recipient, template_id, language, body_parameter_values=nil, media_type=nil, text_header_title=nil, media_url=nil, latitude=nil, longitude=nil, name=nil, address=nil, lto_expiration_time_ms=nil, coupon_code=nil, quick_replies=nil, actions=nil, carousel_cards=nil)
87
+ allowed_media_types = ['image', 'document', 'video', 'audio', 'text', 'location']
88
+ template = {
89
+ 'template_id' => template_id,
90
+ 'language' => language,
91
+ 'body_parameter_values' => body_parameter_values ? body_parameter_values : {}
92
+ }
93
+
94
+ content = {
95
+ 'message_type' => 'TEMPLATE',
96
+ 'template' => template
97
+ }
98
+
62
99
  message = {
63
100
  'originator' => originator,
64
101
  'recipients' => [{'recipient' => recipient}],
65
- 'content' => {
66
- 'message_type' => 'TEMPLATE',
67
- 'template' => {
68
- 'template_id' => template_id,
69
- 'body_parameter_values' => body_parameter_values
70
- }
71
- }
102
+ 'content' => content
72
103
  }
73
104
 
74
105
  if media_type
106
+ unless allowed_media_types.include?(media_type)
107
+ raise ArgumentError, "Invalid media_type: #{media_type}. Allowed values are: #{allowed_media_types.join(', ')}"
108
+ end
75
109
  if media_type == 'location'
76
110
  message['content']['template']['media'] = {
77
- 'media_type' => 'location',
111
+ 'media_type' => media_type,
78
112
  'location' => {
79
113
  'latitude' => latitude,
80
114
  'longitude' => longitude,
81
- 'name' => location_name,
82
- 'address' => location_address
115
+ 'name' => name,
116
+ 'address' => address
83
117
  }
84
118
  }
119
+ elsif media_type == 'text'
120
+ message['content']['template']['media'] = {
121
+ 'media_type' => media_type,
122
+ 'text_header_title' => text_header_title
123
+ }
85
124
  else
86
125
  message['content']['template']['media'] = { 'media_type' => media_type, 'media_url' => media_url }
87
126
  end
@@ -89,7 +128,7 @@ module Direct7
89
128
 
90
129
  if lto_expiration_time_ms
91
130
  message['content']['template']['limited_time_offer'] = {
92
- 'expiration_time_ms' => 'lto_expiration_time_ms',
131
+ 'expiration_time_ms' => lto_expiration_time_ms,
93
132
  }
94
133
  end
95
134
 
@@ -107,7 +146,7 @@ module Direct7
107
146
 
108
147
  if quick_replies
109
148
  message['content']['template']['buttons'] = {
110
- 'quick_replies' => actquick_repliesions,
149
+ 'quick_replies' => quick_replies,
111
150
  }
112
151
  end
113
152
 
@@ -116,14 +155,70 @@ module Direct7
116
155
  'actions' => actions,
117
156
  }
118
157
  end
119
-
120
158
  if carousel_cards
121
159
  message['content']['template']['carousel'] = {
122
160
  'cards' => carousel_cards,
123
161
  }
124
162
  end
163
+ response = @client.post(@client.host, '/whatsapp/v2/send', true, params= {'messages' => [message]})
164
+ @log.info('Message sent successfully.')
165
+ response
166
+ end
167
+
168
+ def send_whatsapp_interactive_message(originator, recipient, interactive_type, header_type=nil,
169
+ header_text=nil, header_link=nil, header_file_name=nil, body_text=nil,
170
+ footer_text=nil, parameters=nil, sections=nil, buttons=nil,list_button_text=nil)
171
+
172
+ message = {
173
+ 'originator' => originator,
174
+ 'recipients' => [{'recipient' => recipient}],
175
+ 'content' => {
176
+ 'message_type' => 'INTERACTIVE',
177
+ 'interactive' => {
178
+ 'type' => interactive_type,
179
+ 'header' => {
180
+ 'type' => header_type,
181
+ },
182
+ 'body' => {
183
+ 'text' => body_text,
184
+ },
185
+ 'footer' => {
186
+ 'text' => footer_text,
187
+ }
188
+ }
189
+ }
190
+ }
191
+
192
+ if header_type
193
+ if header_type == 'text'
194
+ message['content']['interactive']['header']["text"] = header_text
195
+
196
+ elsif header_type == 'image' || header_type == 'video' || header_type == 'document'
197
+ message['content']['interactive']['header'][header_type] = {
198
+ 'filename' => (header_type == "document" ? header_file_name : nil),
199
+ 'link' => header_link
200
+ }
201
+ end
202
+ end
203
+
204
+ if interactive_type
205
+ if interactive_type == 'cta_url'
206
+ message['content']['interactive']['action'] = {
207
+ 'parameters' => parameters,
208
+ }
209
+ elsif interactive_type == 'button'
210
+ message['content']['interactive']['action'] = {
211
+ 'buttons' => buttons,
212
+ }
213
+ elsif interactive_type == 'list'
214
+ message['content']['interactive']['action'] = {
215
+ 'sections' => sections,
216
+ 'button' => list_button_text
217
+ }
218
+ end
219
+ end
125
220
 
126
- response = @client.post(@client.host, '/whatsapp/v2/send', true, params: { 'messages' => [message] })
221
+ response = @client.post(@client.host, '/whatsapp/v2/send', true, params= { 'messages' => [message] })
127
222
  @log.info('Message sent successfully.')
128
223
  response
129
224
  end
data/test/test.rb CHANGED
@@ -1,11 +1,12 @@
1
- require '../lib/direct7/client'
2
- require '../lib/direct7/errors/errors'
1
+ $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
2
+
3
+ require 'direct7/client'
4
+ require 'direct7/errors/errors'
3
5
  require 'test/unit'
4
- require_relative '../lib/direct7/client'
5
6
 
6
7
  class TestSERVICES < Test::Unit::TestCase
7
8
  def setup
8
- @client = Direct7::Client.new('Your API Token')
9
+ @client = Direct7::Client.new('API TOKEN')
9
10
  end
10
11
 
11
12
  def test_send_message
@@ -13,12 +14,20 @@ class TestSERVICES < Test::Unit::TestCase
13
14
  originator='SignOTP',
14
15
  report_url='https://the_url_to_recieve_delivery_report.com',
15
16
  schedule_time=nil,
16
- { recipients: ['+991999999XXXX'], content: 'Greetings from D7 API', unicode: false }
17
+ { recipients: ['+991999999XXXX'], content: 'New', unicode: false }
17
18
  )
18
19
  puts response1
19
- response2 = @client.sms.get_status(request_id= '001a1a4e-0221-4cb7-a524-a2a5b337cbe8')
20
+ response2 = @client.sms.send_message(
21
+ originator='SignOTP',
22
+ report_url='https://the_url_to_recieve_delivery_report.com',
23
+ schedule_time=nil,
24
+ { recipients: ['+991999999XXXX'], content: 'مرحبا بالعالم!', unicode: true }
25
+ )
20
26
  puts response2
27
+ response3 = @client.sms.get_status(request_id= '001a1a4e-0221-4cb7-a524-a2a5b337cbe8')
28
+ puts response3
21
29
  end
30
+
22
31
  def test_slack_send_message
23
32
  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
33
  puts response1
@@ -49,40 +58,534 @@ class TestSERVICES < Test::Unit::TestCase
49
58
  puts response
50
59
  end
51
60
 
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"
61
+
62
+ # Whatsapp
63
+ # Freeform: Contacts
64
+
65
+ def test_send_whatsapp_freeform_contact
66
+ contact_addresses = [
67
+ {
68
+ "street": "1 Lucky Shrub Way",
69
+ "city": "Menlo Park",
70
+ "state": "CA",
71
+ "zip": "94025",
72
+ "country": "United States",
73
+ "country_code": "US",
74
+ "type": "WORK"
75
+ },
76
+ {
77
+ "street": "1 Hacker Way",
78
+ "city": "Menlo Park",
79
+ "state": "CA",
80
+ "zip": "94025",
81
+ "country": "United States",
82
+ "country_code": "US",
83
+ "type": "WORK"
84
+ }
85
+ ]
86
+ phones = [
87
+ {
88
+ "phone": "+16505559999",
89
+ "type": "HOME"
90
+ },
91
+ {
92
+ "phone": "+19175559999",
93
+ "type": "WORK",
94
+ "wa_id": "19175559999"
95
+ }
96
+ ]
97
+
98
+ emails = [
99
+ {
100
+ "email": "bjohnson@luckyshrub.com",
101
+ "type": "WORK"
102
+ },
103
+ {
104
+ "email": "bjohnson@luckyshrubplants.com",
105
+ "type": "HOME"
106
+ }
107
+ ]
108
+ urls = [
109
+ {
110
+ "url": "https://www.luckyshrub.com",
111
+ "type": "WORK"
112
+ },
113
+ {
114
+ "url": "https://www.facebook.com/luckyshrubplants",
115
+ "type": "WORK"
116
+ }
117
+ ]
118
+ response = @client.whatsapp.send_whatsapp_freeform_message(
119
+ originator= "971563XXXXXX",
120
+ recipient= "991999999XXXX",
121
+ message_type="CONTACTS",
122
+ body=nil,
123
+ first_name="Barbara",
124
+ last_name="Johnson",
125
+ formatted_name="Barbara J. Johnson",
126
+ middle_name="Joana",
127
+ suffix="Esq.",
128
+ prefix="Dr.",
129
+ birthday='4567-12-12',
130
+ phones=phones,
131
+ emails=emails,
132
+ urls=urls,
133
+ latitude=nil, longitude=nil, name=nil, address=nil, type=nil, url=nil, caption=nil, filename=nil, message_id=nil, emoji=nil,
134
+ contact_addresses=contact_addresses,
135
+
56
136
  )
137
+ # response = @client.whatsapp.get_status(request_id="81eca535-8131-4866-be18-b3d933604069")
57
138
  puts response
139
+ end
140
+
141
+ # Freeform: Text
142
+ def test_send_whatsapp_freeform_text
58
143
  response = @client.whatsapp.send_whatsapp_freeform_message(
59
- originator= "91906154XXXX",
60
- recipient= "+91999999XXXX",
61
- message_type="CONTACTS", first_name="Amal", last_name="Anu", formatted_name="Amal Anu", phones=["91906152XXXX"], emails = ["amal@gmail.com"]
144
+ originator='971563XXXXXX',
145
+ recipient='+991999999XXXX',
146
+ message_type='TEXT',
147
+ body='HI',
148
+
62
149
  )
63
- response = @client.whatsapp.get_status(request_id="81eca535-8131-4866-be18-b3d933604069")
64
150
  puts response
65
151
  end
66
152
 
67
- def test_send_whatsapp_freeform_message_text
153
+
154
+ # Freeform: Reaction
155
+ def test_send_whatsapp_freeform_text
68
156
  response = @client.whatsapp.send_whatsapp_freeform_message(
69
- originator= "+XXXXXXXXXXXX",
70
- recipient= "XXXXXXXXXXX",
71
- message_type= "TEXT",
72
- body= "Hi",
157
+ originator='971563XXXXXX',
158
+ recipient='+991999999XXXX',
159
+ message_type='REACTION',
160
+ body=nil, first_name=nil, last_name=nil, formatted_name=nil, middle_name=nil, suffix=nil, prefix=nil, birthday=nil, phones=nil, emails=nil, urls=nil, latitude=nil, longitude=nil, name=nil, address=nil, type=nil, url=nil, caption=nil, filename=nil,
161
+ message_id="3e382940-1cd6-11ef-883c-0242ac1b002c",
162
+ emoji= "😀"
73
163
  )
74
164
  puts response
75
165
  end
76
166
 
77
- def test_send_whatsapp_freeform_message_attachment
78
- response = @client.whatsapp.send_whatsapp_freeform_message(
79
- originator= "+XXXXXXXXXXXX",
80
- recipient= "XXXXXXXXXXX",
81
- message_type= "ATTACHMENT",
82
- type= "image",
83
- url= "https=//upload.wikimedia.org",
84
- caption= "Tet"
167
+
168
+ # // ATTACHMENT: image
169
+ def test_send_whatsapp_freeform_text
170
+ response = @client.whatsapp.send_whatsapp_freeform_message(
171
+ originator='971563XXXXXX',
172
+ recipient='+991999999XXXX',
173
+ message_type='ATTACHMENT',
174
+ body=nil, first_name=nil, last_name=nil, formatted_name=nil, middle_name=nil, suffix=nil, prefix=nil, birthday=nil, phones=nil, emails=nil, urls=nil, latitude=nil, longitude=nil, name=nil, address=nil,
175
+ type='image',
176
+ url='https://t4.ftcdn.net/jpg/01/43/23/83/360_F_143238306_lh0ap42wgot36y44WybfQpvsJB5A1CHc.jpg',
177
+ caption='Tet'
178
+ )
179
+ puts response
180
+ end
181
+
182
+
183
+ # // ATTACHMENT: video
184
+ def test_send_whatsapp_freeform_text
185
+ response = @client.whatsapp.send_whatsapp_freeform_message(
186
+ originator='971563XXXXXX',
187
+ recipient='+991999999XXXX',
188
+ message_type='ATTACHMENT',
189
+ body=nil, first_name=nil, last_name=nil, formatted_name=nil, middle_name=nil, suffix=nil, prefix=nil, birthday=nil, phones=nil, emails=nil, urls=nil, latitude=nil, longitude=nil, name=nil, address=nil,
190
+ type='video',
191
+ url='https://www.onirikal.com/videos/mp4/nestlegold.mp4',
192
+ caption='Tet'
193
+ )
194
+ puts response
195
+ end
196
+
197
+ # // ATTACHMENT: document
198
+ def test_send_whatsapp_freeform_text
199
+ response = @client.whatsapp.send_whatsapp_freeform_message(
200
+ originator='971563XXXXXX',
201
+ recipient='+991999999XXXX',
202
+ message_type='ATTACHMENT',
203
+ body=nil, first_name=nil, last_name=nil, formatted_name=nil, middle_name=nil, suffix=nil, prefix=nil, birthday=nil, phones=nil, emails=nil, urls=nil, latitude=nil, longitude=nil, name=nil, address=nil,
204
+ type='document',
205
+ url='https://www.clickdimensions.com/links/TestPDFfile.pdf',
206
+ caption= "Test PDF file pdf",
207
+ filename= "TestPDFfile.pdf"
208
+ )
209
+ puts response
210
+ end
211
+
212
+ # // ATTACHMENT: audio
213
+ def test_send_whatsapp_freeform_text
214
+ response = @client.whatsapp.send_whatsapp_freeform_message(
215
+ originator='971563XXXXXX',
216
+ recipient='+991999999XXXX',
217
+ message_type='ATTACHMENT',
218
+ body=nil, first_name=nil, last_name=nil, formatted_name=nil, middle_name=nil, suffix=nil, prefix=nil, birthday=nil, phones=nil, emails=nil, urls=nil, latitude=nil, longitude=nil, name=nil, address=nil,
219
+ type='audio',
220
+ url='http://fate-suite.ffmpeg.org/mpegaudio/extra_overread.mp3'
221
+ )
222
+ puts response
223
+ end
224
+
225
+
226
+ # // ATTACHMENT: sticker
227
+ def test_send_whatsapp_freeform_text
228
+ response = @client.whatsapp.send_whatsapp_freeform_message(
229
+ originator='971563XXXXXX',
230
+ recipient='+991999999XXXX',
231
+ message_type='ATTACHMENT',
232
+ body=nil, first_name=nil, last_name=nil, formatted_name=nil, middle_name=nil, suffix=nil, prefix=nil, birthday=nil, phones=nil, emails=nil, urls=nil, latitude=nil, longitude=nil, name=nil, address=nil,
233
+ type='sticker',
234
+ url='https://raw.githubusercontent.com/sagarbhavsar4328/dummys3bucket/master/sample3.webp'
235
+ )
236
+ puts response
237
+ end
238
+
239
+ # // Location
240
+ def test_send_whatsapp_freeform_text
241
+ response = @client.whatsapp.send_whatsapp_freeform_message(
242
+ originator='971563XXXXXX',
243
+ recipient='+991999999XXXX',
244
+ message_type='LOCATION',
245
+ body=nil, first_name=nil, last_name=nil, formatted_name=nil, middle_name=nil, suffix=nil, prefix=nil, birthday=nil, phones=nil, emails=nil, urls=nil,
246
+ latitude='12.93803129081362',
247
+ longitude='77.61088653615994',
248
+ name='Mobile Pvt Ltd',
249
+ address='Bengaluru, Karnataka 56009'
250
+ )
251
+ puts response
252
+ end
253
+
254
+ # // Templated: no body parm
255
+ def test_send_whatsapp_templated_message
256
+ response = @client.whatsapp.send_whatsapp_templated_message(
257
+ originator='971563XXXXXX',
258
+ recipient='991999999XXXX',
259
+ template_id="testing_alpha", language="en"
260
+ )
261
+ puts response
262
+ end
263
+
264
+ # // Templated: with body parm
265
+ def test_send_whatsapp_templated_message
266
+ response = @client.whatsapp.send_whatsapp_templated_message(
267
+ originator='971563XXXXXX',
268
+ recipient='991999999XXXX',
269
+ template_id="with_personalize",
270
+ language="en",
271
+ body_parameter_values={"0": "Anil"}
272
+ )
273
+ puts response
274
+ end
275
+
276
+ # Templated: Text
277
+ def test_send_whatsapp_templated_message
278
+ response = @client.whatsapp.send_whatsapp_templated_message(
279
+ originator='971563XXXXXX',
280
+ recipient='991999999XXXX',
281
+ template_id="header_param", language="en",
282
+ body_parameter_values=nil,
283
+ media_type="text",
284
+ text_header_title="Ds"
285
+ )
286
+ puts response
287
+ end
288
+
289
+ # Templated: Image
290
+ def test_send_whatsapp_templated_message
291
+ response = @client.whatsapp.send_whatsapp_templated_message(
292
+ originator='971563XXXXXX',
293
+ recipient='991999999XXXX',
294
+ template_id="image",
295
+ language="en",
296
+ body_parameter_values=nil,
297
+ media_type="image",
298
+ text_header_title=nil,
299
+ media_url='https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg'
300
+ )
301
+ puts response
302
+ end
303
+
304
+ # Templated: Video
305
+ def test_send_whatsapp_templated_message
306
+ response = @client.whatsapp.send_whatsapp_templated_message(
307
+ originator='971563XXXXXX',
308
+ recipient='991999999XXXX',
309
+ template_id="video",
310
+ language="en",
311
+ body_parameter_values=nil,
312
+ media_type="video",
313
+ text_header_title=nil,
314
+ media_url='http://www.onirikal.com/videos/mp4/nestlegold.mp4'
315
+ )
316
+ puts response
317
+ end
318
+
319
+ # Templated: document
320
+ def test_send_whatsapp_templated_message
321
+ response = @client.whatsapp.send_whatsapp_templated_message(
322
+ originator='971563XXXXXX',
323
+ recipient='991999999XXXX',
324
+ template_id="document",
325
+ language="en",
326
+ body_parameter_values={"0": "first_parameter_in_your_template"},
327
+ media_type="document",
328
+ text_header_title=nil,
329
+ media_url='https://www.clickdimensions.com/links/TestPDFfile.pdf'
330
+ )
331
+ puts response
332
+ end
333
+
334
+ # Templated: Location
335
+ def test_send_whatsapp_templated_message
336
+ response = @client.whatsapp.send_whatsapp_templated_message(
337
+ originator='971563XXXXXX',
338
+ recipient='991999999XXXX',
339
+ template_id='location',
340
+ language='en',
341
+ body_parameter_values=nil,
342
+ media_type='location',
343
+ text_header_title=nil, media_url=nil,
344
+ latitude='12.93803129081362',
345
+ longitude='77.61088653615994',
346
+ name='Mobile Pvt Ltd',
347
+ address='30, Hosur Rd, 7th Block, Koramangala, Bengaluru, Karnataka 560095'
348
+ )
349
+ puts response
350
+ end
351
+
352
+ # # Templated: quick_replies
353
+ def test_send_whatsapp_templated_message
354
+ quick_replies = [
355
+ {
356
+ "button_index" => "0",
357
+ "button_payload" => "1"
358
+ },
359
+ {
360
+ "button_index" => "1",
361
+ "button_payload" => "2"
362
+ }
363
+ ]
364
+ response = @client.whatsapp.send_whatsapp_templated_message(
365
+ originator='971563XXXXXX',
366
+ recipient='991999999XXXX',
367
+ template_id="quick_reply",
368
+ language="en",
369
+ body_parameter_values=nil, media_type=nil, text_header_title=nil, media_url=nil, latitude=nil, longitude=nil, name=nil, address=nil,lto_expiration_time_ms=nil, coupon_code=nil,
370
+ quick_replies=quick_replies
371
+ )
372
+ puts response
373
+ end
374
+
375
+
376
+ # Templated: actions
377
+ actions = [
378
+ {
379
+ "action_type" => "url",
380
+ "action_index" => "0",
381
+ "action_payload" => "dash"
382
+ }
383
+ ]
384
+
385
+ def test_send_whatsapp_templated_message
386
+ actions = [
387
+ {
388
+ "action_type" => "url",
389
+ "action_index" => "0",
390
+ "action_payload" => "dash"
391
+ }
392
+ ]
393
+ response = @client.whatsapp.send_whatsapp_templated_message(
394
+ originator='971563XXXXXX',
395
+ recipient='991999999XXXX',
396
+ template_id="call_to_action",
397
+ language="en",
398
+ body_parameter_values=nil, media_type=nil, text_header_title=nil, media_url=nil, latitude=nil, longitude=nil, name=nil, address=nil,lto_expiration_time_ms=nil, coupon_code=nil,
399
+ quick_replies=nil,
400
+ actions=actions
401
+ )
402
+ puts response
403
+ end
404
+
405
+ # // Templated: coupon_code
406
+ def test_send_whatsapp_templated_message
407
+ response = @client.whatsapp.send_whatsapp_templated_message(
408
+ originator='971563XXXXXX',
409
+ recipient='991999999XXXX',
410
+ template_id="coupon_code",
411
+ language="en",
412
+ body_parameter_values={"0": "first_parameter_in_your_template"},
413
+ media_type=nil, text_header_title=nil, media_url=nil, latitude=nil, longitude=nil, name=nil, address=nil,lto_expiration_time_ms=nil,
414
+ coupon_code="DAS558HG"
415
+ )
416
+ puts response
417
+ end
418
+
419
+ # Templated: LTO
420
+ def test_send_whatsapp_templated_message
421
+ response = @client.whatsapp.send_whatsapp_templated_message(
422
+ originator='971563XXXXXX',
423
+ recipient='991999999XXXX',
424
+ template_id="limited_time_offer", language="en",
425
+ body_parameter_values=nil,
426
+ media_type="image",
427
+ text_header_title=nil,
428
+ media_url="https://t4.ftcdn.net/jpg/01/43/23/83/360_F_143238306_lh0ap42wgot36y44WybfQpvsJB5A1CHc.jpg",
429
+ latitude=nil, longitude=nil, name=nil, address=nil,
430
+ lto_expiration_time_ms="1708804800000",
431
+ coupon_code="DWS44"
432
+ )
433
+ puts response
434
+ end
435
+
436
+ # // Templated: Carousel
437
+ def test_send_whatsapp_templated_message
438
+ cards = [
439
+ {
440
+ "card_index" => "0",
441
+ "components" => [
442
+ {
443
+ "type" => "header",
444
+ "parameters" => [
445
+ {
446
+ "type" => "image",
447
+ "image" => {
448
+ "link" => "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
449
+ }
450
+ }
451
+ ]
452
+ },
453
+ {
454
+ "type" => "button",
455
+ "sub_type" => "quick_reply",
456
+ "index" => "0",
457
+ "parameters" => [
458
+ {
459
+ "type" => "payload",
460
+ "payload" => "2259NqSd"
461
+ }
462
+ ]
463
+ }
464
+ ]
465
+ },
466
+ {
467
+ "card_index" => "1",
468
+ "components" => [
469
+ {
470
+ "type" => "header",
471
+ "parameters" => [
472
+ {
473
+ "type" => "image",
474
+ "image" => {
475
+ "link" => "https://www.selfdrive.ae/banner_image/desktop/21112023164328_409449002729.jpg"
476
+ }
477
+ }
478
+ ]
479
+ },
480
+ {
481
+ "type" => "button",
482
+ "sub_type" => "quick_reply",
483
+ "index" => "0",
484
+ "parameters" => [
485
+ {
486
+ "type" => "payload",
487
+ "payload" => "59NqSdd"
488
+ }
489
+ ]
490
+ }
491
+ ]
492
+ }
493
+ ]
494
+ response = @client.whatsapp.send_whatsapp_templated_message(
495
+ originator='971563XXXXXX',
496
+ recipient='991999999XXXX',
497
+ template_id="carousel_card",
498
+ language="en",
499
+ body_parameter_values=nil, media_type=nil, text_header_title=nil, media_url=nil, latitude=nil, longitude=nil, name=nil, address=nil,lto_expiration_time_ms=nil, coupon_code=nil,
500
+ quick_replies=nil, actions=nil, carousel_cards=cards
85
501
  )
86
502
  puts response
87
503
  end
504
+
505
+ # Interactive : cta
506
+ def test_send_whatsapp_interactive_message
507
+ parameters = {
508
+ "display_text": "Visit Us",
509
+ "url": "https://www.luckyshrub.com?clickID=kqDGWd24Q5TRwoEQTICY7W1JKoXvaZOXWAS7h1P76s0R7Paec4"
510
+ }
511
+ response = @client.whatsapp.send_whatsapp_interactive_message(
512
+ originator='971563XXXXXX',
513
+ recipient='991999999XXXX',
514
+ interactive_type= "cta_url",
515
+ header_type= "text",
516
+ header_text= "Payment$ for D7 Whatsapp Service",
517
+ header_link=nil, header_file_name=nil,
518
+ body_text= "Direct7 Networks is a messaging service provider that specializes in helping organizations efficiently communicate with their customers.",
519
+ footer_text= "Thank You",
520
+ parameters= parameters
521
+ )
522
+ puts response
523
+ end
524
+
525
+
526
+ # Interactive : button
527
+ def test_send_whatsapp_interactive_message
528
+ buttons = [{"type": "reply", "reply": {"id": "1", "title": "Debit Card"}}, {
529
+ "type": "reply",
530
+ "reply": {"id": "2", "title": "Credit"}
531
+ }]
532
+ response = @client.whatsapp.send_whatsapp_interactive_message(
533
+ originator='971563XXXXXX',
534
+ recipient='991999999XXXX',
535
+ interactive_type= "button",
536
+ header_type= "text",
537
+ header_text= "Payment$ for D7 Whatsapp Service",
538
+ header_link=nil, header_file_name=nil,
539
+ body_text= "Direct7 Networks is a messaging service provider that specializes in helping organizations efficiently communicate with their customers.",
540
+ footer_text= "Thank You",
541
+ parameters= nil, sections=nil,
542
+ buttons=buttons
543
+ )
544
+ puts response
545
+ end
546
+
547
+ # Interactive : list
548
+ def test_send_whatsapp_interactive_message
549
+ sections = [
550
+ {
551
+ "title": "SMS Messaging",
552
+ "rows": [
553
+ {
554
+ "id": "1",
555
+ "title": "Normal SMS",
556
+ "description": "Signup for free at the D7 platform to use our Messaging APIs."
557
+ },
558
+ {
559
+ "id": "2",
560
+ "title": "Verify",
561
+ "description": "D7 Verify API is to applications requires SMS based OTP authentications."
562
+ }
563
+ ]
564
+ },
565
+ {
566
+ "title": "Whatsapp",
567
+ "rows": [
568
+ {
569
+ "id": "3",
570
+ "title": "WhatsApp Messages",
571
+ "description": "D7 Whatsapp API is to applications requires pre-registration."
572
+ }
573
+ ]
574
+ }
575
+ ]
576
+ response = @client.whatsapp.send_whatsapp_interactive_message(
577
+ originator='971563XXXXXX',
578
+ recipient='991999999XXXX',
579
+ interactive_type= "list",
580
+ header_type= "text",
581
+ header_text= "Payment$ for D7 Whatsapp Service",
582
+ header_link=nil, header_file_name=nil,
583
+ body_text= "Direct7 Networks is a messaging service provider that specializes in helping organizations efficiently communicate with their customers.",
584
+ footer_text= "Thank You",
585
+ parameters= nil, sections=sections,
586
+ buttons=nil, list_button_text='Choose Service'
587
+ )
588
+ puts response
589
+ end
590
+
88
591
  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.13
4
+ version: 0.0.15
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-03-11 00:00:00.000000000 Z
11
+ date: 2024-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -129,6 +129,8 @@ files:
129
129
  - direct7-0.0.10.gem
130
130
  - direct7-0.0.11.gem
131
131
  - direct7-0.0.12.gem
132
+ - direct7-0.0.13.gem
133
+ - direct7-0.0.14.gem
132
134
  - direct7.gemspec
133
135
  - doc/Direct7.html
134
136
  - doc/Direct7/AuthenticationError.html
@@ -2216,7 +2218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
2216
2218
  - !ruby/object:Gem::Version
2217
2219
  version: '0'
2218
2220
  requirements: []
2219
- rubygems_version: 3.4.22
2221
+ rubygems_version: 3.3.5
2220
2222
  signing_key:
2221
2223
  specification_version: 4
2222
2224
  summary: Ruby SDK for Direct7 Platform REST API