plivo 4.18.0 → 4.22.0

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
  SHA1:
3
- metadata.gz: e6a3db3d74dfd421dc5abd1ff8d789461c2af629
4
- data.tar.gz: ceb2c8debfa9704d378f59a920f9edbe4f1809e1
3
+ metadata.gz: 99a81ae9a72d5cd9f5332d84de77f442c565b9a5
4
+ data.tar.gz: 274d0f0c5e278e9fb003eda9c2b022a6840a99b0
5
5
  SHA512:
6
- metadata.gz: 7c579fb2504706df20e2d56dfa5856fffb69f6a024f005eeeb44f2c54b700c4f52f1749675c7fc4554fa4a61dcc9d905114f8e0648ddb5e51a2567d35be820c6
7
- data.tar.gz: f567d3806d6ba132efed4dcdab2fed7b16290f9bcc2c8b73322bf67908aabbf7658ab424b30ec473720d0f99989f997713631d3489695377fd1ea92f44243615
6
+ metadata.gz: 8e5703701787286d5a30a520dedb09bd7c03593f0ac7f8d54a1cfa0ceafaaec31a8b91e135282022f8fcf2fc3fb79191e794bafe844733ac7fc09c337c1d86a3
7
+ data.tar.gz: edf485c5a4d6e3429dc1dec71fe32fe3d31662627bec06d2de407ee6320fc6b5b0bc1d5dce6ef79d6e88305fe76264dfbea5c848bc77e7f829a5168e3577cda9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Change Log
2
2
 
3
+ ## [4.22.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.22.0) (2021-11-11)
4
+ **Features - Voice: Multiparty calls**
5
+ - The [Add Multiparty Call API](https://www.plivo.com/docs/voice/api/multiparty-call/participants#add-a-participant) allows for greater functionality by accepting options like `start recording audio`, `stop recording audio`, and their HTTP methods.
6
+ - [Multiparty Calls](https://www.plivo.com/docs/voice/api/multiparty-call/) now has new APIs to `stop` and `play` audio.
7
+
8
+ ## [4.21.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.21.0) (2021-10-11)
9
+ **Features - Messaging**
10
+ - 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.
11
+
12
+ Example for [send SMS](https://github.com/plivo/plivo-ruby#send-a-message)
13
+
14
+ ## [4.20.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.20.0) (2021-08-04)
15
+ - Added continue speak XML element support.
16
+
17
+ ## [4.19.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.19.0) (2021-07-19)
18
+ - Add support for Voice MultiPartyCall APIs (includes retry) and XML, validate voice UTs
19
+
3
20
  ## [4.18.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.18.0) (2021-07-13)
4
21
  - Power pack ID has been included to the response for the [list all messages API](https://www.plivo.com/docs/sms/api/message/list-all-messages/) and the [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message).
5
22
  - Support for filtering messages by Power pack ID has been added to the [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages).
data/README.md CHANGED
@@ -8,9 +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
-
12
- gem 'plivo', '>= 4.18.0'
13
-
11
+ gem 'plivo', '>= 4.22.0'
14
12
  ```
15
13
 
16
14
  And then execute:
@@ -41,7 +39,7 @@ client = RestClient.new;
41
39
  Alternatively, you can specifiy the authentication credentials while initializing the `RestClient`.
42
40
 
43
41
  ```ruby
44
- client = RestClient.new('your_auth_id', 'your_auth_token');
42
+ client = RestClient.new('<auth_id>', '<auth_token>');
45
43
  ```
46
44
 
47
45
  ### The basics
@@ -78,17 +76,15 @@ end
78
76
  ### Send a message
79
77
 
80
78
  ```ruby
81
- require 'rubygems'
82
- require 'plivo'
83
-
79
+ require "plivo"
84
80
  include Plivo
85
81
 
86
82
  client = RestClient.new
87
- message_created = client.messages.create(
88
- 'your_source_number',
89
- %w[your_destination_number_1 your_destination_number_2],
90
- 'Hello, world!'
91
- )
83
+ response = client.messages.create(
84
+ src: '+14156667778',
85
+ dst: '+14156667777',
86
+ text: 'Hello, this is a sample text'
87
+ )
92
88
  ```
93
89
 
94
90
  ### Make a call
@@ -101,8 +97,8 @@ include Plivo
101
97
 
102
98
  client = RestClient.new
103
99
  call_made = client.calls.create(
104
- 'your_source_number',
105
- ['your_destination_number'],
100
+ '+14156667778',
101
+ ['+14156667777'],
106
102
  'https://answer.url'
107
103
  )
108
104
  ```
@@ -151,10 +147,7 @@ require 'plivo'
151
147
 
152
148
  include Plivo
153
149
 
154
- AUTH_ID = 'AUTH_ID'
155
- AUTH_TOKEN = 'AUTH_TOKEN'
156
-
157
- client = Phlo.new(AUTH_ID, AUTH_TOKEN)
150
+ client = Phlo.new('<auth_id>', '<auth_token>')
158
151
 
159
152
  # if credentials are stored in the PLIVO_AUTH_ID and the PLIVO_AUTH_TOKEN environment variables
160
153
  # then initialize client as:
@@ -164,8 +157,8 @@ client = Phlo.new(AUTH_ID, AUTH_TOKEN)
164
157
  begin
165
158
  #parameters set in PHLO - params
166
159
  params = {
167
- from: '9999999999',
168
- to: '0000000000'
160
+ from: '+14156667778',
161
+ to: '+14156667777'
169
162
  }
170
163
  response = phlo.run(params)
171
164
  puts response
@@ -175,7 +168,7 @@ begin
175
168
  ```
176
169
 
177
170
  ### More examples
178
- Refer to the [Ruby API Reference](https://api-reference.plivo.com/latest/ruby/introduction/overview) for more examples. Also refer to the [guide to setting up dev environment](https://developers.plivo.com/getting-started/setting-up-dev-environment/) on [Plivo Developers Portal](https://developers.plivo.com) to setup a Sinatra server & use it to test out your integration in under 5 minutes.
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.
179
172
 
180
173
  ## Reporting issues
181
174
  Report any feedback or problems with this version by [opening an issue on Github](https://github.com/plivo/plivo-ruby/issues).
@@ -114,5 +114,35 @@ module Plivo
114
114
  Response.new(response_json, @_identifier_string)
115
115
  end
116
116
  end
117
+
118
+ class SecondaryResource < Resource
119
+ attr_reader :secondary_id
120
+ def initialize(client, options = nil)
121
+ super
122
+ configure_secondary_options(options) if options
123
+ configure_secondary_resource_uri
124
+ end
125
+
126
+ def configure_secondary_options(options)
127
+ valid_param?(:options, options, Hash, false)
128
+ @secondary_id = options[:member_id] if options.key?(:member_id)
129
+ secondary_parse_and_set(options[:resource_json]) if options.key?(:resource_json)
130
+ end
131
+
132
+ def secondary_parse_and_set(resource_json)
133
+ return unless resource_json
134
+
135
+ valid_param?(:resource_json, resource_json, Hash, true)
136
+ return unless @_secondary_identifier_string && (resource_json.key? @_secondary_identifier_string)
137
+ @secondary_id = resource_json[@_secondary_identifier_string]
138
+ end
139
+
140
+ def configure_secondary_resource_uri
141
+ to_join = @secondary_id ? [@_client.auth_id, @_name, @id, @_secondary_name, @secondary_id] : [@_client.auth_id, @_name, @id]
142
+ to_join = ['', 'v1', 'Account'] << to_join
143
+ to_join << ''
144
+ @_resource_uri = to_join.join('/')
145
+ end
146
+ end
117
147
  end
118
148
  end
@@ -33,7 +33,7 @@ module Plivo
33
33
  raise Exceptions::PlivoRESTError, "Resource at #{response[:url]} "\
34
34
  'couldn\'t be deleted'
35
35
  end
36
- elsif !([200, 201, 202, 207].include? response[:status])
36
+ elsif !([200, 201, 202, 204, 207].include? response[:status])
37
37
  raise Exceptions::PlivoRESTError, "Received #{response[:status]} for #{method}"
38
38
  end
39
39
  @@voice_retry_count = 0
@@ -266,6 +266,7 @@ module Plivo
266
266
  req.url resource_path
267
267
  req.options.timeout = timeout if timeout
268
268
  req.body = data
269
+ puts req
269
270
  end
270
271
  else
271
272
  if !data.nil? && (data.has_key? 'is_callinsights_request')
@@ -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
- #@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, dst, text = nil, options = nil, powerpack_uuid = nil)
76
- valid_param?(:src, src, [Integer, String, Symbol], false)
77
- valid_param?(:text, text, [String, Symbol], false)
78
- valid_param?(:dst, dst, Array, true)
79
- valid_param?(:powerpack_uuid, powerpack_uuid, [String, Symbol], false)
80
- dst.each do |dst_num|
81
- valid_param?(:dst_num, dst_num, [Integer, String, Symbol], true)
82
- end
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
- if dst.include? src
85
- raise InvalidRequestError, 'src and dst cannot be same'
86
- end
84
+ if (value[:dst] == value[:src])
85
+ raise InvalidRequestError, 'src and dst cannot be same'
86
+ end
87
87
 
88
- if src.nil? && powerpack_uuid.nil?
89
- raise InvalidRequestError, 'src and powerpack uuid both cannot be nil'
90
- end
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
- if !src.nil? && !powerpack_uuid.nil?
93
- raise InvalidRequestError, 'src and powerpack uuid both cannot be present'
94
- end
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
- params = {
97
- src: src,
98
- dst: dst.join('<'),
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
- return perform_create(params) if options.nil?
104
- valid_param?(:options, options, Hash, true)
100
+ params = {
101
+ src: value[:src],
102
+ dst: value[:dst],
103
+ text: value[:text],
104
+ powerpack_uuid: value[:powerpack_uuid]
105
+ }
105
106
 
106
- if options.key?(:type) &&
107
- valid_param?(:type, options[:type], String, true, ['sms', 'mms'])
108
- params[:type] = options[:type]
109
- end
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
- if options.key?(:url) && valid_param?(:url, options[:url], String, true)
112
- params[:url] = options[:url]
113
- if options.key?(:method) &&
114
- valid_param?(:method, options[:method], String, true, %w[POST GET])
115
- params[:method] = options[:method]
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[:method] = 'POST'
176
+ params[:dst] = dst
118
177
  end
119
- end
120
178
 
121
- if options.key?(:log) &&
122
- valid_param?(:log, options[:log], [TrueClass, FalseClass], true)
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
- if options.key?(:trackable) &&
127
- valid_param?(:trackable, options[:trackable], [TrueClass, FalseClass], true)
128
- params[:trackable] = options[:trackable]
129
- end
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
- if options.key?(:media_urls) &&
132
- valid_param?(:media_urls, options[:media_urls], Array, true)
133
- params[:media_urls] = options[:media_urls]
134
- end
135
- if options.key?(:media_ids) &&
136
- valid_param?(:media_ids, options[:media_ids], Array, true)
137
- params[:media_ids] = options[:media_ids]
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 [String] :powerpack_id Filter the results by powerpack id.
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)