bandwidth-sdk 5.0.0 → 7.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/README.md +90 -13
- data/lib/bandwidth.rb +5 -2
- data/lib/bandwidth/api_helper.rb +5 -17
- data/lib/bandwidth/client.rb +23 -9
- data/lib/bandwidth/configuration.rb +54 -18
- data/lib/bandwidth/http/auth/{two_factor_auth_basic_auth.rb → multi_factor_auth_basic_auth.rb} +3 -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/messaging_lib/messaging.rb +1 -0
- data/lib/bandwidth/messaging_lib/messaging/client.rb +14 -5
- data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +25 -29
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +11 -2
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +47 -2
- data/lib/bandwidth/messaging_lib/messaging/models/media.rb +5 -75
- data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +13 -2
- data/lib/bandwidth/messaging_lib/messaging/models/priority_enum.rb +19 -0
- data/lib/bandwidth/models/base_model.rb +19 -8
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth.rb +23 -0
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/client.rb +60 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/controllers/base_controller.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth/controllers/api_controller.rb → multi_factor_auth_lib/multi_factor_auth/controllers/mfa_controller.rb} +69 -18
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb +34 -0
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/forbidden_request_exception.rb +29 -0
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/unauthorized_request_exception.rb +29 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_code_request_schema.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_messaging_response.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_verify_code_response.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_verify_request_schema.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_voice_response.rb +0 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup.rb +20 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → phone_number_lookup_lib/phone_number_lookup}/client.rb +15 -6
- 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/utilities/date_time_helper.rb +156 -0
- data/lib/bandwidth/voice_lib/voice.rb +14 -18
- data/lib/bandwidth/voice_lib/voice/client.rb +14 -5
- data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +248 -230
- data/lib/bandwidth/voice_lib/voice/exceptions/{api_error_response_exception.rb → api_error_exception.rb} +2 -2
- data/lib/bandwidth/voice_lib/voice/models/{recording_metadata_response.rb → call_recording_metadata.rb} +47 -28
- data/lib/bandwidth/voice_lib/voice/models/call_state.rb +232 -0
- data/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb +2 -20
- 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} +8 -8
- data/lib/bandwidth/voice_lib/voice/models/{conference_recording_metadata_response.rb → conference_recording_metadata.rb} +34 -18
- data/lib/bandwidth/voice_lib/voice/models/{conference_detail.rb → conference_state.rb} +22 -14
- data/lib/bandwidth/voice_lib/voice/models/{api_create_call_request.rb → create_call_request.rb} +35 -59
- data/lib/bandwidth/voice_lib/voice/models/{api_call_response.rb → create_call_response.rb} +28 -23
- data/lib/bandwidth/voice_lib/voice/models/{modify_call_recording_state.rb → modify_call_recording_request.rb} +4 -4
- data/lib/bandwidth/voice_lib/voice/models/{api_modify_call_request.rb → modify_call_request.rb} +25 -25
- data/lib/bandwidth/voice_lib/voice/models/{api_modify_conference_request.rb → modify_conference_request.rb} +11 -11
- 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/{api_transcribe_recording_request.rb → transcribe_recording_request.rb} +8 -8
- data/lib/bandwidth/voice_lib/voice/models/{transcription.rb → transcription_metadata.rb} +19 -10
- data/lib/bandwidth/web_rtc_lib/web_rtc.rb +1 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +14 -5
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +14 -14
- 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/integration/test_integration.rb +583 -0
- metadata +47 -35
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +0 -20
- data/lib/bandwidth/voice_lib/voice/models/api_call_state_response.rb +0 -164
- data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +0 -47
- 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
|
@@ -32,6 +32,12 @@ module Bandwidth
|
|
|
32
32
|
# @return [String]
|
|
33
33
|
attr_accessor :tag
|
|
34
34
|
|
|
35
|
+
# The message's priority, currently for toll-free or short code SMS only.
|
|
36
|
+
# Messages with a priority value of `"high"` are given preference over your
|
|
37
|
+
# other traffic.
|
|
38
|
+
# @return [PriorityEnum]
|
|
39
|
+
attr_accessor :priority
|
|
40
|
+
|
|
35
41
|
# A mapping from model property names to API property names.
|
|
36
42
|
def self.names
|
|
37
43
|
@_hash = {} if @_hash.nil?
|
|
@@ -41,6 +47,7 @@ module Bandwidth
|
|
|
41
47
|
@_hash['text'] = 'text'
|
|
42
48
|
@_hash['media'] = 'media'
|
|
43
49
|
@_hash['tag'] = 'tag'
|
|
50
|
+
@_hash['priority'] = 'priority'
|
|
44
51
|
@_hash
|
|
45
52
|
end
|
|
46
53
|
|
|
@@ -49,13 +56,15 @@ module Bandwidth
|
|
|
49
56
|
from = nil,
|
|
50
57
|
text = nil,
|
|
51
58
|
media = nil,
|
|
52
|
-
tag = nil
|
|
59
|
+
tag = nil,
|
|
60
|
+
priority = nil)
|
|
53
61
|
@application_id = application_id
|
|
54
62
|
@to = to
|
|
55
63
|
@from = from
|
|
56
64
|
@text = text
|
|
57
65
|
@media = media
|
|
58
66
|
@tag = tag
|
|
67
|
+
@priority = priority
|
|
59
68
|
end
|
|
60
69
|
|
|
61
70
|
# Creates an instance of the object from a hash.
|
|
@@ -69,6 +78,7 @@ module Bandwidth
|
|
|
69
78
|
text = hash['text']
|
|
70
79
|
media = hash['media']
|
|
71
80
|
tag = hash['tag']
|
|
81
|
+
priority = hash['priority']
|
|
72
82
|
|
|
73
83
|
# Create object from extracted values.
|
|
74
84
|
MessageRequest.new(application_id,
|
|
@@ -76,7 +86,8 @@ module Bandwidth
|
|
|
76
86
|
from,
|
|
77
87
|
text,
|
|
78
88
|
media,
|
|
79
|
-
tag
|
|
89
|
+
tag,
|
|
90
|
+
priority)
|
|
80
91
|
end
|
|
81
92
|
end
|
|
82
93
|
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# bandwidth
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module Bandwidth
|
|
7
|
+
# The message's priority, currently for toll-free or short code SMS only.
|
|
8
|
+
# Messages with a priority value of `"high"` are given preference over your
|
|
9
|
+
# other traffic.
|
|
10
|
+
class PriorityEnum
|
|
11
|
+
PRIORITY_ENUM = [
|
|
12
|
+
# TODO: Write general description for DEFAULT
|
|
13
|
+
DEFAULT = 'default'.freeze,
|
|
14
|
+
|
|
15
|
+
# TODO: Write general description for HIGH
|
|
16
|
+
HIGH = 'high'.freeze
|
|
17
|
+
].freeze
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -13,15 +13,26 @@ module Bandwidth
|
|
|
13
13
|
value = instance_variable_get(name)
|
|
14
14
|
name = name[1..-1]
|
|
15
15
|
key = self.class.names.key?(name) ? self.class.names[name] : name
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
|
|
17
|
+
hash[key] = nil
|
|
18
|
+
unless value.nil?
|
|
19
|
+
if respond_to?("to_#{name}")
|
|
20
|
+
if (value.instance_of? Array) || (value.instance_of? Hash)
|
|
21
|
+
params = [hash, key]
|
|
22
|
+
hash[key] = send("to_#{name}", *params)
|
|
23
|
+
else
|
|
24
|
+
hash[key] = send("to_#{name}")
|
|
25
|
+
end
|
|
26
|
+
elsif value.instance_of? Array
|
|
27
|
+
hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
|
|
28
|
+
elsif value.instance_of? Hash
|
|
29
|
+
hash[key] = {}
|
|
30
|
+
value.each do |k, v|
|
|
31
|
+
hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v
|
|
32
|
+
end
|
|
33
|
+
else
|
|
34
|
+
hash[key] = value.is_a?(BaseModel) ? value.to_hash : value
|
|
22
35
|
end
|
|
23
|
-
else
|
|
24
|
-
hash[key] = value.is_a?(BaseModel) ? value.to_hash : value
|
|
25
36
|
end
|
|
26
37
|
end
|
|
27
38
|
hash
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# bandwidth
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
require_relative 'multi_factor_auth/client.rb'
|
|
8
|
+
|
|
9
|
+
# Models
|
|
10
|
+
require_relative 'multi_factor_auth/models/two_factor_code_request_schema.rb'
|
|
11
|
+
require_relative 'multi_factor_auth/models/two_factor_voice_response.rb'
|
|
12
|
+
require_relative 'multi_factor_auth/models/two_factor_messaging_response.rb'
|
|
13
|
+
require_relative 'multi_factor_auth/models/two_factor_verify_request_schema.rb'
|
|
14
|
+
require_relative 'multi_factor_auth/models/two_factor_verify_code_response.rb'
|
|
15
|
+
|
|
16
|
+
# Exceptions
|
|
17
|
+
require_relative 'multi_factor_auth/exceptions/error_with_request_exception.rb'
|
|
18
|
+
require_relative 'multi_factor_auth/exceptions/unauthorized_request' \
|
|
19
|
+
'_exception.rb'
|
|
20
|
+
require_relative 'multi_factor_auth/exceptions/forbidden_request_exception.rb'
|
|
21
|
+
# Controllers
|
|
22
|
+
require_relative 'multi_factor_auth/controllers/base_controller.rb'
|
|
23
|
+
require_relative 'multi_factor_auth/controllers/mfa_controller.rb'
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# bandwidth
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module Bandwidth
|
|
7
|
+
module MultiFactorAuth
|
|
8
|
+
# bandwidth client class.
|
|
9
|
+
class Client
|
|
10
|
+
attr_reader :config
|
|
11
|
+
|
|
12
|
+
# Access to mfa controller.
|
|
13
|
+
# @return [MFAController] Returns the controller instance.
|
|
14
|
+
def mfa
|
|
15
|
+
@mfa ||= MFAController.new config
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
|
|
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,
|
|
23
|
+
base_url: 'https://www.example.com',
|
|
24
|
+
messaging_basic_auth_user_name: 'TODO: Replace',
|
|
25
|
+
messaging_basic_auth_password: 'TODO: Replace',
|
|
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',
|
|
30
|
+
voice_basic_auth_user_name: 'TODO: Replace',
|
|
31
|
+
voice_basic_auth_password: 'TODO: Replace',
|
|
32
|
+
web_rtc_basic_auth_user_name: 'TODO: Replace',
|
|
33
|
+
web_rtc_basic_auth_password: 'TODO: Replace',
|
|
34
|
+
config: nil)
|
|
35
|
+
@config = if config.nil?
|
|
36
|
+
Configuration.new(timeout: timeout,
|
|
37
|
+
max_retries: max_retries,
|
|
38
|
+
retry_interval: retry_interval,
|
|
39
|
+
backoff_factor: backoff_factor,
|
|
40
|
+
retry_statuses: retry_statuses,
|
|
41
|
+
retry_methods: retry_methods,
|
|
42
|
+
environment: environment,
|
|
43
|
+
base_url: base_url,
|
|
44
|
+
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
|
45
|
+
messaging_basic_auth_password: messaging_basic_auth_password,
|
|
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,
|
|
50
|
+
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
|
51
|
+
voice_basic_auth_password: voice_basic_auth_password,
|
|
52
|
+
web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
|
|
53
|
+
web_rtc_basic_auth_password: web_rtc_basic_auth_password)
|
|
54
|
+
else
|
|
55
|
+
config
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
File without changes
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
# ( https://apimatic.io ).
|
|
5
5
|
|
|
6
6
|
module Bandwidth
|
|
7
|
-
module
|
|
8
|
-
#
|
|
9
|
-
class
|
|
7
|
+
module MultiFactorAuth
|
|
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:
|
|
@@ -19,7 +19,7 @@ module TwoFactorAuth
|
|
|
19
19
|
def create_voice_two_factor(account_id,
|
|
20
20
|
body)
|
|
21
21
|
# Prepare query url.
|
|
22
|
-
_query_builder = config.get_base_uri(Server::
|
|
22
|
+
_query_builder = config.get_base_uri(Server::MULTIFACTORAUTHDEFAULT)
|
|
23
23
|
_query_builder << '/accounts/{accountId}/code/voice'
|
|
24
24
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
25
25
|
_query_builder,
|
|
@@ -39,13 +39,28 @@ module TwoFactorAuth
|
|
|
39
39
|
headers: _headers,
|
|
40
40
|
parameters: body.to_json
|
|
41
41
|
)
|
|
42
|
-
|
|
42
|
+
MultiFactorAuthBasicAuth.apply(config, _request)
|
|
43
43
|
_response = execute_request(_request)
|
|
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:
|
|
@@ -66,7 +81,7 @@ module TwoFactorAuth
|
|
|
66
81
|
def create_messaging_two_factor(account_id,
|
|
67
82
|
body)
|
|
68
83
|
# Prepare query url.
|
|
69
|
-
_query_builder = config.get_base_uri(Server::
|
|
84
|
+
_query_builder = config.get_base_uri(Server::MULTIFACTORAUTHDEFAULT)
|
|
70
85
|
_query_builder << '/accounts/{accountId}/code/messaging'
|
|
71
86
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
72
87
|
_query_builder,
|
|
@@ -86,13 +101,28 @@ module TwoFactorAuth
|
|
|
86
101
|
headers: _headers,
|
|
87
102
|
parameters: body.to_json
|
|
88
103
|
)
|
|
89
|
-
|
|
104
|
+
MultiFactorAuthBasicAuth.apply(config, _request)
|
|
90
105
|
_response = execute_request(_request)
|
|
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:
|
|
@@ -114,7 +144,7 @@ module TwoFactorAuth
|
|
|
114
144
|
def create_verify_two_factor(account_id,
|
|
115
145
|
body)
|
|
116
146
|
# Prepare query url.
|
|
117
|
-
_query_builder = config.get_base_uri(Server::
|
|
147
|
+
_query_builder = config.get_base_uri(Server::MULTIFACTORAUTHDEFAULT)
|
|
118
148
|
_query_builder << '/accounts/{accountId}/code/verify'
|
|
119
149
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
120
150
|
_query_builder,
|
|
@@ -134,13 +164,34 @@ module TwoFactorAuth
|
|
|
134
164
|
headers: _headers,
|
|
135
165
|
parameters: body.to_json
|
|
136
166
|
)
|
|
137
|
-
|
|
167
|
+
MultiFactorAuthBasicAuth.apply(config, _request)
|
|
138
168
|
_response = execute_request(_request)
|
|
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
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# bandwidth
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module Bandwidth
|
|
7
|
+
# ErrorWithRequest class.
|
|
8
|
+
class ErrorWithRequestException < APIException
|
|
9
|
+
# An error message pertaining to what the issue could be
|
|
10
|
+
# @return [String]
|
|
11
|
+
attr_accessor :error
|
|
12
|
+
|
|
13
|
+
# The associated requestId from AWS
|
|
14
|
+
# @return [String]
|
|
15
|
+
attr_accessor :request_id
|
|
16
|
+
|
|
17
|
+
# The constructor.
|
|
18
|
+
# @param [String] The reason for raising an exception.
|
|
19
|
+
# @param [HttpResponse] The HttpReponse of the API call.
|
|
20
|
+
def initialize(reason, response)
|
|
21
|
+
super(reason, response)
|
|
22
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
23
|
+
unbox(hash)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Populates this object by extracting properties from a hash.
|
|
27
|
+
# @param [Hash] The deserialized response sent by the server in the
|
|
28
|
+
# response body.
|
|
29
|
+
def unbox(hash)
|
|
30
|
+
@error = hash['error']
|
|
31
|
+
@request_id = hash['requestId']
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/forbidden_request_exception.rb
ADDED
|
@@ -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
|
+
# ForbiddenRequest class.
|
|
8
|
+
class ForbiddenRequestException < APIException
|
|
9
|
+
# The message containing the reason behind the request being forbidden
|
|
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,29 @@
|
|
|
1
|
+
# bandwidth
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module Bandwidth
|
|
7
|
+
# UnauthorizedRequest class.
|
|
8
|
+
class UnauthorizedRequestException < APIException
|
|
9
|
+
# The message containing the reason behind the request being unauthorized
|
|
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
|