plivo 4.56.0 → 4.57.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/plivo/interactive.rb +139 -0
- data/lib/plivo/resources/messages.rb +43 -0
- data/lib/plivo/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a90c7167882dbe60104e0ff29cf88e4b4df1d762
|
4
|
+
data.tar.gz: e52148f05ce9e96049b63ea1453f9c050932c303
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 418f3f2d85ea8482e99314de098c8719dae66581a5f9ea9d470ecb7f3820b3829a0348ea704810928d73a513b3704fcce6b3c2058eab247c63fd7bcb6b2916cb
|
7
|
+
data.tar.gz: 7f69bf8b16f6d7408d0767b58f8b041fe89eb66c2360b8a0fbafd2cb3b6c517118875b19204f3c7259210e98dce611113814771d78f6ed5d82451597e2177e2c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [4.57.0](https://github.com/plivo/plivo-ruby/tree/v4.57.0) (2023-05-07)
|
4
|
+
**Feature - Adding support for interactive whatsapp messages**
|
5
|
+
- Added new param `interactive` to [send message API](https://www.plivo.com/docs/sms/api/message#send-a-message) to support interactive `whatsapp` messages
|
6
|
+
|
3
7
|
## [4.56.0](https://github.com/plivo/plivo-ruby/tree/v4.56.0) (2023-04-18)
|
4
8
|
**Feature - Support for dynamic button components when sending a templated WhatsApp message**
|
5
9
|
- Added new param `payload` in templates to support dynamic payload in templates
|
data/README.md
CHANGED
@@ -0,0 +1,139 @@
|
|
1
|
+
require_relative "template"
|
2
|
+
|
3
|
+
module Plivo
|
4
|
+
class Interactive
|
5
|
+
attr_accessor :type, :header, :body, :footer, :action
|
6
|
+
|
7
|
+
def initialize(type: nil, header: nil, body: nil, footer: nil, action: nil)
|
8
|
+
@type = type
|
9
|
+
@header = header
|
10
|
+
@body = body
|
11
|
+
@footer = footer
|
12
|
+
@action = action
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_hash
|
16
|
+
{
|
17
|
+
type: @type,
|
18
|
+
header: @header&.to_hash,
|
19
|
+
body: @body&.to_hash,
|
20
|
+
footer: @footer&.to_hash,
|
21
|
+
action: @action&.to_hash
|
22
|
+
}.reject { |_, v| v.nil? }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class Header
|
27
|
+
attr_accessor :type, :text, :media
|
28
|
+
|
29
|
+
def initialize(type: nil, text: nil, media: nil)
|
30
|
+
@type = type
|
31
|
+
@text = text
|
32
|
+
@media = media
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_hash
|
36
|
+
{
|
37
|
+
type: @type,
|
38
|
+
text: @text,
|
39
|
+
media: @media
|
40
|
+
}.reject { |_, v| v.nil? }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class Body
|
45
|
+
attr_accessor :text
|
46
|
+
|
47
|
+
def initialize(text: nil)
|
48
|
+
@text = text
|
49
|
+
end
|
50
|
+
|
51
|
+
def to_hash
|
52
|
+
{
|
53
|
+
text: @text
|
54
|
+
}.reject { |_, v| v.nil? }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
class Footer
|
59
|
+
attr_accessor :text
|
60
|
+
|
61
|
+
def initialize(text: nil)
|
62
|
+
@text = text
|
63
|
+
end
|
64
|
+
|
65
|
+
def to_hash
|
66
|
+
{
|
67
|
+
text: @text
|
68
|
+
}.reject { |_, v| v.nil? }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
class Action
|
73
|
+
attr_accessor :buttons, :sections
|
74
|
+
|
75
|
+
def initialize(buttons: nil, sections: nil)
|
76
|
+
@buttons = buttons ? buttons.map { |b| Buttons.new(**b) } : []
|
77
|
+
@sections = sections ? sections.map { |s| Section.new(**s) } : []
|
78
|
+
end
|
79
|
+
|
80
|
+
def to_hash
|
81
|
+
{
|
82
|
+
buttons: @buttons.map(&:to_hash),
|
83
|
+
sections: @sections.map(&:to_hash),
|
84
|
+
}.reject { |_, v| v.nil? }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
class Buttons
|
89
|
+
attr_accessor :id, :title, :cta_url
|
90
|
+
|
91
|
+
def initialize(id: nil, title: nil, cta_url: nil)
|
92
|
+
@id = id
|
93
|
+
@title = title
|
94
|
+
@cta_url = cta_url
|
95
|
+
end
|
96
|
+
|
97
|
+
def to_hash
|
98
|
+
{
|
99
|
+
id: @id,
|
100
|
+
title: @title,
|
101
|
+
cta_url: @cta_url
|
102
|
+
}.reject { |_, v| v.nil? }
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
class Section
|
107
|
+
attr_accessor :title, :rows
|
108
|
+
|
109
|
+
def initialize(title: nil, rows: nil)
|
110
|
+
@title = title
|
111
|
+
@rows = rows ? rows.map { |r| Row.new(**r) } : []
|
112
|
+
end
|
113
|
+
|
114
|
+
def to_hash
|
115
|
+
{
|
116
|
+
title: @title,
|
117
|
+
rows: @rows.map(&:to_hash),
|
118
|
+
}.reject { |_, v| v.nil? }
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
class Row
|
123
|
+
attr_accessor :id, :title, :description
|
124
|
+
|
125
|
+
def initialize(id: nil, title: nil, description: nil)
|
126
|
+
@id = id
|
127
|
+
@title = title
|
128
|
+
@description = description
|
129
|
+
end
|
130
|
+
|
131
|
+
def to_hash
|
132
|
+
{
|
133
|
+
id: @id,
|
134
|
+
title: @title,
|
135
|
+
description: @description
|
136
|
+
}.reject { |_, v| v.nil? }
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -92,6 +92,7 @@ module Plivo
|
|
92
92
|
# @option options [String] :dlt_template_id This is the DLT template id passed in the message request.
|
93
93
|
# @option options [String] :dlt_template_category This is the DLT template category passed in the message request.
|
94
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.
|
95
96
|
|
96
97
|
def create(src = nil, dst = nil, text = nil, options = nil, powerpack_uuid = nil)
|
97
98
|
#All params in One HASH
|
@@ -227,6 +228,29 @@ module Plivo
|
|
227
228
|
end
|
228
229
|
end
|
229
230
|
|
231
|
+
if value.key?(:template) && value.key?(:type) && (value[:type] != "whatsapp")
|
232
|
+
raise InvalidRequestError, 'template parameter is only applicable when type is whatsapp'
|
233
|
+
end
|
234
|
+
|
235
|
+
if value.is_a?(Hash) && !value[:interactive].nil?
|
236
|
+
if value.key?(:interactive)
|
237
|
+
if value[:interactive].is_a?(String)
|
238
|
+
begin
|
239
|
+
json_interactive = JSON.parse(value[:interactive])
|
240
|
+
params[:interactive] = json_interactive
|
241
|
+
rescue JSON::ParserError => e
|
242
|
+
raise InvalidRequestError, 'failed to parse interactive as JSON'
|
243
|
+
end
|
244
|
+
elsif value[:interactive].is_a?(Hash)
|
245
|
+
params[:interactive] = value[:interactive]
|
246
|
+
elsif value[:interactive].is_a?(Plivo::Interactive)
|
247
|
+
params[:interactive] = value[:interactive].to_hash
|
248
|
+
else
|
249
|
+
raise InvalidRequestError, 'invalid interactive format'
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
230
254
|
#legacy code compatibility
|
231
255
|
else
|
232
256
|
valid_param?(:src, src, [Integer, String, Symbol], false)
|
@@ -372,6 +396,25 @@ module Plivo
|
|
372
396
|
end
|
373
397
|
end
|
374
398
|
|
399
|
+
if options.is_a?(Hash) && !options[:interactive].nil?
|
400
|
+
if options.key?(:interactive)
|
401
|
+
if options[:interactive].is_a?(String)
|
402
|
+
begin
|
403
|
+
json_interactive = JSON.parse(options[:interactive])
|
404
|
+
params[:interactive] = json_interactive
|
405
|
+
rescue JSON::ParserError => e
|
406
|
+
raise InvalidRequestError, 'failed to parse interactive as JSON'
|
407
|
+
end
|
408
|
+
elsif options[:interactive].is_a?(Hash)
|
409
|
+
params[:interactive] = options[:interactive]
|
410
|
+
elsif options[:interactive].is_a?(Plivo::Interactive)
|
411
|
+
params[:interactive] = options[:interactive].to_hash
|
412
|
+
else
|
413
|
+
raise InvalidRequestError, 'invalid interactive format'
|
414
|
+
end
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
375
418
|
end
|
376
419
|
perform_create(params)
|
377
420
|
end
|
data/lib/plivo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plivo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.57.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Plivo SDKs Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- lib/plivo/base/response.rb
|
167
167
|
- lib/plivo/base_client.rb
|
168
168
|
- lib/plivo/exceptions.rb
|
169
|
+
- lib/plivo/interactive.rb
|
169
170
|
- lib/plivo/jwt.rb
|
170
171
|
- lib/plivo/phlo_client.rb
|
171
172
|
- lib/plivo/resources.rb
|