bandwidth-sdk 2.1.1 → 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +85 -70
- data/lib/bandwidth.rb +7 -1
- data/lib/bandwidth/client.rb +20 -2
- data/lib/bandwidth/configuration.rb +45 -9
- data/lib/bandwidth/http/auth/two_factor_auth_basic_auth.rb +22 -0
- data/lib/bandwidth/http/auth/web_rtc_basic_auth.rb +22 -0
- data/lib/bandwidth/http/faraday_client.rb +2 -6
- data/lib/bandwidth/messaging_lib/messaging.rb +1 -3
- data/lib/bandwidth/messaging_lib/messaging/client.rb +11 -2
- data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +45 -88
- 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 +20 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb +49 -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/utilities/file_wrapper.rb +17 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/bridge.rb +22 -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/phone_number.rb +2 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/record.rb +5 -1
- data/lib/bandwidth/voice_lib/bxml/verbs/send_dtmf.rb +4 -1
- data/lib/bandwidth/voice_lib/bxml/verbs/start_recording.rb +4 -1
- data/lib/bandwidth/voice_lib/voice.rb +13 -4
- data/lib/bandwidth/voice_lib/voice/client.rb +11 -2
- data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +629 -112
- data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
- data/lib/bandwidth/voice_lib/voice/exceptions/{error_response_exception.rb → api_error_response_exception.rb} +3 -3
- data/lib/bandwidth/voice_lib/voice/models/api_call_response.rb +11 -2
- data/lib/bandwidth/voice_lib/voice/models/api_call_state_response.rb +164 -0
- data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +20 -2
- data/lib/bandwidth/voice_lib/voice/models/api_modify_call_request.rb +1 -1
- data/lib/bandwidth/voice_lib/voice/models/api_transcribe_recording_request.rb +71 -0
- data/lib/bandwidth/voice_lib/voice/models/call_engine_modify_conference_request.rb +35 -0
- data/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb +35 -0
- data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +47 -0
- data/lib/bandwidth/voice_lib/voice/models/modify_call_recording_state.rb +1 -1
- data/lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb +35 -25
- data/lib/bandwidth/voice_lib/voice/models/state1_enum.rb +4 -7
- data/lib/bandwidth/voice_lib/voice/models/state2_enum.rb +20 -0
- data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +7 -4
- data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +26 -0
- data/lib/bandwidth/voice_lib/voice/models/status2_enum.rb +32 -0
- data/lib/bandwidth/voice_lib/voice/models/status_enum.rb +17 -0
- data/lib/bandwidth/{messaging_lib/messaging/models/field_error.rb → voice_lib/voice/models/transcript.rb} +15 -15
- data/lib/bandwidth/voice_lib/voice/models/transcription.rb +62 -0
- data/lib/bandwidth/voice_lib/voice/models/transcription_response.rb +42 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc.rb +21 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +49 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +682 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +49 -0
- data/lib/bandwidth/{messaging_lib/messaging/exceptions/path_client_exception.rb → web_rtc_lib/web_rtc/exceptions/error_exception.rb} +4 -19
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +47 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +83 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +35 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/publish_permission_enum.rb +17 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +44 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +54 -0
- metadata +58 -11
- data/lib/bandwidth/voice_lib/voice/models/api_get_account_recordings_metadata_request.rb +0 -65
- data/lib/bandwidth/voice_lib/voice/models/transcription_status_enum.rb +0 -20
- data/lib/bandwidth/voice_lib/voice/models/type_enum.rb +0 -32
@@ -19,8 +19,13 @@ 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
|
-
voice_basic_auth_password: 'TODO: Replace',
|
25
|
+
voice_basic_auth_password: 'TODO: Replace',
|
26
|
+
web_rtc_basic_auth_user_name: 'TODO: Replace',
|
27
|
+
web_rtc_basic_auth_password: 'TODO: Replace',
|
28
|
+
config: nil)
|
24
29
|
@config = if config.nil?
|
25
30
|
Configuration.new(timeout: timeout,
|
26
31
|
max_retries: max_retries,
|
@@ -29,8 +34,12 @@ module Bandwidth
|
|
29
34
|
environment: environment,
|
30
35
|
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
31
36
|
messaging_basic_auth_password: messaging_basic_auth_password,
|
37
|
+
two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
|
38
|
+
two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
|
32
39
|
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
33
|
-
voice_basic_auth_password: voice_basic_auth_password
|
40
|
+
voice_basic_auth_password: voice_basic_auth_password,
|
41
|
+
web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
|
42
|
+
web_rtc_basic_auth_password: web_rtc_basic_auth_password)
|
34
43
|
else
|
35
44
|
config
|
36
45
|
end
|
@@ -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
|
)
|
@@ -198,15 +145,16 @@ module Messaging
|
|
198
145
|
# @param [String] user_id Required parameter: Example:
|
199
146
|
# @param [String] media_id Required parameter: Example:
|
200
147
|
# @param [Long] content_length Required parameter: Example:
|
201
|
-
# @param [
|
202
|
-
# @param [String] content_type Optional parameter:
|
148
|
+
# @param [File | UploadIO] body Required parameter: Example:
|
149
|
+
# @param [String] content_type Optional parameter:
|
150
|
+
# Example:application/octet-stream
|
203
151
|
# @param [String] cache_control Optional parameter: Example:
|
204
152
|
# @return [void] response from the API call
|
205
153
|
def upload_media(user_id,
|
206
154
|
media_id,
|
207
155
|
content_length,
|
208
156
|
body,
|
209
|
-
content_type:
|
157
|
+
content_type: 'application/octet-stream',
|
210
158
|
cache_control: nil)
|
211
159
|
# Prepare query url.
|
212
160
|
_query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT)
|
@@ -218,10 +166,19 @@ module Messaging
|
|
218
166
|
)
|
219
167
|
_query_url = APIHelper.clean_url _query_builder
|
220
168
|
|
169
|
+
if body.is_a? FileWrapper
|
170
|
+
body_wrapper = body.file
|
171
|
+
body_content_type = body.content_type
|
172
|
+
else
|
173
|
+
body_wrapper = body
|
174
|
+
body_content_type = content_type
|
175
|
+
end
|
176
|
+
|
221
177
|
# Prepare headers.
|
222
178
|
_headers = {
|
179
|
+
'content-type' => body_content_type,
|
180
|
+
'content-length' => body_wrapper.size.to_s,
|
223
181
|
'Content-Length' => content_length,
|
224
|
-
'Content-Type' => content_type,
|
225
182
|
'Cache-Control' => cache_control
|
226
183
|
}
|
227
184
|
|
@@ -229,39 +186,39 @@ module Messaging
|
|
229
186
|
_request = config.http_client.put(
|
230
187
|
_query_url,
|
231
188
|
headers: _headers,
|
232
|
-
parameters:
|
189
|
+
parameters: body_wrapper
|
233
190
|
)
|
234
191
|
MessagingBasicAuth.apply(config, _request)
|
235
192
|
_response = execute_request(_request)
|
236
193
|
|
237
194
|
# Validate response against endpoint and global error codes.
|
238
195
|
if _response.status_code == 400
|
239
|
-
raise
|
196
|
+
raise MessagingException.new(
|
240
197
|
'400 Request is malformed or invalid',
|
241
198
|
_response
|
242
199
|
)
|
243
200
|
elsif _response.status_code == 401
|
244
|
-
raise
|
201
|
+
raise MessagingException.new(
|
245
202
|
'401 The specified user does not have access to the account',
|
246
203
|
_response
|
247
204
|
)
|
248
205
|
elsif _response.status_code == 403
|
249
|
-
raise
|
206
|
+
raise MessagingException.new(
|
250
207
|
'403 The user does not have access to this API',
|
251
208
|
_response
|
252
209
|
)
|
253
210
|
elsif _response.status_code == 404
|
254
|
-
raise
|
211
|
+
raise MessagingException.new(
|
255
212
|
'404 Path not found',
|
256
213
|
_response
|
257
214
|
)
|
258
215
|
elsif _response.status_code == 415
|
259
|
-
raise
|
216
|
+
raise MessagingException.new(
|
260
217
|
'415 The content-type of the request is incorrect',
|
261
218
|
_response
|
262
219
|
)
|
263
220
|
elsif _response.status_code == 429
|
264
|
-
raise
|
221
|
+
raise MessagingException.new(
|
265
222
|
'429 The rate limit has been reached',
|
266
223
|
_response
|
267
224
|
)
|
@@ -297,32 +254,32 @@ module Messaging
|
|
297
254
|
|
298
255
|
# Validate response against endpoint and global error codes.
|
299
256
|
if _response.status_code == 400
|
300
|
-
raise
|
257
|
+
raise MessagingException.new(
|
301
258
|
'400 Request is malformed or invalid',
|
302
259
|
_response
|
303
260
|
)
|
304
261
|
elsif _response.status_code == 401
|
305
|
-
raise
|
262
|
+
raise MessagingException.new(
|
306
263
|
'401 The specified user does not have access to the account',
|
307
264
|
_response
|
308
265
|
)
|
309
266
|
elsif _response.status_code == 403
|
310
|
-
raise
|
267
|
+
raise MessagingException.new(
|
311
268
|
'403 The user does not have access to this API',
|
312
269
|
_response
|
313
270
|
)
|
314
271
|
elsif _response.status_code == 404
|
315
|
-
raise
|
272
|
+
raise MessagingException.new(
|
316
273
|
'404 Path not found',
|
317
274
|
_response
|
318
275
|
)
|
319
276
|
elsif _response.status_code == 415
|
320
|
-
raise
|
277
|
+
raise MessagingException.new(
|
321
278
|
'415 The content-type of the request is incorrect',
|
322
279
|
_response
|
323
280
|
)
|
324
281
|
elsif _response.status_code == 429
|
325
|
-
raise
|
282
|
+
raise MessagingException.new(
|
326
283
|
'429 The rate limit has been reached',
|
327
284
|
_response
|
328
285
|
)
|
@@ -365,32 +322,32 @@ module Messaging
|
|
365
322
|
|
366
323
|
# Validate response against endpoint and global error codes.
|
367
324
|
if _response.status_code == 400
|
368
|
-
raise
|
325
|
+
raise MessagingException.new(
|
369
326
|
'400 Request is malformed or invalid',
|
370
327
|
_response
|
371
328
|
)
|
372
329
|
elsif _response.status_code == 401
|
373
|
-
raise
|
330
|
+
raise MessagingException.new(
|
374
331
|
'401 The specified user does not have access to the account',
|
375
332
|
_response
|
376
333
|
)
|
377
334
|
elsif _response.status_code == 403
|
378
|
-
raise
|
335
|
+
raise MessagingException.new(
|
379
336
|
'403 The user does not have access to this API',
|
380
337
|
_response
|
381
338
|
)
|
382
339
|
elsif _response.status_code == 404
|
383
|
-
raise
|
340
|
+
raise MessagingException.new(
|
384
341
|
'404 Path not found',
|
385
342
|
_response
|
386
343
|
)
|
387
344
|
elsif _response.status_code == 415
|
388
|
-
raise
|
345
|
+
raise MessagingException.new(
|
389
346
|
'415 The content-type of the request is incorrect',
|
390
347
|
_response
|
391
348
|
)
|
392
349
|
elsif _response.status_code == 429
|
393
|
-
raise
|
350
|
+
raise MessagingException.new(
|
394
351
|
'429 The rate limit has been reached',
|
395
352
|
_response
|
396
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,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,49 @@
|
|
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',
|
26
|
+
web_rtc_basic_auth_user_name: 'TODO: Replace',
|
27
|
+
web_rtc_basic_auth_password: 'TODO: Replace',
|
28
|
+
config: nil)
|
29
|
+
@config = if config.nil?
|
30
|
+
Configuration.new(timeout: timeout,
|
31
|
+
max_retries: max_retries,
|
32
|
+
retry_interval: retry_interval,
|
33
|
+
backoff_factor: backoff_factor,
|
34
|
+
environment: environment,
|
35
|
+
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
36
|
+
messaging_basic_auth_password: messaging_basic_auth_password,
|
37
|
+
two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
|
38
|
+
two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
|
39
|
+
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
40
|
+
voice_basic_auth_password: voice_basic_auth_password,
|
41
|
+
web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
|
42
|
+
web_rtc_basic_auth_password: web_rtc_basic_auth_password)
|
43
|
+
else
|
44
|
+
config
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
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
|