plivo 4.20.0 → 4.21.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 +6 -0
- data/README.md +14 -19
- data/lib/plivo/resources/messages.rb +145 -55
- data/lib/plivo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4221884a48c30837e399b3cccf82a2b316b1c8b
|
4
|
+
data.tar.gz: 439b0e03c1e2208bc8c00670decba683c9c4a8d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d349d186ca2bd0b10e6b38b29bb1d44f431e9e00fc97643e72f82c78ff154f1850df29a030bc6fcad71cf7e9e74831d0049b94a2eb5eb3c091fe833d364e461e
|
7
|
+
data.tar.gz: f2cc7bdb7e9aafa70a7954c20f6344a25833e565ad8db8d3bff362de546bb46139a886757b3290e4c3f5ca2ecb8e6726aedc3ebbf81dbd4563d0fed70758b656
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [4.21.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.21.0) (2021-10-11)
|
4
|
+
**Features - Messaging**
|
5
|
+
- This version includes advancements to the Messaging Interface that deals with the [Send SMS/MMS](https://www.plivo.com/docs/sms/api/message#send-a-message) interface, Creating a standard structure for `request/input` arguments to make implementation easier and incorporating support for the older interface.
|
6
|
+
|
7
|
+
Example for [send SMS](https://github.com/plivo/plivo-ruby#send-a-message)
|
8
|
+
|
3
9
|
## [4.20.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.20.0) (2021-08-04)
|
4
10
|
- Added continue speak XML element support.
|
5
11
|
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ The Plivo Ruby SDK makes it simpler to integrate communications into your Ruby a
|
|
8
8
|
Add this line to your application's Gemfile:
|
9
9
|
|
10
10
|
```ruby
|
11
|
-
gem 'plivo', '>= 4.
|
11
|
+
gem 'plivo', '>= 4.21.0'
|
12
12
|
```
|
13
13
|
|
14
14
|
And then execute:
|
@@ -39,7 +39,7 @@ client = RestClient.new;
|
|
39
39
|
Alternatively, you can specifiy the authentication credentials while initializing the `RestClient`.
|
40
40
|
|
41
41
|
```ruby
|
42
|
-
client = RestClient.new('
|
42
|
+
client = RestClient.new('<auth_id>', '<auth_token>');
|
43
43
|
```
|
44
44
|
|
45
45
|
### The basics
|
@@ -76,17 +76,15 @@ end
|
|
76
76
|
### Send a message
|
77
77
|
|
78
78
|
```ruby
|
79
|
-
require
|
80
|
-
require 'plivo'
|
81
|
-
|
79
|
+
require "plivo"
|
82
80
|
include Plivo
|
83
81
|
|
84
82
|
client = RestClient.new
|
85
|
-
|
86
|
-
'
|
87
|
-
|
88
|
-
'Hello,
|
89
|
-
)
|
83
|
+
response = client.messages.create(
|
84
|
+
src: '+14156667778',
|
85
|
+
dst: '+14156667777',
|
86
|
+
text: 'Hello, this is a sample text'
|
87
|
+
)
|
90
88
|
```
|
91
89
|
|
92
90
|
### Make a call
|
@@ -99,8 +97,8 @@ include Plivo
|
|
99
97
|
|
100
98
|
client = RestClient.new
|
101
99
|
call_made = client.calls.create(
|
102
|
-
'
|
103
|
-
['
|
100
|
+
'+14156667778',
|
101
|
+
['+14156667777'],
|
104
102
|
'https://answer.url'
|
105
103
|
)
|
106
104
|
```
|
@@ -149,10 +147,7 @@ require 'plivo'
|
|
149
147
|
|
150
148
|
include Plivo
|
151
149
|
|
152
|
-
|
153
|
-
AUTH_TOKEN = 'AUTH_TOKEN'
|
154
|
-
|
155
|
-
client = Phlo.new(AUTH_ID, AUTH_TOKEN)
|
150
|
+
client = Phlo.new('<auth_id>', '<auth_token>')
|
156
151
|
|
157
152
|
# if credentials are stored in the PLIVO_AUTH_ID and the PLIVO_AUTH_TOKEN environment variables
|
158
153
|
# then initialize client as:
|
@@ -162,8 +157,8 @@ client = Phlo.new(AUTH_ID, AUTH_TOKEN)
|
|
162
157
|
begin
|
163
158
|
#parameters set in PHLO - params
|
164
159
|
params = {
|
165
|
-
from: '
|
166
|
-
to: '
|
160
|
+
from: '+14156667778',
|
161
|
+
to: '+14156667777'
|
167
162
|
}
|
168
163
|
response = phlo.run(params)
|
169
164
|
puts response
|
@@ -173,7 +168,7 @@ begin
|
|
173
168
|
```
|
174
169
|
|
175
170
|
### More examples
|
176
|
-
|
171
|
+
More examples are available [here](https://github.com/plivo/plivo-examples-ruby). Also refer to the [guides for configuring the Rails server to run various scenarios](https://www.plivo.com/docs/sms/quickstart/ruby-rails/) & use it to test out your integration in under 5 minutes.
|
177
172
|
|
178
173
|
## Reporting issues
|
179
174
|
Report any feedback or problems with this version by [opening an issue on Github](https://github.com/plivo/plivo-ruby/issues).
|
@@ -69,72 +69,160 @@ module Plivo
|
|
69
69
|
# @option options [String] :method The method used to call the url. Defaults to POST.
|
70
70
|
# @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.
|
71
71
|
# @option options [String] :trackable set to false
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
def create(src, dst, text = nil, options = nil, powerpack_uuid = nil)
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
valid_param?(:
|
82
|
-
|
72
|
+
# @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'])
|
73
|
+
# @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'])
|
74
|
+
|
75
|
+
def create(src = nil, dst = nil, text = nil, options = nil, powerpack_uuid = nil)
|
76
|
+
#All params in One HASH
|
77
|
+
value = src
|
78
|
+
if(value.is_a?(Hash))
|
79
|
+
valid_param?(:src, value[:src], [Integer, String, Symbol], false)
|
80
|
+
valid_param?(:text, value[:text], [String, Symbol], true)
|
81
|
+
valid_param?(:dst, value[:dst], [String, Array], true)
|
82
|
+
valid_param?(:powerpack_uuid, value[:powerpack_uuid], [String, Symbol], false)
|
83
83
|
|
84
|
-
|
85
|
-
|
86
|
-
|
84
|
+
if (value[:dst] == value[:src])
|
85
|
+
raise InvalidRequestError, 'src and dst cannot be same'
|
86
|
+
end
|
87
87
|
|
88
|
-
|
89
|
-
|
90
|
-
|
88
|
+
if value.key?(:value).nil? && value.key(:powerpack_uuid).nil?
|
89
|
+
raise InvalidRequestError, 'value and powerpack uuid both cannot be nil'
|
90
|
+
end
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
|
92
|
+
if !value.key?(:value).nil? && !value.key(:powerpack_uuid).nil?
|
93
|
+
raise InvalidRequestError, 'value and powerpack uuid both cannot be present'
|
94
|
+
end
|
95
95
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
text: text,
|
100
|
-
powerpack_uuid: powerpack_uuid
|
101
|
-
}
|
96
|
+
if !value.key?(:dst).nil? && !value.key(:powerpack_uuid).nil?
|
97
|
+
raise InvalidRequestError, 'dst is a required parameter'
|
98
|
+
end
|
102
99
|
|
103
|
-
|
104
|
-
|
100
|
+
params = {
|
101
|
+
src: value[:src],
|
102
|
+
dst: value[:dst],
|
103
|
+
text: value[:text],
|
104
|
+
powerpack_uuid: value[:powerpack_uuid]
|
105
|
+
}
|
105
106
|
|
106
|
-
|
107
|
-
valid_param?(:type,
|
108
|
-
|
109
|
-
|
107
|
+
#Handling optional params in One HASH
|
108
|
+
if value.key?(:type) && valid_param?(:type, value[:type],String, true, %w[sms mms])
|
109
|
+
params[:type] = value[:type]
|
110
|
+
end
|
111
|
+
|
112
|
+
if value.key?(:url) && valid_param?(:url, value[:url], String, true)
|
113
|
+
params[:url] = value[:url]
|
114
|
+
if value.key?(:method) &&
|
115
|
+
valid_param?(:method, value[:method], String, true, %w[POST GET])
|
116
|
+
params[:method] = value[:method]
|
117
|
+
else
|
118
|
+
params[:method] = 'POST'
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
if value.key?(:log) &&
|
123
|
+
valid_param?(:log, value[:log], [TrueClass, FalseClass], true)
|
124
|
+
params[:log] = value[:log]
|
125
|
+
end
|
126
|
+
|
127
|
+
if value.key?(:trackable) &&
|
128
|
+
valid_param?(:trackable, value[:trackable], [TrueClass, FalseClass], true)
|
129
|
+
params[:trackable] = value[:trackable]
|
130
|
+
end
|
131
|
+
|
132
|
+
if value.key?(:media_urls) &&
|
133
|
+
valid_param?(:media_urls, value[:media_urls], Array, true)
|
134
|
+
params[:media_urls] = value[:media_urls]
|
135
|
+
end
|
136
|
+
|
137
|
+
if value.key?(:media_ids) &&
|
138
|
+
valid_param?(:media_ids, value[:media_ids], Array, true)
|
139
|
+
params[:media_ids] = value[:media_ids]
|
140
|
+
end
|
141
|
+
|
142
|
+
#legacy code compatibility
|
143
|
+
else
|
144
|
+
valid_param?(:src, src, [Integer, String, Symbol], false)
|
145
|
+
valid_param?(:text, text, [String, Symbol], true)
|
146
|
+
valid_param?(:dst, dst, [String, Array], true)
|
147
|
+
valid_param?(:powerpack_uuid, powerpack_uuid, [String, Symbol], false)
|
148
|
+
dst.each do |dst_num|
|
149
|
+
valid_param?(:dst_num, dst_num, [Integer, String, Symbol], true)
|
150
|
+
end
|
151
|
+
|
152
|
+
if dst.include? src
|
153
|
+
raise InvalidRequestError, 'src and dst cannot be same'
|
154
|
+
end
|
110
155
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
156
|
+
if src.nil? && powerpack_uuid.nil?
|
157
|
+
raise InvalidRequestError, 'src and powerpack uuid both cannot be nil'
|
158
|
+
end
|
159
|
+
|
160
|
+
if !src.nil? && !powerpack_uuid.nil?
|
161
|
+
raise InvalidRequestError, 'src and powerpack uuid both cannot be present'
|
162
|
+
end
|
163
|
+
|
164
|
+
params = {
|
165
|
+
src: src,
|
166
|
+
text: text,
|
167
|
+
powerpack_uuid: powerpack_uuid
|
168
|
+
}
|
169
|
+
|
170
|
+
if (dst.is_a?(Array))
|
171
|
+
dst.each do |dst_num|
|
172
|
+
valid_param?(:dst_num, dst_num, [Integer, String, Symbol], true)
|
173
|
+
params[:dst] = dst.join('<')
|
174
|
+
end
|
116
175
|
else
|
117
|
-
params[:
|
176
|
+
params[:dst] = dst
|
118
177
|
end
|
119
|
-
end
|
120
178
|
|
121
|
-
|
122
|
-
|
123
|
-
params[:log] = options[:log]
|
124
|
-
end
|
179
|
+
return perform_create(params) if options.nil?
|
180
|
+
valid_param?(:options, options, Hash, true)
|
125
181
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
182
|
+
if options.key?(:type) &&
|
183
|
+
valid_param?(:type, options[:type], String, true, %w[sms mms])
|
184
|
+
params[:type] = options[:type]
|
185
|
+
end
|
130
186
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
187
|
+
if options.key?(:url) && valid_param?(:url, options[:url], String, true)
|
188
|
+
params[:url] = options[:url]
|
189
|
+
if options.key?(:method) &&
|
190
|
+
valid_param?(:method, options[:method], String, true, %w[POST GET])
|
191
|
+
params[:method] = options[:method]
|
192
|
+
else
|
193
|
+
params[:method] = 'POST'
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
if options.key?(:media_urls) &&
|
198
|
+
valid_param?(:media_urls, options[:media_urls], Array, true)
|
199
|
+
params[:media_urls] = options[:media_urls]
|
200
|
+
end
|
201
|
+
|
202
|
+
if options.key?(:media_ids) &&
|
203
|
+
valid_param?(:media_ids, options[:media_ids], Array, true)
|
204
|
+
params[:media_ids] = options[:media_ids]
|
205
|
+
end
|
206
|
+
|
207
|
+
if options.key?(:log) &&
|
208
|
+
valid_param?(:log, options[:log], [TrueClass, FalseClass], true)
|
209
|
+
params[:log] = options[:log]
|
210
|
+
end
|
211
|
+
|
212
|
+
if options.key?(:media_urls) &&
|
213
|
+
valid_param?(:media_urls, options[:media_urls], Array, true)
|
214
|
+
params[:media_urls] = options[:media_urls]
|
215
|
+
end
|
216
|
+
|
217
|
+
if options.key?(:media_ids) &&
|
218
|
+
valid_param?(:media_ids, options[:media_ids], Array, true)
|
219
|
+
params[:media_ids] = options[:media_ids]
|
220
|
+
end
|
221
|
+
|
222
|
+
if options.key?(:trackable) &&
|
223
|
+
valid_param?(:trackable, options[:trackable], [TrueClass, FalseClass], true)
|
224
|
+
params[:trackable] = options[:trackable]
|
225
|
+
end
|
138
226
|
end
|
139
227
|
perform_create(params)
|
140
228
|
end
|
@@ -153,7 +241,9 @@ module Plivo
|
|
153
241
|
# @option options [Int] :limit Used to display the number of results per page. The maximum number of results that can be fetched is 20.
|
154
242
|
# @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.
|
155
243
|
# @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}.
|
156
|
-
# @option options
|
244
|
+
# @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'])
|
245
|
+
# @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'])
|
246
|
+
# @option options [String] :powerpack_id Filter the results by powerpack id
|
157
247
|
def list(options = nil)
|
158
248
|
return perform_list if options.nil?
|
159
249
|
valid_param?(:options, options, Hash, true)
|
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.21.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: 2021-
|
11
|
+
date: 2021-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|