bandwidth-sdk 6.2.0 → 9.0.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/lib/bandwidth/api_helper.rb +19 -29
- data/lib/bandwidth/client.rb +8 -8
- data/lib/bandwidth/configuration.rb +20 -32
- data/lib/bandwidth/http/auth/{two_factor_auth_basic_auth.rb → multi_factor_auth_basic_auth.rb} +3 -3
- data/lib/bandwidth/http/faraday_client.rb +1 -1
- data/lib/bandwidth/messaging_lib/messaging/client.rb +14 -5
- data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +78 -71
- data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +3 -5
- data/lib/bandwidth/messaging_lib/messaging/exceptions/messaging_exception.rb +5 -2
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_callback_message.rb +31 -11
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +54 -25
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +102 -24
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb +23 -4
- data/lib/bandwidth/messaging_lib/messaging/models/deferred_result.rb +20 -4
- data/lib/bandwidth/messaging_lib/messaging/models/media.rb +27 -80
- data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +32 -14
- data/lib/bandwidth/messaging_lib/messaging/models/page_info.rb +28 -8
- data/lib/bandwidth/messaging_lib/messaging/models/tag.rb +20 -4
- data/lib/bandwidth/models/base_model.rb +30 -8
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/client.rb +15 -6
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/controllers/base_controller.rb +3 -5
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/controllers/mfa_controller.rb +28 -23
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/exceptions/error_with_request_exception.rb +5 -2
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/exceptions/forbidden_request_exception.rb +4 -1
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/exceptions/unauthorized_request_exception.rb +4 -1
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_code_request_schema.rb +27 -12
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_messaging_response.rb +17 -2
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_verify_code_response.rb +17 -2
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_verify_request_schema.rb +29 -10
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_voice_response.rb +17 -2
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth.rb +23 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb +212 -210
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb +3 -5
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb +4 -1
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb +17 -2
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb +20 -4
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb +28 -7
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb +43 -18
- data/lib/bandwidth/utilities/date_time_helper.rb +156 -0
- data/lib/bandwidth/utilities/file_wrapper.rb +1 -2
- data/lib/bandwidth/voice_lib/voice/client.rb +14 -5
- data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +418 -379
- data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +3 -5
- data/lib/bandwidth/voice_lib/voice/exceptions/{api_error_response_exception.rb → api_error_exception.rb} +8 -5
- data/lib/bandwidth/voice_lib/voice/models/call_callback.rb +343 -0
- data/lib/bandwidth/voice_lib/voice/models/call_recording_metadata.rb +250 -0
- data/lib/bandwidth/voice_lib/voice/models/call_state.rb +284 -0
- data/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb +2 -20
- data/lib/bandwidth/voice_lib/voice/models/conference_callback.rb +211 -0
- data/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb +2 -20
- data/lib/bandwidth/voice_lib/voice/models/{conference_member_detail.rb → conference_member_state.rb} +43 -20
- data/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata.rb +173 -0
- data/lib/bandwidth/voice_lib/voice/models/conference_state.rb +153 -0
- data/lib/bandwidth/voice_lib/voice/models/create_call_request.rb +301 -0
- data/lib/bandwidth/voice_lib/voice/models/create_call_response.rb +256 -0
- data/lib/bandwidth/voice_lib/voice/models/diversion.rb +80 -0
- data/lib/bandwidth/voice_lib/voice/models/fallback_method_enum.rb +17 -0
- data/lib/bandwidth/voice_lib/voice/models/machine_detection_configuration.rb +218 -0
- data/lib/bandwidth/voice_lib/voice/models/mode_enum.rb +20 -0
- data/lib/bandwidth/voice_lib/voice/models/{modify_call_recording_state.rb → modify_call_recording_request.rb} +19 -6
- data/lib/bandwidth/voice_lib/voice/models/modify_call_request.rb +156 -0
- data/lib/bandwidth/voice_lib/voice/models/modify_conference_request.rb +144 -0
- data/lib/bandwidth/voice_lib/voice/models/state1_enum.rb +7 -4
- data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +4 -7
- data/lib/bandwidth/voice_lib/voice/models/transcribe_recording_request.rb +108 -0
- data/lib/bandwidth/voice_lib/voice/models/transcript.rb +20 -4
- data/lib/bandwidth/voice_lib/voice/models/transcription.rb +35 -17
- data/lib/bandwidth/voice_lib/voice/models/transcription_metadata.rb +89 -0
- data/lib/bandwidth/voice_lib/voice/models/transcription_response.rb +18 -1
- data/lib/bandwidth/voice_lib/voice.rb +20 -18
- data/lib/bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb +7 -2
- data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +4 -4
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +75 -64
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +3 -5
- data/lib/bandwidth/web_rtc_lib/web_rtc/exceptions/error_exception.rb +5 -2
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +20 -5
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +37 -14
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +15 -2
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +20 -4
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +20 -3
- data/lib/bandwidth.rb +20 -18
- data/test/integration/test_integration.rb +92 -57
- metadata +35 -31
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +0 -22
- data/lib/bandwidth/voice_lib/voice/models/api_call_response.rb +0 -207
- data/lib/bandwidth/voice_lib/voice/models/api_call_state_response.rb +0 -164
- data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +0 -248
- data/lib/bandwidth/voice_lib/voice/models/api_modify_call_request.rb +0 -116
- data/lib/bandwidth/voice_lib/voice/models/api_modify_conference_request.rb +0 -107
- data/lib/bandwidth/voice_lib/voice/models/api_transcribe_recording_request.rb +0 -80
- data/lib/bandwidth/voice_lib/voice/models/conference_detail.rb +0 -108
- data/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata_response.rb +0 -126
- data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +0 -47
- data/lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb +0 -190
- data/lib/bandwidth/voice_lib/voice/models/state2_enum.rb +0 -20
- data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +0 -29
- data/lib/bandwidth/voice_lib/voice/models/status3_enum.rb +0 -32
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ee8c7426138e841e2fea1dbff5d5e3c79372a5cd30c20fe6f2b271104d9101d6
|
|
4
|
+
data.tar.gz: d6463c59e3d52f560968494124e4563a61d7f2aa0b2b0f04f23e92f65f97247a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 255385a80dbc57bccc6dab0f124b9588481eb8075dadce183677b9ca5c7f7d62a65512b876d076d51f051a7de96ca920948e70c4d9b4c1be01cbda03b37f8898
|
|
7
|
+
data.tar.gz: 755608aac58ac160de2711c5c3e8b0e57426a023f32c80dc047a2d3c7ee3d345eeb3188dfdfdaeec315690dac6cb377253799119a816a5ae3d34f3135686e24c
|
data/lib/bandwidth/api_helper.rb
CHANGED
|
@@ -13,13 +13,14 @@ module Bandwidth
|
|
|
13
13
|
def self.serialize_array(key, array, formatting: 'indexed')
|
|
14
14
|
tuples = []
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
case formatting
|
|
17
|
+
when 'unindexed'
|
|
17
18
|
tuples += array.map { |element| ["#{key}[]", element] }
|
|
18
|
-
|
|
19
|
+
when 'indexed'
|
|
19
20
|
tuples += array.map.with_index do |element, index|
|
|
20
21
|
["#{key}[#{index}]", element]
|
|
21
22
|
end
|
|
22
|
-
|
|
23
|
+
when 'plain'
|
|
23
24
|
tuples += array.map { |element| [key, element] }
|
|
24
25
|
else
|
|
25
26
|
raise ArgumentError, 'Invalid format provided.'
|
|
@@ -60,7 +61,7 @@ module Bandwidth
|
|
|
60
61
|
end
|
|
61
62
|
|
|
62
63
|
# Find the template parameter and replace it with its value.
|
|
63
|
-
query_builder = query_builder.gsub(
|
|
64
|
+
query_builder = query_builder.gsub("{#{key}}", replace_value)
|
|
64
65
|
end
|
|
65
66
|
query_builder
|
|
66
67
|
end
|
|
@@ -85,15 +86,16 @@ module Bandwidth
|
|
|
85
86
|
unless value.nil?
|
|
86
87
|
if value.instance_of? Array
|
|
87
88
|
value.compact!
|
|
88
|
-
query_builder +=
|
|
89
|
+
query_builder += case array_serialization
|
|
90
|
+
when 'csv'
|
|
89
91
|
"#{seperator}#{key}=#{value.map do |element|
|
|
90
92
|
CGI.escape(element.to_s)
|
|
91
93
|
end.join(',')}"
|
|
92
|
-
|
|
94
|
+
when 'psv'
|
|
93
95
|
"#{seperator}#{key}=#{value.map do |element|
|
|
94
96
|
CGI.escape(element.to_s)
|
|
95
97
|
end.join('|')}"
|
|
96
|
-
|
|
98
|
+
when 'tsv'
|
|
97
99
|
"#{seperator}#{key}=#{value.map do |element|
|
|
98
100
|
CGI.escape(element.to_s)
|
|
99
101
|
end.join("\t")}"
|
|
@@ -119,7 +121,7 @@ module Bandwidth
|
|
|
119
121
|
raise ArgumentError, 'Invalid Url.' unless url.instance_of? String
|
|
120
122
|
|
|
121
123
|
# Ensure that the urls are absolute.
|
|
122
|
-
matches = url.match(%r{^(https
|
|
124
|
+
matches = url.match(%r{^(https?://[^/]+)})
|
|
123
125
|
raise ArgumentError, 'Invalid Url format.' if matches.nil?
|
|
124
126
|
|
|
125
127
|
# Get the http protocol match.
|
|
@@ -130,7 +132,7 @@ module Bandwidth
|
|
|
130
132
|
|
|
131
133
|
# Remove redundant forward slashes.
|
|
132
134
|
query = url[protocol.length...(!index.nil? ? index : url.length)]
|
|
133
|
-
query.gsub!(%r{
|
|
135
|
+
query.gsub!(%r{//+}, '/')
|
|
134
136
|
|
|
135
137
|
# Get the parameters.
|
|
136
138
|
parameters = !index.nil? ? url[url.index('?')...url.length] : ''
|
|
@@ -142,7 +144,7 @@ module Bandwidth
|
|
|
142
144
|
# Parses JSON string.
|
|
143
145
|
# @param [String] A JSON string.
|
|
144
146
|
def self.json_deserialize(json)
|
|
145
|
-
|
|
147
|
+
JSON.parse(json)
|
|
146
148
|
rescue StandardError
|
|
147
149
|
raise TypeError, 'Server responded with invalid JSON.'
|
|
148
150
|
end
|
|
@@ -171,6 +173,7 @@ module Bandwidth
|
|
|
171
173
|
a.each do |key, value_a|
|
|
172
174
|
b.each do |k, value_b|
|
|
173
175
|
next unless key == k
|
|
176
|
+
|
|
174
177
|
x[k] = []
|
|
175
178
|
if value_a.instance_of? Array
|
|
176
179
|
value_a.each do |v|
|
|
@@ -215,13 +218,12 @@ module Bandwidth
|
|
|
215
218
|
elsif obj.instance_of? Array
|
|
216
219
|
if formatting == 'indexed'
|
|
217
220
|
obj.each_with_index do |value, index|
|
|
218
|
-
retval.merge!(APIHelper.form_encode(value, instance_name
|
|
219
|
-
index.to_s + ']'))
|
|
221
|
+
retval.merge!(APIHelper.form_encode(value, "#{instance_name}[#{index}]"))
|
|
220
222
|
end
|
|
221
223
|
elsif serializable_types.map { |x| obj[0].is_a? x }.any?
|
|
222
224
|
obj.each do |value|
|
|
223
225
|
abc = if formatting == 'unindexed'
|
|
224
|
-
APIHelper.form_encode(value, instance_name
|
|
226
|
+
APIHelper.form_encode(value, "#{instance_name}[]",
|
|
225
227
|
formatting: formatting)
|
|
226
228
|
else
|
|
227
229
|
APIHelper.form_encode(value, instance_name,
|
|
@@ -231,14 +233,14 @@ module Bandwidth
|
|
|
231
233
|
end
|
|
232
234
|
else
|
|
233
235
|
obj.each_with_index do |value, index|
|
|
234
|
-
retval.merge!(APIHelper.form_encode(value, instance_name
|
|
235
|
-
|
|
236
|
+
retval.merge!(APIHelper.form_encode(value, "#{instance_name}[#{index}]",
|
|
237
|
+
formatting: formatting))
|
|
236
238
|
end
|
|
237
239
|
end
|
|
238
240
|
elsif obj.instance_of? Hash
|
|
239
241
|
obj.each do |key, value|
|
|
240
|
-
retval.merge!(APIHelper.form_encode(value, instance_name
|
|
241
|
-
|
|
242
|
+
retval.merge!(APIHelper.form_encode(value, "#{instance_name}[#{key}]",
|
|
243
|
+
formatting: formatting))
|
|
242
244
|
end
|
|
243
245
|
elsif obj.instance_of? File
|
|
244
246
|
retval[instance_name] = UploadIO.new(
|
|
@@ -273,17 +275,5 @@ module Bandwidth
|
|
|
273
275
|
end
|
|
274
276
|
val
|
|
275
277
|
end
|
|
276
|
-
|
|
277
|
-
# Safely converts a string into an rfc3339 DateTime object
|
|
278
|
-
# @param [String] The datetime string
|
|
279
|
-
# @return [DateTime] A DateTime object of rfc3339 format
|
|
280
|
-
def self.rfc3339(date_time)
|
|
281
|
-
# missing timezone information
|
|
282
|
-
if date_time.end_with?('Z') || date_time.index('+')
|
|
283
|
-
DateTime.rfc3339(date_time)
|
|
284
|
-
else
|
|
285
|
-
DateTime.rfc3339(date_time + 'Z')
|
|
286
|
-
end
|
|
287
|
-
end
|
|
288
278
|
end
|
|
289
279
|
end
|
data/lib/bandwidth/client.rb
CHANGED
|
@@ -12,10 +12,10 @@ module Bandwidth
|
|
|
12
12
|
def messaging_client
|
|
13
13
|
@messaging_client ||= Messaging::Client.new(config: config)
|
|
14
14
|
end
|
|
15
|
-
# Access to
|
|
16
|
-
# @return [
|
|
17
|
-
def
|
|
18
|
-
@
|
|
15
|
+
# Access to multi_factor_auth_client controller.
|
|
16
|
+
# @return [MultiFactorAuth::Client] Returns the client instance.
|
|
17
|
+
def multi_factor_auth_client
|
|
18
|
+
@multi_factor_auth_client ||= MultiFactorAuth::Client.new(config: config)
|
|
19
19
|
end
|
|
20
20
|
# Access to phone_number_lookup_client controller.
|
|
21
21
|
# @return [PhoneNumberLookup::Client] Returns the client instance.
|
|
@@ -41,8 +41,8 @@ module Bandwidth
|
|
|
41
41
|
base_url: 'https://www.example.com',
|
|
42
42
|
messaging_basic_auth_user_name: 'TODO: Replace',
|
|
43
43
|
messaging_basic_auth_password: 'TODO: Replace',
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
multi_factor_auth_basic_auth_user_name: 'TODO: Replace',
|
|
45
|
+
multi_factor_auth_basic_auth_password: 'TODO: Replace',
|
|
46
46
|
phone_number_lookup_basic_auth_user_name: 'TODO: Replace',
|
|
47
47
|
phone_number_lookup_basic_auth_password: 'TODO: Replace',
|
|
48
48
|
voice_basic_auth_user_name: 'TODO: Replace',
|
|
@@ -59,8 +59,8 @@ module Bandwidth
|
|
|
59
59
|
base_url: base_url,
|
|
60
60
|
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
|
61
61
|
messaging_basic_auth_password: messaging_basic_auth_password,
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name,
|
|
63
|
+
multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password,
|
|
64
64
|
phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name,
|
|
65
65
|
phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password,
|
|
66
66
|
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
|
@@ -17,7 +17,7 @@ module Bandwidth
|
|
|
17
17
|
SERVER = [
|
|
18
18
|
DEFAULT = 'default'.freeze,
|
|
19
19
|
MESSAGINGDEFAULT = 'MessagingDefault'.freeze,
|
|
20
|
-
|
|
20
|
+
MULTIFACTORAUTHDEFAULT = 'MultiFactorAuthDefault'.freeze,
|
|
21
21
|
PHONENUMBERLOOKUPDEFAULT = 'PhoneNumberLookupDefault'.freeze,
|
|
22
22
|
VOICEDEFAULT = 'VoiceDefault'.freeze,
|
|
23
23
|
WEBRTCDEFAULT = 'WebRtcDefault'.freeze
|
|
@@ -28,25 +28,13 @@ module Bandwidth
|
|
|
28
28
|
# are configured in this class.
|
|
29
29
|
class Configuration
|
|
30
30
|
# The attribute readers for properties.
|
|
31
|
-
attr_reader :http_client
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
attr_reader :environment
|
|
39
|
-
attr_reader :base_url
|
|
40
|
-
attr_reader :messaging_basic_auth_user_name
|
|
41
|
-
attr_reader :messaging_basic_auth_password
|
|
42
|
-
attr_reader :two_factor_auth_basic_auth_user_name
|
|
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
|
|
46
|
-
attr_reader :voice_basic_auth_user_name
|
|
47
|
-
attr_reader :voice_basic_auth_password
|
|
48
|
-
attr_reader :web_rtc_basic_auth_user_name
|
|
49
|
-
attr_reader :web_rtc_basic_auth_password
|
|
31
|
+
attr_reader :http_client, :timeout, :max_retries, :retry_interval, :backoff_factor,
|
|
32
|
+
:retry_statuses, :retry_methods, :environment, :base_url,
|
|
33
|
+
:messaging_basic_auth_user_name, :messaging_basic_auth_password,
|
|
34
|
+
:multi_factor_auth_basic_auth_user_name, :multi_factor_auth_basic_auth_password,
|
|
35
|
+
:phone_number_lookup_basic_auth_user_name, :phone_number_lookup_basic_auth_password,
|
|
36
|
+
:voice_basic_auth_user_name, :voice_basic_auth_password,
|
|
37
|
+
:web_rtc_basic_auth_user_name, :web_rtc_basic_auth_password
|
|
50
38
|
|
|
51
39
|
class << self
|
|
52
40
|
attr_reader :environments
|
|
@@ -60,8 +48,8 @@ module Bandwidth
|
|
|
60
48
|
base_url: 'https://www.example.com',
|
|
61
49
|
messaging_basic_auth_user_name: 'TODO: Replace',
|
|
62
50
|
messaging_basic_auth_password: 'TODO: Replace',
|
|
63
|
-
|
|
64
|
-
|
|
51
|
+
multi_factor_auth_basic_auth_user_name: 'TODO: Replace',
|
|
52
|
+
multi_factor_auth_basic_auth_password: 'TODO: Replace',
|
|
65
53
|
phone_number_lookup_basic_auth_user_name: 'TODO: Replace',
|
|
66
54
|
phone_number_lookup_basic_auth_password: 'TODO: Replace',
|
|
67
55
|
voice_basic_auth_user_name: 'TODO: Replace',
|
|
@@ -100,10 +88,10 @@ module Bandwidth
|
|
|
100
88
|
@messaging_basic_auth_password = messaging_basic_auth_password
|
|
101
89
|
|
|
102
90
|
# The username to use with basic authentication
|
|
103
|
-
@
|
|
91
|
+
@multi_factor_auth_basic_auth_user_name = multi_factor_auth_basic_auth_user_name
|
|
104
92
|
|
|
105
93
|
# The password to use with basic authentication
|
|
106
|
-
@
|
|
94
|
+
@multi_factor_auth_basic_auth_password = multi_factor_auth_basic_auth_password
|
|
107
95
|
|
|
108
96
|
# The username to use with basic authentication
|
|
109
97
|
@phone_number_lookup_basic_auth_user_name = phone_number_lookup_basic_auth_user_name
|
|
@@ -132,8 +120,8 @@ module Bandwidth
|
|
|
132
120
|
environment: nil, base_url: nil,
|
|
133
121
|
messaging_basic_auth_user_name: nil,
|
|
134
122
|
messaging_basic_auth_password: nil,
|
|
135
|
-
|
|
136
|
-
|
|
123
|
+
multi_factor_auth_basic_auth_user_name: nil,
|
|
124
|
+
multi_factor_auth_basic_auth_password: nil,
|
|
137
125
|
phone_number_lookup_basic_auth_user_name: nil,
|
|
138
126
|
phone_number_lookup_basic_auth_password: nil,
|
|
139
127
|
voice_basic_auth_user_name: nil,
|
|
@@ -150,8 +138,8 @@ module Bandwidth
|
|
|
150
138
|
base_url ||= self.base_url
|
|
151
139
|
messaging_basic_auth_user_name ||= self.messaging_basic_auth_user_name
|
|
152
140
|
messaging_basic_auth_password ||= self.messaging_basic_auth_password
|
|
153
|
-
|
|
154
|
-
|
|
141
|
+
multi_factor_auth_basic_auth_user_name ||= self.multi_factor_auth_basic_auth_user_name
|
|
142
|
+
multi_factor_auth_basic_auth_password ||= self.multi_factor_auth_basic_auth_password
|
|
155
143
|
phone_number_lookup_basic_auth_user_name ||= self.phone_number_lookup_basic_auth_user_name
|
|
156
144
|
phone_number_lookup_basic_auth_password ||= self.phone_number_lookup_basic_auth_password
|
|
157
145
|
voice_basic_auth_user_name ||= self.voice_basic_auth_user_name
|
|
@@ -166,8 +154,8 @@ module Bandwidth
|
|
|
166
154
|
environment: environment, base_url: base_url,
|
|
167
155
|
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
|
168
156
|
messaging_basic_auth_password: messaging_basic_auth_password,
|
|
169
|
-
|
|
170
|
-
|
|
157
|
+
multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name,
|
|
158
|
+
multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password,
|
|
171
159
|
phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name,
|
|
172
160
|
phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password,
|
|
173
161
|
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
|
@@ -190,7 +178,7 @@ module Bandwidth
|
|
|
190
178
|
Environment::PRODUCTION => {
|
|
191
179
|
Server::DEFAULT => 'api.bandwidth.com',
|
|
192
180
|
Server::MESSAGINGDEFAULT => 'https://messaging.bandwidth.com/api/v2',
|
|
193
|
-
Server::
|
|
181
|
+
Server::MULTIFACTORAUTHDEFAULT => 'https://mfa.bandwidth.com/api/v1',
|
|
194
182
|
Server::PHONENUMBERLOOKUPDEFAULT => 'https://numbers.bandwidth.com/api/v1',
|
|
195
183
|
Server::VOICEDEFAULT => 'https://voice.bandwidth.com',
|
|
196
184
|
Server::WEBRTCDEFAULT => 'https://api.webrtc.bandwidth.com/v1'
|
|
@@ -198,7 +186,7 @@ module Bandwidth
|
|
|
198
186
|
Environment::CUSTOM => {
|
|
199
187
|
Server::DEFAULT => '{base_url}',
|
|
200
188
|
Server::MESSAGINGDEFAULT => '{base_url}',
|
|
201
|
-
Server::
|
|
189
|
+
Server::MULTIFACTORAUTHDEFAULT => '{base_url}',
|
|
202
190
|
Server::PHONENUMBERLOOKUPDEFAULT => '{base_url}',
|
|
203
191
|
Server::VOICEDEFAULT => '{base_url}',
|
|
204
192
|
Server::WEBRTCDEFAULT => '{base_url}'
|
data/lib/bandwidth/http/auth/{two_factor_auth_basic_auth.rb → multi_factor_auth_basic_auth.rb}
RENAMED
|
@@ -7,13 +7,13 @@ require 'base64'
|
|
|
7
7
|
|
|
8
8
|
module Bandwidth
|
|
9
9
|
# Utility class for basic authorization.
|
|
10
|
-
class
|
|
10
|
+
class MultiFactorAuthBasicAuth
|
|
11
11
|
# Add basic authentication to the request.
|
|
12
12
|
# @param [HttpRequest] The HttpRequest object to which authentication will
|
|
13
13
|
# be added.
|
|
14
14
|
def self.apply(config, http_request)
|
|
15
|
-
username = config.
|
|
16
|
-
password = config.
|
|
15
|
+
username = config.multi_factor_auth_basic_auth_user_name
|
|
16
|
+
password = config.multi_factor_auth_basic_auth_password
|
|
17
17
|
value = Base64.strict_encode64("#{username}:#{password}")
|
|
18
18
|
header_value = "Basic #{value}"
|
|
19
19
|
http_request.headers['Authorization'] = header_value
|
|
@@ -27,7 +27,7 @@ module Bandwidth
|
|
|
27
27
|
methods: retry_methods
|
|
28
28
|
faraday.adapter Faraday.default_adapter
|
|
29
29
|
faraday.options[:params_encoder] = Faraday::FlatParamsEncoder
|
|
30
|
-
faraday.options[:timeout] = timeout if timeout
|
|
30
|
+
faraday.options[:timeout] = timeout if timeout.positive?
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
@@ -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
|
-
|
|
24
|
-
|
|
26
|
+
multi_factor_auth_basic_auth_user_name: 'TODO: Replace',
|
|
27
|
+
multi_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
|
-
|
|
40
|
-
|
|
46
|
+
multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name,
|
|
47
|
+
multi_factor_auth_basic_auth_password: multi_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,
|