plivo 4.9.0 → 4.13.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: bb94696da06990a70578e5b44e4eb14df13ff9ab
4
- data.tar.gz: c8d2d47ddd432b5f15adc75a8fc09d3c0c8f7a82
3
+ metadata.gz: 8c0b51ab5d0b175827b3db20495da181efa57e07
4
+ data.tar.gz: be490b21e0e114d458578c5e0dc2d0b986e87959
5
5
  SHA512:
6
- metadata.gz: 1a08ee7057cae689aedd2608b23a2fc5184a94ac13786b9a43a47d588e8d987c86ad2a4a86487826a0f8056e0fcd44a2e362d38fb806c95b9ba4ac11751a068c
7
- data.tar.gz: 1b8e9f01eaf93503fca9924c045455c7c18500d2a3e081259b3d6175e36ab33ae2f14d7b12ba4445d3c0c4920a457ef798ae6672fa1a1918047b21a0250acc88
6
+ metadata.gz: dbad3689ef259c9e549093b4b16e116e8828631e216783657a95108adde98d863f8b22cbf24ea27a76595abdd9dd49bd71fb624a6badee4fa7e77866d7149fbd
7
+ data.tar.gz: 6dbadf7e2797168ccf6f1778d743a2c15df300eccb9354561bf23fcbba3d14de0c814cbd2fd0e80dc5877a5d1467fe570a15b01e7d4ab290d5107ee0df4fe34e
@@ -1,5 +1,21 @@
1
1
  # Change Log
2
2
 
3
+ ## [4.13.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.13.0) (2020-09-30)
4
+ - Add support for Lookup API
5
+
6
+ ## [4.12.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.12.0) (2020-09-24)
7
+ - Add "public_uri" optional param support for Application API.
8
+
9
+ ## [4.11.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.11.0) (2020-08-25)
10
+ - Add Powerpack for mms
11
+
12
+ ## [4.10.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.10.0) (2020-09-04)
13
+ - Add ConferenceUuid & CallState for Get Details of a Call API
14
+ - Upgrade faraday & faraday_middleware dependencies
15
+
16
+ ## [4.9.1](https://github.com/plivo/plivo-ruby/releases/tag/v4.9.1) (2020-08-19)
17
+ - Internal changes in Phlo for MultiPartyCall component
18
+
3
19
  ## [4.9.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.9.0) (2020-07-23)
4
20
  - Add retries to multiple regions for voice requests.
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.9.0'
11
+ gem 'plivo', '>= 4.13.0'
12
12
  ```
13
13
 
14
14
  And then execute:
@@ -105,6 +105,21 @@ call_made = client.calls.create(
105
105
  )
106
106
  ```
107
107
 
108
+ ### Lookup a number
109
+
110
+ ```ruby
111
+ require 'rubygems'
112
+ require 'plivo'
113
+
114
+ include Plivo
115
+
116
+ client = RestClient.new
117
+ resp = client.lookup.get(
118
+ '<number-here>',
119
+ "carrier"
120
+ )
121
+ ```
122
+
108
123
  ### Generate Plivo XML
109
124
 
110
125
  ```ruby
@@ -0,0 +1,24 @@
1
+ require "rubygems"
2
+ require "plivo"
3
+
4
+ include Plivo
5
+ include Plivo::Exceptions
6
+
7
+ AUTH_ID = ""
8
+ AUTH_TOKEN = ""
9
+
10
+ client = RestClient.new(AUTH_ID, AUTH_TOKEN)
11
+
12
+ # if credentials are stored in the PLIVO_AUTH_ID and the PLIVO_AUTH_TOKEN environment variables
13
+ # then initialize client as:
14
+ # client = RestClient.new
15
+
16
+ begin
17
+ resp = client.lookup.get(
18
+ "<insert-number-here>",
19
+ "carrier"
20
+ )
21
+ puts resp
22
+ rescue PlivoRESTError => e
23
+ puts "Exception: " + e.message
24
+ end
@@ -12,9 +12,10 @@ 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
+ require_relative 'resources/lookup'
18
19
 
19
20
  module Plivo
20
21
  module Resources
@@ -24,6 +24,7 @@ module Plivo
24
24
  # @option options [Boolean] :default_endpoint_app - If set to true, this parameter ensures that newly created endpoints, which don't have an app_id, point to this application.
25
25
  # @option options [String] :subaccount - Id of the subaccount, in case only subaccount applications are needed.
26
26
  # @option options [Boolean] :log_incoming_messages - If set to true, this parameter ensures that incoming messages are logged.
27
+ # @option options [Boolean] :public_uri - If set to true, this parameter enables public_uri.
27
28
  # @return [Application] Application
28
29
  def update(options = nil)
29
30
  return perform_update({}) if options.nil?
@@ -48,7 +49,7 @@ module Plivo
48
49
  end
49
50
  end
50
51
 
51
- %i[default_number_app default_endpoint_app log_incoming_messages].each do |param|
52
+ %i[default_number_app default_endpoint_app log_incoming_messages public_uri].each do |param|
52
53
  if options.key?(param) &&
53
54
  valid_param?(param, options[param], [TrueClass, FalseClass], true)
54
55
  params[param] = options[param]
@@ -134,6 +135,7 @@ module Plivo
134
135
  # @option options [Boolean] :default_endpoint_app - If set to true, this parameter ensures that newly created endpoints, which don't have an app_id, point to this application.
135
136
  # @option options [String] :subaccount - Id of the subaccount, in case only subaccount applications are needed.
136
137
  # @option options [Boolean] :log_incoming_messages - If set to true, this parameter ensures that incoming messages are logged.
138
+ # @option options [Boolean] :public_uri - If set to true, this parameter enables public_uri.
137
139
  # @return [Application] Application
138
140
  def create(app_name, options = nil)
139
141
  valid_param?(:app_name, app_name, [String, Symbol], true)
@@ -161,7 +163,7 @@ module Plivo
161
163
  end
162
164
  end
163
165
 
164
- %i[default_number_app default_endpoint_app log_incoming_messages].each do |param|
166
+ %i[default_number_app default_endpoint_app log_incoming_messages public_uri].each do |param|
165
167
  if options.key?(param) &&
166
168
  valid_param?(param, options[param], [TrueClass, FalseClass], true)
167
169
  params[param] = options[param]
@@ -212,7 +212,9 @@ module Plivo
212
212
  call_direction: @call_direction,
213
213
  call_duration: @call_duration,
214
214
  call_status: @call_status,
215
+ call_state: @call_state,
215
216
  call_uuid: @call_uuid,
217
+ conference_uuid: @conference_uuid,
216
218
  end_time: @end_time,
217
219
  from_number: @from_number,
218
220
  initiation_time: @initiation_time,
@@ -399,7 +401,7 @@ module Plivo
399
401
  # - To filter out those numbers that contain a particular number sequence, use to_number={ sequence}
400
402
  # - To filter out a number that matches an exact number, use to_number={ exact_number}
401
403
  def list_live(options = nil)
402
-
404
+
403
405
  if options.nil?
404
406
  options = {}
405
407
  else
@@ -0,0 +1,88 @@
1
+ module Plivo
2
+ module Resources
3
+ include Plivo::Utils
4
+
5
+ class LookupBaseResource
6
+ def initialize(fields = nil)
7
+ valid_param?(:fields, fields, Hash, false)
8
+ fields.each do |k, v|
9
+ instance_variable_set("@#{k}", v)
10
+ self.class.send(:attr_reader, k)
11
+ end
12
+ end
13
+
14
+ def to_s
15
+ hash = {}
16
+ instance_variables.each { |var| hash[var.to_s.delete("@")] = instance_variable_get(var) }
17
+ hash.to_s
18
+ end
19
+ end
20
+
21
+ class Country < LookupBaseResource
22
+ end
23
+
24
+ class NumberFormat < LookupBaseResource
25
+ end
26
+
27
+ class Carrier < LookupBaseResource
28
+ end
29
+
30
+ # Not subclassing from Base::Resource because it cannot set nested
31
+ # attributes. Named the class 'LookupResponse' because the name
32
+ # 'Number' is already taken.
33
+ class LookupResponse < LookupBaseResource
34
+ def initialize(client, options = nil)
35
+ # there is no use for client here
36
+ valid_param?(:options, options, Hash, false)
37
+ parse_and_set(options[:resource_json]) if options.key?(:resource_json)
38
+ end
39
+
40
+ def parse_and_set(resp)
41
+ return unless resp
42
+ valid_param?(:resp, resp, Hash, true)
43
+
44
+ resp.each do |k, v|
45
+ case k
46
+ when "country"
47
+ instance_variable_set("@#{k}", Country.new(v))
48
+ when "format"
49
+ instance_variable_set("@#{k}", NumberFormat.new(v))
50
+ when "carrier"
51
+ instance_variable_set("@#{k}", Carrier.new(v))
52
+ else
53
+ instance_variable_set("@#{k}", v)
54
+ end
55
+ self.class.send(:attr_reader, k)
56
+ end
57
+ end
58
+ end
59
+
60
+ class LookupInterface < Base::ResourceInterface
61
+ def initialize(client, resource_list_json = nil)
62
+ @_resource_type = LookupResponse
63
+ @_identifier_string = "phone_number"
64
+ super
65
+ # Override _resource_uri only after calling super
66
+ @_resource_uri = "/v1/Lookup/Number/"
67
+ end
68
+
69
+ ##
70
+ # Lookup a number
71
+ # @param [String] number
72
+ # @return [LookupResponse] LookupResponse
73
+ def get(number, type = "carrier")
74
+ valid_param?(:number, number, [String, Symbol], true)
75
+ perform_get(number, { "type" => type })
76
+ end
77
+
78
+ private
79
+
80
+ # overridden to ensure 'Account' and extra shash isn't added to URL path
81
+ def perform_get(identifier, params = nil)
82
+ valid_param?(:identifier, identifier, [String, Symbol], true)
83
+ response_json = @_client.send_request(@_resource_uri + identifier.to_s, "GET", params, nil, false, is_voice_request: @_is_voice_request)
84
+ @_resource_type.new(@_client, resource_json: response_json)
85
+ end
86
+ end
87
+ end
88
+ end
@@ -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)
@@ -1,6 +1,6 @@
1
- require_relative 'resources'
2
- require_relative 'base_client'
3
- require_relative 'base'
1
+ require_relative "resources"
2
+ require_relative "base_client"
3
+ require_relative "base"
4
4
 
5
5
  module Plivo
6
6
  class RestClient < BaseClient
@@ -13,8 +13,9 @@ module Plivo
13
13
  attr_reader :call_feedback
14
14
  attr_reader :powerpacks
15
15
  attr_reader :powerpacks, :media
16
+ attr_reader :lookup
16
17
 
17
- def initialize(auth_id = nil, auth_token = nil, proxy_options = nil, timeout=5)
18
+ def initialize(auth_id = nil, auth_token = nil, proxy_options = nil, timeout = 5)
18
19
  configure_base_uri
19
20
  super
20
21
  configure_interfaces
@@ -47,6 +48,7 @@ module Plivo
47
48
  @addresses = Resources::AddressInterface.new(self)
48
49
  @identities = Resources::IdentityInterface.new(self)
49
50
  @call_feedback = Resources::CallFeedbackInterface.new(self)
51
+ @lookup = Resources::LookupInterface.new(self)
50
52
  end
51
53
  end
52
54
  end
@@ -1,3 +1,3 @@
1
1
  module Plivo
2
- VERSION = '4.9.0'.freeze
2
+ VERSION = "4.13.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.9.0
4
+ version: 4.13.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-08-05 00:00:00.000000000 Z
11
+ date: 2020-10-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
@@ -165,6 +165,7 @@ files:
165
165
  - ci/config.yml
166
166
  - examples/conference_bridge.rb
167
167
  - examples/jwt.rb
168
+ - examples/lookup.rb
168
169
  - examples/multi_party_call.rb
169
170
  - examples/phlos.rb
170
171
  - lib/plivo.rb
@@ -185,11 +186,12 @@ files:
185
186
  - lib/plivo/resources/conferences.rb
186
187
  - lib/plivo/resources/endpoints.rb
187
188
  - lib/plivo/resources/identities.rb
189
+ - lib/plivo/resources/lookup.rb
188
190
  - lib/plivo/resources/media.rb
189
- - lib/plivo/resources/member.rb
190
191
  - lib/plivo/resources/messages.rb
191
192
  - lib/plivo/resources/nodes.rb
192
193
  - lib/plivo/resources/numbers.rb
194
+ - lib/plivo/resources/phlo_member.rb
193
195
  - lib/plivo/resources/phlos.rb
194
196
  - lib/plivo/resources/powerpacks.rb
195
197
  - lib/plivo/resources/pricings.rb