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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5539a17ccb877e0e80a53959cbbc354314c0300c3c3ce1e90de0c4b5eae9f18a
|
4
|
+
data.tar.gz: 1f0466592184f21361287991b49a596c46d5de6f34dca9b727884f077591bf72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd6452d48d8a62e0bce5fb173132aac42f52918632c696e4153bfedc6d3c6db9769ab2941c0031d5c70b4ed245d35f0bee4929c54a6511441ad60e59c77c1fb5
|
7
|
+
data.tar.gz: 677a0c3e526b2d0f90d4d7905f7b914ce44f8d7a8eee47760693682da200c441cd476030a5e051dc87fdb716aea287d0184584d3c91691cb636ed49ecdaa07be
|
data/README.md
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
# Bandwidth Ruby SDK
|
2
|
-
|
3
|
-
Bandwidth's API docs can be found at https://dev.bandwidth.com
|
4
2
|
|
5
|
-
|
3
|
+
## Getting Started
|
6
4
|
|
7
|
-
|
5
|
+
### Installation
|
8
6
|
|
9
7
|
```
|
10
8
|
gem install bandwidth-sdk
|
11
9
|
```
|
12
10
|
|
13
|
-
|
11
|
+
### Initialize
|
14
12
|
|
15
13
|
```ruby
|
16
14
|
require 'bandwidth'
|
@@ -18,21 +16,27 @@ require 'bandwidth'
|
|
18
16
|
include Bandwidth
|
19
17
|
include Bandwidth::Voice
|
20
18
|
include Bandwidth::Messaging
|
19
|
+
include Bandwidth::WebRtc
|
20
|
+
include Bandwidth::TwoFactorAuth
|
21
21
|
|
22
22
|
bandwidth_client = Bandwidth::Client.new(
|
23
23
|
voice_basic_auth_user_name: 'username',
|
24
24
|
voice_basic_auth_password: 'password',
|
25
|
-
messaging_basic_auth_user_name: '
|
26
|
-
messaging_basic_auth_password: '
|
25
|
+
messaging_basic_auth_user_name: 'username',
|
26
|
+
messaging_basic_auth_password: 'username',
|
27
|
+
two_factor_auth_basic_auth_user_name: 'username',
|
28
|
+
two_factor_auth_basic_auth_password: 'password',
|
29
|
+
web_rtc_basic_auth_user_name: 'username',
|
30
|
+
web_rtc_basic_auth_password: 'password'
|
27
31
|
)
|
32
|
+
account_id = "12345"
|
28
33
|
```
|
29
34
|
|
30
|
-
|
35
|
+
### Create Phone Call
|
31
36
|
|
32
37
|
```ruby
|
33
38
|
voice_client = bandwidth_client.voice_client.client
|
34
39
|
|
35
|
-
account_id = '1'
|
36
40
|
body = ApiCreateCallRequest.new
|
37
41
|
body.from = '+16666666666'
|
38
42
|
body.to = '+17777777777'
|
@@ -49,7 +53,7 @@ rescue Bandwidth::ErrorResponseException => e
|
|
49
53
|
end
|
50
54
|
```
|
51
55
|
|
52
|
-
|
56
|
+
### Generate BXML
|
53
57
|
|
54
58
|
```ruby
|
55
59
|
response = Bandwidth::Voice::Response.new()
|
@@ -59,12 +63,11 @@ response.push(hangup)
|
|
59
63
|
puts response.to_bxml()
|
60
64
|
```
|
61
65
|
|
62
|
-
|
66
|
+
### Send Text Message
|
63
67
|
|
64
68
|
```ruby
|
65
69
|
messaging_client = bandwidth_client.messaging_client.client
|
66
70
|
|
67
|
-
account_id = '1'
|
68
71
|
body = MessageRequest.new
|
69
72
|
body.application_id = '1-2-3'
|
70
73
|
body.to = ['+17777777777']
|
@@ -83,3 +86,77 @@ rescue Bandwidth::PathClientException => e
|
|
83
86
|
puts e.response_code #400
|
84
87
|
end
|
85
88
|
```
|
89
|
+
|
90
|
+
### Create A MFA Request
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
auth_client = bandwidth_client.two_factor_auth_client.mfa
|
94
|
+
|
95
|
+
from_phone = "+18888888888"
|
96
|
+
to_phone = "+17777777777"
|
97
|
+
messaging_application_id = "1-d-b"
|
98
|
+
scope = "scope"
|
99
|
+
digits = 6
|
100
|
+
|
101
|
+
body = TwoFactorCodeRequestSchema.new
|
102
|
+
body.from = from_phone
|
103
|
+
body.to = to_phone
|
104
|
+
body.application_id = messaging_application_id
|
105
|
+
body.scope = scope
|
106
|
+
body.digits = digits
|
107
|
+
body.message = "Your temporary {NAME} {SCOPE} code is {CODE}"
|
108
|
+
|
109
|
+
auth_client.create_messaging_two_factor(account_id, body)
|
110
|
+
|
111
|
+
code = "123456" #This is the user input to validate
|
112
|
+
|
113
|
+
body = TwoFactorVerifyRequestSchema.new
|
114
|
+
body.from = from_phone
|
115
|
+
body.to = to_phone
|
116
|
+
body.application_id = application_id
|
117
|
+
body.scope = scope
|
118
|
+
body.code = code
|
119
|
+
body.digits = digits
|
120
|
+
body.expiration_time_in_minutes = 3
|
121
|
+
|
122
|
+
response = auth_client.create_verify_two_factor(account_id, body)
|
123
|
+
puts "Auth status: " + response.data.valid.to_s
|
124
|
+
```
|
125
|
+
|
126
|
+
### WebRtc Participant & Session Management
|
127
|
+
|
128
|
+
```ruby
|
129
|
+
web_rtc_client = bandwidth_client.web_rtc_client.client
|
130
|
+
|
131
|
+
create_session_body = Session.new
|
132
|
+
create_session_body.tag = 'new-session'
|
133
|
+
|
134
|
+
create_session_response = web_rtc_client.create_session(account_id, :body => create_session_body)
|
135
|
+
session_id = create_session_response.data.id
|
136
|
+
puts session_id
|
137
|
+
|
138
|
+
create_participant_body = Participant.new
|
139
|
+
create_participant_body.publish_permissions = [
|
140
|
+
PublishPermissionEnum::AUDIO,
|
141
|
+
PublishPermissionEnum::VIDEO
|
142
|
+
]
|
143
|
+
create_participant_body.callback_url = "https://sample.com"
|
144
|
+
|
145
|
+
create_participant_response = web_rtc_client.create_participant(account_id, :body => create_participant_body)
|
146
|
+
participant_id = create_participant_response.data.participant.id
|
147
|
+
puts participant_id
|
148
|
+
|
149
|
+
web_rtc_client.add_participant_to_session(account_id, session_id, participant_id)
|
150
|
+
```
|
151
|
+
|
152
|
+
## Supported Ruby Versions
|
153
|
+
|
154
|
+
This package can be used with Ruby >= 2.0
|
155
|
+
|
156
|
+
## Documentation
|
157
|
+
|
158
|
+
Documentation for this package can be found at https://dev.bandwidth.com/sdks/ruby.html
|
159
|
+
|
160
|
+
## Credentials
|
161
|
+
|
162
|
+
Information for credentials for this package can be found at https://dev.bandwidth.com/guides/accountCredentials.html
|
data/lib/bandwidth.rb
CHANGED
@@ -37,6 +37,8 @@ require_relative 'bandwidth/messaging_lib/messaging'
|
|
37
37
|
require_relative 'bandwidth/http/auth/messaging_basic_auth.rb'
|
38
38
|
require_relative 'bandwidth/two_factor_auth_lib/two_factor_auth'
|
39
39
|
require_relative 'bandwidth/http/auth/two_factor_auth_basic_auth.rb'
|
40
|
+
require_relative 'bandwidth/phone_number_lookup_lib/phone_number_lookup'
|
41
|
+
require_relative 'bandwidth/http/auth/phone_number_lookup_basic_auth.rb'
|
40
42
|
require_relative 'bandwidth/voice_lib/voice'
|
41
43
|
require_relative 'bandwidth/http/auth/voice_basic_auth.rb'
|
42
44
|
require_relative 'bandwidth/web_rtc_lib/web_rtc'
|
data/lib/bandwidth/api_helper.rb
CHANGED
@@ -68,9 +68,7 @@ module Bandwidth
|
|
68
68
|
# Appends the given set of parameters to the given query string.
|
69
69
|
# @param [String] The query string builder to add the query parameters to.
|
70
70
|
# @param [Hash] The parameters to append.
|
71
|
-
|
72
|
-
def self.append_url_with_query_parameters(query_builder, parameters,
|
73
|
-
array_serialization: 'indexed')
|
71
|
+
def self.append_url_with_query_parameters(query_builder, parameters)
|
74
72
|
# Perform parameter validation.
|
75
73
|
unless query_builder.instance_of? String
|
76
74
|
raise ArgumentError, 'Given value for parameter \"query_builder\"
|
@@ -80,6 +78,8 @@ module Bandwidth
|
|
80
78
|
# Return if there are no parameters to replace.
|
81
79
|
return query_builder if parameters.nil?
|
82
80
|
|
81
|
+
array_serialization = 'indexed'
|
82
|
+
|
83
83
|
parameters.each do |key, value|
|
84
84
|
seperator = query_builder.include?('?') ? '&' : '?'
|
85
85
|
unless value.nil?
|
@@ -156,8 +156,8 @@ module Bandwidth
|
|
156
156
|
# Form encodes a hash of parameters.
|
157
157
|
# @param [Hash] The hash of parameters to encode.
|
158
158
|
# @return [Hash] A hash with the same parameters form encoded.
|
159
|
-
def self.form_encode_parameters(form_parameters
|
160
|
-
|
159
|
+
def self.form_encode_parameters(form_parameters)
|
160
|
+
array_serialization = 'indexed'
|
161
161
|
encoded = {}
|
162
162
|
form_parameters.each do |key, value|
|
163
163
|
encoded.merge!(APIHelper.form_encode(value, key, formatting:
|
data/lib/bandwidth/client.rb
CHANGED
@@ -17,6 +17,11 @@ module Bandwidth
|
|
17
17
|
def two_factor_auth_client
|
18
18
|
@two_factor_auth_client ||= TwoFactorAuth::Client.new(config: config)
|
19
19
|
end
|
20
|
+
# Access to phone_number_lookup_client controller.
|
21
|
+
# @return [PhoneNumberLookup::Client] Returns the client instance.
|
22
|
+
def phone_number_lookup_client
|
23
|
+
@phone_number_lookup_client ||= PhoneNumberLookup::Client.new(config: config)
|
24
|
+
end
|
20
25
|
# Access to voice_client controller.
|
21
26
|
# @return [Voice::Client] Returns the client instance.
|
22
27
|
def voice_client
|
@@ -29,12 +34,17 @@ module Bandwidth
|
|
29
34
|
end
|
30
35
|
|
31
36
|
def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
|
32
|
-
backoff_factor:
|
37
|
+
backoff_factor: 2,
|
38
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
39
|
+
retry_methods: %i[get put get put],
|
40
|
+
environment: Environment::PRODUCTION,
|
33
41
|
base_url: 'https://www.example.com',
|
34
42
|
messaging_basic_auth_user_name: 'TODO: Replace',
|
35
43
|
messaging_basic_auth_password: 'TODO: Replace',
|
36
44
|
two_factor_auth_basic_auth_user_name: 'TODO: Replace',
|
37
45
|
two_factor_auth_basic_auth_password: 'TODO: Replace',
|
46
|
+
phone_number_lookup_basic_auth_user_name: 'TODO: Replace',
|
47
|
+
phone_number_lookup_basic_auth_password: 'TODO: Replace',
|
38
48
|
voice_basic_auth_user_name: 'TODO: Replace',
|
39
49
|
voice_basic_auth_password: 'TODO: Replace',
|
40
50
|
web_rtc_basic_auth_user_name: 'TODO: Replace',
|
@@ -43,12 +53,16 @@ module Bandwidth
|
|
43
53
|
Configuration.new(timeout: timeout, max_retries: max_retries,
|
44
54
|
retry_interval: retry_interval,
|
45
55
|
backoff_factor: backoff_factor,
|
56
|
+
retry_statuses: retry_statuses,
|
57
|
+
retry_methods: retry_methods,
|
46
58
|
environment: environment,
|
47
59
|
base_url: base_url,
|
48
60
|
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
49
61
|
messaging_basic_auth_password: messaging_basic_auth_password,
|
50
62
|
two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
|
51
63
|
two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
|
64
|
+
phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name,
|
65
|
+
phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password,
|
52
66
|
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
53
67
|
voice_basic_auth_password: voice_basic_auth_password,
|
54
68
|
web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
|
@@ -18,6 +18,7 @@ module Bandwidth
|
|
18
18
|
DEFAULT = 'default'.freeze,
|
19
19
|
MESSAGINGDEFAULT = 'MessagingDefault'.freeze,
|
20
20
|
TWOFACTORAUTHDEFAULT = 'TwoFactorAuthDefault'.freeze,
|
21
|
+
PHONENUMBERLOOKUPDEFAULT = 'PhoneNumberLookupDefault'.freeze,
|
21
22
|
VOICEDEFAULT = 'VoiceDefault'.freeze,
|
22
23
|
WEBRTCDEFAULT = 'WebRtcDefault'.freeze
|
23
24
|
].freeze
|
@@ -32,12 +33,16 @@ module Bandwidth
|
|
32
33
|
attr_reader :max_retries
|
33
34
|
attr_reader :retry_interval
|
34
35
|
attr_reader :backoff_factor
|
36
|
+
attr_reader :retry_statuses
|
37
|
+
attr_reader :retry_methods
|
35
38
|
attr_reader :environment
|
36
39
|
attr_reader :base_url
|
37
40
|
attr_reader :messaging_basic_auth_user_name
|
38
41
|
attr_reader :messaging_basic_auth_password
|
39
42
|
attr_reader :two_factor_auth_basic_auth_user_name
|
40
43
|
attr_reader :two_factor_auth_basic_auth_password
|
44
|
+
attr_reader :phone_number_lookup_basic_auth_user_name
|
45
|
+
attr_reader :phone_number_lookup_basic_auth_password
|
41
46
|
attr_reader :voice_basic_auth_user_name
|
42
47
|
attr_reader :voice_basic_auth_password
|
43
48
|
attr_reader :web_rtc_basic_auth_user_name
|
@@ -48,12 +53,17 @@ module Bandwidth
|
|
48
53
|
end
|
49
54
|
|
50
55
|
def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
|
51
|
-
backoff_factor:
|
56
|
+
backoff_factor: 2,
|
57
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
58
|
+
retry_methods: %i[get put get put],
|
59
|
+
environment: Environment::PRODUCTION,
|
52
60
|
base_url: 'https://www.example.com',
|
53
61
|
messaging_basic_auth_user_name: 'TODO: Replace',
|
54
62
|
messaging_basic_auth_password: 'TODO: Replace',
|
55
63
|
two_factor_auth_basic_auth_user_name: 'TODO: Replace',
|
56
64
|
two_factor_auth_basic_auth_password: 'TODO: Replace',
|
65
|
+
phone_number_lookup_basic_auth_user_name: 'TODO: Replace',
|
66
|
+
phone_number_lookup_basic_auth_password: 'TODO: Replace',
|
57
67
|
voice_basic_auth_user_name: 'TODO: Replace',
|
58
68
|
voice_basic_auth_password: 'TODO: Replace',
|
59
69
|
web_rtc_basic_auth_user_name: 'TODO: Replace',
|
@@ -71,6 +81,12 @@ module Bandwidth
|
|
71
81
|
# by in order to provide backoff
|
72
82
|
@backoff_factor = backoff_factor
|
73
83
|
|
84
|
+
# A list of HTTP statuses to retry
|
85
|
+
@retry_statuses = retry_statuses
|
86
|
+
|
87
|
+
# A list of HTTP methods to retry
|
88
|
+
@retry_methods = retry_methods
|
89
|
+
|
74
90
|
# Current API environment
|
75
91
|
@environment = String(environment)
|
76
92
|
|
@@ -89,6 +105,12 @@ module Bandwidth
|
|
89
105
|
# The password to use with basic authentication
|
90
106
|
@two_factor_auth_basic_auth_password = two_factor_auth_basic_auth_password
|
91
107
|
|
108
|
+
# The username to use with basic authentication
|
109
|
+
@phone_number_lookup_basic_auth_user_name = phone_number_lookup_basic_auth_user_name
|
110
|
+
|
111
|
+
# The password to use with basic authentication
|
112
|
+
@phone_number_lookup_basic_auth_password = phone_number_lookup_basic_auth_password
|
113
|
+
|
92
114
|
# The username to use with basic authentication
|
93
115
|
@voice_basic_auth_user_name = voice_basic_auth_user_name
|
94
116
|
|
@@ -106,11 +128,14 @@ module Bandwidth
|
|
106
128
|
end
|
107
129
|
|
108
130
|
def clone_with(timeout: nil, max_retries: nil, retry_interval: nil,
|
109
|
-
backoff_factor: nil,
|
131
|
+
backoff_factor: nil, retry_statuses: nil, retry_methods: nil,
|
132
|
+
environment: nil, base_url: nil,
|
110
133
|
messaging_basic_auth_user_name: nil,
|
111
134
|
messaging_basic_auth_password: nil,
|
112
135
|
two_factor_auth_basic_auth_user_name: nil,
|
113
136
|
two_factor_auth_basic_auth_password: nil,
|
137
|
+
phone_number_lookup_basic_auth_user_name: nil,
|
138
|
+
phone_number_lookup_basic_auth_password: nil,
|
114
139
|
voice_basic_auth_user_name: nil,
|
115
140
|
voice_basic_auth_password: nil,
|
116
141
|
web_rtc_basic_auth_user_name: nil,
|
@@ -119,12 +144,16 @@ module Bandwidth
|
|
119
144
|
max_retries ||= self.max_retries
|
120
145
|
retry_interval ||= self.retry_interval
|
121
146
|
backoff_factor ||= self.backoff_factor
|
147
|
+
retry_statuses ||= self.retry_statuses
|
148
|
+
retry_methods ||= self.retry_methods
|
122
149
|
environment ||= self.environment
|
123
150
|
base_url ||= self.base_url
|
124
151
|
messaging_basic_auth_user_name ||= self.messaging_basic_auth_user_name
|
125
152
|
messaging_basic_auth_password ||= self.messaging_basic_auth_password
|
126
153
|
two_factor_auth_basic_auth_user_name ||= self.two_factor_auth_basic_auth_user_name
|
127
154
|
two_factor_auth_basic_auth_password ||= self.two_factor_auth_basic_auth_password
|
155
|
+
phone_number_lookup_basic_auth_user_name ||= self.phone_number_lookup_basic_auth_user_name
|
156
|
+
phone_number_lookup_basic_auth_password ||= self.phone_number_lookup_basic_auth_password
|
128
157
|
voice_basic_auth_user_name ||= self.voice_basic_auth_user_name
|
129
158
|
voice_basic_auth_password ||= self.voice_basic_auth_password
|
130
159
|
web_rtc_basic_auth_user_name ||= self.web_rtc_basic_auth_user_name
|
@@ -133,11 +162,14 @@ module Bandwidth
|
|
133
162
|
Configuration.new(
|
134
163
|
timeout: timeout, max_retries: max_retries,
|
135
164
|
retry_interval: retry_interval, backoff_factor: backoff_factor,
|
165
|
+
retry_statuses: retry_statuses, retry_methods: retry_methods,
|
136
166
|
environment: environment, base_url: base_url,
|
137
167
|
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
138
168
|
messaging_basic_auth_password: messaging_basic_auth_password,
|
139
169
|
two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
|
140
170
|
two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
|
171
|
+
phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name,
|
172
|
+
phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password,
|
141
173
|
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
142
174
|
voice_basic_auth_password: voice_basic_auth_password,
|
143
175
|
web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
|
@@ -148,7 +180,9 @@ module Bandwidth
|
|
148
180
|
def create_http_client
|
149
181
|
FaradayClient.new(timeout: timeout, max_retries: max_retries,
|
150
182
|
retry_interval: retry_interval,
|
151
|
-
backoff_factor: backoff_factor
|
183
|
+
backoff_factor: backoff_factor,
|
184
|
+
retry_statuses: retry_statuses,
|
185
|
+
retry_methods: retry_methods)
|
152
186
|
end
|
153
187
|
|
154
188
|
# All the environments the SDK can run in.
|
@@ -157,6 +191,7 @@ module Bandwidth
|
|
157
191
|
Server::DEFAULT => 'api.bandwidth.com',
|
158
192
|
Server::MESSAGINGDEFAULT => 'https://messaging.bandwidth.com/api/v2',
|
159
193
|
Server::TWOFACTORAUTHDEFAULT => 'https://mfa.bandwidth.com/api/v1',
|
194
|
+
Server::PHONENUMBERLOOKUPDEFAULT => 'https://numbers.bandwidth.com/api/v1',
|
160
195
|
Server::VOICEDEFAULT => 'https://voice.bandwidth.com',
|
161
196
|
Server::WEBRTCDEFAULT => 'https://api.webrtc.bandwidth.com/v1'
|
162
197
|
},
|
@@ -164,6 +199,7 @@ module Bandwidth
|
|
164
199
|
Server::DEFAULT => '{base_url}',
|
165
200
|
Server::MESSAGINGDEFAULT => '{base_url}',
|
166
201
|
Server::TWOFACTORAUTHDEFAULT => '{base_url}',
|
202
|
+
Server::PHONENUMBERLOOKUPDEFAULT => '{base_url}',
|
167
203
|
Server::VOICEDEFAULT => '{base_url}',
|
168
204
|
Server::WEBRTCDEFAULT => '{base_url}'
|
169
205
|
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require 'base64'
|
7
|
+
|
8
|
+
module Bandwidth
|
9
|
+
# Utility class for basic authorization.
|
10
|
+
class PhoneNumberLookupBasicAuth
|
11
|
+
# Add basic authentication to the request.
|
12
|
+
# @param [HttpRequest] The HttpRequest object to which authentication will
|
13
|
+
# be added.
|
14
|
+
def self.apply(config, http_request)
|
15
|
+
username = config.phone_number_lookup_basic_auth_user_name
|
16
|
+
password = config.phone_number_lookup_basic_auth_password
|
17
|
+
value = Base64.strict_encode64("#{username}:#{password}")
|
18
|
+
header_value = "Basic #{value}"
|
19
|
+
http_request.headers['Authorization'] = header_value
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -11,7 +11,8 @@ module Bandwidth
|
|
11
11
|
class FaradayClient < HttpClient
|
12
12
|
# The constructor.
|
13
13
|
def initialize(timeout:, max_retries:, retry_interval:,
|
14
|
-
backoff_factor:,
|
14
|
+
backoff_factor:, retry_statuses:, retry_methods:,
|
15
|
+
cache: false, verify: true)
|
15
16
|
@connection = Faraday.new do |faraday|
|
16
17
|
faraday.use Faraday::HttpCache, serializer: Marshal if cache
|
17
18
|
faraday.use FaradayMiddleware::FollowRedirects
|
@@ -21,7 +22,9 @@ module Bandwidth
|
|
21
22
|
faraday.ssl[:ca_file] = Certifi.where
|
22
23
|
faraday.ssl[:verify] = verify
|
23
24
|
faraday.request :retry, max: max_retries, interval: retry_interval,
|
24
|
-
backoff_factor: backoff_factor
|
25
|
+
backoff_factor: backoff_factor,
|
26
|
+
retry_statuses: retry_statuses,
|
27
|
+
methods: retry_methods
|
25
28
|
faraday.adapter Faraday.default_adapter
|
26
29
|
faraday.options[:params_encoder] = Faraday::FlatParamsEncoder
|
27
30
|
faraday.options[:timeout] = timeout if timeout > 0
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
|
7
|
+
require_relative 'phone_number_lookup/client.rb'
|
8
|
+
|
9
|
+
# Models
|
10
|
+
require_relative 'phone_number_lookup/models/order_request.rb'
|
11
|
+
require_relative 'phone_number_lookup/models/order_response.rb'
|
12
|
+
require_relative 'phone_number_lookup/models/order_status.rb'
|
13
|
+
require_relative 'phone_number_lookup/models/result.rb'
|
14
|
+
|
15
|
+
# Exceptions
|
16
|
+
require_relative 'phone_number_lookup/exceptions/accounts_tnlookup400_error' \
|
17
|
+
'_exception.rb'
|
18
|
+
# Controllers
|
19
|
+
require_relative 'phone_number_lookup/controllers/base_controller.rb'
|
20
|
+
require_relative 'phone_number_lookup/controllers/api_controller.rb'
|