bandwidth-sdk 3.13.2 → 6.2.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/LICENSE +1 -1
- data/README.md +90 -13
- 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 +40 -4
- data/lib/bandwidth/http/api_response.rb +2 -0
- data/lib/bandwidth/http/auth/phone_number_lookup_basic_auth.rb +22 -0
- data/lib/bandwidth/http/faraday_client.rb +14 -4
- data/lib/bandwidth/messaging_lib/messaging.rb +4 -0
- data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +135 -20
- data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +1 -1
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +23 -13
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +125 -0
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb +60 -0
- data/lib/bandwidth/messaging_lib/messaging/models/media.rb +4 -4
- data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +21 -8
- data/lib/bandwidth/messaging_lib/messaging/models/page_info.rb +62 -0
- data/lib/bandwidth/messaging_lib/messaging/models/priority_enum.rb +19 -0
- 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/{two_factor_auth_lib/two_factor_auth/exceptions/invalid_request_exception.rb → phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb} +5 -5
- 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/two_factor_auth_lib/two_factor_auth.rb +4 -2
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb +4 -4
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb +1 -1
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/{api_controller.rb → mfa_controller.rb} +65 -14
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/error_with_request_exception.rb +34 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/forbidden_request_exception.rb +29 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/unauthorized_request_exception.rb +29 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb +0 -19
- data/lib/bandwidth/voice_lib/voice.rb +1 -1
- data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +51 -52
- data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
- data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +77 -17
- data/lib/bandwidth/voice_lib/voice/models/{call_engine_modify_conference_request.rb → api_modify_conference_request.rb} +14 -14
- data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +3 -3
- data/lib/bandwidth/web_rtc_lib/web_rtc.rb +1 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +10 -1
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +24 -24
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +1 -1
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/device_api_version_enum.rb +17 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +11 -2
- data/test/controllers/controller_test_base.rb +21 -0
- data/test/http_response_catcher.rb +19 -0
- data/test/integration/test_integration.rb +583 -0
- data/test/test_helper.rb +94 -0
- metadata +66 -11
@@ -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
|
@@ -4,11 +4,11 @@
|
|
4
4
|
# ( https://apimatic.io ).
|
5
5
|
|
6
6
|
module Bandwidth
|
7
|
-
#
|
8
|
-
class
|
9
|
-
#
|
7
|
+
# Accounts Tnlookup 400 Error class.
|
8
|
+
class AccountsTnlookup400ErrorException < APIException
|
9
|
+
# A description of what validation error occurred.
|
10
10
|
# @return [String]
|
11
|
-
attr_accessor :
|
11
|
+
attr_accessor :message
|
12
12
|
|
13
13
|
# The constructor.
|
14
14
|
# @param [String] The reason for raising an exception.
|
@@ -23,7 +23,7 @@ module Bandwidth
|
|
23
23
|
# @param [Hash] The deserialized response sent by the server in the
|
24
24
|
# response body.
|
25
25
|
def unbox(hash)
|
26
|
-
@
|
26
|
+
@message = hash['message']
|
27
27
|
end
|
28
28
|
end
|
29
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
|
@@ -14,7 +14,9 @@ require_relative 'two_factor_auth/models/two_factor_verify_request_schema.rb'
|
|
14
14
|
require_relative 'two_factor_auth/models/two_factor_verify_code_response.rb'
|
15
15
|
|
16
16
|
# Exceptions
|
17
|
-
require_relative 'two_factor_auth/exceptions/
|
17
|
+
require_relative 'two_factor_auth/exceptions/error_with_request_exception.rb'
|
18
|
+
require_relative 'two_factor_auth/exceptions/unauthorized_request_exception.rb'
|
19
|
+
require_relative 'two_factor_auth/exceptions/forbidden_request_exception.rb'
|
18
20
|
# Controllers
|
19
21
|
require_relative 'two_factor_auth/controllers/base_controller.rb'
|
20
|
-
require_relative 'two_factor_auth/controllers/
|
22
|
+
require_relative 'two_factor_auth/controllers/mfa_controller.rb'
|
@@ -9,10 +9,10 @@ module Bandwidth
|
|
9
9
|
class Client
|
10
10
|
attr_reader :config
|
11
11
|
|
12
|
-
# Access to
|
13
|
-
# @return [
|
14
|
-
def
|
15
|
-
@
|
12
|
+
# Access to mfa controller.
|
13
|
+
# @return [MFAController] Returns the controller instance.
|
14
|
+
def mfa
|
15
|
+
@mfa ||= MFAController.new config
|
16
16
|
end
|
17
17
|
|
18
18
|
def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
|
@@ -5,13 +5,13 @@
|
|
5
5
|
|
6
6
|
module Bandwidth
|
7
7
|
module TwoFactorAuth
|
8
|
-
#
|
9
|
-
class
|
8
|
+
# MFAController
|
9
|
+
class MFAController < BaseController
|
10
10
|
def initialize(config, http_call_back: nil)
|
11
11
|
super(config, http_call_back: http_call_back)
|
12
12
|
end
|
13
13
|
|
14
|
-
#
|
14
|
+
# Allows a user to send a MFA code through a phone call
|
15
15
|
# @param [String] account_id Required parameter: Bandwidth Account ID with
|
16
16
|
# Voice service enabled
|
17
17
|
# @param [TwoFactorCodeRequestSchema] body Required parameter: Example:
|
@@ -23,7 +23,7 @@ module TwoFactorAuth
|
|
23
23
|
_query_builder << '/accounts/{accountId}/code/voice'
|
24
24
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
25
25
|
_query_builder,
|
26
|
-
'accountId' => { 'value' => account_id, 'encode' =>
|
26
|
+
'accountId' => { 'value' => account_id, 'encode' => false }
|
27
27
|
)
|
28
28
|
_query_url = APIHelper.clean_url _query_builder
|
29
29
|
|
@@ -44,8 +44,23 @@ module TwoFactorAuth
|
|
44
44
|
|
45
45
|
# Validate response against endpoint and global error codes.
|
46
46
|
if _response.status_code == 400
|
47
|
-
raise
|
48
|
-
'
|
47
|
+
raise ErrorWithRequestException.new(
|
48
|
+
'If there is any issue with values passed in by the user',
|
49
|
+
_response
|
50
|
+
)
|
51
|
+
elsif _response.status_code == 401
|
52
|
+
raise UnauthorizedRequestException.new(
|
53
|
+
'Authentication is either incorrect or not present',
|
54
|
+
_response
|
55
|
+
)
|
56
|
+
elsif _response.status_code == 403
|
57
|
+
raise ForbiddenRequestException.new(
|
58
|
+
'The user is not authorized to access this resource',
|
59
|
+
_response
|
60
|
+
)
|
61
|
+
elsif _response.status_code == 500
|
62
|
+
raise ErrorWithRequestException.new(
|
63
|
+
'An internal server error occurred',
|
49
64
|
_response
|
50
65
|
)
|
51
66
|
end
|
@@ -58,7 +73,7 @@ module TwoFactorAuth
|
|
58
73
|
)
|
59
74
|
end
|
60
75
|
|
61
|
-
#
|
76
|
+
# Allows a user to send a MFA code through a text message (SMS)
|
62
77
|
# @param [String] account_id Required parameter: Bandwidth Account ID with
|
63
78
|
# Messaging service enabled
|
64
79
|
# @param [TwoFactorCodeRequestSchema] body Required parameter: Example:
|
@@ -70,7 +85,7 @@ module TwoFactorAuth
|
|
70
85
|
_query_builder << '/accounts/{accountId}/code/messaging'
|
71
86
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
72
87
|
_query_builder,
|
73
|
-
'accountId' => { 'value' => account_id, 'encode' =>
|
88
|
+
'accountId' => { 'value' => account_id, 'encode' => false }
|
74
89
|
)
|
75
90
|
_query_url = APIHelper.clean_url _query_builder
|
76
91
|
|
@@ -91,8 +106,23 @@ module TwoFactorAuth
|
|
91
106
|
|
92
107
|
# Validate response against endpoint and global error codes.
|
93
108
|
if _response.status_code == 400
|
94
|
-
raise
|
95
|
-
'
|
109
|
+
raise ErrorWithRequestException.new(
|
110
|
+
'If there is any issue with values passed in by the user',
|
111
|
+
_response
|
112
|
+
)
|
113
|
+
elsif _response.status_code == 401
|
114
|
+
raise UnauthorizedRequestException.new(
|
115
|
+
'Authentication is either incorrect or not present',
|
116
|
+
_response
|
117
|
+
)
|
118
|
+
elsif _response.status_code == 403
|
119
|
+
raise ForbiddenRequestException.new(
|
120
|
+
'The user is not authorized to access this resource',
|
121
|
+
_response
|
122
|
+
)
|
123
|
+
elsif _response.status_code == 500
|
124
|
+
raise ErrorWithRequestException.new(
|
125
|
+
'An internal server error occurred',
|
96
126
|
_response
|
97
127
|
)
|
98
128
|
end
|
@@ -106,7 +136,7 @@ module TwoFactorAuth
|
|
106
136
|
)
|
107
137
|
end
|
108
138
|
|
109
|
-
#
|
139
|
+
# Allows a user to verify an MFA code
|
110
140
|
# @param [String] account_id Required parameter: Bandwidth Account ID with
|
111
141
|
# Two-Factor enabled
|
112
142
|
# @param [TwoFactorVerifyRequestSchema] body Required parameter: Example:
|
@@ -118,7 +148,7 @@ module TwoFactorAuth
|
|
118
148
|
_query_builder << '/accounts/{accountId}/code/verify'
|
119
149
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
120
150
|
_query_builder,
|
121
|
-
'accountId' => { 'value' => account_id, 'encode' =>
|
151
|
+
'accountId' => { 'value' => account_id, 'encode' => false }
|
122
152
|
)
|
123
153
|
_query_url = APIHelper.clean_url _query_builder
|
124
154
|
|
@@ -139,8 +169,29 @@ module TwoFactorAuth
|
|
139
169
|
|
140
170
|
# Validate response against endpoint and global error codes.
|
141
171
|
if _response.status_code == 400
|
142
|
-
raise
|
143
|
-
'
|
172
|
+
raise ErrorWithRequestException.new(
|
173
|
+
'If there is any issue with values passed in by the user',
|
174
|
+
_response
|
175
|
+
)
|
176
|
+
elsif _response.status_code == 401
|
177
|
+
raise UnauthorizedRequestException.new(
|
178
|
+
'Authentication is either incorrect or not present',
|
179
|
+
_response
|
180
|
+
)
|
181
|
+
elsif _response.status_code == 403
|
182
|
+
raise ForbiddenRequestException.new(
|
183
|
+
'The user is not authorized to access this resource',
|
184
|
+
_response
|
185
|
+
)
|
186
|
+
elsif _response.status_code == 429
|
187
|
+
raise ErrorWithRequestException.new(
|
188
|
+
'The user has made too many bad requests and is temporarily locked' \
|
189
|
+
' out',
|
190
|
+
_response
|
191
|
+
)
|
192
|
+
elsif _response.status_code == 500
|
193
|
+
raise ErrorWithRequestException.new(
|
194
|
+
'An internal server error occurred',
|
144
195
|
_response
|
145
196
|
)
|
146
197
|
end
|