plivo 4.12.0 → 4.13.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 +4 -4
- data/CHANGELOG.md +4 -1
- data/README.md +16 -1
- data/examples/lookup.rb +24 -0
- data/lib/plivo/resources.rb +1 -0
- data/lib/plivo/resources/lookup.rb +88 -0
- data/lib/plivo/rest_client.rb +6 -4
- data/lib/plivo/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c0b51ab5d0b175827b3db20495da181efa57e07
|
4
|
+
data.tar.gz: be490b21e0e114d458578c5e0dc2d0b986e87959
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbad3689ef259c9e549093b4b16e116e8828631e216783657a95108adde98d863f8b22cbf24ea27a76595abdd9dd49bd71fb624a6badee4fa7e77866d7149fbd
|
7
|
+
data.tar.gz: 6dbadf7e2797168ccf6f1778d743a2c15df300eccb9354561bf23fcbba3d14de0c814cbd2fd0e80dc5877a5d1467fe570a15b01e7d4ab290d5107ee0df4fe34e
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,12 @@
|
|
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
|
+
|
3
6
|
## [4.12.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.12.0) (2020-09-24)
|
4
7
|
- Add "public_uri" optional param support for Application API.
|
5
8
|
|
6
|
-
## [4.11.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.
|
9
|
+
## [4.11.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.11.0) (2020-08-25)
|
7
10
|
- Add Powerpack for mms
|
8
11
|
|
9
12
|
## [4.10.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.10.0) (2020-09-04)
|
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.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
|
data/examples/lookup.rb
ADDED
@@ -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
|
data/lib/plivo/resources.rb
CHANGED
@@ -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
|
data/lib/plivo/rest_client.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative
|
3
|
-
require_relative
|
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
|
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.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-
|
11
|
+
date: 2020-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -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,6 +186,7 @@ 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
191
|
- lib/plivo/resources/messages.rb
|
190
192
|
- lib/plivo/resources/nodes.rb
|