plivo 4.13.0 → 4.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c0b51ab5d0b175827b3db20495da181efa57e07
4
- data.tar.gz: be490b21e0e114d458578c5e0dc2d0b986e87959
3
+ metadata.gz: d641350610110aad6f806863f07423c6d00c25cc
4
+ data.tar.gz: 575c20c51371033efd51c06d9005bc465ea59502
5
5
  SHA512:
6
- metadata.gz: dbad3689ef259c9e549093b4b16e116e8828631e216783657a95108adde98d863f8b22cbf24ea27a76595abdd9dd49bd71fb624a6badee4fa7e77866d7149fbd
7
- data.tar.gz: 6dbadf7e2797168ccf6f1778d743a2c15df300eccb9354561bf23fcbba3d14de0c814cbd2fd0e80dc5877a5d1467fe570a15b01e7d4ab290d5107ee0df4fe34e
6
+ metadata.gz: 837eec078ee00718c11d4c0ac9dd96a238d017289fb648aed9b9045373afe166f56be1eccea3d65b10d8c8276ba3a3e774682373ef4c9be6940a77dc566104db
7
+ data.tar.gz: 7762e64e47c88778486e5bb584aae0af7fc6ec8d1cdc1ad2025dfb9e778eb4a2d54ba0c9a57a896cf967d54ab46aac7c81b6a5364b1785708e040c894c8bc1da
@@ -1,5 +1,8 @@
1
1
  # Change Log
2
2
 
3
+ ## [4.14.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.14.0) (2020-10-30)
4
+ - Change lookup API endpoint and response.
5
+
3
6
  ## [4.13.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.13.0) (2020-09-30)
4
7
  - Add support for Lookup API
5
8
 
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.13.0'
11
+ gem 'plivo', '>= 4.14.0'
12
12
  ```
13
13
 
14
14
  And then execute:
@@ -114,10 +114,7 @@ require 'plivo'
114
114
  include Plivo
115
115
 
116
116
  client = RestClient.new
117
- resp = client.lookup.get(
118
- '<number-here>',
119
- "carrier"
120
- )
117
+ resp = client.lookup.get('<number-here>')
121
118
  ```
122
119
 
123
120
  ### Generate Plivo XML
@@ -12,5 +12,6 @@ module Plivo
12
12
 
13
13
  CALLINSIGHTS_API_URL = 'https://stats.plivo.com'.freeze
14
14
  PHLO_API_URL = 'https://phlorunner.plivo.com'.freeze
15
+ LOOKUP_API_URL = 'https://lookup.plivo.com'.freeze
15
16
  end
16
17
  end
@@ -61,7 +61,12 @@ module Plivo
61
61
  else
62
62
  process_response(method, response.to_hash)
63
63
  end
64
-
64
+ elsif options[:is_lookup_request] == true
65
+ response = case method
66
+ when 'GET' then send_get(resource_path, data, timeout, is_lookup_request: options[:is_lookup_request])
67
+ else raise_invalid_request("#{method} not supported by Plivo, yet")
68
+ end
69
+ process_response(method, response.to_hash)
65
70
  else
66
71
  response = case method
67
72
  when 'GET' then send_get(resource_path, data, timeout)
@@ -191,6 +196,18 @@ module Plivo
191
196
  faraday.adapter Faraday.default_adapter
192
197
  end
193
198
 
199
+ @lookup_conn = Faraday.new(@lookup_base_uri) do |faraday|
200
+ faraday.headers = @headers
201
+
202
+ # DANGER: Basic auth should always come after headers, else
203
+ # The headers will replace the basic_auth
204
+
205
+ faraday.basic_auth(auth_id, auth_token)
206
+
207
+ faraday.proxy=@proxy_hash if @proxy_hash
208
+ faraday.response :json, content_type: /\bjson$/
209
+ faraday.adapter Faraday.default_adapter
210
+ end
194
211
  end
195
212
 
196
213
  def send_get(resource_path, data, timeout, options = nil)
@@ -210,6 +227,11 @@ module Plivo
210
227
  req.url resource_path, data
211
228
  req.options.timeout = timeout if timeout
212
229
  end
230
+ elsif options[:is_lookup_request] == true
231
+ response = @lookup_conn.get do |req|
232
+ req.url resource_path, data
233
+ req.options.timeout = timeout if timeout
234
+ end
213
235
  end
214
236
  else
215
237
  response = @conn.get do |req|
@@ -63,7 +63,7 @@ module Plivo
63
63
  @_identifier_string = "phone_number"
64
64
  super
65
65
  # Override _resource_uri only after calling super
66
- @_resource_uri = "/v1/Lookup/Number/"
66
+ @_resource_uri = "/v1/Number/"
67
67
  end
68
68
 
69
69
  ##
@@ -80,7 +80,7 @@ module Plivo
80
80
  # overridden to ensure 'Account' and extra shash isn't added to URL path
81
81
  def perform_get(identifier, params = nil)
82
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)
83
+ response_json = @_client.send_request(@_resource_uri + identifier.to_s, "GET", params, nil, false, is_voice_request: @_is_voice_request, is_lookup_request: true)
84
84
  @_resource_type.new(@_client, resource_json: response_json)
85
85
  end
86
86
  end
@@ -29,6 +29,7 @@ module Plivo
29
29
  @voice_base_uri_fallback_1 = Base::API_VOICE_FALLBACK_1
30
30
  @voice_base_uri_fallback_2 = Base::API_VOICE_FALLBACK_2
31
31
  @callinsights_base_uri = Base::CALLINSIGHTS_API_URL
32
+ @lookup_base_uri = Base::LOOKUP_API_URL
32
33
  end
33
34
 
34
35
  def configure_interfaces
@@ -1,3 +1,3 @@
1
1
  module Plivo
2
- VERSION = "4.13.0".freeze
2
+ VERSION = "4.14.0".freeze
3
3
  end
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.13.0
4
+ version: 4.14.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-10-07 00:00:00.000000000 Z
11
+ date: 2020-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday