plivo 4.16.0 → 4.58.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/unitTests.yml +32 -0
  3. data/.gitignore +1 -0
  4. data/CHANGELOG.md +225 -0
  5. data/Dockerfile +12 -0
  6. data/Gemfile +1 -0
  7. data/Makefile +18 -0
  8. data/README.md +389 -20
  9. data/docker-compose.yml +18 -0
  10. data/examples/tollfree_verification.rb +42 -0
  11. data/lib/plivo/base/resource.rb +30 -0
  12. data/lib/plivo/base/resource_interface.rb +18 -2
  13. data/lib/plivo/base.rb +3 -3
  14. data/lib/plivo/base_client.rb +9 -9
  15. data/lib/plivo/interactive.rb +139 -0
  16. data/lib/plivo/location.rb +22 -0
  17. data/lib/plivo/resources/brand.rb +98 -0
  18. data/lib/plivo/resources/call_feedback.rb +0 -1
  19. data/lib/plivo/resources/calls.rb +183 -29
  20. data/lib/plivo/resources/campaign.rb +168 -0
  21. data/lib/plivo/resources/messages.rb +392 -58
  22. data/lib/plivo/resources/multipartycalls.rb +637 -0
  23. data/lib/plivo/resources/numbers.rb +40 -7
  24. data/lib/plivo/resources/profile.rb +93 -0
  25. data/lib/plivo/resources/recordings.rb +29 -2
  26. data/lib/plivo/resources/token.rb +66 -0
  27. data/lib/plivo/resources/tollfree_verification.rb +178 -0
  28. data/lib/plivo/resources/verify_caller_id.rb +110 -0
  29. data/lib/plivo/resources/verify_session.rb +106 -0
  30. data/lib/plivo/resources.rb +8 -0
  31. data/lib/plivo/rest_client.rb +14 -1
  32. data/lib/plivo/template.rb +102 -0
  33. data/lib/plivo/utils.rb +112 -1
  34. data/lib/plivo/version.rb +1 -1
  35. data/lib/plivo/xml/cont.rb +13 -0
  36. data/lib/plivo/xml/dial.rb +1 -1
  37. data/lib/plivo/xml/element.rb +9 -2
  38. data/lib/plivo/xml/emphasis.rb +1 -1
  39. data/lib/plivo/xml/lang.rb +1 -1
  40. data/lib/plivo/xml/multipartycall.rb +216 -0
  41. data/lib/plivo/xml/p.rb +1 -1
  42. data/lib/plivo/xml/plivo_xml.rb +2 -2
  43. data/lib/plivo/xml/prosody.rb +1 -1
  44. data/lib/plivo/xml/response.rb +1 -1
  45. data/lib/plivo/xml/s.rb +1 -1
  46. data/lib/plivo/xml/speak.rb +1 -1
  47. data/lib/plivo/xml/stream.rb +27 -0
  48. data/lib/plivo/xml/w.rb +1 -1
  49. data/lib/plivo/xml.rb +3 -1
  50. data/plivo.gemspec +1 -2
  51. data/setup_sdk.sh +47 -0
  52. metadata +24 -19
  53. data/.travis.yml +0 -11
@@ -29,7 +29,24 @@ module Plivo
29
29
  to_number: @to_number,
30
30
  total_amount: @total_amount,
31
31
  total_rate: @total_rate,
32
- units: @units
32
+ powerpack_id: @powerpack_id,
33
+ units: @units,
34
+ tendlc_campaign_id: @tendlc_campaign_id,
35
+ destination_country_iso2: @destination_country_iso2,
36
+ tendlc_registration_status: @tendlc_registration_status,
37
+ requester_ip: @requester_ip,
38
+ is_domestic: @is_domestic,
39
+ replaced_sender: @replaced_sender,
40
+ dlt_entity_id: @dlt_entity_id,
41
+ dlt_template_id: @dlt_template_id,
42
+ dlt_template_category: @dlt_template_category,
43
+ destination_network: @destination_network,
44
+ carrier_fees_rate: @carrier_fees_rate,
45
+ carrier_fees: @carrier_fees,
46
+ conversation_id: @conversation_id,
47
+ conversation_origin: @conversation_origin,
48
+ conversation_expiration_timestamp: @conversation_expiration_timestamp,
49
+ log: @log
33
50
  }.to_s
34
51
  end
35
52
  end
@@ -51,7 +68,7 @@ module Plivo
51
68
  # @param [Array] dst
52
69
  # @param [String] text
53
70
  # @param [Hash] options
54
- # @option options [String] :type The type of message. Should be `sms` or `mms`. Defaults to `sms`.
71
+ # @option options [String] :type The type of message. Should be `sms` or `mms` or `whatsapp`. Defaults to `sms`.
55
72
  # @option options [String] :url The URL to which with the status of the message is sent. The following parameters are sent to the URL:
56
73
  # - To - Phone number of the recipient
57
74
  # - From - Phone number of the sender
@@ -68,72 +85,375 @@ module Plivo
68
85
  # @option options [String] :method The method used to call the url. Defaults to POST.
69
86
  # @option options [String] :log If set to false, the content of this message will not be logged on the Plivo infrastructure and the dst value will be masked (e.g., 141XXXXX528). Default is set to true.
70
87
  # @option options [String] :trackable set to false
71
- #@option options[List]: media_urls Minimum one media url should be present in Media urls list to send mms. Maximum allowd 10 media urls inside the list (e.g, media_urls : ['https//example.com/test.jpg', 'https://example.com/abcd.gif'])
72
- #@option options[List]: media_ids Minimum one media ids should be present in Media ids list to send mms. Maximum allowd 10 media ids inside the list (e.g, media_ids : ['1fs211ba-355b-11ea-bbc9-02121c1190q7'])
73
-
74
- def create(src, dst, text = nil, options = nil, powerpack_uuid = nil)
75
- valid_param?(:src, src, [Integer, String, Symbol], false)
76
- valid_param?(:text, text, [String, Symbol], false)
77
- valid_param?(:dst, dst, Array, true)
78
- valid_param?(:powerpack_uuid, powerpack_uuid, [String, Symbol], false)
79
- dst.each do |dst_num|
80
- valid_param?(:dst_num, dst_num, [Integer, String, Symbol], true)
81
- end
88
+ # @option options[Int]: message_expiry, int value
89
+ # @option options[List]: media_urls Minimum one media url should be present in Media urls list to send mms. Maximum allowd 10 media urls inside the list (e.g, media_urls : ['https//example.com/test.jpg', 'https://example.com/abcd.gif'])
90
+ # @option options[List]: media_ids Minimum one media ids should be present in Media ids list to send mms. Maximum allowd 10 media ids inside the list (e.g, media_ids : ['1fs211ba-355b-11ea-bbc9-02121c1190q7'])
91
+ # @option options [String] :dlt_entity_id This is the DLT entity id passed in the message request.
92
+ # @option options [String] :dlt_template_id This is the DLT template id passed in the message request.
93
+ # @option options [String] :dlt_template_category This is the DLT template category passed in the message request.
94
+ # @option options [Hash] :template This is the template used in the whatsapp message request. It can handle both JSON and String.
95
+ # @option options [Hash] :interactive This is the interactive parameter used in the whatsapp message request. It can handle both JSON and String.
96
+ # @option options [Hash] :location This is the location parameter used in the whatsapp message request. It can handle both JSON and String.
97
+
98
+ def create(src = nil, dst = nil, text = nil, options = nil, powerpack_uuid = nil)
99
+ #All params in One HASH
100
+ value = src
101
+ if(value.is_a?(Hash))
102
+ valid_param?(:src, value[:src], [Integer, String, Symbol], false)
103
+ valid_param?(:text, value[:text], [String, Symbol], false)
104
+ valid_param?(:dst, value[:dst], [String, Array], true)
105
+ valid_param?(:powerpack_uuid, value[:powerpack_uuid], [String, Symbol], false)
82
106
 
83
- if dst.include? src
84
- raise InvalidRequestError, 'src and dst cannot be same'
85
- end
107
+ if (value[:dst] == value[:src])
108
+ raise InvalidRequestError, 'src and dst cannot be same'
109
+ end
86
110
 
87
- if src.nil? && powerpack_uuid.nil?
88
- raise InvalidRequestError, 'src and powerpack uuid both cannot be nil'
89
- end
111
+ if value.key?(:value).nil? && value.key(:powerpack_uuid).nil?
112
+ raise InvalidRequestError, 'value and powerpack uuid both cannot be nil'
113
+ end
90
114
 
91
- if !src.nil? && !powerpack_uuid.nil?
92
- raise InvalidRequestError, 'src and powerpack uuid both cannot be present'
93
- end
115
+ if !value.key?(:value).nil? && !value.key(:powerpack_uuid).nil?
116
+ raise InvalidRequestError, 'value and powerpack uuid both cannot be present'
117
+ end
94
118
 
95
- params = {
96
- src: src,
97
- dst: dst.join('<'),
98
- text: text,
99
- powerpack_uuid: powerpack_uuid
100
- }
119
+ if !value.key?(:dst).nil? && !value.key(:powerpack_uuid).nil?
120
+ raise InvalidRequestError, 'dst is a required parameter'
121
+ end
101
122
 
102
- return perform_create(params) if options.nil?
103
- valid_param?(:options, options, Hash, true)
123
+ params = {
124
+ src: value[:src],
125
+ text: value[:text],
126
+ powerpack_uuid: value[:powerpack_uuid]
127
+ }
128
+ if (value[:dst].is_a?(Array))
129
+ value[:dst].each do |dst_num|
130
+ valid_param?(:dst_num, dst_num, [Integer, String, Symbol], true)
131
+ params[:dst] = value[:dst].join('<')
132
+ end
133
+ else
134
+ params[:dst] = value[:dst]
135
+ end
104
136
 
105
- if options.key?(:type) &&
106
- valid_param?(:type, options[:type], String, true, ['sms', 'mms'])
107
- params[:type] = options[:type]
108
- end
137
+ #Handling optional params in One HASH
138
+ if value.key?(:type) && valid_param?(:type, value[:type],String, true, %w[sms mms whatsapp])
139
+ params[:type] = value[:type]
140
+ end
141
+
142
+ if value.key?(:url) && valid_param?(:url, value[:url], String, true)
143
+ params[:url] = value[:url]
144
+ if value.key?(:method) &&
145
+ valid_param?(:method, value[:method], String, true, %w[POST GET])
146
+ params[:method] = value[:method]
147
+ else
148
+ params[:method] = 'POST'
149
+ end
150
+ end
151
+
152
+ if value.key?(:log)
153
+ log = value[:log]
154
+ if log.is_a?(TrueClass) || log.is_a?(FalseClass) # Check if log is boolean
155
+ params[:log] = log.to_s # Convert boolean to string
156
+ elsif log.is_a?(String) # Check if log is string
157
+ params[:log] = log
158
+ else
159
+ raise ArgumentError, "Invalid type for log parameter. Expected boolean or string."
160
+ end
161
+ end
162
+
163
+ if value.key?(:message_expiry) &&
164
+ valid_param?(:message_expiry, value[:message_expiry], [Integer, Integer], true)
165
+ params[:message_expiry] = value[:message_expiry]
166
+ end
167
+
168
+ if value.key?(:trackable) &&
169
+ valid_param?(:trackable, value[:trackable], [TrueClass, FalseClass], true)
170
+ params[:trackable] = value[:trackable]
171
+ end
172
+
173
+ if value.key?(:media_urls) &&
174
+ valid_param?(:media_urls, value[:media_urls], Array, true)
175
+ params[:media_urls] = value[:media_urls]
176
+ end
109
177
 
110
- if options.key?(:url) && valid_param?(:url, options[:url], String, true)
111
- params[:url] = options[:url]
112
- if options.key?(:method) &&
113
- valid_param?(:method, options[:method], String, true, %w[POST GET])
114
- params[:method] = options[:method]
178
+ if value.key?(:media_ids) &&
179
+ valid_param?(:media_ids, value[:media_ids], Array, true)
180
+ params[:media_ids] = value[:media_ids]
181
+ end
182
+
183
+ if value.key?(:dlt_entity_id) &&
184
+ valid_param?(:dlt_entity_id, value[:dlt_entity_id], String, true)
185
+ params[:dlt_entity_id] = value[:dlt_entity_id]
186
+ end
187
+
188
+ if value.key?(:dlt_template_id) &&
189
+ valid_param?(:dlt_template_id, value[:dlt_template_id], String, true)
190
+ params[:dlt_template_id] = value[:dlt_template_id]
191
+ end
192
+
193
+ if value.key?(:dlt_template_category) &&
194
+ valid_param?(:dlt_template_category, value[:dlt_template_category], String, true)
195
+ params[:dlt_template_category] = value[:dlt_template_category]
196
+ end
197
+
198
+ # handling whatsapp cases
199
+ if value.key?(:template) && value.key?(:type) && (value[:type] != "whatsapp")
200
+ raise InvalidRequestError, 'template parameter is only applicable when type is whatsapp'
201
+ end
202
+
203
+ if value.is_a?(Hash) && !value[:template].nil?
204
+ if value.key?(:template)
205
+ if value[:template].is_a?(String)
206
+ begin
207
+ json_template = JSON.parse(value[:template])
208
+ params[:template] = json_template
209
+ rescue JSON::ParserError => e
210
+ raise InvalidRequestError, 'failed to parse template as JSON'
211
+ end
212
+ elsif value[:template].is_a?(Hash)
213
+ params[:template] = value[:template]
214
+ elsif value[:template].is_a?(Plivo::Template)
215
+ params[:template] = value[:template].to_hash
216
+ else
217
+ raise InvalidRequestError, 'invalid template format'
218
+ end
219
+ end
220
+ end
221
+
222
+ if !params[:template].nil? && value[:template].is_a?(String)
223
+ if params.dig(:template, "name").to_s.empty? || params.dig(:template, "language").to_s.empty?
224
+ raise InvalidRequestError, 'template name and language must not be null or empty'
225
+ end
115
226
  else
116
- params[:method] = 'POST'
227
+ if !params[:template].nil? && (params.dig(:template, :name).to_s.empty? || params.dig(:template, :language).to_s.empty?)
228
+ raise InvalidRequestError, 'template name and language must not be null or empty'
229
+ end
117
230
  end
118
- end
119
231
 
120
- if options.key?(:log) &&
121
- valid_param?(:log, options[:log], [TrueClass, FalseClass], true)
122
- params[:log] = options[:log]
123
- end
232
+ if value.key?(:template) && value.key?(:type) && (value[:type] != "whatsapp")
233
+ raise InvalidRequestError, 'template parameter is only applicable when type is whatsapp'
234
+ end
124
235
 
125
- if options.key?(:trackable) &&
126
- valid_param?(:trackable, options[:trackable], [TrueClass, FalseClass], true)
127
- params[:trackable] = options[:trackable]
236
+ if value.is_a?(Hash) && !value[:interactive].nil?
237
+ if value.key?(:interactive)
238
+ if value[:interactive].is_a?(String)
239
+ begin
240
+ json_interactive = JSON.parse(value[:interactive])
241
+ params[:interactive] = json_interactive
242
+ rescue JSON::ParserError => e
243
+ raise InvalidRequestError, 'failed to parse interactive as JSON'
244
+ end
245
+ elsif value[:interactive].is_a?(Hash)
246
+ params[:interactive] = value[:interactive]
247
+ elsif value[:interactive].is_a?(Plivo::Interactive)
248
+ params[:interactive] = value[:interactive].to_hash
249
+ else
250
+ raise InvalidRequestError, 'invalid interactive format'
251
+ end
252
+ end
128
253
  end
129
254
 
130
- if options.key?(:media_urls) &&
131
- valid_param?(:media_urls, options[:media_urls], Array, true)
132
- params[:media_urls] = options[:media_urls]
255
+ if value.is_a?(Hash) && !value[:location].nil?
256
+ if value.key?(:location)
257
+ if value[:location].is_a?(String)
258
+ begin
259
+ json_location = JSON.parse(value[:location])
260
+ params[:location] = json_location
261
+ rescue JSON::ParserError => e
262
+ raise InvalidRequestError, 'failed to parse location as JSON'
263
+ end
264
+ elsif value[:location].is_a?(Hash)
265
+ params[:location] = value[:location]
266
+ elsif value[:location].is_a?(Plivo::Location)
267
+ params[:location] = value[:location].to_hash
268
+ else
269
+ raise InvalidRequestError, 'invalid location format'
270
+ end
271
+ end
133
272
  end
134
- if options.key?(:media_ids) &&
135
- valid_param?(:media_ids, options[:media_ids], Array, true)
136
- params[:media_ids] = options[:media_ids]
273
+
274
+ #legacy code compatibility
275
+ else
276
+ valid_param?(:src, src, [Integer, String, Symbol], false)
277
+ valid_param?(:text, text, [String, Symbol], false)
278
+ valid_param?(:dst, dst, [String, Array], true)
279
+ valid_param?(:powerpack_uuid, powerpack_uuid, [String, Symbol], false)
280
+ dst.each do |dst_num|
281
+ valid_param?(:dst_num, dst_num, [Integer, String, Symbol], true)
282
+ end
283
+
284
+ if dst.include? src
285
+ raise InvalidRequestError, 'src and dst cannot be same'
286
+ end
287
+
288
+ if src.nil? && powerpack_uuid.nil?
289
+ raise InvalidRequestError, 'src and powerpack uuid both cannot be nil'
290
+ end
291
+
292
+ if !src.nil? && !powerpack_uuid.nil?
293
+ raise InvalidRequestError, 'src and powerpack uuid both cannot be present'
294
+ end
295
+
296
+ params = {
297
+ src: src,
298
+ text: text,
299
+ powerpack_uuid: powerpack_uuid
300
+ }
301
+
302
+ if (dst.is_a?(Array))
303
+ dst.each do |dst_num|
304
+ valid_param?(:dst_num, dst_num, [Integer, String, Symbol], true)
305
+ params[:dst] = dst.join('<')
306
+ end
307
+ else
308
+ params[:dst] = dst
309
+ end
310
+
311
+ return perform_create(params) if options.nil?
312
+ valid_param?(:options, options, Hash, true)
313
+
314
+ if options.key?(:type) &&
315
+ valid_param?(:type, options[:type], String, true, %w[sms mms whatsapp])
316
+ params[:type] = options[:type]
317
+ end
318
+
319
+ if options.key?(:url) && valid_param?(:url, options[:url], String, true)
320
+ params[:url] = options[:url]
321
+ if options.key?(:method) &&
322
+ valid_param?(:method, options[:method], String, true, %w[POST GET])
323
+ params[:method] = options[:method]
324
+ else
325
+ params[:method] = 'POST'
326
+ end
327
+ end
328
+
329
+ if options.key?(:media_urls) &&
330
+ valid_param?(:media_urls, options[:media_urls], Array, true)
331
+ params[:media_urls] = options[:media_urls]
332
+ end
333
+
334
+ if options.key?(:media_ids) &&
335
+ valid_param?(:media_ids, options[:media_ids], Array, true)
336
+ params[:media_ids] = options[:media_ids]
337
+ end
338
+
339
+ if options.key?(:log)
340
+ log = options[:log]
341
+ if log.is_a?(TrueClass) || log.is_a?(FalseClass) # Check if log is boolean
342
+ params[:log] = log.to_s # Convert boolean to string
343
+ elsif log.is_a?(String) # Check if log is string
344
+ params[:log] = log
345
+ else
346
+ raise ArgumentError, "Invalid type for log parameter. Expected boolean or string."
347
+ end
348
+ end
349
+
350
+ if options.key?(:media_urls) &&
351
+ valid_param?(:media_urls, options[:media_urls], Array, true)
352
+ params[:media_urls] = options[:media_urls]
353
+ end
354
+
355
+ if options.key?(:media_ids) &&
356
+ valid_param?(:media_ids, options[:media_ids], Array, true)
357
+ params[:media_ids] = options[:media_ids]
358
+ end
359
+
360
+ if options.key?(:message_expiry) &&
361
+ valid_param?(:message_expiry, options[:message_expiry], [Integer, Integer], true)
362
+ params[:message_expiry] = options[:message_expiry]
363
+ end
364
+
365
+ if options.key?(:trackable) &&
366
+ valid_param?(:trackable, options[:trackable], [TrueClass, FalseClass], true)
367
+ params[:trackable] = options[:trackable]
368
+ end
369
+
370
+ if options.key?(:dlt_entity_id) &&
371
+ valid_param?(:dlt_entity_id, options[:dlt_entity_id], String, true)
372
+ params[:dlt_entity_id] = options[:dlt_entity_id]
373
+ end
374
+
375
+ if options.key?(:dlt_template_id) &&
376
+ valid_param?(:dlt_template_id, options[:dlt_template_id], String, true)
377
+ params[:dlt_template_id] = options[:dlt_template_id]
378
+ end
379
+
380
+ if options.key?(:dlt_template_category) &&
381
+ valid_param?(:dlt_template_category, options[:dlt_template_category], String, true)
382
+ params[:dlt_template_category] = options[:dlt_template_category]
383
+ end
384
+
385
+ # handling whatsapp cases
386
+ if options.key?(:template) && options.key?(:type) && (options[:type] != "whatsapp")
387
+ raise InvalidRequestError, 'template parameter is only applicable when type is whatsapp'
388
+ end
389
+
390
+ if options.is_a?(Hash) && !options[:template].nil?
391
+ if options.key?(:template)
392
+ if options[:template].is_a?(String)
393
+ begin
394
+ json_template = JSON.parse(options[:template])
395
+ params[:template] = json_template
396
+ rescue JSON::ParserError => e
397
+ raise InvalidRequestError, 'failed to parse template as JSON'
398
+ end
399
+ elsif options[:template].is_a?(Hash)
400
+ params[:template] = options[:template]
401
+ elsif options[:template].is_a?(Plivo::Template)
402
+ params[:template] = options[:template].to_hash
403
+ else
404
+ raise InvalidRequestError, 'invalid template format'
405
+ end
406
+ end
407
+ end
408
+
409
+ if !options[:template].nil? && options[:template].is_a?(String)
410
+ if options.dig(:template, "name").to_s.empty? || options.dig(:template, "language").to_s.empty?
411
+ raise InvalidRequestError, 'template name and language must not be null or empty'
412
+ end
413
+ else
414
+ if !options[:template].nil? && (options.dig(:template, :name).to_s.empty? || options.dig(:template, :language).to_s.empty?)
415
+ raise InvalidRequestError, 'template name and language must not be null or empty'
416
+ end
417
+ end
418
+
419
+ if options.is_a?(Hash) && !options[:interactive].nil?
420
+ if options.key?(:interactive)
421
+ if options[:interactive].is_a?(String)
422
+ begin
423
+ json_interactive = JSON.parse(options[:interactive])
424
+ params[:interactive] = json_interactive
425
+ rescue JSON::ParserError => e
426
+ raise InvalidRequestError, 'failed to parse interactive as JSON'
427
+ end
428
+ elsif options[:interactive].is_a?(Hash)
429
+ params[:interactive] = options[:interactive]
430
+ elsif options[:interactive].is_a?(Plivo::Interactive)
431
+ params[:interactive] = options[:interactive].to_hash
432
+ else
433
+ raise InvalidRequestError, 'invalid interactive format'
434
+ end
435
+ end
436
+ end
437
+
438
+ if options.is_a?(Hash) && !options[:location].nil?
439
+ if options.key?(:location)
440
+ if options[:location].is_a?(String)
441
+ begin
442
+ json_location = JSON.parse(options[:location])
443
+ params[:location] = json_location
444
+ rescue JSON::ParserError => e
445
+ raise InvalidRequestError, 'failed to parse location as JSON'
446
+ end
447
+ elsif options[:location].is_a?(Hash)
448
+ params[:location] = options[:location]
449
+ elsif options[:location].is_a?(Plivo::Location)
450
+ params[:location] = options[:location].to_hash
451
+ else
452
+ raise InvalidRequestError, 'invalid location format'
453
+ end
454
+ end
455
+ end
456
+
137
457
  end
138
458
  perform_create(params)
139
459
  end
@@ -141,6 +461,7 @@ module Plivo
141
461
  # @param [Hash] options
142
462
  # @option options [String] :subaccount The id of the subaccount, if message details of the subaccount is needed.
143
463
  # @option options [String] :message_direction Filter the results by message direction. The valid inputs are inbound and outbound.
464
+ # @option options [String] :message_type Filter the results by message type. The valid inputs are sms mms and whatsapp.
144
465
  # @option options [String] :message_time Filter out messages according to the time of completion. The filter can be used in the following five forms:
145
466
  # - message_time: The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. Eg:- To get all messages that were sent/received at 2012-03-21 11:47[:30], use message_time=2012-03-21 11:47[:30]
146
467
  # - message_time\__gt: gt stands for greater than. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. Eg:- To get all messages that were sent/received after 2012-03-21 11:47, use message_time\__gt=2012-03-21 11:47
@@ -152,8 +473,14 @@ module Plivo
152
473
  # @option options [Int] :limit Used to display the number of results per page. The maximum number of results that can be fetched is 20.
153
474
  # @option options [Int] :offset Denotes the number of value items by which the results should be offset. Eg:- If the result contains a 1000 values and limit is set to 10 and offset is set to 705, then values 706 through 715 are displayed in the results. This parameter is also used for pagination of the results.
154
475
  # @option options [String] :error_code Delivery Response code returned by the carrier attempting the delivery. See Supported error codes {https://www.plivo.com/docs/api/message/#standard-plivo-error-codes}.
155
- #@option options[List]: media_urls Minimum one media url should be present in Media urls list to send mms. Maximum allowd 10 media urls inside the list (e.g, media_urls : ['https//example.com/test.jpg', 'https://example.com/abcd.gif'])
156
- #@option options[List]: media_ids Minimum one media ids should be present in Media ids list to send mms. Maximum allowd 10 media ids inside the list (e.g, media_ids : ['1fs211ba-355b-11ea-bbc9-02121c1190q7'])
476
+ # @option options[List]: media_urls Minimum one media url should be present in Media urls list to send mms. Maximum allowd 10 media urls inside the list (e.g, media_urls : ['https//example.com/test.jpg', 'https://example.com/abcd.gif'])
477
+ # @option options[List]: media_ids Minimum one media ids should be present in Media ids list to send mms. Maximum allowd 10 media ids inside the list (e.g, media_ids : ['1fs211ba-355b-11ea-bbc9-02121c1190q7'])
478
+ # @option options [String] :powerpack_id Filter the results by powerpack id
479
+ # @option options [string]: tendlc_campaign_id - exact tendlc campaign id search
480
+ # @option options [string]:destination_country_iso2 - valid 2 character country_iso2
481
+ # @option options [string] : tendlc_registration_status - registered or unregistered enum allowed
482
+ # @option options [string] : conversation_id - The id of the conversation for whatsapp messages
483
+ # @option options [string] : conversartion_origin - The type of the conversation for whatsapp messages
157
484
  def list(options = nil)
158
485
  return perform_list if options.nil?
159
486
  valid_param?(:options, options, Hash, true)
@@ -161,7 +488,8 @@ module Plivo
161
488
  params = {}
162
489
  params_expected = %i[
163
490
  subaccount message_time message_time__gt message_time__gte
164
- message_time__lt message_time__lte error_code
491
+ message_time__lt message_time__lte error_code powerpack_id tendlc_campaign_id tendlc_registration_status destination_country_iso2
492
+ message_type conversation_id conversartion_origin
165
493
  ]
166
494
  params_expected.each do |param|
167
495
  if options.key?(param) &&
@@ -185,11 +513,17 @@ module Plivo
185
513
 
186
514
  if options.key?(:message_state) &&
187
515
  valid_param?(:message_state, options[:message_state],
188
- [String, Symbol], true, %w[queued sent failed delivered
516
+ [String, Symbol], true, %w[queued sent failed delivered read
189
517
  undelivered rejected])
190
518
  params[:message_state] = options[:message_state]
191
519
  end
192
520
 
521
+ if options.key?(:message_type) &&
522
+ valid_param?(:message_type, options[:message_type],
523
+ [String, Symbol], true, %w[sms mms whatsapp])
524
+ params[:message_type] = options[:message_type]
525
+ end
526
+
193
527
  if options.key?(:limit) &&
194
528
  (options[:limit] > 20 || options[:limit] <= 0)
195
529
  raise_invalid_request('The maximum number of results that can be '\