plivo 4.8.0 → 4.11.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: dbbe456a4f4f19cb4d520c470c32a12fbf1d886a
4
- data.tar.gz: 017ae48d6b340d1f71267a8c726b1ccacab11bde
3
+ metadata.gz: bc30f1aeebcfbed23f4f8a989b417c7b8f2c1bd4
4
+ data.tar.gz: 9676720fbbfb5d6a274f1ca6814f1ca23f8f71e2
5
5
  SHA512:
6
- metadata.gz: c2b4252b08ad48e9302fb37ec1f8dc1362ea4c2af5b95334841eada03f1e88865453dea532e5fe6d15a829dd868ebabc67cf75a41905ba8276b6d158edda4d23
7
- data.tar.gz: 578e0a1b358eb14dba2ae2b03b6925975586a262122628bf84257c63f50cc3d59bfc9ea486c4fc71590ecbbdd037c7ddab863c4ebe7451f4308330a64fbd6498
6
+ metadata.gz: a02efb737c56f688bd70f639c640a8c7de86b2acd692f8c5cc3fd1f9277b9d01d4e88d396c71db78ee4cd5d0eab311547ae5e889c3c6ca83606eac8d49fa639f
7
+ data.tar.gz: 7df6df39629bc3151b7f7824c6c0206ef25d291f957e968e1350cc60097c5c27454d26f2a48bc7be17a9003c9525f65c709d10d4e027aa61f3a3775aeddf59a1
@@ -1,5 +1,21 @@
1
1
  # Change Log
2
2
 
3
+ ## [4.11.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.9.0) (2020-08-25)
4
+ - Add Powerpack for mms
5
+
6
+ ## [4.10.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.10.0) (2020-09-04)
7
+ - Add ConferenceUuid & CallState for Get Details of a Call API
8
+ - Upgrade faraday & faraday_middleware dependencies
9
+
10
+ ## [4.9.1](https://github.com/plivo/plivo-ruby/releases/tag/v4.9.1) (2020-08-19)
11
+ - Internal changes in Phlo for MultiPartyCall component
12
+
13
+ ## [4.9.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.9.0) (2020-07-23)
14
+ - Add retries to multiple regions for voice requests.
15
+
16
+ ## [4.8.1](https://github.com/plivo/plivo-ruby/releases/tag/v4.8.1) (2020-06-05)
17
+ - Fix Record a Conference API response.
18
+
3
19
  ## [4.8.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.8.0) (2020-05-28)
4
20
  - Add JWT helper functions.
5
21
 
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.8.0'
11
+ gem 'plivo', '>= 4.11.0'
12
12
  ```
13
13
 
14
14
  And then execute:
@@ -13,11 +13,20 @@ begin
13
13
  '{username}',
14
14
  '{uid}'
15
15
  )
16
- # update token validity (from, lifetime, till)
16
+ # update token validity (from, lifetime)
17
17
  acctkn.update_validity(Time.now, 300)
18
18
  # add voice grants (incoming, outgoing)
19
19
  acctkn.add_voice_grants(Plivo::Token::VoiceGrants.new(true, true))
20
20
  puts acctkn.to_jwt
21
+
22
+ # update token validity (from, nil, till)
23
+ acctkn.update_validity(Time.now, nil, Time.now + 300)
24
+ # add voice grants (incoming, outgoing)
25
+ acctkn.add_voice_grants(Plivo::Token::VoiceGrants.new(true, true))
26
+ puts acctkn.to_jwt
21
27
  rescue ValidationError => e
22
28
  puts 'Exception: ' + e.message
23
29
  end
30
+
31
+ # Sample Response:
32
+ #
@@ -5,6 +5,11 @@ require_relative 'base/response'
5
5
  module Plivo
6
6
  module Base
7
7
  PLIVO_API_URL = 'https://api.plivo.com'.freeze
8
+
9
+ API_VOICE = 'https://voice.plivo.com'.freeze
10
+ API_VOICE_FALLBACK_1 = 'https://voice-usw1.plivo.com'.freeze
11
+ API_VOICE_FALLBACK_2 = 'https://voice-use1.plivo.com'.freeze
12
+
8
13
  CALLINSIGHTS_API_URL = 'https://stats.plivo.com'.freeze
9
14
  PHLO_API_URL = 'https://phlorunner.plivo.com'.freeze
10
15
  end
@@ -8,6 +8,7 @@ module Plivo
8
8
  configure_client(client)
9
9
  configure_options(options) if options
10
10
  configure_resource_uri
11
+ @_is_voice_request = false
11
12
  end
12
13
 
13
14
  private
@@ -56,7 +57,7 @@ module Plivo
56
57
  'without an identifier')
57
58
  end
58
59
 
59
- response_json = @_client.send_request(@_resource_uri, 'POST', params, nil, use_multipart_conn)
60
+ response_json = @_client.send_request(@_resource_uri, 'POST', params, nil, use_multipart_conn, is_voice_request: @_is_voice_request)
60
61
 
61
62
  parse_and_set(params)
62
63
  parse_and_set(response_json)
@@ -65,7 +66,7 @@ module Plivo
65
66
 
66
67
  def perform_action(action = nil, method = 'GET', params = nil, parse = false)
67
68
  resource_path = action ? @_resource_uri + action + '/' : @_resource_uri
68
- response = @_client.send_request(resource_path, method, params)
69
+ response = @_client.send_request(resource_path, method, params,nil,false,is_voice_request: @_is_voice_request)
69
70
  parse ? parse_and_set(response) : self
70
71
  method == 'POST' ? parse_and_set(params) : self
71
72
  self
@@ -73,7 +74,7 @@ module Plivo
73
74
 
74
75
  def perform_custome_action(action = nil, method = 'GET', params = nil, parse = false)
75
76
  resource_path = action ? @_resource_uri + action + '/' : @_resource_uri
76
- response = @_client.send_request(resource_path, method, params)
77
+ response = @_client.send_request(resource_path, method, params,nil,false,is_voice_request: @_is_voice_request)
77
78
  parse ? parse_and_set(response) : self
78
79
  method == 'POST' ? parse_and_set(params) : self
79
80
  self
@@ -81,7 +82,7 @@ module Plivo
81
82
 
82
83
  def perform_action_apiresponse(action = nil, method = 'GET', params = nil, parse = false)
83
84
  resource_path = action ? @_resource_uri + action + '/' : @_resource_uri
84
- response = @_client.send_request(resource_path, method, params)
85
+ response = @_client.send_request(resource_path, method, params,nil,false,is_voice_request: @_is_voice_request)
85
86
  parse ? parse_and_set(response) : self
86
87
  method == 'POST' ? parse_and_set(params) : self
87
88
  method == 'DELETE' ? parse_and_set(params) : self
@@ -90,7 +91,7 @@ module Plivo
90
91
 
91
92
  def perform_custom_action_apiresponse(action = nil, method = 'GET', params = nil, parse = false)
92
93
  resource_path = action ? '/v1/Account/' + @_client.auth_id + '/'+ action + '/' : @_resource_uri
93
- response = @_client.send_request(resource_path, method, params)
94
+ response = @_client.send_request(resource_path, method, params,nil,false,is_voice_request: @_is_voice_request)
94
95
  parse ? parse_and_set(response) : self
95
96
  method == 'POST' ? parse_and_set(params) : self
96
97
  method == 'DELETE' ? parse_and_set(params) : self
@@ -103,12 +104,12 @@ module Plivo
103
104
  'without an identifier')
104
105
  end
105
106
 
106
- Response.new(@_client.send_request(@_resource_uri, 'DELETE', params),
107
+ Response.new(@_client.send_request(@_resource_uri, 'DELETE', params, nil, false, is_voice_request: @_is_voice_request),
107
108
  @_identifier_string)
108
109
  end
109
110
 
110
111
  def perform_run(params)
111
- response_json = @_client.send_request(@_resource_uri, 'POST', params, nil)
112
+ response_json = @_client.send_request(@_resource_uri, 'POST', params, nil,false,is_voice_request: @_is_voice_request)
112
113
  parse_and_set(response_json)
113
114
  Response.new(response_json, @_identifier_string)
114
115
  end
@@ -6,6 +6,7 @@ module Plivo
6
6
  configure_client(client)
7
7
  configure_resource_uri
8
8
  parse_and_set(resource_list_json) if resource_list_json
9
+ @_is_voice_request = false
9
10
  end
10
11
 
11
12
  private
@@ -41,25 +42,25 @@ module Plivo
41
42
 
42
43
  def perform_get(identifier, params = nil)
43
44
  valid_param?(:identifier, identifier, [String, Symbol], true)
44
- response_json = @_client.send_request(@_resource_uri + identifier.to_s + '/', 'GET', params)
45
+ response_json = @_client.send_request(@_resource_uri + identifier.to_s + '/', 'GET', params, nil, false, is_voice_request: @_is_voice_request)
45
46
  @_resource_type.new(@_client, resource_json: response_json)
46
47
  end
47
48
 
48
49
  def perform_get_without_identifier(params)
49
50
  valid_param?(:params, params, Hash, true)
50
- response_json = @_client.send_request(@_resource_uri, 'GET', params)
51
+ response_json = @_client.send_request(@_resource_uri, 'GET', params, nil, false, is_voice_request: @_is_voice_request)
51
52
  @_resource_type.new(@_client, resource_json: response_json)
52
53
  end
53
54
 
54
55
  def perform_create(params, use_multipart_conn=false)
55
56
  Response.new(
56
- @_client.send_request(@_resource_uri, 'POST', params, nil, use_multipart_conn),
57
+ @_client.send_request(@_resource_uri, 'POST', params, nil, use_multipart_conn, is_voice_request: @_is_voice_request),
57
58
  @_identifier_string
58
59
  )
59
60
  end
60
61
 
61
62
  def perform_post(params)
62
- response_json = @_client.send_request(@_resource_uri, 'POST', params)
63
+ response_json = @_client.send_request(@_resource_uri, 'POST', params, nil, false, is_voice_request: @_is_voice_request)
63
64
 
64
65
  parse_and_set(response_json)
65
66
  self
@@ -74,7 +75,7 @@ module Plivo
74
75
  end
75
76
 
76
77
  def perform_list(params = nil)
77
- response_json = @_client.send_request(@_resource_uri, 'GET', params)
78
+ response_json = @_client.send_request(@_resource_uri, 'GET', params, nil, false, is_voice_request: @_is_voice_request)
78
79
  parse_and_set(response_json)
79
80
  {
80
81
  api_id: @api_id,
@@ -85,14 +86,14 @@ module Plivo
85
86
 
86
87
  def perform_action(action = nil, method = 'GET', params = nil, parse = false)
87
88
  resource_path = action ? @_resource_uri + action + '/' : @_resource_uri
88
- response = @_client.send_request(resource_path, method, params)
89
+ response = @_client.send_request(resource_path, method, params, nil, false, is_voice_request: @_is_voice_request)
89
90
  parse ? parse_and_set(response) : self
90
91
  method == 'POST' ? parse_and_set(params) : self
91
92
  self
92
93
  end
93
94
 
94
95
  def perform_list_without_object(params = nil)
95
- response_json = @_client.send_request(@_resource_uri, 'GET', params)
96
+ response_json = @_client.send_request(@_resource_uri, 'GET', params, nil, false, is_voice_request: @_is_voice_request)
96
97
  parse_and_set(response_json)
97
98
  response_json
98
99
  end
@@ -13,7 +13,7 @@ module Plivo
13
13
  class BaseClient
14
14
  # Base stuff
15
15
  attr_reader :headers, :auth_credentials
16
-
16
+ @@voice_retry_count = 0
17
17
  def initialize(auth_id = nil, auth_token = nil, proxy_options = nil, timeout=5)
18
18
  configure_credentials(auth_id, auth_token)
19
19
  configure_proxies(proxy_options)
@@ -36,21 +36,42 @@ module Plivo
36
36
  elsif !([200, 201, 202, 207].include? response[:status])
37
37
  raise Exceptions::PlivoRESTError, "Received #{response[:status]} for #{method}"
38
38
  end
39
-
39
+ @@voice_retry_count = 0
40
40
  response[:body]
41
41
  end
42
42
 
43
- def send_request(resource_path, method = 'GET', data = {}, timeout = nil, use_multipart_conn = false)
43
+ def send_request(resource_path, method = 'GET', data = {}, timeout = nil, use_multipart_conn = false, options = nil)
44
44
  timeout ||= @timeout
45
45
 
46
- response = case method
47
- when 'GET' then send_get(resource_path, data, timeout)
48
- when 'POST' then send_post(resource_path, data, timeout, use_multipart_conn)
49
- when 'DELETE' then send_delete(resource_path, data, timeout)
50
- else raise_invalid_request("#{method} not supported by Plivo, yet")
51
- end
46
+ if options[:is_voice_request] == true
47
+ response = case method
48
+ when 'GET' then send_get(resource_path, data, timeout, is_voice_request: options[:is_voice_request], voice_retry_count: @@voice_retry_count)
49
+ when 'POST' then send_post(resource_path, data, timeout, use_multipart_conn, is_voice_request: options[:is_voice_request], voice_retry_count: @@voice_retry_count)
50
+ when 'DELETE' then send_delete(resource_path, data, timeout, is_voice_request: options[:is_voice_request], voice_retry_count: @@voice_retry_count)
51
+ else raise_invalid_request("#{method} not supported by Plivo, yet")
52
+ end
53
+
54
+ if response.status >= 500
55
+ @@voice_retry_count += 1
56
+ if @@voice_retry_count > 2
57
+ return process_response(method, response.to_hash)
58
+ end
59
+ is_voice_request = true
60
+ send_request(resource_path, method, data, timeout, use_multipart_conn, is_voice_request: is_voice_request)
61
+ else
62
+ process_response(method, response.to_hash)
63
+ end
52
64
 
53
- process_response(method, response.to_hash)
65
+ else
66
+ response = case method
67
+ when 'GET' then send_get(resource_path, data, timeout)
68
+ when 'POST' then send_post(resource_path, data, timeout, use_multipart_conn)
69
+ when 'DELETE' then send_delete(resource_path, data, timeout)
70
+ else raise_invalid_request("#{method} not supported by Plivo, yet")
71
+ end
72
+
73
+ process_response(method, response.to_hash)
74
+ end
54
75
  end
55
76
 
56
77
  private
@@ -118,6 +139,45 @@ module Plivo
118
139
  faraday.adapter Faraday.default_adapter
119
140
  end
120
141
 
142
+ @voice_conn_no_retry = Faraday.new(@voice_base_uri) do |faraday|
143
+ faraday.headers = @headers
144
+
145
+ # DANGER: Basic auth should always come after headers, else
146
+ # The headers will replace the basic_auth
147
+
148
+ faraday.basic_auth(auth_id, auth_token)
149
+
150
+ faraday.proxy=@proxy_hash if @proxy_hash
151
+ faraday.response :json, content_type: /\bjson$/
152
+ faraday.adapter Faraday.default_adapter
153
+ end
154
+
155
+ @voice_conn_retry_1 = Faraday.new(@voice_base_uri_fallback_1) do |faraday|
156
+ faraday.headers = @headers
157
+
158
+ # DANGER: Basic auth should always come after headers, else
159
+ # The headers will replace the basic_auth
160
+
161
+ faraday.basic_auth(auth_id, auth_token)
162
+
163
+ faraday.proxy=@proxy_hash if @proxy_hash
164
+ faraday.response :json, content_type: /\bjson$/
165
+ faraday.adapter Faraday.default_adapter
166
+ end
167
+
168
+ @voice_conn_retry_2 = Faraday.new(@voice_base_uri_fallback_2) do |faraday|
169
+ faraday.headers = @headers
170
+
171
+ # DANGER: Basic auth should always come after headers, else
172
+ # The headers will replace the basic_auth
173
+
174
+ faraday.basic_auth(auth_id, auth_token)
175
+
176
+ faraday.proxy=@proxy_hash if @proxy_hash
177
+ faraday.response :json, content_type: /\bjson$/
178
+ faraday.adapter Faraday.default_adapter
179
+ end
180
+
121
181
  @callinsights_conn = Faraday.new(@callinsights_base_uri) do |faraday|
122
182
  faraday.headers = @headers
123
183
 
@@ -133,15 +193,34 @@ module Plivo
133
193
 
134
194
  end
135
195
 
136
- def send_get(resource_path, data, timeout)
137
- response = @conn.get do |req|
138
- req.url resource_path, data
139
- req.options.timeout = timeout if timeout
196
+ def send_get(resource_path, data, timeout, options = nil)
197
+ if options
198
+ if options[:voice_retry_count] == 0 and options[:is_voice_request] == true
199
+ response = @voice_conn_no_retry.get do |req|
200
+ req.url resource_path, data
201
+ req.options.timeout = timeout if timeout
202
+ end
203
+ elsif options[:voice_retry_count] == 1 and options[:is_voice_request] == true
204
+ response = @voice_conn_retry_1.get do |req|
205
+ req.url resource_path, data
206
+ req.options.timeout = timeout if timeout
207
+ end
208
+ elsif options[:voice_retry_count] == 2 and options[:is_voice_request] == true
209
+ response = @voice_conn_retry_2.get do |req|
210
+ req.url resource_path, data
211
+ req.options.timeout = timeout if timeout
212
+ end
213
+ end
214
+ else
215
+ response = @conn.get do |req|
216
+ req.url resource_path, data
217
+ req.options.timeout = timeout if timeout
218
+ end
140
219
  end
141
220
  response
142
221
  end
143
222
 
144
- def send_post(resource_path, data, timeout, use_multipart_conn)
223
+ def send_post(resource_path, data, timeout, use_multipart_conn, options = nil)
145
224
  if use_multipart_conn
146
225
  multipart_conn = Faraday.new(@base_uri) do |faraday|
147
226
  faraday.headers = {
@@ -178,7 +257,26 @@ module Plivo
178
257
  req.options.timeout = timeout if timeout
179
258
  req.body = JSON.generate(data) if data
180
259
  end
181
-
260
+ elsif options
261
+ if options[:voice_retry_count] == 0 and options[:is_voice_request] == true
262
+ response = @voice_conn_no_retry.post do |req|
263
+ req.url resource_path
264
+ req.options.timeout = timeout if timeout
265
+ req.body = JSON.generate(data) if data
266
+ end
267
+ elsif options[:voice_retry_count] == 1 and options[:is_voice_request] == true
268
+ response = @voice_conn_retry_1.post do |req|
269
+ req.url resource_path
270
+ req.options.timeout = timeout if timeout
271
+ req.body = JSON.generate(data) if data
272
+ end
273
+ elsif options[:voice_retry_count] == 2 and options[:is_voice_request] == true
274
+ response = @voice_conn_retry_2.post do |req|
275
+ req.url resource_path
276
+ req.options.timeout = timeout if timeout
277
+ req.body = JSON.generate(data) if data
278
+ end
279
+ end
182
280
  else
183
281
  response = @conn.post do |req|
184
282
  req.url resource_path
@@ -190,11 +288,33 @@ module Plivo
190
288
  response
191
289
  end
192
290
 
193
- def send_delete(resource_path, data, timeout)
194
- response = @conn.delete do |req|
195
- req.url resource_path
196
- req.options.timeout = timeout if timeout
197
- req.body = JSON.generate(data) if data
291
+ def send_delete(resource_path, data, timeout, options = nil)
292
+ if options
293
+ if options[:voice_retry_count] == 0 and options[:is_voice_request] == true
294
+ response = @voice_conn_no_retry.delete do |req|
295
+ req.url resource_path
296
+ req.options.timeout = timeout if timeout
297
+ req.body = JSON.generate(data) if data
298
+ end
299
+ elsif options[:voice_retry_count] == 1 and options[:is_voice_request] == true
300
+ response = @voice_conn_retry_1.delete do |req|
301
+ req.url resource_path
302
+ req.options.timeout = timeout if timeout
303
+ req.body = JSON.generate(data) if data
304
+ end
305
+ elsif options[:voice_retry_count] == 2 and options[:is_voice_request] == true
306
+ response = @voice_conn_retry_2.delete do |req|
307
+ req.url resource_path
308
+ req.options.timeout = timeout if timeout
309
+ req.body = JSON.generate(data) if data
310
+ end
311
+ end
312
+ else
313
+ response = @conn.delete do |req|
314
+ req.url resource_path
315
+ req.options.timeout = timeout if timeout
316
+ req.body = JSON.generate(data) if data
317
+ end
198
318
  end
199
319
  response
200
320
  end
@@ -12,7 +12,7 @@ require_relative 'resources/addresses'
12
12
  require_relative 'resources/identities'
13
13
  require_relative 'resources/phlos'
14
14
  require_relative 'resources/nodes'
15
- require_relative 'resources/member'
15
+ require_relative 'resources/phlo_member'
16
16
  require_relative 'resources/call_feedback'
17
17
  require_relative 'resources/media'
18
18
 
@@ -8,6 +8,7 @@ module Plivo
8
8
  @_name = 'Application'
9
9
  @_identifier_string = 'app_id'
10
10
  super
11
+ @_is_voice_request = true
11
12
  end
12
13
 
13
14
  # @param [Hash] options
@@ -109,6 +110,7 @@ module Plivo
109
110
  @_resource_type = Application
110
111
  @_identifier_string = 'app_id'
111
112
  super
113
+ @_is_voice_request = true
112
114
  end
113
115
 
114
116
  # @param [String] app_id
@@ -6,6 +6,7 @@ module Plivo
6
6
  @_name = 'Call'
7
7
  @_identifier_string = 'call_uuid'
8
8
  super
9
+ @_is_voice_request = true
9
10
  end
10
11
 
11
12
  def update(options)
@@ -199,7 +200,7 @@ module Plivo
199
200
 
200
201
  def cancel_request
201
202
  resource_path = @_resource_uri.sub('Call', 'Request')
202
- @_client.send_request(resource_path, 'DELETE', nil)
203
+ @_client.send_request(resource_path, 'DELETE', nil, nil, false , is_voice_request: @_is_voice_request)
203
204
  end
204
205
 
205
206
  def to_s
@@ -211,7 +212,9 @@ module Plivo
211
212
  call_direction: @call_direction,
212
213
  call_duration: @call_duration,
213
214
  call_status: @call_status,
215
+ call_state: @call_state,
214
216
  call_uuid: @call_uuid,
217
+ conference_uuid: @conference_uuid,
215
218
  end_time: @end_time,
216
219
  from_number: @from_number,
217
220
  initiation_time: @initiation_time,
@@ -240,6 +243,7 @@ module Plivo
240
243
  @_resource_type = Call
241
244
  @_identifier_string = 'call_uuid'
242
245
  super
246
+ @_is_voice_request = true
243
247
  end
244
248
 
245
249
  ##
@@ -288,9 +292,9 @@ module Plivo
288
292
  answer_method: answer_method
289
293
  }
290
294
 
291
- return perform_create(params) if options.nil?
295
+ return perform_create(params, false) if options.nil?
292
296
 
293
- perform_create(params.merge(options))
297
+ perform_create(params.merge(options), false)
294
298
  end
295
299
 
296
300
  ##
@@ -397,7 +401,7 @@ module Plivo
397
401
  # - To filter out those numbers that contain a particular number sequence, use to_number={ sequence}
398
402
  # - To filter out a number that matches an exact number, use to_number={ exact_number}
399
403
  def list_live(options = nil)
400
-
404
+
401
405
  if options.nil?
402
406
  options = {}
403
407
  else
@@ -6,6 +6,7 @@ module Plivo
6
6
  @_name = 'Conference'
7
7
  @_identifier_string = 'conference_name'
8
8
  super
9
+ @_is_voice_request = true
9
10
  end
10
11
 
11
12
  def delete
@@ -186,18 +187,12 @@ module Plivo
186
187
  end
187
188
 
188
189
  def to_s
189
- unless @members.nil?
190
- members_json = @members.map do |member|
191
- JSON.parse(to_json_member(member))
192
- end
190
+ response_json = {}
191
+ response_variables = self.instance_variables.drop(5)
192
+ response_variables.each do |variable|
193
+ response_json[variable.to_s[1..-1]] = self.instance_variable_get(variable)
193
194
  end
194
- {
195
- conference_name: @conference_name,
196
- conference_run_time: @conference_run_time,
197
- conference_member_count: @conference_member_count,
198
- members: members_json,
199
- api_id: @api_id
200
- }.to_s
195
+ return response_json.to_s
201
196
  end
202
197
 
203
198
  def to_json_member(member)
@@ -221,6 +216,7 @@ module Plivo
221
216
  @_resource_type = Conference
222
217
  @_identifier_string = 'conference_name'
223
218
  super
219
+ @_is_voice_request = true
224
220
  end
225
221
 
226
222
  def get(conference_name)
@@ -6,6 +6,7 @@ module Plivo
6
6
  @_name = 'Endpoint'
7
7
  @_identifier_string = 'endpoint_id'
8
8
  super
9
+ @_is_voice_request = true
9
10
  end
10
11
 
11
12
  # @param [Hash] options
@@ -71,6 +72,7 @@ module Plivo
71
72
  @_resource_type = Endpoint
72
73
  @_identifier_string = 'endpoint_id'
73
74
  super
75
+ @_is_voice_request = true
74
76
  end
75
77
 
76
78
  # @param [String] endpoint_id
@@ -15,7 +15,7 @@ module Plivo
15
15
  def configure_node_type(node_type)
16
16
  case node_type
17
17
  when 'multi_party_call'
18
- MultiPartyCall
18
+ PhloMultiPartyCall
19
19
  # when 'conference_bridge'
20
20
  # ConferenceBridge
21
21
  end
@@ -42,7 +42,7 @@ module Plivo
42
42
 
43
43
  def member(member_address)
44
44
  options = {'member_address' => member_address, 'node_id' => @id, 'phlo_id' => @phlo_id, 'node_type' => @node_type}
45
- Member.new(@_client, {resource_json: options})
45
+ PhloMember.new(@_client, {resource_json: options})
46
46
  end
47
47
 
48
48
  private
@@ -51,7 +51,7 @@ module Plivo
51
51
  end
52
52
  end
53
53
 
54
- class MultiPartyCall < Node
54
+ class PhloMultiPartyCall < Node
55
55
  def initialize(client,options=nil)
56
56
  @_name = 'multi_party_call'
57
57
  super
@@ -1,6 +1,6 @@
1
1
  module Plivo
2
2
  module Resources
3
- class Member < Base::Resource
3
+ class PhloMember < Base::Resource
4
4
  def initialize(client, options)
5
5
  @_name = 'member'
6
6
  @_identifier_string = 'member_address'
@@ -85,6 +85,10 @@ module Plivo
85
85
  valid_param?(:type, options[:type], String, true)
86
86
  params[:type] = options[:type]
87
87
  end
88
+ if options.key?(:service) &&
89
+ valid_param?(:service, options[:service], String, true)
90
+ params[:service] = options[:service]
91
+ end
88
92
  perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Number',
89
93
  'GET', params, true)
90
94
  end
@@ -136,22 +140,45 @@ module Plivo
136
140
  valid_param?(:type, options[:type], String, true)
137
141
  params[:type] = options[:type]
138
142
  end
143
+ if options.key?(:service) &&
144
+ valid_param?(:service, options[:service], String, true)
145
+ params[:service] = options[:service]
146
+ end
139
147
  response = perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Number',
140
148
  'GET', param, true)
141
149
  meta = response['meta']
142
150
  return meta['total_count']
143
151
  end
144
152
 
145
- def find_number(number)
153
+ def find_number(number, options = nil)
146
154
  number_pool_uuid = getnumberpool_uuid(uuid)
147
- perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Number/' + number.to_s ,
155
+ if options.nil?
156
+ return perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Number/' + number.to_s ,
148
157
  'GET')
158
+ end
159
+ params = {}
160
+ if options.key?(:service) &&
161
+ valid_param?(:service, options[:service], String, true)
162
+ params[:service] = options[:service]
163
+ end
164
+ perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Number/' + number.to_s ,
165
+ 'GET', params)
149
166
  end
150
167
 
151
- def add_number(number)
168
+ def add_number(number, options = nil)
152
169
  number_pool_uuid = getnumberpool_uuid(uuid)
153
- perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Number/' + number.to_s ,
170
+ if options.nil?
171
+ return perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Number/' + number.to_s ,
154
172
  'POST')
173
+ return
174
+ end
175
+ params = {}
176
+ if options.key?(:service) &&
177
+ valid_param?(:service, options[:service], String, true)
178
+ params[:service] = options[:service]
179
+ end
180
+ perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Number/' + number.to_s ,
181
+ 'POST', params)
155
182
  end
156
183
 
157
184
  def add_tollfree(tollfree)
@@ -242,6 +269,10 @@ module Plivo
242
269
  number_pool_uuid = getnumberpool_uuid(uuid)
243
270
  params = {}
244
271
  params[:rent] = true
272
+ if options.key?(:service) &&
273
+ valid_param?(:service, options[:service], String, true)
274
+ params[:service] = options[:service]
275
+ end
245
276
  if options.key?(:number)
246
277
  return perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Number/' + options[:number].to_s ,
247
278
  'POST', params)
@@ -360,6 +391,10 @@ module Plivo
360
391
  valid_param?(:type, options[:type], String, true)
361
392
  params[:type] = options[:type]
362
393
  end
394
+ if options.key?(:service) &&
395
+ valid_param?(:service, options[:service], String, true)
396
+ params[:service] = options[:service]
397
+ end
363
398
  perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number',
364
399
  'GET', params, true)
365
400
  end
@@ -401,20 +436,42 @@ module Plivo
401
436
  valid_param?(:type, options[:type], String, true)
402
437
  params[:type] = options[:type]
403
438
  end
439
+ if options.key?(:service) &&
440
+ valid_param?(:service, options[:service], String, true)
441
+ params[:service] = options[:service]
442
+ end
404
443
  response = perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number',
405
444
  'GET', params, true)
406
445
  meta = response['meta']
407
446
  return meta['total_count']
408
447
  end
409
448
 
410
- def find(number)
411
- perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number/' + number.to_s ,
449
+ def find(number, options = nil)
450
+ if options.nil?
451
+ return perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number/' + number.to_s ,
412
452
  'GET')
453
+ end
454
+ params = {}
455
+ if options.key?(:service) &&
456
+ valid_param?(:service, options[:service], String, true)
457
+ params[:service] = options[:service]
458
+ end
459
+ perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number/' + number.to_s ,
460
+ 'GET', params)
413
461
  end
414
462
 
415
- def add(number)
416
- perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number/' + number.to_s ,
463
+ def add(number, options = nil)
464
+ if options.nil?
465
+ return perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number/' + number.to_s ,
417
466
  'POST')
467
+ end
468
+ params = {}
469
+ if options.key?(:service) &&
470
+ valid_param?(:service, options[:service], String, true)
471
+ params[:service] = options[:service]
472
+ end
473
+ perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number/' + number.to_s ,
474
+ 'POST', params)
418
475
  end
419
476
 
420
477
  def remove(number, unrent= false)
@@ -425,6 +482,10 @@ module Plivo
425
482
  def buy_add_number(options = nil)
426
483
  params = {}
427
484
  params[:rent] = true
485
+ if options.key?(:service) &&
486
+ valid_param?(:service, options[:service], String, true)
487
+ params[:service] = options[:service]
488
+ end
428
489
  if options.key?(:number)
429
490
  return perform_custom_action_apiresponse('NumberPool/' + number_pool_id + '/Number/' + options[:number].to_s ,
430
491
  'POST', params)
@@ -6,6 +6,7 @@ module Plivo
6
6
  @_name = 'Recording'
7
7
  @_identifier_string = 'recording_id'
8
8
  super
9
+ @_is_voice_request = true
9
10
  end
10
11
 
11
12
  def delete
@@ -36,6 +37,7 @@ module Plivo
36
37
  @_resource_type = Recording
37
38
  @_identifier_string = 'recording_id'
38
39
  super
40
+ @_is_voice_request = true
39
41
  end
40
42
 
41
43
  # @param [Hash] options
@@ -24,6 +24,9 @@ module Plivo
24
24
 
25
25
  def configure_base_uri
26
26
  @base_uri = Base::PLIVO_API_URL
27
+ @voice_base_uri = Base::API_VOICE
28
+ @voice_base_uri_fallback_1 = Base::API_VOICE_FALLBACK_1
29
+ @voice_base_uri_fallback_2 = Base::API_VOICE_FALLBACK_2
27
30
  @callinsights_base_uri = Base::CALLINSIGHTS_API_URL
28
31
  end
29
32
 
@@ -1,3 +1,3 @@
1
1
  module Plivo
2
- VERSION = '4.8.0'.freeze
2
+ VERSION = '4.11.0'.freeze
3
3
  end
@@ -31,8 +31,8 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  spec.required_ruby_version = '>= 2.0.0'
33
33
 
34
- spec.add_dependency 'faraday', '~> 0.9'
35
- spec.add_dependency 'faraday_middleware', '~> 0.12.2'
34
+ spec.add_dependency 'faraday', '~> 1.0.1'
35
+ spec.add_dependency 'faraday_middleware', '~> 1.0.0'
36
36
  spec.add_dependency 'htmlentities'
37
37
  spec.add_dependency 'jwt'
38
38
 
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.8.0
4
+ version: 4.11.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: 2020-05-28 00:00:00.000000000 Z
11
+ date: 2020-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.9'
19
+ version: 1.0.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.9'
26
+ version: 1.0.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday_middleware
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.12.2
33
+ version: 1.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.12.2
40
+ version: 1.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: htmlentities
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -186,10 +186,10 @@ files:
186
186
  - lib/plivo/resources/endpoints.rb
187
187
  - lib/plivo/resources/identities.rb
188
188
  - lib/plivo/resources/media.rb
189
- - lib/plivo/resources/member.rb
190
189
  - lib/plivo/resources/messages.rb
191
190
  - lib/plivo/resources/nodes.rb
192
191
  - lib/plivo/resources/numbers.rb
192
+ - lib/plivo/resources/phlo_member.rb
193
193
  - lib/plivo/resources/phlos.rb
194
194
  - lib/plivo/resources/powerpacks.rb
195
195
  - lib/plivo/resources/pricings.rb