bandwidth-sdk 3.0.0 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bandwidth.rb +2 -1
- data/lib/bandwidth/client.rb +9 -0
- data/lib/bandwidth/configuration.rb +22 -4
- data/lib/bandwidth/http/auth/two_factor_auth_basic_auth.rb +22 -0
- data/lib/bandwidth/messaging_lib/messaging/client.rb +4 -0
- data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +1 -1
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +20 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb +44 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/api_controller.rb +153 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb +49 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/invalid_request_exception.rb +29 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_code_request_schema.rb +88 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_messaging_response.rb +35 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_code_response.rb +35 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb +94 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_voice_response.rb +35 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/conference.rb +28 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/gather.rb +8 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/record.rb +2 -1
- data/lib/bandwidth/voice_lib/bxml/verbs/send_dtmf.rb +4 -1
- data/lib/bandwidth/voice_lib/voice.rb +2 -0
- data/lib/bandwidth/voice_lib/voice/client.rb +4 -0
- data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +145 -78
- data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
- data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +20 -2
- data/lib/bandwidth/voice_lib/voice/models/call_engine_modify_conference_request.rb +35 -0
- data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +4 -1
- data/lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb +1 -1
- data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +8 -14
- data/lib/bandwidth/voice_lib/voice/models/status2_enum.rb +32 -0
- data/lib/bandwidth/voice_lib/voice/models/status_enum.rb +4 -13
- data/lib/bandwidth/voice_lib/voice/models/transcription.rb +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48115c5ef2d3c4b9f64d4ef6afce6b6ecb94cdde4b445afb21fc4c1819b079c0
|
4
|
+
data.tar.gz: d9f295c220a2ac75b090ca8a419a1ae2375779119d9cb4bd7a14d09f0f5fed93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0d4a309e16b781e6e020688cc1ab153b171aa6a9f59e1e34ddaa81d442c851623cae0a4fdc9d081d62623cee0935277e28265b8da883c7dc2a66aab0c762093
|
7
|
+
data.tar.gz: d2c7435d3f124001aa11bc8c610336086309b511e65c9744d3007082b03b812c7c14e200005774b5d078b3fb512e62fa483218d7855791efd8206b6868531fc9
|
data/lib/bandwidth.rb
CHANGED
@@ -35,8 +35,9 @@ require_relative 'bandwidth/configuration.rb'
|
|
35
35
|
# Namespaces
|
36
36
|
require_relative 'bandwidth/messaging_lib/messaging'
|
37
37
|
require_relative 'bandwidth/http/auth/messaging_basic_auth.rb'
|
38
|
+
require_relative 'bandwidth/two_factor_auth_lib/two_factor_auth'
|
39
|
+
require_relative 'bandwidth/http/auth/two_factor_auth_basic_auth.rb'
|
38
40
|
require_relative 'bandwidth/voice_lib/voice'
|
39
41
|
require_relative 'bandwidth/http/auth/voice_basic_auth.rb'
|
40
42
|
|
41
|
-
|
42
43
|
# Controllers
|
data/lib/bandwidth/client.rb
CHANGED
@@ -12,6 +12,11 @@ module Bandwidth
|
|
12
12
|
def messaging_client
|
13
13
|
@messaging_client ||= Messaging::Client.new(config: config)
|
14
14
|
end
|
15
|
+
# Access to two_factor_auth_client controller.
|
16
|
+
# @return [TwoFactorAuth::Client] Returns the client instance.
|
17
|
+
def two_factor_auth_client
|
18
|
+
@two_factor_auth_client ||= TwoFactorAuth::Client.new(config: config)
|
19
|
+
end
|
15
20
|
# Access to voice_client controller.
|
16
21
|
# @return [Voice::Client] Returns the client instance.
|
17
22
|
def voice_client
|
@@ -22,6 +27,8 @@ module Bandwidth
|
|
22
27
|
backoff_factor: 1, environment: Environment::PRODUCTION,
|
23
28
|
messaging_basic_auth_user_name: 'TODO: Replace',
|
24
29
|
messaging_basic_auth_password: 'TODO: Replace',
|
30
|
+
two_factor_auth_basic_auth_user_name: 'TODO: Replace',
|
31
|
+
two_factor_auth_basic_auth_password: 'TODO: Replace',
|
25
32
|
voice_basic_auth_user_name: 'TODO: Replace',
|
26
33
|
voice_basic_auth_password: 'TODO: Replace', config: nil)
|
27
34
|
@config = if config.nil?
|
@@ -31,6 +38,8 @@ module Bandwidth
|
|
31
38
|
environment: environment,
|
32
39
|
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
33
40
|
messaging_basic_auth_password: messaging_basic_auth_password,
|
41
|
+
two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
|
42
|
+
two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
|
34
43
|
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
35
44
|
voice_basic_auth_password: voice_basic_auth_password)
|
36
45
|
else
|
@@ -16,6 +16,7 @@ module Bandwidth
|
|
16
16
|
SERVER = [
|
17
17
|
DEFAULT = 'default'.freeze,
|
18
18
|
MESSAGINGDEFAULT = 'MessagingDefault'.freeze,
|
19
|
+
TWOFACTORAUTHDEFAULT = 'TwoFactorAuthDefault'.freeze,
|
19
20
|
VOICEDEFAULT = 'VoiceDefault'.freeze
|
20
21
|
].freeze
|
21
22
|
end
|
@@ -32,6 +33,8 @@ module Bandwidth
|
|
32
33
|
attr_reader :environment
|
33
34
|
attr_reader :messaging_basic_auth_user_name
|
34
35
|
attr_reader :messaging_basic_auth_password
|
36
|
+
attr_reader :two_factor_auth_basic_auth_user_name
|
37
|
+
attr_reader :two_factor_auth_basic_auth_password
|
35
38
|
attr_reader :voice_basic_auth_user_name
|
36
39
|
attr_reader :voice_basic_auth_password
|
37
40
|
|
@@ -43,6 +46,8 @@ module Bandwidth
|
|
43
46
|
backoff_factor: 1, environment: Environment::PRODUCTION,
|
44
47
|
messaging_basic_auth_user_name: 'TODO: Replace',
|
45
48
|
messaging_basic_auth_password: 'TODO: Replace',
|
49
|
+
two_factor_auth_basic_auth_user_name: 'TODO: Replace',
|
50
|
+
two_factor_auth_basic_auth_password: 'TODO: Replace',
|
46
51
|
voice_basic_auth_user_name: 'TODO: Replace',
|
47
52
|
voice_basic_auth_password: 'TODO: Replace')
|
48
53
|
# The value to use for connection timeout
|
@@ -59,7 +64,7 @@ module Bandwidth
|
|
59
64
|
@backoff_factor = backoff_factor
|
60
65
|
|
61
66
|
# Current API environment
|
62
|
-
@environment = environment
|
67
|
+
@environment = String(environment)
|
63
68
|
|
64
69
|
# The username to use with basic authentication
|
65
70
|
@messaging_basic_auth_user_name = messaging_basic_auth_user_name
|
@@ -67,6 +72,12 @@ module Bandwidth
|
|
67
72
|
# The password to use with basic authentication
|
68
73
|
@messaging_basic_auth_password = messaging_basic_auth_password
|
69
74
|
|
75
|
+
# The username to use with basic authentication
|
76
|
+
@two_factor_auth_basic_auth_user_name = two_factor_auth_basic_auth_user_name
|
77
|
+
|
78
|
+
# The password to use with basic authentication
|
79
|
+
@two_factor_auth_basic_auth_password = two_factor_auth_basic_auth_password
|
80
|
+
|
70
81
|
# The username to use with basic authentication
|
71
82
|
@voice_basic_auth_user_name = voice_basic_auth_user_name
|
72
83
|
|
@@ -81,6 +92,8 @@ module Bandwidth
|
|
81
92
|
backoff_factor: nil, environment: nil,
|
82
93
|
messaging_basic_auth_user_name: nil,
|
83
94
|
messaging_basic_auth_password: nil,
|
95
|
+
two_factor_auth_basic_auth_user_name: nil,
|
96
|
+
two_factor_auth_basic_auth_password: nil,
|
84
97
|
voice_basic_auth_user_name: nil,
|
85
98
|
voice_basic_auth_password: nil)
|
86
99
|
timeout ||= self.timeout
|
@@ -90,6 +103,8 @@ module Bandwidth
|
|
90
103
|
environment ||= self.environment
|
91
104
|
messaging_basic_auth_user_name ||= self.messaging_basic_auth_user_name
|
92
105
|
messaging_basic_auth_password ||= self.messaging_basic_auth_password
|
106
|
+
two_factor_auth_basic_auth_user_name ||= self.two_factor_auth_basic_auth_user_name
|
107
|
+
two_factor_auth_basic_auth_password ||= self.two_factor_auth_basic_auth_password
|
93
108
|
voice_basic_auth_user_name ||= self.voice_basic_auth_user_name
|
94
109
|
voice_basic_auth_password ||= self.voice_basic_auth_password
|
95
110
|
|
@@ -99,6 +114,8 @@ module Bandwidth
|
|
99
114
|
environment: environment,
|
100
115
|
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
101
116
|
messaging_basic_auth_password: messaging_basic_auth_password,
|
117
|
+
two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
|
118
|
+
two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
|
102
119
|
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
103
120
|
voice_basic_auth_password: voice_basic_auth_password
|
104
121
|
)
|
@@ -111,20 +128,21 @@ module Bandwidth
|
|
111
128
|
end
|
112
129
|
|
113
130
|
# All the environments the SDK can run in.
|
114
|
-
|
131
|
+
ENVIRONMENTS = {
|
115
132
|
Environment::PRODUCTION => {
|
116
133
|
Server::DEFAULT => 'api.bandwidth.com',
|
117
134
|
Server::MESSAGINGDEFAULT => 'https://messaging.bandwidth.com/api/v2',
|
135
|
+
Server::TWOFACTORAUTHDEFAULT => 'https://mfa.bandwidth.com/api/v1/',
|
118
136
|
Server::VOICEDEFAULT => 'https://voice.bandwidth.com'
|
119
137
|
}
|
120
|
-
}
|
138
|
+
}.freeze
|
121
139
|
|
122
140
|
# Generates the appropriate base URI for the environment and the server.
|
123
141
|
# @param [Configuration::Server] The server enum for which the base URI is
|
124
142
|
# required.
|
125
143
|
# @return [String] The base URI.
|
126
144
|
def get_base_uri(server = Server::DEFAULT)
|
127
|
-
|
145
|
+
ENVIRONMENTS[environment][server].clone
|
128
146
|
end
|
129
147
|
end
|
130
148
|
end
|
@@ -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 TwoFactorAuthBasicAuth
|
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.two_factor_auth_basic_auth_user_name
|
16
|
+
password = config.two_factor_auth_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
|
@@ -19,6 +19,8 @@ module Bandwidth
|
|
19
19
|
backoff_factor: 1, environment: Environment::PRODUCTION,
|
20
20
|
messaging_basic_auth_user_name: 'TODO: Replace',
|
21
21
|
messaging_basic_auth_password: 'TODO: Replace',
|
22
|
+
two_factor_auth_basic_auth_user_name: 'TODO: Replace',
|
23
|
+
two_factor_auth_basic_auth_password: 'TODO: Replace',
|
22
24
|
voice_basic_auth_user_name: 'TODO: Replace',
|
23
25
|
voice_basic_auth_password: 'TODO: Replace', config: nil)
|
24
26
|
@config = if config.nil?
|
@@ -29,6 +31,8 @@ module Bandwidth
|
|
29
31
|
environment: environment,
|
30
32
|
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
31
33
|
messaging_basic_auth_password: messaging_basic_auth_password,
|
34
|
+
two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
|
35
|
+
two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
|
32
36
|
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
33
37
|
voice_basic_auth_password: voice_basic_auth_password)
|
34
38
|
else
|
@@ -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 'two_factor_auth/client.rb'
|
8
|
+
|
9
|
+
# Models
|
10
|
+
require_relative 'two_factor_auth/models/two_factor_code_request_schema.rb'
|
11
|
+
require_relative 'two_factor_auth/models/two_factor_voice_response.rb'
|
12
|
+
require_relative 'two_factor_auth/models/two_factor_messaging_response.rb'
|
13
|
+
require_relative 'two_factor_auth/models/two_factor_verify_request_schema.rb'
|
14
|
+
require_relative 'two_factor_auth/models/two_factor_verify_code_response.rb'
|
15
|
+
|
16
|
+
# Exceptions
|
17
|
+
require_relative 'two_factor_auth/exceptions/invalid_request_exception.rb'
|
18
|
+
# Controllers
|
19
|
+
require_relative 'two_factor_auth/controllers/base_controller.rb'
|
20
|
+
require_relative 'two_factor_auth/controllers/api_controller.rb'
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
module TwoFactorAuth
|
8
|
+
# bandwidth client class.
|
9
|
+
class Client
|
10
|
+
attr_reader :config
|
11
|
+
|
12
|
+
# Access to client controller.
|
13
|
+
# @return [APIController] Returns the controller instance.
|
14
|
+
def client
|
15
|
+
@client ||= APIController.new config
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
|
19
|
+
backoff_factor: 1, environment: Environment::PRODUCTION,
|
20
|
+
messaging_basic_auth_user_name: 'TODO: Replace',
|
21
|
+
messaging_basic_auth_password: 'TODO: Replace',
|
22
|
+
two_factor_auth_basic_auth_user_name: 'TODO: Replace',
|
23
|
+
two_factor_auth_basic_auth_password: 'TODO: Replace',
|
24
|
+
voice_basic_auth_user_name: 'TODO: Replace',
|
25
|
+
voice_basic_auth_password: 'TODO: Replace', config: nil)
|
26
|
+
@config = if config.nil?
|
27
|
+
Configuration.new(timeout: timeout,
|
28
|
+
max_retries: max_retries,
|
29
|
+
retry_interval: retry_interval,
|
30
|
+
backoff_factor: backoff_factor,
|
31
|
+
environment: environment,
|
32
|
+
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
33
|
+
messaging_basic_auth_password: messaging_basic_auth_password,
|
34
|
+
two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
|
35
|
+
two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
|
36
|
+
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
37
|
+
voice_basic_auth_password: voice_basic_auth_password)
|
38
|
+
else
|
39
|
+
config
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
module TwoFactorAuth
|
8
|
+
# APIController
|
9
|
+
class APIController < BaseController
|
10
|
+
def initialize(config, http_call_back: nil)
|
11
|
+
super(config, http_call_back: http_call_back)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Two-Factor authentication with Bandwidth Voice services
|
15
|
+
# @param [String] account_id Required parameter: Bandwidth Account ID with
|
16
|
+
# Voice service enabled
|
17
|
+
# @param [TwoFactorCodeRequestSchema] body Required parameter: Example:
|
18
|
+
# @return [TwoFactorVoiceResponse] response from the API call
|
19
|
+
def create_voice_two_factor(account_id,
|
20
|
+
body)
|
21
|
+
# Prepare query url.
|
22
|
+
_query_builder = config.get_base_uri(Server::TWOFACTORAUTHDEFAULT)
|
23
|
+
_query_builder << '/accounts/{accountId}/code/voice'
|
24
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
25
|
+
_query_builder,
|
26
|
+
'accountId' => account_id
|
27
|
+
)
|
28
|
+
_query_url = APIHelper.clean_url _query_builder
|
29
|
+
|
30
|
+
# Prepare headers.
|
31
|
+
_headers = {
|
32
|
+
'accept' => 'application/json',
|
33
|
+
'content-type' => 'application/json; charset=utf-8'
|
34
|
+
}
|
35
|
+
|
36
|
+
# Prepare and execute HttpRequest.
|
37
|
+
_request = config.http_client.post(
|
38
|
+
_query_url,
|
39
|
+
headers: _headers,
|
40
|
+
parameters: body.to_json
|
41
|
+
)
|
42
|
+
TwoFactorAuthBasicAuth.apply(config, _request)
|
43
|
+
_response = execute_request(_request)
|
44
|
+
|
45
|
+
# Validate response against endpoint and global error codes.
|
46
|
+
if _response.status_code == 400
|
47
|
+
raise InvalidRequestException.new(
|
48
|
+
'client request error',
|
49
|
+
_response
|
50
|
+
)
|
51
|
+
end
|
52
|
+
validate_response(_response)
|
53
|
+
|
54
|
+
# Return appropriate response type.
|
55
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
56
|
+
ApiResponse.new(_response,
|
57
|
+
data: TwoFactorVoiceResponse.from_hash(decoded))
|
58
|
+
end
|
59
|
+
|
60
|
+
# Two-Factor authentication with Bandwidth messaging services
|
61
|
+
# @param [String] account_id Required parameter: Bandwidth Account ID with
|
62
|
+
# Messaging service enabled
|
63
|
+
# @param [TwoFactorCodeRequestSchema] body Required parameter: Example:
|
64
|
+
# @return [TwoFactorMessagingResponse] response from the API call
|
65
|
+
def create_messaging_two_factor(account_id,
|
66
|
+
body)
|
67
|
+
# Prepare query url.
|
68
|
+
_query_builder = config.get_base_uri(Server::TWOFACTORAUTHDEFAULT)
|
69
|
+
_query_builder << '/accounts/{accountId}/code/messaging'
|
70
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
71
|
+
_query_builder,
|
72
|
+
'accountId' => account_id
|
73
|
+
)
|
74
|
+
_query_url = APIHelper.clean_url _query_builder
|
75
|
+
|
76
|
+
# Prepare headers.
|
77
|
+
_headers = {
|
78
|
+
'accept' => 'application/json',
|
79
|
+
'content-type' => 'application/json; charset=utf-8'
|
80
|
+
}
|
81
|
+
|
82
|
+
# Prepare and execute HttpRequest.
|
83
|
+
_request = config.http_client.post(
|
84
|
+
_query_url,
|
85
|
+
headers: _headers,
|
86
|
+
parameters: body.to_json
|
87
|
+
)
|
88
|
+
TwoFactorAuthBasicAuth.apply(config, _request)
|
89
|
+
_response = execute_request(_request)
|
90
|
+
|
91
|
+
# Validate response against endpoint and global error codes.
|
92
|
+
if _response.status_code == 400
|
93
|
+
raise InvalidRequestException.new(
|
94
|
+
'client request error',
|
95
|
+
_response
|
96
|
+
)
|
97
|
+
end
|
98
|
+
validate_response(_response)
|
99
|
+
|
100
|
+
# Return appropriate response type.
|
101
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
102
|
+
ApiResponse.new(_response,
|
103
|
+
data: TwoFactorMessagingResponse.from_hash(decoded))
|
104
|
+
end
|
105
|
+
|
106
|
+
# Verify a previously sent two-factor authentication code
|
107
|
+
# @param [String] account_id Required parameter: Bandwidth Account ID with
|
108
|
+
# Two-Factor enabled
|
109
|
+
# @param [TwoFactorVerifyRequestSchema] body Required parameter: Example:
|
110
|
+
# @return [TwoFactorVerifyCodeResponse] response from the API call
|
111
|
+
def create_verify_two_factor(account_id,
|
112
|
+
body)
|
113
|
+
# Prepare query url.
|
114
|
+
_query_builder = config.get_base_uri(Server::TWOFACTORAUTHDEFAULT)
|
115
|
+
_query_builder << '/accounts/{accountId}/code/verify'
|
116
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
117
|
+
_query_builder,
|
118
|
+
'accountId' => account_id
|
119
|
+
)
|
120
|
+
_query_url = APIHelper.clean_url _query_builder
|
121
|
+
|
122
|
+
# Prepare headers.
|
123
|
+
_headers = {
|
124
|
+
'accept' => 'application/json',
|
125
|
+
'content-type' => 'application/json; charset=utf-8'
|
126
|
+
}
|
127
|
+
|
128
|
+
# Prepare and execute HttpRequest.
|
129
|
+
_request = config.http_client.post(
|
130
|
+
_query_url,
|
131
|
+
headers: _headers,
|
132
|
+
parameters: body.to_json
|
133
|
+
)
|
134
|
+
TwoFactorAuthBasicAuth.apply(config, _request)
|
135
|
+
_response = execute_request(_request)
|
136
|
+
|
137
|
+
# Validate response against endpoint and global error codes.
|
138
|
+
if _response.status_code == 400
|
139
|
+
raise InvalidRequestException.new(
|
140
|
+
'client request error',
|
141
|
+
_response
|
142
|
+
)
|
143
|
+
end
|
144
|
+
validate_response(_response)
|
145
|
+
|
146
|
+
# Return appropriate response type.
|
147
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
148
|
+
ApiResponse.new(_response,
|
149
|
+
data: TwoFactorVerifyCodeResponse.from_hash(decoded))
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
@@ -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-refs/tags/ruby3.5.0'
|
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
|