bandwidth-sdk 2.2.1 → 3.3.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.rb +1 -3
- data/lib/bandwidth/messaging_lib/messaging/client.rb +4 -0
- data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +30 -83
- data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +1 -1
- data/lib/bandwidth/messaging_lib/messaging/exceptions/{generic_client_exception.rb → messaging_exception.rb} +2 -14
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +19 -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 +129 -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/models/two_factor_code_request_schema.rb +62 -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 +71 -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/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/client.rb +4 -0
- data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
- metadata +29 -7
- data/lib/bandwidth/messaging_lib/messaging/exceptions/path_client_exception.rb +0 -49
- data/lib/bandwidth/messaging_lib/messaging/models/field_error.rb +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db721efc4186c0731719649e2bde114ffc72d80b1ac76f4a072ba216232b10c1
|
4
|
+
data.tar.gz: bd2ee7c57603b5aad60d06f65093001fb72b7eb92527e34c425f8d7ba5d0ccf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d748d911c24f76ab1a83768f43fbcdb7ce291ec78029108516ec584efc5a1b5c78aefe1900c2bce269a362d38af246e68076775ed529d68b15833c9cd3ecd217
|
7
|
+
data.tar.gz: 2554808b7efba12a144353204518746df52313bb3c8296178fa1f5629301c00e1c12c6140615032a159c6f45986920292f9d63fc5d803d505df33c91ba7633d4
|
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
|
@@ -7,7 +7,6 @@
|
|
7
7
|
require_relative 'messaging/client.rb'
|
8
8
|
|
9
9
|
# Models
|
10
|
-
require_relative 'messaging/models/field_error.rb'
|
11
10
|
require_relative 'messaging/models/media.rb'
|
12
11
|
require_relative 'messaging/models/tag.rb'
|
13
12
|
require_relative 'messaging/models/deferred_result.rb'
|
@@ -16,8 +15,7 @@ require_relative 'messaging/models/bandwidth_message.rb'
|
|
16
15
|
require_relative 'messaging/models/message_request.rb'
|
17
16
|
|
18
17
|
# Exceptions
|
19
|
-
require_relative 'messaging/exceptions/
|
20
|
-
require_relative 'messaging/exceptions/path_client_exception.rb'
|
18
|
+
require_relative 'messaging/exceptions/messaging_exception.rb'
|
21
19
|
# Controllers
|
22
20
|
require_relative 'messaging/controllers/base_controller.rb'
|
23
21
|
require_relative 'messaging/controllers/api_controller.rb'
|
@@ -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
|
@@ -11,59 +11,6 @@ module Messaging
|
|
11
11
|
super(config, http_call_back: http_call_back)
|
12
12
|
end
|
13
13
|
|
14
|
-
# getMessage
|
15
|
-
# @return [void] response from the API call
|
16
|
-
def get_message
|
17
|
-
# Prepare query url.
|
18
|
-
_query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT)
|
19
|
-
_query_builder << '/ping'
|
20
|
-
_query_url = APIHelper.clean_url _query_builder
|
21
|
-
|
22
|
-
# Prepare and execute HttpRequest.
|
23
|
-
_request = config.http_client.get(
|
24
|
-
_query_url
|
25
|
-
)
|
26
|
-
MessagingBasicAuth.apply(config, _request)
|
27
|
-
_response = execute_request(_request)
|
28
|
-
|
29
|
-
# Validate response against endpoint and global error codes.
|
30
|
-
if _response.status_code == 400
|
31
|
-
raise GenericClientException.new(
|
32
|
-
'400 Request is malformed or invalid',
|
33
|
-
_response
|
34
|
-
)
|
35
|
-
elsif _response.status_code == 401
|
36
|
-
raise PathClientException.new(
|
37
|
-
'401 The specified user does not have access to the account',
|
38
|
-
_response
|
39
|
-
)
|
40
|
-
elsif _response.status_code == 403
|
41
|
-
raise PathClientException.new(
|
42
|
-
'403 The user does not have access to this API',
|
43
|
-
_response
|
44
|
-
)
|
45
|
-
elsif _response.status_code == 404
|
46
|
-
raise PathClientException.new(
|
47
|
-
'404 Path not found',
|
48
|
-
_response
|
49
|
-
)
|
50
|
-
elsif _response.status_code == 415
|
51
|
-
raise GenericClientException.new(
|
52
|
-
'415 The content-type of the request is incorrect',
|
53
|
-
_response
|
54
|
-
)
|
55
|
-
elsif _response.status_code == 429
|
56
|
-
raise GenericClientException.new(
|
57
|
-
'429 The rate limit has been reached',
|
58
|
-
_response
|
59
|
-
)
|
60
|
-
end
|
61
|
-
validate_response(_response)
|
62
|
-
|
63
|
-
# Return appropriate response type.
|
64
|
-
ApiResponse.new(_response)
|
65
|
-
end
|
66
|
-
|
67
14
|
# listMedia
|
68
15
|
# @param [String] user_id Required parameter: Example:
|
69
16
|
# @param [String] continuation_token Optional parameter: Example:
|
@@ -95,32 +42,32 @@ module Messaging
|
|
95
42
|
|
96
43
|
# Validate response against endpoint and global error codes.
|
97
44
|
if _response.status_code == 400
|
98
|
-
raise
|
45
|
+
raise MessagingException.new(
|
99
46
|
'400 Request is malformed or invalid',
|
100
47
|
_response
|
101
48
|
)
|
102
49
|
elsif _response.status_code == 401
|
103
|
-
raise
|
50
|
+
raise MessagingException.new(
|
104
51
|
'401 The specified user does not have access to the account',
|
105
52
|
_response
|
106
53
|
)
|
107
54
|
elsif _response.status_code == 403
|
108
|
-
raise
|
55
|
+
raise MessagingException.new(
|
109
56
|
'403 The user does not have access to this API',
|
110
57
|
_response
|
111
58
|
)
|
112
59
|
elsif _response.status_code == 404
|
113
|
-
raise
|
60
|
+
raise MessagingException.new(
|
114
61
|
'404 Path not found',
|
115
62
|
_response
|
116
63
|
)
|
117
64
|
elsif _response.status_code == 415
|
118
|
-
raise
|
65
|
+
raise MessagingException.new(
|
119
66
|
'415 The content-type of the request is incorrect',
|
120
67
|
_response
|
121
68
|
)
|
122
69
|
elsif _response.status_code == 429
|
123
|
-
raise
|
70
|
+
raise MessagingException.new(
|
124
71
|
'429 The rate limit has been reached',
|
125
72
|
_response
|
126
73
|
)
|
@@ -158,32 +105,32 @@ module Messaging
|
|
158
105
|
|
159
106
|
# Validate response against endpoint and global error codes.
|
160
107
|
if _response.status_code == 400
|
161
|
-
raise
|
108
|
+
raise MessagingException.new(
|
162
109
|
'400 Request is malformed or invalid',
|
163
110
|
_response
|
164
111
|
)
|
165
112
|
elsif _response.status_code == 401
|
166
|
-
raise
|
113
|
+
raise MessagingException.new(
|
167
114
|
'401 The specified user does not have access to the account',
|
168
115
|
_response
|
169
116
|
)
|
170
117
|
elsif _response.status_code == 403
|
171
|
-
raise
|
118
|
+
raise MessagingException.new(
|
172
119
|
'403 The user does not have access to this API',
|
173
120
|
_response
|
174
121
|
)
|
175
122
|
elsif _response.status_code == 404
|
176
|
-
raise
|
123
|
+
raise MessagingException.new(
|
177
124
|
'404 Path not found',
|
178
125
|
_response
|
179
126
|
)
|
180
127
|
elsif _response.status_code == 415
|
181
|
-
raise
|
128
|
+
raise MessagingException.new(
|
182
129
|
'415 The content-type of the request is incorrect',
|
183
130
|
_response
|
184
131
|
)
|
185
132
|
elsif _response.status_code == 429
|
186
|
-
raise
|
133
|
+
raise MessagingException.new(
|
187
134
|
'429 The rate limit has been reached',
|
188
135
|
_response
|
189
136
|
)
|
@@ -246,32 +193,32 @@ module Messaging
|
|
246
193
|
|
247
194
|
# Validate response against endpoint and global error codes.
|
248
195
|
if _response.status_code == 400
|
249
|
-
raise
|
196
|
+
raise MessagingException.new(
|
250
197
|
'400 Request is malformed or invalid',
|
251
198
|
_response
|
252
199
|
)
|
253
200
|
elsif _response.status_code == 401
|
254
|
-
raise
|
201
|
+
raise MessagingException.new(
|
255
202
|
'401 The specified user does not have access to the account',
|
256
203
|
_response
|
257
204
|
)
|
258
205
|
elsif _response.status_code == 403
|
259
|
-
raise
|
206
|
+
raise MessagingException.new(
|
260
207
|
'403 The user does not have access to this API',
|
261
208
|
_response
|
262
209
|
)
|
263
210
|
elsif _response.status_code == 404
|
264
|
-
raise
|
211
|
+
raise MessagingException.new(
|
265
212
|
'404 Path not found',
|
266
213
|
_response
|
267
214
|
)
|
268
215
|
elsif _response.status_code == 415
|
269
|
-
raise
|
216
|
+
raise MessagingException.new(
|
270
217
|
'415 The content-type of the request is incorrect',
|
271
218
|
_response
|
272
219
|
)
|
273
220
|
elsif _response.status_code == 429
|
274
|
-
raise
|
221
|
+
raise MessagingException.new(
|
275
222
|
'429 The rate limit has been reached',
|
276
223
|
_response
|
277
224
|
)
|
@@ -307,32 +254,32 @@ module Messaging
|
|
307
254
|
|
308
255
|
# Validate response against endpoint and global error codes.
|
309
256
|
if _response.status_code == 400
|
310
|
-
raise
|
257
|
+
raise MessagingException.new(
|
311
258
|
'400 Request is malformed or invalid',
|
312
259
|
_response
|
313
260
|
)
|
314
261
|
elsif _response.status_code == 401
|
315
|
-
raise
|
262
|
+
raise MessagingException.new(
|
316
263
|
'401 The specified user does not have access to the account',
|
317
264
|
_response
|
318
265
|
)
|
319
266
|
elsif _response.status_code == 403
|
320
|
-
raise
|
267
|
+
raise MessagingException.new(
|
321
268
|
'403 The user does not have access to this API',
|
322
269
|
_response
|
323
270
|
)
|
324
271
|
elsif _response.status_code == 404
|
325
|
-
raise
|
272
|
+
raise MessagingException.new(
|
326
273
|
'404 Path not found',
|
327
274
|
_response
|
328
275
|
)
|
329
276
|
elsif _response.status_code == 415
|
330
|
-
raise
|
277
|
+
raise MessagingException.new(
|
331
278
|
'415 The content-type of the request is incorrect',
|
332
279
|
_response
|
333
280
|
)
|
334
281
|
elsif _response.status_code == 429
|
335
|
-
raise
|
282
|
+
raise MessagingException.new(
|
336
283
|
'429 The rate limit has been reached',
|
337
284
|
_response
|
338
285
|
)
|
@@ -375,32 +322,32 @@ module Messaging
|
|
375
322
|
|
376
323
|
# Validate response against endpoint and global error codes.
|
377
324
|
if _response.status_code == 400
|
378
|
-
raise
|
325
|
+
raise MessagingException.new(
|
379
326
|
'400 Request is malformed or invalid',
|
380
327
|
_response
|
381
328
|
)
|
382
329
|
elsif _response.status_code == 401
|
383
|
-
raise
|
330
|
+
raise MessagingException.new(
|
384
331
|
'401 The specified user does not have access to the account',
|
385
332
|
_response
|
386
333
|
)
|
387
334
|
elsif _response.status_code == 403
|
388
|
-
raise
|
335
|
+
raise MessagingException.new(
|
389
336
|
'403 The user does not have access to this API',
|
390
337
|
_response
|
391
338
|
)
|
392
339
|
elsif _response.status_code == 404
|
393
|
-
raise
|
340
|
+
raise MessagingException.new(
|
394
341
|
'404 Path not found',
|
395
342
|
_response
|
396
343
|
)
|
397
344
|
elsif _response.status_code == 415
|
398
|
-
raise
|
345
|
+
raise MessagingException.new(
|
399
346
|
'415 The content-type of the request is incorrect',
|
400
347
|
_response
|
401
348
|
)
|
402
349
|
elsif _response.status_code == 429
|
403
|
-
raise
|
350
|
+
raise MessagingException.new(
|
404
351
|
'429 The rate limit has been reached',
|
405
352
|
_response
|
406
353
|
)
|
@@ -4,8 +4,8 @@
|
|
4
4
|
# ( https://apimatic.io ).
|
5
5
|
|
6
6
|
module Bandwidth
|
7
|
-
#
|
8
|
-
class
|
7
|
+
# MessagingException class.
|
8
|
+
class MessagingException < APIException
|
9
9
|
# TODO: Write general description for this method
|
10
10
|
# @return [String]
|
11
11
|
attr_accessor :type
|
@@ -14,10 +14,6 @@ module Bandwidth
|
|
14
14
|
# @return [String]
|
15
15
|
attr_accessor :description
|
16
16
|
|
17
|
-
# TODO: Write general description for this method
|
18
|
-
# @return [List of FieldError]
|
19
|
-
attr_accessor :field_errors
|
20
|
-
|
21
17
|
# The constructor.
|
22
18
|
# @param [String] The reason for raising an exception.
|
23
19
|
# @param [HttpResponse] The HttpReponse of the API call.
|
@@ -33,14 +29,6 @@ module Bandwidth
|
|
33
29
|
def unbox(hash)
|
34
30
|
@type = hash['type']
|
35
31
|
@description = hash['description']
|
36
|
-
# Parameter is an array, so we need to iterate through it
|
37
|
-
@field_errors = nil
|
38
|
-
unless hash['fieldErrors'].nil?
|
39
|
-
@field_errors = []
|
40
|
-
hash['fieldErrors'].each do |structure|
|
41
|
-
@field_errors << (FieldError.from_hash(structure) if structure)
|
42
|
-
end
|
43
|
-
end
|
44
32
|
end
|
45
33
|
end
|
46
34
|
end
|
@@ -0,0 +1,19 @@
|
|
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
|
+
# Controllers
|
18
|
+
require_relative 'two_factor_auth/controllers/base_controller.rb'
|
19
|
+
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,129 @@
|
|
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
|
+
validate_response(_response)
|
45
|
+
|
46
|
+
# Return appropriate response type.
|
47
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
48
|
+
ApiResponse.new(_response,
|
49
|
+
data: TwoFactorVoiceResponse.from_hash(decoded))
|
50
|
+
end
|
51
|
+
|
52
|
+
# Two-Factor authentication with Bandwidth messaging services
|
53
|
+
# @param [String] account_id Required parameter: Bandwidth Account ID with
|
54
|
+
# Messaging service enabled
|
55
|
+
# @param [TwoFactorCodeRequestSchema] body Required parameter: Example:
|
56
|
+
# @return [TwoFactorMessagingResponse] response from the API call
|
57
|
+
def create_messaging_two_factor(account_id,
|
58
|
+
body)
|
59
|
+
# Prepare query url.
|
60
|
+
_query_builder = config.get_base_uri(Server::TWOFACTORAUTHDEFAULT)
|
61
|
+
_query_builder << '/accounts/{accountId}/code/messaging'
|
62
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
63
|
+
_query_builder,
|
64
|
+
'accountId' => account_id
|
65
|
+
)
|
66
|
+
_query_url = APIHelper.clean_url _query_builder
|
67
|
+
|
68
|
+
# Prepare headers.
|
69
|
+
_headers = {
|
70
|
+
'accept' => 'application/json',
|
71
|
+
'content-type' => 'application/json; charset=utf-8'
|
72
|
+
}
|
73
|
+
|
74
|
+
# Prepare and execute HttpRequest.
|
75
|
+
_request = config.http_client.post(
|
76
|
+
_query_url,
|
77
|
+
headers: _headers,
|
78
|
+
parameters: body.to_json
|
79
|
+
)
|
80
|
+
TwoFactorAuthBasicAuth.apply(config, _request)
|
81
|
+
_response = execute_request(_request)
|
82
|
+
validate_response(_response)
|
83
|
+
|
84
|
+
# Return appropriate response type.
|
85
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
86
|
+
ApiResponse.new(_response,
|
87
|
+
data: TwoFactorMessagingResponse.from_hash(decoded))
|
88
|
+
end
|
89
|
+
|
90
|
+
# Verify a previously sent two-factor authentication code
|
91
|
+
# @param [String] account_id Required parameter: Bandwidth Account ID with
|
92
|
+
# Two-Factor enabled
|
93
|
+
# @param [TwoFactorVerifyRequestSchema] body Required parameter: Example:
|
94
|
+
# @return [TwoFactorVerifyCodeResponse] response from the API call
|
95
|
+
def create_verify_two_factor(account_id,
|
96
|
+
body)
|
97
|
+
# Prepare query url.
|
98
|
+
_query_builder = config.get_base_uri(Server::TWOFACTORAUTHDEFAULT)
|
99
|
+
_query_builder << '/accounts/{accountId}/code/verify'
|
100
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
101
|
+
_query_builder,
|
102
|
+
'accountId' => account_id
|
103
|
+
)
|
104
|
+
_query_url = APIHelper.clean_url _query_builder
|
105
|
+
|
106
|
+
# Prepare headers.
|
107
|
+
_headers = {
|
108
|
+
'accept' => 'application/json',
|
109
|
+
'content-type' => 'application/json; charset=utf-8'
|
110
|
+
}
|
111
|
+
|
112
|
+
# Prepare and execute HttpRequest.
|
113
|
+
_request = config.http_client.post(
|
114
|
+
_query_url,
|
115
|
+
headers: _headers,
|
116
|
+
parameters: body.to_json
|
117
|
+
)
|
118
|
+
TwoFactorAuthBasicAuth.apply(config, _request)
|
119
|
+
_response = execute_request(_request)
|
120
|
+
validate_response(_response)
|
121
|
+
|
122
|
+
# Return appropriate response type.
|
123
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
124
|
+
ApiResponse.new(_response,
|
125
|
+
data: TwoFactorVerifyCodeResponse.from_hash(decoded))
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
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.3.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
|
data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_code_request_schema.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# TwoFactorCodeRequestSchema Model.
|
8
|
+
class TwoFactorCodeRequestSchema < BaseModel
|
9
|
+
# TODO: Write general description for this method
|
10
|
+
# @return [String]
|
11
|
+
attr_accessor :to
|
12
|
+
|
13
|
+
# TODO: Write general description for this method
|
14
|
+
# @return [String]
|
15
|
+
attr_accessor :from
|
16
|
+
|
17
|
+
# TODO: Write general description for this method
|
18
|
+
# @return [String]
|
19
|
+
attr_accessor :application_id
|
20
|
+
|
21
|
+
# TODO: Write general description for this method
|
22
|
+
# @return [String]
|
23
|
+
attr_accessor :scope
|
24
|
+
|
25
|
+
# A mapping from model property names to API property names.
|
26
|
+
def self.names
|
27
|
+
@_hash = {} if @_hash.nil?
|
28
|
+
@_hash['to'] = 'to'
|
29
|
+
@_hash['from'] = 'from'
|
30
|
+
@_hash['application_id'] = 'applicationId'
|
31
|
+
@_hash['scope'] = 'scope'
|
32
|
+
@_hash
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(to = nil,
|
36
|
+
from = nil,
|
37
|
+
application_id = nil,
|
38
|
+
scope = nil)
|
39
|
+
@to = to
|
40
|
+
@from = from
|
41
|
+
@application_id = application_id
|
42
|
+
@scope = scope
|
43
|
+
end
|
44
|
+
|
45
|
+
# Creates an instance of the object from a hash.
|
46
|
+
def self.from_hash(hash)
|
47
|
+
return nil unless hash
|
48
|
+
|
49
|
+
# Extract variables from the hash.
|
50
|
+
to = hash['to']
|
51
|
+
from = hash['from']
|
52
|
+
application_id = hash['applicationId']
|
53
|
+
scope = hash['scope']
|
54
|
+
|
55
|
+
# Create object from extracted values.
|
56
|
+
TwoFactorCodeRequestSchema.new(to,
|
57
|
+
from,
|
58
|
+
application_id,
|
59
|
+
scope)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_messaging_response.rb
ADDED
@@ -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
|
+
# TwoFactorMessagingResponse Model.
|
8
|
+
class TwoFactorMessagingResponse < BaseModel
|
9
|
+
# TODO: Write general description for this method
|
10
|
+
# @return [String]
|
11
|
+
attr_accessor :message_id
|
12
|
+
|
13
|
+
# A mapping from model property names to API property names.
|
14
|
+
def self.names
|
15
|
+
@_hash = {} if @_hash.nil?
|
16
|
+
@_hash['message_id'] = 'messageId'
|
17
|
+
@_hash
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(message_id = nil)
|
21
|
+
@message_id = message_id
|
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
|
+
message_id = hash['messageId']
|
30
|
+
|
31
|
+
# Create object from extracted values.
|
32
|
+
TwoFactorMessagingResponse.new(message_id)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_code_response.rb
ADDED
@@ -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
|
+
# TwoFactorVerifyCodeResponse Model.
|
8
|
+
class TwoFactorVerifyCodeResponse < BaseModel
|
9
|
+
# TODO: Write general description for this method
|
10
|
+
# @return [Boolean]
|
11
|
+
attr_accessor :valid
|
12
|
+
|
13
|
+
# A mapping from model property names to API property names.
|
14
|
+
def self.names
|
15
|
+
@_hash = {} if @_hash.nil?
|
16
|
+
@_hash['valid'] = 'valid'
|
17
|
+
@_hash
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(valid = nil)
|
21
|
+
@valid = valid
|
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
|
+
valid = hash['valid']
|
30
|
+
|
31
|
+
# Create object from extracted values.
|
32
|
+
TwoFactorVerifyCodeResponse.new(valid)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# TwoFactorVerifyRequestSchema Model.
|
8
|
+
class TwoFactorVerifyRequestSchema < BaseModel
|
9
|
+
# TODO: Write general description for this method
|
10
|
+
# @return [String]
|
11
|
+
attr_accessor :to
|
12
|
+
|
13
|
+
# TODO: Write general description for this method
|
14
|
+
# @return [String]
|
15
|
+
attr_accessor :from
|
16
|
+
|
17
|
+
# TODO: Write general description for this method
|
18
|
+
# @return [String]
|
19
|
+
attr_accessor :application_id
|
20
|
+
|
21
|
+
# TODO: Write general description for this method
|
22
|
+
# @return [String]
|
23
|
+
attr_accessor :scope
|
24
|
+
|
25
|
+
# TODO: Write general description for this method
|
26
|
+
# @return [String]
|
27
|
+
attr_accessor :code
|
28
|
+
|
29
|
+
# A mapping from model property names to API property names.
|
30
|
+
def self.names
|
31
|
+
@_hash = {} if @_hash.nil?
|
32
|
+
@_hash['to'] = 'to'
|
33
|
+
@_hash['from'] = 'from'
|
34
|
+
@_hash['application_id'] = 'applicationId'
|
35
|
+
@_hash['scope'] = 'scope'
|
36
|
+
@_hash['code'] = 'code'
|
37
|
+
@_hash
|
38
|
+
end
|
39
|
+
|
40
|
+
def initialize(to = nil,
|
41
|
+
from = nil,
|
42
|
+
application_id = nil,
|
43
|
+
scope = nil,
|
44
|
+
code = nil)
|
45
|
+
@to = to
|
46
|
+
@from = from
|
47
|
+
@application_id = application_id
|
48
|
+
@scope = scope
|
49
|
+
@code = code
|
50
|
+
end
|
51
|
+
|
52
|
+
# Creates an instance of the object from a hash.
|
53
|
+
def self.from_hash(hash)
|
54
|
+
return nil unless hash
|
55
|
+
|
56
|
+
# Extract variables from the hash.
|
57
|
+
to = hash['to']
|
58
|
+
from = hash['from']
|
59
|
+
application_id = hash['applicationId']
|
60
|
+
scope = hash['scope']
|
61
|
+
code = hash['code']
|
62
|
+
|
63
|
+
# Create object from extracted values.
|
64
|
+
TwoFactorVerifyRequestSchema.new(to,
|
65
|
+
from,
|
66
|
+
application_id,
|
67
|
+
scope,
|
68
|
+
code)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
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
|
+
# TwoFactorVoiceResponse Model.
|
8
|
+
class TwoFactorVoiceResponse < BaseModel
|
9
|
+
# TODO: Write general description for this method
|
10
|
+
# @return [String]
|
11
|
+
attr_accessor :call_id
|
12
|
+
|
13
|
+
# A mapping from model property names to API property names.
|
14
|
+
def self.names
|
15
|
+
@_hash = {} if @_hash.nil?
|
16
|
+
@_hash['call_id'] = 'callId'
|
17
|
+
@_hash
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(call_id = nil)
|
21
|
+
@call_id = call_id
|
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
|
+
call_id = hash['callId']
|
30
|
+
|
31
|
+
# Create object from extracted values.
|
32
|
+
TwoFactorVoiceResponse.new(call_id)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -28,8 +28,16 @@ module Bandwidth
|
|
28
28
|
s.to_bxml(xml)
|
29
29
|
end
|
30
30
|
end
|
31
|
+
def nest_verbs_list(xml, property)
|
32
|
+
if property
|
33
|
+
property.each do |verb|
|
34
|
+
verb.to_bxml(xml)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
31
38
|
embedded_xml(xml, speak_sentence, SpeakSentence)
|
32
39
|
embedded_xml(xml, play_audio, PlayAudio)
|
40
|
+
nest_verbs_list(xml, nested_verbs)
|
33
41
|
end
|
34
42
|
end
|
35
43
|
end
|
@@ -20,7 +20,8 @@ module Bandwidth
|
|
20
20
|
'fileFormat' => file_format,
|
21
21
|
'transcribe' => transcribe,
|
22
22
|
'transcriptionAvailableUrl' => transcription_available_url,
|
23
|
-
'transcriptionAvailableMethod' => transcription_available_method
|
23
|
+
'transcriptionAvailableMethod' => transcription_available_method,
|
24
|
+
'silenceTimeout' => silence_timeout
|
24
25
|
}))
|
25
26
|
end
|
26
27
|
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
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bandwidth-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- APIMatic SDK Generator
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|
@@ -72,14 +72,28 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 2.0
|
75
|
+
version: '2.0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 2.0
|
82
|
+
version: '2.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: builder
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 3.2.4
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.2.4
|
83
97
|
description: Bandwidth's set of APIs
|
84
98
|
email: support@apimatic.io
|
85
99
|
executables: []
|
@@ -95,6 +109,7 @@ files:
|
|
95
109
|
- lib/bandwidth/exceptions/api_exception.rb
|
96
110
|
- lib/bandwidth/http/api_response.rb
|
97
111
|
- lib/bandwidth/http/auth/messaging_basic_auth.rb
|
112
|
+
- lib/bandwidth/http/auth/two_factor_auth_basic_auth.rb
|
98
113
|
- lib/bandwidth/http/auth/voice_basic_auth.rb
|
99
114
|
- lib/bandwidth/http/faraday_client.rb
|
100
115
|
- lib/bandwidth/http/http_call_back.rb
|
@@ -106,16 +121,23 @@ files:
|
|
106
121
|
- lib/bandwidth/messaging_lib/messaging/client.rb
|
107
122
|
- lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb
|
108
123
|
- lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb
|
109
|
-
- lib/bandwidth/messaging_lib/messaging/exceptions/
|
110
|
-
- lib/bandwidth/messaging_lib/messaging/exceptions/path_client_exception.rb
|
124
|
+
- lib/bandwidth/messaging_lib/messaging/exceptions/messaging_exception.rb
|
111
125
|
- lib/bandwidth/messaging_lib/messaging/models/bandwidth_callback_message.rb
|
112
126
|
- lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb
|
113
127
|
- lib/bandwidth/messaging_lib/messaging/models/deferred_result.rb
|
114
|
-
- lib/bandwidth/messaging_lib/messaging/models/field_error.rb
|
115
128
|
- lib/bandwidth/messaging_lib/messaging/models/media.rb
|
116
129
|
- lib/bandwidth/messaging_lib/messaging/models/message_request.rb
|
117
130
|
- lib/bandwidth/messaging_lib/messaging/models/tag.rb
|
118
131
|
- lib/bandwidth/models/base_model.rb
|
132
|
+
- lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb
|
133
|
+
- lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb
|
134
|
+
- lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/api_controller.rb
|
135
|
+
- lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb
|
136
|
+
- lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_code_request_schema.rb
|
137
|
+
- lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_messaging_response.rb
|
138
|
+
- lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_code_response.rb
|
139
|
+
- lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb
|
140
|
+
- lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_voice_response.rb
|
119
141
|
- lib/bandwidth/utilities/file_wrapper.rb
|
120
142
|
- lib/bandwidth/voice_lib/bxml/bxml.rb
|
121
143
|
- lib/bandwidth/voice_lib/bxml/verbs/forward.rb
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# bandwidth
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Bandwidth
|
7
|
-
# PathClientException class.
|
8
|
-
class PathClientException < APIException
|
9
|
-
# TODO: Write general description for this method
|
10
|
-
# @return [String]
|
11
|
-
attr_accessor :timestamp
|
12
|
-
|
13
|
-
# TODO: Write general description for this method
|
14
|
-
# @return [Integer]
|
15
|
-
attr_accessor :status
|
16
|
-
|
17
|
-
# TODO: Write general description for this method
|
18
|
-
# @return [String]
|
19
|
-
attr_accessor :error
|
20
|
-
|
21
|
-
# TODO: Write general description for this method
|
22
|
-
# @return [String]
|
23
|
-
attr_accessor :message
|
24
|
-
|
25
|
-
# TODO: Write general description for this method
|
26
|
-
# @return [String]
|
27
|
-
attr_accessor :path
|
28
|
-
|
29
|
-
# The constructor.
|
30
|
-
# @param [String] The reason for raising an exception.
|
31
|
-
# @param [HttpResponse] The HttpReponse of the API call.
|
32
|
-
def initialize(reason, response)
|
33
|
-
super(reason, response)
|
34
|
-
hash = APIHelper.json_deserialize(@response.raw_body)
|
35
|
-
unbox(hash)
|
36
|
-
end
|
37
|
-
|
38
|
-
# Populates this object by extracting properties from a hash.
|
39
|
-
# @param [Hash] The deserialized response sent by the server in the
|
40
|
-
# response body.
|
41
|
-
def unbox(hash)
|
42
|
-
@timestamp = hash['timestamp']
|
43
|
-
@status = hash['status']
|
44
|
-
@error = hash['error']
|
45
|
-
@message = hash['message']
|
46
|
-
@path = hash['path']
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# bandwidth
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Bandwidth
|
7
|
-
# FieldError Model.
|
8
|
-
class FieldError < BaseModel
|
9
|
-
# TODO: Write general description for this method
|
10
|
-
# @return [String]
|
11
|
-
attr_accessor :field_name
|
12
|
-
|
13
|
-
# TODO: Write general description for this method
|
14
|
-
# @return [String]
|
15
|
-
attr_accessor :description
|
16
|
-
|
17
|
-
# A mapping from model property names to API property names.
|
18
|
-
def self.names
|
19
|
-
@_hash = {} if @_hash.nil?
|
20
|
-
@_hash['field_name'] = 'fieldName'
|
21
|
-
@_hash['description'] = 'description'
|
22
|
-
@_hash
|
23
|
-
end
|
24
|
-
|
25
|
-
def initialize(field_name = nil,
|
26
|
-
description = nil)
|
27
|
-
@field_name = field_name
|
28
|
-
@description = description
|
29
|
-
end
|
30
|
-
|
31
|
-
# Creates an instance of the object from a hash.
|
32
|
-
def self.from_hash(hash)
|
33
|
-
return nil unless hash
|
34
|
-
|
35
|
-
# Extract variables from the hash.
|
36
|
-
field_name = hash['fieldName']
|
37
|
-
description = hash['description']
|
38
|
-
|
39
|
-
# Create object from extracted values.
|
40
|
-
FieldError.new(field_name,
|
41
|
-
description)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|