bandwidth-sdk 6.1.0 → 6.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +89 -12
- data/lib/bandwidth.rb +2 -0
- data/lib/bandwidth/api_helper.rb +5 -5
- data/lib/bandwidth/client.rb +15 -1
- data/lib/bandwidth/configuration.rb +39 -3
- data/lib/bandwidth/http/auth/phone_number_lookup_basic_auth.rb +22 -0
- data/lib/bandwidth/http/faraday_client.rb +5 -2
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup.rb +20 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/client.rb +60 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb +1551 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb +49 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb +29 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb +35 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb +45 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb +74 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb +107 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +10 -1
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/device_api_version_enum.rb +2 -2
- data/test/controllers/controller_test_base.rb +21 -0
- data/test/http_response_catcher.rb +19 -0
- data/test/integration/test_integration.rb +14 -1
- data/test/test_helper.rb +94 -0
- metadata +20 -7
@@ -0,0 +1,49 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# BaseController.
|
8
|
+
class BaseController
|
9
|
+
attr_accessor :config, :http_call_back
|
10
|
+
|
11
|
+
def initialize(config, http_call_back: nil)
|
12
|
+
@config = config
|
13
|
+
@http_call_back = http_call_back
|
14
|
+
|
15
|
+
@global_headers = {
|
16
|
+
'user-agent' => 'ruby-sdk'
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def validate_parameters(args)
|
21
|
+
args.each do |_name, value|
|
22
|
+
if value.nil?
|
23
|
+
raise ArgumentError, "Required parameter #{_name} cannot be nil."
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def execute_request(request, binary: false)
|
29
|
+
@http_call_back.on_before_request(request) if @http_call_back
|
30
|
+
|
31
|
+
APIHelper.clean_hash(request.headers)
|
32
|
+
request.headers.merge!(@global_headers)
|
33
|
+
|
34
|
+
response = if binary
|
35
|
+
config.http_client.execute_as_binary(request)
|
36
|
+
else
|
37
|
+
config.http_client.execute_as_string(request)
|
38
|
+
end
|
39
|
+
@http_call_back.on_after_response(response) if @http_call_back
|
40
|
+
|
41
|
+
response
|
42
|
+
end
|
43
|
+
|
44
|
+
def validate_response(response)
|
45
|
+
raise APIException.new 'HTTP Response Not OK', response unless
|
46
|
+
response.status_code.between?(200, 208) # [200,208] = HTTP OK
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# Accounts Tnlookup 400 Error class.
|
8
|
+
class AccountsTnlookup400ErrorException < APIException
|
9
|
+
# A description of what validation error occurred.
|
10
|
+
# @return [String]
|
11
|
+
attr_accessor :message
|
12
|
+
|
13
|
+
# The constructor.
|
14
|
+
# @param [String] The reason for raising an exception.
|
15
|
+
# @param [HttpResponse] The HttpReponse of the API call.
|
16
|
+
def initialize(reason, response)
|
17
|
+
super(reason, response)
|
18
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
19
|
+
unbox(hash)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Populates this object by extracting properties from a hash.
|
23
|
+
# @param [Hash] The deserialized response sent by the server in the
|
24
|
+
# response body.
|
25
|
+
def unbox(hash)
|
26
|
+
@message = hash['message']
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# Create TN Lookup Request
|
8
|
+
class OrderRequest < BaseModel
|
9
|
+
# TODO: Write general description for this method
|
10
|
+
# @return [List of String]
|
11
|
+
attr_accessor :tns
|
12
|
+
|
13
|
+
# A mapping from model property names to API property names.
|
14
|
+
def self.names
|
15
|
+
@_hash = {} if @_hash.nil?
|
16
|
+
@_hash['tns'] = 'tns'
|
17
|
+
@_hash
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(tns = nil)
|
21
|
+
@tns = tns
|
22
|
+
end
|
23
|
+
|
24
|
+
# Creates an instance of the object from a hash.
|
25
|
+
def self.from_hash(hash)
|
26
|
+
return nil unless hash
|
27
|
+
|
28
|
+
# Extract variables from the hash.
|
29
|
+
tns = hash['tns']
|
30
|
+
|
31
|
+
# Create object from extracted values.
|
32
|
+
OrderRequest.new(tns)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# The request has been accepted for processing but not yet finished and in a
|
8
|
+
# terminal state (COMPLETE, PARTIAL_COMPLETE, or FAILED)
|
9
|
+
class OrderResponse < BaseModel
|
10
|
+
# TODO: Write general description for this method
|
11
|
+
# @return [String]
|
12
|
+
attr_accessor :request_id
|
13
|
+
|
14
|
+
# TODO: Write general description for this method
|
15
|
+
# @return [String]
|
16
|
+
attr_accessor :status
|
17
|
+
|
18
|
+
# A mapping from model property names to API property names.
|
19
|
+
def self.names
|
20
|
+
@_hash = {} if @_hash.nil?
|
21
|
+
@_hash['request_id'] = 'requestId'
|
22
|
+
@_hash['status'] = 'status'
|
23
|
+
@_hash
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(request_id = nil,
|
27
|
+
status = nil)
|
28
|
+
@request_id = request_id
|
29
|
+
@status = status
|
30
|
+
end
|
31
|
+
|
32
|
+
# Creates an instance of the object from a hash.
|
33
|
+
def self.from_hash(hash)
|
34
|
+
return nil unless hash
|
35
|
+
|
36
|
+
# Extract variables from the hash.
|
37
|
+
request_id = hash['requestId']
|
38
|
+
status = hash['status']
|
39
|
+
|
40
|
+
# Create object from extracted values.
|
41
|
+
OrderResponse.new(request_id,
|
42
|
+
status)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# If requestId exists, the result for that request is returned. See the
|
8
|
+
# Examples for details on the various responses that you can receive.
|
9
|
+
# Generally, if you see a Response Code of 0 in a result for a TN, information
|
10
|
+
# will be available for it. Any other Response Code will indicate no
|
11
|
+
# information was available for the TN.
|
12
|
+
class OrderStatus < BaseModel
|
13
|
+
# The requestId.
|
14
|
+
# @return [String]
|
15
|
+
attr_accessor :request_id
|
16
|
+
|
17
|
+
# The status of the request (IN_PROGRESS, COMPLETE, PARTIAL_COMPLETE, or
|
18
|
+
# FAILED).
|
19
|
+
# @return [String]
|
20
|
+
attr_accessor :status
|
21
|
+
|
22
|
+
# The telephone numbers whose lookup failed
|
23
|
+
# @return [List of String]
|
24
|
+
attr_accessor :failed_telephone_numbers
|
25
|
+
|
26
|
+
# The carrier information results for the specified telephone number.
|
27
|
+
# @return [List of Result]
|
28
|
+
attr_accessor :result
|
29
|
+
|
30
|
+
# A mapping from model property names to API property names.
|
31
|
+
def self.names
|
32
|
+
@_hash = {} if @_hash.nil?
|
33
|
+
@_hash['request_id'] = 'requestId'
|
34
|
+
@_hash['status'] = 'status'
|
35
|
+
@_hash['failed_telephone_numbers'] = 'failedTelephoneNumbers'
|
36
|
+
@_hash['result'] = 'result'
|
37
|
+
@_hash
|
38
|
+
end
|
39
|
+
|
40
|
+
def initialize(request_id = nil,
|
41
|
+
status = nil,
|
42
|
+
failed_telephone_numbers = nil,
|
43
|
+
result = nil)
|
44
|
+
@request_id = request_id
|
45
|
+
@status = status
|
46
|
+
@failed_telephone_numbers = failed_telephone_numbers
|
47
|
+
@result = result
|
48
|
+
end
|
49
|
+
|
50
|
+
# Creates an instance of the object from a hash.
|
51
|
+
def self.from_hash(hash)
|
52
|
+
return nil unless hash
|
53
|
+
|
54
|
+
# Extract variables from the hash.
|
55
|
+
request_id = hash['requestId']
|
56
|
+
status = hash['status']
|
57
|
+
failed_telephone_numbers = hash['failedTelephoneNumbers']
|
58
|
+
# Parameter is an array, so we need to iterate through it
|
59
|
+
result = nil
|
60
|
+
unless hash['result'].nil?
|
61
|
+
result = []
|
62
|
+
hash['result'].each do |structure|
|
63
|
+
result << (Result.from_hash(structure) if structure)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Create object from extracted values.
|
68
|
+
OrderStatus.new(request_id,
|
69
|
+
status,
|
70
|
+
failed_telephone_numbers,
|
71
|
+
result)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# Result Model.
|
8
|
+
class Result < BaseModel
|
9
|
+
# Our vendor's response code.
|
10
|
+
# @return [Integer]
|
11
|
+
attr_accessor :response_code
|
12
|
+
|
13
|
+
# Message associated with the response code.
|
14
|
+
# @return [String]
|
15
|
+
attr_accessor :message
|
16
|
+
|
17
|
+
# The telephone number in E.164 format.
|
18
|
+
# @return [String]
|
19
|
+
attr_accessor :e_164_format
|
20
|
+
|
21
|
+
# The formatted version of the telephone number.
|
22
|
+
# @return [String]
|
23
|
+
attr_accessor :formatted
|
24
|
+
|
25
|
+
# The country of the telephone number.
|
26
|
+
# @return [String]
|
27
|
+
attr_accessor :country
|
28
|
+
|
29
|
+
# The line type of the telephone number.
|
30
|
+
# @return [String]
|
31
|
+
attr_accessor :line_type
|
32
|
+
|
33
|
+
# The service provider of the telephone number.
|
34
|
+
# @return [String]
|
35
|
+
attr_accessor :line_provider
|
36
|
+
|
37
|
+
# The first half of the Home Network Identity (HNI).
|
38
|
+
# @return [String]
|
39
|
+
attr_accessor :mobile_country_code
|
40
|
+
|
41
|
+
# The second half of the HNI.
|
42
|
+
# @return [String]
|
43
|
+
attr_accessor :mobile_network_code
|
44
|
+
|
45
|
+
# A mapping from model property names to API property names.
|
46
|
+
def self.names
|
47
|
+
@_hash = {} if @_hash.nil?
|
48
|
+
@_hash['response_code'] = 'Response Code'
|
49
|
+
@_hash['message'] = 'Message'
|
50
|
+
@_hash['e_164_format'] = 'E.164 Format'
|
51
|
+
@_hash['formatted'] = 'Formatted'
|
52
|
+
@_hash['country'] = 'Country'
|
53
|
+
@_hash['line_type'] = 'Line Type'
|
54
|
+
@_hash['line_provider'] = 'Line Provider'
|
55
|
+
@_hash['mobile_country_code'] = 'Mobile Country Code'
|
56
|
+
@_hash['mobile_network_code'] = 'Mobile Network Code'
|
57
|
+
@_hash
|
58
|
+
end
|
59
|
+
|
60
|
+
def initialize(response_code = nil,
|
61
|
+
message = nil,
|
62
|
+
e_164_format = nil,
|
63
|
+
formatted = nil,
|
64
|
+
country = nil,
|
65
|
+
line_type = nil,
|
66
|
+
line_provider = nil,
|
67
|
+
mobile_country_code = nil,
|
68
|
+
mobile_network_code = nil)
|
69
|
+
@response_code = response_code
|
70
|
+
@message = message
|
71
|
+
@e_164_format = e_164_format
|
72
|
+
@formatted = formatted
|
73
|
+
@country = country
|
74
|
+
@line_type = line_type
|
75
|
+
@line_provider = line_provider
|
76
|
+
@mobile_country_code = mobile_country_code
|
77
|
+
@mobile_network_code = mobile_network_code
|
78
|
+
end
|
79
|
+
|
80
|
+
# Creates an instance of the object from a hash.
|
81
|
+
def self.from_hash(hash)
|
82
|
+
return nil unless hash
|
83
|
+
|
84
|
+
# Extract variables from the hash.
|
85
|
+
response_code = hash['Response Code']
|
86
|
+
message = hash['Message']
|
87
|
+
e_164_format = hash['E.164 Format']
|
88
|
+
formatted = hash['Formatted']
|
89
|
+
country = hash['Country']
|
90
|
+
line_type = hash['Line Type']
|
91
|
+
line_provider = hash['Line Provider']
|
92
|
+
mobile_country_code = hash['Mobile Country Code']
|
93
|
+
mobile_network_code = hash['Mobile Network Code']
|
94
|
+
|
95
|
+
# Create object from extracted values.
|
96
|
+
Result.new(response_code,
|
97
|
+
message,
|
98
|
+
e_164_format,
|
99
|
+
formatted,
|
100
|
+
country,
|
101
|
+
line_type,
|
102
|
+
line_provider,
|
103
|
+
mobile_country_code,
|
104
|
+
mobile_network_code)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -16,12 +16,17 @@ module Bandwidth
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
|
19
|
-
backoff_factor:
|
19
|
+
backoff_factor: 2,
|
20
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
21
|
+
retry_methods: %i[get put get put],
|
22
|
+
environment: Environment::PRODUCTION,
|
20
23
|
base_url: 'https://www.example.com',
|
21
24
|
messaging_basic_auth_user_name: 'TODO: Replace',
|
22
25
|
messaging_basic_auth_password: 'TODO: Replace',
|
23
26
|
two_factor_auth_basic_auth_user_name: 'TODO: Replace',
|
24
27
|
two_factor_auth_basic_auth_password: 'TODO: Replace',
|
28
|
+
phone_number_lookup_basic_auth_user_name: 'TODO: Replace',
|
29
|
+
phone_number_lookup_basic_auth_password: 'TODO: Replace',
|
25
30
|
voice_basic_auth_user_name: 'TODO: Replace',
|
26
31
|
voice_basic_auth_password: 'TODO: Replace',
|
27
32
|
web_rtc_basic_auth_user_name: 'TODO: Replace',
|
@@ -32,12 +37,16 @@ module Bandwidth
|
|
32
37
|
max_retries: max_retries,
|
33
38
|
retry_interval: retry_interval,
|
34
39
|
backoff_factor: backoff_factor,
|
40
|
+
retry_statuses: retry_statuses,
|
41
|
+
retry_methods: retry_methods,
|
35
42
|
environment: environment,
|
36
43
|
base_url: base_url,
|
37
44
|
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
38
45
|
messaging_basic_auth_password: messaging_basic_auth_password,
|
39
46
|
two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
|
40
47
|
two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
|
48
|
+
phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name,
|
49
|
+
phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password,
|
41
50
|
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
42
51
|
voice_basic_auth_password: voice_basic_auth_password,
|
43
52
|
web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
|
@@ -8,10 +8,10 @@ module Bandwidth
|
|
8
8
|
class DeviceApiVersionEnum
|
9
9
|
DEVICE_API_VERSION_ENUM = [
|
10
10
|
# TODO: Write general description for V3
|
11
|
-
V3 = '
|
11
|
+
V3 = 'V3'.freeze,
|
12
12
|
|
13
13
|
# TODO: Write general description for V2
|
14
|
-
V2 = '
|
14
|
+
V2 = 'V2'.freeze
|
15
15
|
].freeze
|
16
16
|
end
|
17
17
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require 'json'
|
7
|
+
require 'minitest/autorun'
|
8
|
+
require 'minitest/hell'
|
9
|
+
require 'minitest/pride'
|
10
|
+
require 'minitest/proveit'
|
11
|
+
require 'bandwidth'
|
12
|
+
require_relative '../test_helper'
|
13
|
+
require_relative '../http_response_catcher'
|
14
|
+
|
15
|
+
class ControllerTestBase < Minitest::Test
|
16
|
+
parallelize_me!
|
17
|
+
include Bandwidth
|
18
|
+
|
19
|
+
# Create configuration and set any test parameters
|
20
|
+
CONFIG = Configuration.new
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
class HttpResponseCatcher < Bandwidth::HttpCallBack
|
7
|
+
attr_accessor :response
|
8
|
+
|
9
|
+
def on_before_request(request)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Catching the response
|
13
|
+
def on_after_response(response)
|
14
|
+
@response = response
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
|
@@ -35,7 +35,9 @@ class IntegrationTest < Test::Unit::TestCase
|
|
35
35
|
messaging_basic_auth_user_name: USERNAME,
|
36
36
|
messaging_basic_auth_password: PASSWORD,
|
37
37
|
two_factor_auth_basic_auth_user_name: USERNAME,
|
38
|
-
two_factor_auth_basic_auth_password: PASSWORD
|
38
|
+
two_factor_auth_basic_auth_password: PASSWORD,
|
39
|
+
phone_number_lookup_basic_auth_user_name: USERNAME,
|
40
|
+
phone_number_lookup_basic_auth_password: PASSWORD
|
39
41
|
)
|
40
42
|
end
|
41
43
|
|
@@ -567,4 +569,15 @@ class IntegrationTest < Test::Unit::TestCase
|
|
567
569
|
actual = response.to_bxml()
|
568
570
|
assert_equal(expected, actual)
|
569
571
|
end
|
572
|
+
|
573
|
+
def test_tn_lookup
|
574
|
+
body = OrderRequest.new
|
575
|
+
body.tns = [PHONE_NUMBER_OUTBOUND]
|
576
|
+
create_response = @bandwidth_client.phone_number_lookup_client.client.create_lookup_request(ACCOUNT_ID, body)
|
577
|
+
assert(create_response.data.request_id.length > 0, "request_id value not set")
|
578
|
+
|
579
|
+
request_id = create_response.data.request_id
|
580
|
+
get_response = @bandwidth_client.phone_number_lookup_client.client.get_lookup_request_status(ACCOUNT_ID, request_id)
|
581
|
+
assert(get_response.data.status.length > 0, "status value not set")
|
582
|
+
end
|
570
583
|
end
|