bandwidth-sdk 7.1.0 → 9.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/lib/bandwidth/api_helper.rb +20 -17
- data/lib/bandwidth/configuration.rb +7 -19
- data/lib/bandwidth/http/faraday_client.rb +1 -1
- data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +53 -42
- data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +3 -5
- data/lib/bandwidth/messaging_lib/messaging/exceptions/messaging_exception.rb +5 -2
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_callback_message.rb +31 -11
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +54 -25
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +65 -32
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb +23 -4
- data/lib/bandwidth/messaging_lib/messaging/models/deferred_result.rb +20 -4
- data/lib/bandwidth/messaging_lib/messaging/models/media.rb +23 -6
- data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +32 -14
- data/lib/bandwidth/messaging_lib/messaging/models/page_info.rb +28 -8
- data/lib/bandwidth/messaging_lib/messaging/models/tag.rb +20 -4
- data/lib/bandwidth/models/base_model.rb +11 -0
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/base_controller.rb +3 -5
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/mfa_controller.rb +21 -16
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb +5 -2
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/forbidden_request_exception.rb +4 -1
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/unauthorized_request_exception.rb +4 -1
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_code_request_schema.rb +27 -12
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_messaging_response.rb +17 -2
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_code_response.rb +17 -2
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_request_schema.rb +29 -10
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_voice_response.rb +17 -2
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb +212 -210
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb +3 -5
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb +4 -1
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb +17 -2
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb +20 -4
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb +28 -7
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb +43 -18
- data/lib/bandwidth/utilities/date_time_helper.rb +2 -2
- data/lib/bandwidth/utilities/file_wrapper.rb +1 -2
- data/lib/bandwidth/voice_lib/bxml/verbs/ring.rb +2 -1
- data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +173 -161
- data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +3 -5
- data/lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb +6 -3
- data/lib/bandwidth/voice_lib/voice/models/call_callback.rb +343 -0
- data/lib/bandwidth/voice_lib/voice/models/call_recording_metadata.rb +78 -37
- data/lib/bandwidth/voice_lib/voice/models/call_state.rb +94 -42
- data/lib/bandwidth/voice_lib/voice/models/conference_callback.rb +211 -0
- data/lib/bandwidth/voice_lib/voice/models/conference_member_state.rb +35 -12
- data/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata.rb +55 -24
- data/lib/bandwidth/voice_lib/voice/models/conference_state.rb +54 -17
- data/lib/bandwidth/voice_lib/voice/models/create_call_request.rb +173 -96
- data/lib/bandwidth/voice_lib/voice/models/create_call_response.rb +85 -41
- data/lib/bandwidth/voice_lib/voice/models/diversion.rb +80 -0
- data/lib/bandwidth/voice_lib/voice/models/fallback_method_enum.rb +17 -0
- data/lib/bandwidth/voice_lib/voice/models/machine_detection_configuration.rb +218 -0
- data/lib/bandwidth/voice_lib/voice/models/mode_enum.rb +20 -0
- data/lib/bandwidth/voice_lib/voice/models/modify_call_recording_request.rb +15 -2
- data/lib/bandwidth/voice_lib/voice/models/modify_call_request.rb +59 -19
- data/lib/bandwidth/voice_lib/voice/models/modify_conference_request.rb +55 -18
- data/lib/bandwidth/voice_lib/voice/models/transcribe_recording_request.rb +40 -12
- data/lib/bandwidth/voice_lib/voice/models/transcript.rb +20 -4
- data/lib/bandwidth/voice_lib/voice/models/transcription.rb +80 -0
- data/lib/bandwidth/voice_lib/voice/models/transcription_metadata.rb +26 -8
- data/lib/bandwidth/voice_lib/voice/models/transcription_response.rb +18 -1
- data/lib/bandwidth/voice_lib/voice.rb +7 -1
- data/lib/bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb +5 -4
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +61 -50
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +3 -5
- data/lib/bandwidth/web_rtc_lib/web_rtc/exceptions/error_exception.rb +5 -2
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +20 -5
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +37 -14
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +15 -2
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +20 -4
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +20 -3
- data/lib/bandwidth.rb +19 -18
- data/test/integration/test_integration.rb +110 -62
- metadata +13 -6
@@ -11,7 +11,7 @@ module Voice
|
|
11
11
|
super(config, http_call_back: http_call_back)
|
12
12
|
end
|
13
13
|
|
14
|
-
# Creates an outbound call.
|
14
|
+
# Creates an outbound phone call.
|
15
15
|
# @param [String] account_id Required parameter: Example:
|
16
16
|
# @param [CreateCallRequest] body Required parameter: Example:
|
17
17
|
# @return [CreateCallResponse] response from the API call
|
@@ -42,41 +42,42 @@ module Voice
|
|
42
42
|
_response = execute_request(_request)
|
43
43
|
|
44
44
|
# Validate response against endpoint and global error codes.
|
45
|
-
|
45
|
+
case _response.status_code
|
46
|
+
when 400
|
46
47
|
raise ApiErrorException.new(
|
47
48
|
'Something\'s not quite right... Your request is invalid. Please' \
|
48
49
|
' fix it before trying again.',
|
49
50
|
_response
|
50
51
|
)
|
51
|
-
|
52
|
+
when 401
|
52
53
|
raise APIException.new(
|
53
54
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
54
55
|
' credentials to authenticate to the API.',
|
55
56
|
_response
|
56
57
|
)
|
57
|
-
|
58
|
+
when 403
|
58
59
|
raise ApiErrorException.new(
|
59
60
|
'User unauthorized to perform this action.',
|
60
61
|
_response
|
61
62
|
)
|
62
|
-
|
63
|
+
when 404
|
63
64
|
raise ApiErrorException.new(
|
64
65
|
'The resource specified cannot be found or does not belong to you.',
|
65
66
|
_response
|
66
67
|
)
|
67
|
-
|
68
|
+
when 415
|
68
69
|
raise ApiErrorException.new(
|
69
70
|
'We don\'t support that media type. If a request body is required,' \
|
70
71
|
' please send it to us as `application/json`.',
|
71
72
|
_response
|
72
73
|
)
|
73
|
-
|
74
|
+
when 429
|
74
75
|
raise ApiErrorException.new(
|
75
76
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
76
77
|
' slow your request rate down and try again.',
|
77
78
|
_response
|
78
79
|
)
|
79
|
-
|
80
|
+
when 500
|
80
81
|
raise ApiErrorException.new(
|
81
82
|
'Something unexpected happened. Please try again.',
|
82
83
|
_response
|
@@ -121,41 +122,42 @@ module Voice
|
|
121
122
|
_response = execute_request(_request)
|
122
123
|
|
123
124
|
# Validate response against endpoint and global error codes.
|
124
|
-
|
125
|
+
case _response.status_code
|
126
|
+
when 400
|
125
127
|
raise ApiErrorException.new(
|
126
128
|
'Something\'s not quite right... Your request is invalid. Please' \
|
127
129
|
' fix it before trying again.',
|
128
130
|
_response
|
129
131
|
)
|
130
|
-
|
132
|
+
when 401
|
131
133
|
raise APIException.new(
|
132
134
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
133
135
|
' credentials to authenticate to the API.',
|
134
136
|
_response
|
135
137
|
)
|
136
|
-
|
138
|
+
when 403
|
137
139
|
raise ApiErrorException.new(
|
138
140
|
'User unauthorized to perform this action.',
|
139
141
|
_response
|
140
142
|
)
|
141
|
-
|
143
|
+
when 404
|
142
144
|
raise ApiErrorException.new(
|
143
145
|
'The resource specified cannot be found or does not belong to you.',
|
144
146
|
_response
|
145
147
|
)
|
146
|
-
|
148
|
+
when 415
|
147
149
|
raise ApiErrorException.new(
|
148
150
|
'We don\'t support that media type. If a request body is required,' \
|
149
151
|
' please send it to us as `application/json`.',
|
150
152
|
_response
|
151
153
|
)
|
152
|
-
|
154
|
+
when 429
|
153
155
|
raise ApiErrorException.new(
|
154
156
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
155
157
|
' slow your request rate down and try again.',
|
156
158
|
_response
|
157
159
|
)
|
158
|
-
|
160
|
+
when 500
|
159
161
|
raise ApiErrorException.new(
|
160
162
|
'Something unexpected happened. Please try again.',
|
161
163
|
_response
|
@@ -203,41 +205,42 @@ module Voice
|
|
203
205
|
_response = execute_request(_request)
|
204
206
|
|
205
207
|
# Validate response against endpoint and global error codes.
|
206
|
-
|
208
|
+
case _response.status_code
|
209
|
+
when 400
|
207
210
|
raise ApiErrorException.new(
|
208
211
|
'Something\'s not quite right... Your request is invalid. Please' \
|
209
212
|
' fix it before trying again.',
|
210
213
|
_response
|
211
214
|
)
|
212
|
-
|
215
|
+
when 401
|
213
216
|
raise APIException.new(
|
214
217
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
215
218
|
' credentials to authenticate to the API.',
|
216
219
|
_response
|
217
220
|
)
|
218
|
-
|
221
|
+
when 403
|
219
222
|
raise ApiErrorException.new(
|
220
223
|
'User unauthorized to perform this action.',
|
221
224
|
_response
|
222
225
|
)
|
223
|
-
|
226
|
+
when 404
|
224
227
|
raise ApiErrorException.new(
|
225
228
|
'The resource specified cannot be found or does not belong to you.',
|
226
229
|
_response
|
227
230
|
)
|
228
|
-
|
231
|
+
when 415
|
229
232
|
raise ApiErrorException.new(
|
230
233
|
'We don\'t support that media type. If a request body is required,' \
|
231
234
|
' please send it to us as `application/json`.',
|
232
235
|
_response
|
233
236
|
)
|
234
|
-
|
237
|
+
when 429
|
235
238
|
raise ApiErrorException.new(
|
236
239
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
237
240
|
' slow your request rate down and try again.',
|
238
241
|
_response
|
239
242
|
)
|
240
|
-
|
243
|
+
when 500
|
241
244
|
raise ApiErrorException.new(
|
242
245
|
'Something unexpected happened. Please try again.',
|
243
246
|
_response
|
@@ -282,41 +285,42 @@ module Voice
|
|
282
285
|
_response = execute_request(_request)
|
283
286
|
|
284
287
|
# Validate response against endpoint and global error codes.
|
285
|
-
|
288
|
+
case _response.status_code
|
289
|
+
when 400
|
286
290
|
raise ApiErrorException.new(
|
287
291
|
'Something\'s not quite right... Your request is invalid. Please' \
|
288
292
|
' fix it before trying again.',
|
289
293
|
_response
|
290
294
|
)
|
291
|
-
|
295
|
+
when 401
|
292
296
|
raise APIException.new(
|
293
297
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
294
298
|
' credentials to authenticate to the API.',
|
295
299
|
_response
|
296
300
|
)
|
297
|
-
|
301
|
+
when 403
|
298
302
|
raise ApiErrorException.new(
|
299
303
|
'User unauthorized to perform this action.',
|
300
304
|
_response
|
301
305
|
)
|
302
|
-
|
306
|
+
when 404
|
303
307
|
raise ApiErrorException.new(
|
304
308
|
'The resource specified cannot be found or does not belong to you.',
|
305
309
|
_response
|
306
310
|
)
|
307
|
-
|
311
|
+
when 415
|
308
312
|
raise ApiErrorException.new(
|
309
313
|
'We don\'t support that media type. If a request body is required,' \
|
310
314
|
' please send it to us as `application/json`.',
|
311
315
|
_response
|
312
316
|
)
|
313
|
-
|
317
|
+
when 429
|
314
318
|
raise ApiErrorException.new(
|
315
319
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
316
320
|
' slow your request rate down and try again.',
|
317
321
|
_response
|
318
322
|
)
|
319
|
-
|
323
|
+
when 500
|
320
324
|
raise ApiErrorException.new(
|
321
325
|
'Something unexpected happened. Please try again.',
|
322
326
|
_response
|
@@ -329,7 +333,7 @@ module Voice
|
|
329
333
|
end
|
330
334
|
|
331
335
|
# Returns a (potentially empty) list of metadata for the recordings that
|
332
|
-
# took place during the specified call
|
336
|
+
# took place during the specified call.
|
333
337
|
# @param [String] account_id Required parameter: Example:
|
334
338
|
# @param [String] call_id Required parameter: Example:
|
335
339
|
# @return [List of CallRecordingMetadata] response from the API call
|
@@ -359,41 +363,42 @@ module Voice
|
|
359
363
|
_response = execute_request(_request)
|
360
364
|
|
361
365
|
# Validate response against endpoint and global error codes.
|
362
|
-
|
366
|
+
case _response.status_code
|
367
|
+
when 400
|
363
368
|
raise ApiErrorException.new(
|
364
369
|
'Something\'s not quite right... Your request is invalid. Please' \
|
365
370
|
' fix it before trying again.',
|
366
371
|
_response
|
367
372
|
)
|
368
|
-
|
373
|
+
when 401
|
369
374
|
raise APIException.new(
|
370
375
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
371
376
|
' credentials to authenticate to the API.',
|
372
377
|
_response
|
373
378
|
)
|
374
|
-
|
379
|
+
when 403
|
375
380
|
raise ApiErrorException.new(
|
376
381
|
'User unauthorized to perform this action.',
|
377
382
|
_response
|
378
383
|
)
|
379
|
-
|
384
|
+
when 404
|
380
385
|
raise ApiErrorException.new(
|
381
386
|
'The resource specified cannot be found or does not belong to you.',
|
382
387
|
_response
|
383
388
|
)
|
384
|
-
|
389
|
+
when 415
|
385
390
|
raise ApiErrorException.new(
|
386
391
|
'We don\'t support that media type. If a request body is required,' \
|
387
392
|
' please send it to us as `application/json`.',
|
388
393
|
_response
|
389
394
|
)
|
390
|
-
|
395
|
+
when 429
|
391
396
|
raise ApiErrorException.new(
|
392
397
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
393
398
|
' slow your request rate down and try again.',
|
394
399
|
_response
|
395
400
|
)
|
396
|
-
|
401
|
+
when 500
|
397
402
|
raise ApiErrorException.new(
|
398
403
|
'Something unexpected happened. Please try again.',
|
399
404
|
_response
|
@@ -442,41 +447,42 @@ module Voice
|
|
442
447
|
_response = execute_request(_request)
|
443
448
|
|
444
449
|
# Validate response against endpoint and global error codes.
|
445
|
-
|
450
|
+
case _response.status_code
|
451
|
+
when 400
|
446
452
|
raise ApiErrorException.new(
|
447
453
|
'Something\'s not quite right... Your request is invalid. Please' \
|
448
454
|
' fix it before trying again.',
|
449
455
|
_response
|
450
456
|
)
|
451
|
-
|
457
|
+
when 401
|
452
458
|
raise APIException.new(
|
453
459
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
454
460
|
' credentials to authenticate to the API.',
|
455
461
|
_response
|
456
462
|
)
|
457
|
-
|
463
|
+
when 403
|
458
464
|
raise ApiErrorException.new(
|
459
465
|
'User unauthorized to perform this action.',
|
460
466
|
_response
|
461
467
|
)
|
462
|
-
|
468
|
+
when 404
|
463
469
|
raise ApiErrorException.new(
|
464
470
|
'The resource specified cannot be found or does not belong to you.',
|
465
471
|
_response
|
466
472
|
)
|
467
|
-
|
473
|
+
when 415
|
468
474
|
raise ApiErrorException.new(
|
469
475
|
'We don\'t support that media type. If a request body is required,' \
|
470
476
|
' please send it to us as `application/json`.',
|
471
477
|
_response
|
472
478
|
)
|
473
|
-
|
479
|
+
when 429
|
474
480
|
raise ApiErrorException.new(
|
475
481
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
476
482
|
' slow your request rate down and try again.',
|
477
483
|
_response
|
478
484
|
)
|
479
|
-
|
485
|
+
when 500
|
480
486
|
raise ApiErrorException.new(
|
481
487
|
'Something unexpected happened. Please try again.',
|
482
488
|
_response
|
@@ -518,41 +524,42 @@ module Voice
|
|
518
524
|
_response = execute_request(_request)
|
519
525
|
|
520
526
|
# Validate response against endpoint and global error codes.
|
521
|
-
|
527
|
+
case _response.status_code
|
528
|
+
when 400
|
522
529
|
raise ApiErrorException.new(
|
523
530
|
'Something\'s not quite right... Your request is invalid. Please' \
|
524
531
|
' fix it before trying again.',
|
525
532
|
_response
|
526
533
|
)
|
527
|
-
|
534
|
+
when 401
|
528
535
|
raise APIException.new(
|
529
536
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
530
537
|
' credentials to authenticate to the API.',
|
531
538
|
_response
|
532
539
|
)
|
533
|
-
|
540
|
+
when 403
|
534
541
|
raise ApiErrorException.new(
|
535
542
|
'User unauthorized to perform this action.',
|
536
543
|
_response
|
537
544
|
)
|
538
|
-
|
545
|
+
when 404
|
539
546
|
raise ApiErrorException.new(
|
540
547
|
'The resource specified cannot be found or does not belong to you.',
|
541
548
|
_response
|
542
549
|
)
|
543
|
-
|
550
|
+
when 415
|
544
551
|
raise ApiErrorException.new(
|
545
552
|
'We don\'t support that media type. If a request body is required,' \
|
546
553
|
' please send it to us as `application/json`.',
|
547
554
|
_response
|
548
555
|
)
|
549
|
-
|
556
|
+
when 429
|
550
557
|
raise ApiErrorException.new(
|
551
558
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
552
559
|
' slow your request rate down and try again.',
|
553
560
|
_response
|
554
561
|
)
|
555
|
-
|
562
|
+
when 500
|
556
563
|
raise ApiErrorException.new(
|
557
564
|
'Something unexpected happened. Please try again.',
|
558
565
|
_response
|
@@ -583,55 +590,50 @@ module Voice
|
|
583
590
|
)
|
584
591
|
_query_url = APIHelper.clean_url _query_builder
|
585
592
|
|
586
|
-
# Prepare headers.
|
587
|
-
_headers = {
|
588
|
-
'accept' => 'application/json'
|
589
|
-
}
|
590
|
-
|
591
593
|
# Prepare and execute HttpRequest.
|
592
594
|
_request = config.http_client.get(
|
593
|
-
_query_url
|
594
|
-
headers: _headers
|
595
|
+
_query_url
|
595
596
|
)
|
596
597
|
VoiceBasicAuth.apply(config, _request)
|
597
598
|
_response = execute_request(_request)
|
598
599
|
|
599
600
|
# Validate response against endpoint and global error codes.
|
600
|
-
|
601
|
+
case _response.status_code
|
602
|
+
when 400
|
601
603
|
raise ApiErrorException.new(
|
602
604
|
'Something\'s not quite right... Your request is invalid. Please' \
|
603
605
|
' fix it before trying again.',
|
604
606
|
_response
|
605
607
|
)
|
606
|
-
|
608
|
+
when 401
|
607
609
|
raise APIException.new(
|
608
610
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
609
611
|
' credentials to authenticate to the API.',
|
610
612
|
_response
|
611
613
|
)
|
612
|
-
|
614
|
+
when 403
|
613
615
|
raise ApiErrorException.new(
|
614
616
|
'User unauthorized to perform this action.',
|
615
617
|
_response
|
616
618
|
)
|
617
|
-
|
619
|
+
when 404
|
618
620
|
raise ApiErrorException.new(
|
619
621
|
'The resource specified cannot be found or does not belong to you.',
|
620
622
|
_response
|
621
623
|
)
|
622
|
-
|
624
|
+
when 415
|
623
625
|
raise ApiErrorException.new(
|
624
626
|
'We don\'t support that media type. If a request body is required,' \
|
625
627
|
' please send it to us as `application/json`.',
|
626
628
|
_response
|
627
629
|
)
|
628
|
-
|
630
|
+
when 429
|
629
631
|
raise ApiErrorException.new(
|
630
632
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
631
633
|
' slow your request rate down and try again.',
|
632
634
|
_response
|
633
635
|
)
|
634
|
-
|
636
|
+
when 500
|
635
637
|
raise ApiErrorException.new(
|
636
638
|
'Something unexpected happened. Please try again.',
|
637
639
|
_response
|
@@ -640,11 +642,8 @@ module Voice
|
|
640
642
|
validate_response(_response)
|
641
643
|
|
642
644
|
# Return appropriate response type.
|
643
|
-
decoded = APIHelper.json_deserialize(_response.raw_body) unless
|
644
|
-
_response.raw_body.nil? ||
|
645
|
-
_response.raw_body.to_s.strip.empty?
|
646
645
|
ApiResponse.new(
|
647
|
-
_response, data:
|
646
|
+
_response, data: _response.raw_body
|
648
647
|
)
|
649
648
|
end
|
650
649
|
|
@@ -675,41 +674,42 @@ module Voice
|
|
675
674
|
_response = execute_request(_request)
|
676
675
|
|
677
676
|
# Validate response against endpoint and global error codes.
|
678
|
-
|
677
|
+
case _response.status_code
|
678
|
+
when 400
|
679
679
|
raise ApiErrorException.new(
|
680
680
|
'Something\'s not quite right... Your request is invalid. Please' \
|
681
681
|
' fix it before trying again.',
|
682
682
|
_response
|
683
683
|
)
|
684
|
-
|
684
|
+
when 401
|
685
685
|
raise APIException.new(
|
686
686
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
687
687
|
' credentials to authenticate to the API.',
|
688
688
|
_response
|
689
689
|
)
|
690
|
-
|
690
|
+
when 403
|
691
691
|
raise ApiErrorException.new(
|
692
692
|
'User unauthorized to perform this action.',
|
693
693
|
_response
|
694
694
|
)
|
695
|
-
|
695
|
+
when 404
|
696
696
|
raise ApiErrorException.new(
|
697
697
|
'The resource specified cannot be found or does not belong to you.',
|
698
698
|
_response
|
699
699
|
)
|
700
|
-
|
700
|
+
when 415
|
701
701
|
raise ApiErrorException.new(
|
702
702
|
'We don\'t support that media type. If a request body is required,' \
|
703
703
|
' please send it to us as `application/json`.',
|
704
704
|
_response
|
705
705
|
)
|
706
|
-
|
706
|
+
when 429
|
707
707
|
raise ApiErrorException.new(
|
708
708
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
709
709
|
' slow your request rate down and try again.',
|
710
710
|
_response
|
711
711
|
)
|
712
|
-
|
712
|
+
when 500
|
713
713
|
raise ApiErrorException.new(
|
714
714
|
'Something unexpected happened. Please try again.',
|
715
715
|
_response
|
@@ -754,41 +754,42 @@ module Voice
|
|
754
754
|
_response = execute_request(_request)
|
755
755
|
|
756
756
|
# Validate response against endpoint and global error codes.
|
757
|
-
|
757
|
+
case _response.status_code
|
758
|
+
when 400
|
758
759
|
raise ApiErrorException.new(
|
759
760
|
'Something\'s not quite right... Your request is invalid. Please' \
|
760
761
|
' fix it before trying again.',
|
761
762
|
_response
|
762
763
|
)
|
763
|
-
|
764
|
+
when 401
|
764
765
|
raise APIException.new(
|
765
766
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
766
767
|
' credentials to authenticate to the API.',
|
767
768
|
_response
|
768
769
|
)
|
769
|
-
|
770
|
+
when 403
|
770
771
|
raise ApiErrorException.new(
|
771
772
|
'User unauthorized to perform this action.',
|
772
773
|
_response
|
773
774
|
)
|
774
|
-
|
775
|
+
when 404
|
775
776
|
raise ApiErrorException.new(
|
776
777
|
'The resource specified cannot be found or does not belong to you.',
|
777
778
|
_response
|
778
779
|
)
|
779
|
-
|
780
|
+
when 415
|
780
781
|
raise ApiErrorException.new(
|
781
782
|
'We don\'t support that media type. If a request body is required,' \
|
782
783
|
' please send it to us as `application/json`.',
|
783
784
|
_response
|
784
785
|
)
|
785
|
-
|
786
|
+
when 429
|
786
787
|
raise ApiErrorException.new(
|
787
788
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
788
789
|
' slow your request rate down and try again.',
|
789
790
|
_response
|
790
791
|
)
|
791
|
-
|
792
|
+
when 500
|
792
793
|
raise ApiErrorException.new(
|
793
794
|
'Something unexpected happened. Please try again.',
|
794
795
|
_response
|
@@ -839,47 +840,48 @@ module Voice
|
|
839
840
|
_response = execute_request(_request)
|
840
841
|
|
841
842
|
# Validate response against endpoint and global error codes.
|
842
|
-
|
843
|
+
case _response.status_code
|
844
|
+
when 400
|
843
845
|
raise ApiErrorException.new(
|
844
846
|
'Something\'s not quite right... Your request is invalid. Please' \
|
845
847
|
' fix it before trying again.',
|
846
848
|
_response
|
847
849
|
)
|
848
|
-
|
850
|
+
when 401
|
849
851
|
raise APIException.new(
|
850
852
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
851
853
|
' credentials to authenticate to the API.',
|
852
854
|
_response
|
853
855
|
)
|
854
|
-
|
856
|
+
when 403
|
855
857
|
raise ApiErrorException.new(
|
856
858
|
'User unauthorized to perform this action.',
|
857
859
|
_response
|
858
860
|
)
|
859
|
-
|
861
|
+
when 404
|
860
862
|
raise ApiErrorException.new(
|
861
863
|
'The resource specified cannot be found or does not belong to you.',
|
862
864
|
_response
|
863
865
|
)
|
864
|
-
|
866
|
+
when 410
|
865
867
|
raise ApiErrorException.new(
|
866
868
|
'The media for this recording has been deleted, so we can\'t' \
|
867
869
|
' transcribe it',
|
868
870
|
_response
|
869
871
|
)
|
870
|
-
|
872
|
+
when 415
|
871
873
|
raise ApiErrorException.new(
|
872
874
|
'We don\'t support that media type. If a request body is required,' \
|
873
875
|
' please send it to us as `application/json`.',
|
874
876
|
_response
|
875
877
|
)
|
876
|
-
|
878
|
+
when 429
|
877
879
|
raise ApiErrorException.new(
|
878
880
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
879
881
|
' slow your request rate down and try again.',
|
880
882
|
_response
|
881
883
|
)
|
882
|
-
|
884
|
+
when 500
|
883
885
|
raise ApiErrorException.new(
|
884
886
|
'Something unexpected happened. Please try again.',
|
885
887
|
_response
|
@@ -918,41 +920,42 @@ module Voice
|
|
918
920
|
_response = execute_request(_request)
|
919
921
|
|
920
922
|
# Validate response against endpoint and global error codes.
|
921
|
-
|
923
|
+
case _response.status_code
|
924
|
+
when 400
|
922
925
|
raise ApiErrorException.new(
|
923
926
|
'Something\'s not quite right... Your request is invalid. Please' \
|
924
927
|
' fix it before trying again.',
|
925
928
|
_response
|
926
929
|
)
|
927
|
-
|
930
|
+
when 401
|
928
931
|
raise APIException.new(
|
929
932
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
930
933
|
' credentials to authenticate to the API.',
|
931
934
|
_response
|
932
935
|
)
|
933
|
-
|
936
|
+
when 403
|
934
937
|
raise ApiErrorException.new(
|
935
938
|
'User unauthorized to perform this action.',
|
936
939
|
_response
|
937
940
|
)
|
938
|
-
|
941
|
+
when 404
|
939
942
|
raise ApiErrorException.new(
|
940
943
|
'The resource specified cannot be found or does not belong to you.',
|
941
944
|
_response
|
942
945
|
)
|
943
|
-
|
946
|
+
when 415
|
944
947
|
raise ApiErrorException.new(
|
945
948
|
'We don\'t support that media type. If a request body is required,' \
|
946
949
|
' please send it to us as `application/json`.',
|
947
950
|
_response
|
948
951
|
)
|
949
|
-
|
952
|
+
when 429
|
950
953
|
raise ApiErrorException.new(
|
951
954
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
952
955
|
' slow your request rate down and try again.',
|
953
956
|
_response
|
954
957
|
)
|
955
|
-
|
958
|
+
when 500
|
956
959
|
raise ApiErrorException.new(
|
957
960
|
'Something unexpected happened. Please try again.',
|
958
961
|
_response
|
@@ -1009,41 +1012,42 @@ module Voice
|
|
1009
1012
|
_response = execute_request(_request)
|
1010
1013
|
|
1011
1014
|
# Validate response against endpoint and global error codes.
|
1012
|
-
|
1015
|
+
case _response.status_code
|
1016
|
+
when 400
|
1013
1017
|
raise ApiErrorException.new(
|
1014
1018
|
'Something\'s not quite right... Your request is invalid. Please' \
|
1015
1019
|
' fix it before trying again.',
|
1016
1020
|
_response
|
1017
1021
|
)
|
1018
|
-
|
1022
|
+
when 401
|
1019
1023
|
raise APIException.new(
|
1020
1024
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
1021
1025
|
' credentials to authenticate to the API.',
|
1022
1026
|
_response
|
1023
1027
|
)
|
1024
|
-
|
1028
|
+
when 403
|
1025
1029
|
raise ApiErrorException.new(
|
1026
1030
|
'User unauthorized to perform this action.',
|
1027
1031
|
_response
|
1028
1032
|
)
|
1029
|
-
|
1033
|
+
when 404
|
1030
1034
|
raise ApiErrorException.new(
|
1031
1035
|
'The resource specified cannot be found or does not belong to you.',
|
1032
1036
|
_response
|
1033
1037
|
)
|
1034
|
-
|
1038
|
+
when 415
|
1035
1039
|
raise ApiErrorException.new(
|
1036
1040
|
'We don\'t support that media type. If a request body is required,' \
|
1037
1041
|
' please send it to us as `application/json`.',
|
1038
1042
|
_response
|
1039
1043
|
)
|
1040
|
-
|
1044
|
+
when 429
|
1041
1045
|
raise ApiErrorException.new(
|
1042
1046
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
1043
1047
|
' slow your request rate down and try again.',
|
1044
1048
|
_response
|
1045
1049
|
)
|
1046
|
-
|
1050
|
+
when 500
|
1047
1051
|
raise ApiErrorException.new(
|
1048
1052
|
'Something unexpected happened. Please try again.',
|
1049
1053
|
_response
|
@@ -1089,41 +1093,42 @@ module Voice
|
|
1089
1093
|
_response = execute_request(_request)
|
1090
1094
|
|
1091
1095
|
# Validate response against endpoint and global error codes.
|
1092
|
-
|
1096
|
+
case _response.status_code
|
1097
|
+
when 400
|
1093
1098
|
raise ApiErrorException.new(
|
1094
1099
|
'Something\'s not quite right... Your request is invalid. Please' \
|
1095
1100
|
' fix it before trying again.',
|
1096
1101
|
_response
|
1097
1102
|
)
|
1098
|
-
|
1103
|
+
when 401
|
1099
1104
|
raise APIException.new(
|
1100
1105
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
1101
1106
|
' credentials to authenticate to the API.',
|
1102
1107
|
_response
|
1103
1108
|
)
|
1104
|
-
|
1109
|
+
when 403
|
1105
1110
|
raise ApiErrorException.new(
|
1106
1111
|
'User unauthorized to perform this action.',
|
1107
1112
|
_response
|
1108
1113
|
)
|
1109
|
-
|
1114
|
+
when 404
|
1110
1115
|
raise ApiErrorException.new(
|
1111
1116
|
'The resource specified cannot be found or does not belong to you.',
|
1112
1117
|
_response
|
1113
1118
|
)
|
1114
|
-
|
1119
|
+
when 415
|
1115
1120
|
raise ApiErrorException.new(
|
1116
1121
|
'We don\'t support that media type. If a request body is required,' \
|
1117
1122
|
' please send it to us as `application/json`.',
|
1118
1123
|
_response
|
1119
1124
|
)
|
1120
|
-
|
1125
|
+
when 429
|
1121
1126
|
raise ApiErrorException.new(
|
1122
1127
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
1123
1128
|
' slow your request rate down and try again.',
|
1124
1129
|
_response
|
1125
1130
|
)
|
1126
|
-
|
1131
|
+
when 500
|
1127
1132
|
raise ApiErrorException.new(
|
1128
1133
|
'Something unexpected happened. Please try again.',
|
1129
1134
|
_response
|
@@ -1171,41 +1176,42 @@ module Voice
|
|
1171
1176
|
_response = execute_request(_request)
|
1172
1177
|
|
1173
1178
|
# Validate response against endpoint and global error codes.
|
1174
|
-
|
1179
|
+
case _response.status_code
|
1180
|
+
when 400
|
1175
1181
|
raise ApiErrorException.new(
|
1176
1182
|
'Something\'s not quite right... Your request is invalid. Please' \
|
1177
1183
|
' fix it before trying again.',
|
1178
1184
|
_response
|
1179
1185
|
)
|
1180
|
-
|
1186
|
+
when 401
|
1181
1187
|
raise APIException.new(
|
1182
1188
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
1183
1189
|
' credentials to authenticate to the API.',
|
1184
1190
|
_response
|
1185
1191
|
)
|
1186
|
-
|
1192
|
+
when 403
|
1187
1193
|
raise ApiErrorException.new(
|
1188
1194
|
'User unauthorized to perform this action.',
|
1189
1195
|
_response
|
1190
1196
|
)
|
1191
|
-
|
1197
|
+
when 404
|
1192
1198
|
raise ApiErrorException.new(
|
1193
1199
|
'The resource specified cannot be found or does not belong to you.',
|
1194
1200
|
_response
|
1195
1201
|
)
|
1196
|
-
|
1202
|
+
when 415
|
1197
1203
|
raise ApiErrorException.new(
|
1198
1204
|
'We don\'t support that media type. If a request body is required,' \
|
1199
1205
|
' please send it to us as `application/json`.',
|
1200
1206
|
_response
|
1201
1207
|
)
|
1202
|
-
|
1208
|
+
when 429
|
1203
1209
|
raise ApiErrorException.new(
|
1204
1210
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
1205
1211
|
' slow your request rate down and try again.',
|
1206
1212
|
_response
|
1207
1213
|
)
|
1208
|
-
|
1214
|
+
when 500
|
1209
1215
|
raise ApiErrorException.new(
|
1210
1216
|
'Something unexpected happened. Please try again.',
|
1211
1217
|
_response
|
@@ -1253,41 +1259,42 @@ module Voice
|
|
1253
1259
|
_response = execute_request(_request)
|
1254
1260
|
|
1255
1261
|
# Validate response against endpoint and global error codes.
|
1256
|
-
|
1262
|
+
case _response.status_code
|
1263
|
+
when 400
|
1257
1264
|
raise ApiErrorException.new(
|
1258
1265
|
'Something\'s not quite right... Your request is invalid. Please' \
|
1259
1266
|
' fix it before trying again.',
|
1260
1267
|
_response
|
1261
1268
|
)
|
1262
|
-
|
1269
|
+
when 401
|
1263
1270
|
raise APIException.new(
|
1264
1271
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
1265
1272
|
' credentials to authenticate to the API.',
|
1266
1273
|
_response
|
1267
1274
|
)
|
1268
|
-
|
1275
|
+
when 403
|
1269
1276
|
raise ApiErrorException.new(
|
1270
1277
|
'User unauthorized to perform this action.',
|
1271
1278
|
_response
|
1272
1279
|
)
|
1273
|
-
|
1280
|
+
when 404
|
1274
1281
|
raise ApiErrorException.new(
|
1275
1282
|
'The resource specified cannot be found or does not belong to you.',
|
1276
1283
|
_response
|
1277
1284
|
)
|
1278
|
-
|
1285
|
+
when 415
|
1279
1286
|
raise ApiErrorException.new(
|
1280
1287
|
'We don\'t support that media type. If a request body is required,' \
|
1281
1288
|
' please send it to us as `application/json`.',
|
1282
1289
|
_response
|
1283
1290
|
)
|
1284
|
-
|
1291
|
+
when 429
|
1285
1292
|
raise ApiErrorException.new(
|
1286
1293
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
1287
1294
|
' slow your request rate down and try again.',
|
1288
1295
|
_response
|
1289
1296
|
)
|
1290
|
-
|
1297
|
+
when 500
|
1291
1298
|
raise ApiErrorException.new(
|
1292
1299
|
'Something unexpected happened. Please try again.',
|
1293
1300
|
_response
|
@@ -1332,41 +1339,42 @@ module Voice
|
|
1332
1339
|
_response = execute_request(_request)
|
1333
1340
|
|
1334
1341
|
# Validate response against endpoint and global error codes.
|
1335
|
-
|
1342
|
+
case _response.status_code
|
1343
|
+
when 400
|
1336
1344
|
raise ApiErrorException.new(
|
1337
1345
|
'Something\'s not quite right... Your request is invalid. Please' \
|
1338
1346
|
' fix it before trying again.',
|
1339
1347
|
_response
|
1340
1348
|
)
|
1341
|
-
|
1349
|
+
when 401
|
1342
1350
|
raise APIException.new(
|
1343
1351
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
1344
1352
|
' credentials to authenticate to the API.',
|
1345
1353
|
_response
|
1346
1354
|
)
|
1347
|
-
|
1355
|
+
when 403
|
1348
1356
|
raise ApiErrorException.new(
|
1349
1357
|
'User unauthorized to perform this action.',
|
1350
1358
|
_response
|
1351
1359
|
)
|
1352
|
-
|
1360
|
+
when 404
|
1353
1361
|
raise ApiErrorException.new(
|
1354
1362
|
'The resource specified cannot be found or does not belong to you.',
|
1355
1363
|
_response
|
1356
1364
|
)
|
1357
|
-
|
1365
|
+
when 415
|
1358
1366
|
raise ApiErrorException.new(
|
1359
1367
|
'We don\'t support that media type. If a request body is required,' \
|
1360
1368
|
' please send it to us as `application/json`.',
|
1361
1369
|
_response
|
1362
1370
|
)
|
1363
|
-
|
1371
|
+
when 429
|
1364
1372
|
raise ApiErrorException.new(
|
1365
1373
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
1366
1374
|
' slow your request rate down and try again.',
|
1367
1375
|
_response
|
1368
1376
|
)
|
1369
|
-
|
1377
|
+
when 500
|
1370
1378
|
raise ApiErrorException.new(
|
1371
1379
|
'Something unexpected happened. Please try again.',
|
1372
1380
|
_response
|
@@ -1412,41 +1420,42 @@ module Voice
|
|
1412
1420
|
_response = execute_request(_request)
|
1413
1421
|
|
1414
1422
|
# Validate response against endpoint and global error codes.
|
1415
|
-
|
1423
|
+
case _response.status_code
|
1424
|
+
when 400
|
1416
1425
|
raise ApiErrorException.new(
|
1417
1426
|
'Something\'s not quite right... Your request is invalid. Please' \
|
1418
1427
|
' fix it before trying again.',
|
1419
1428
|
_response
|
1420
1429
|
)
|
1421
|
-
|
1430
|
+
when 401
|
1422
1431
|
raise APIException.new(
|
1423
1432
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
1424
1433
|
' credentials to authenticate to the API.',
|
1425
1434
|
_response
|
1426
1435
|
)
|
1427
|
-
|
1436
|
+
when 403
|
1428
1437
|
raise ApiErrorException.new(
|
1429
1438
|
'User unauthorized to perform this action.',
|
1430
1439
|
_response
|
1431
1440
|
)
|
1432
|
-
|
1441
|
+
when 404
|
1433
1442
|
raise ApiErrorException.new(
|
1434
1443
|
'The resource specified cannot be found or does not belong to you.',
|
1435
1444
|
_response
|
1436
1445
|
)
|
1437
|
-
|
1446
|
+
when 415
|
1438
1447
|
raise ApiErrorException.new(
|
1439
1448
|
'We don\'t support that media type. If a request body is required,' \
|
1440
1449
|
' please send it to us as `application/json`.',
|
1441
1450
|
_response
|
1442
1451
|
)
|
1443
|
-
|
1452
|
+
when 429
|
1444
1453
|
raise ApiErrorException.new(
|
1445
1454
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
1446
1455
|
' slow your request rate down and try again.',
|
1447
1456
|
_response
|
1448
1457
|
)
|
1449
|
-
|
1458
|
+
when 500
|
1450
1459
|
raise ApiErrorException.new(
|
1451
1460
|
'Something unexpected happened. Please try again.',
|
1452
1461
|
_response
|
@@ -1495,41 +1504,42 @@ module Voice
|
|
1495
1504
|
_response = execute_request(_request)
|
1496
1505
|
|
1497
1506
|
# Validate response against endpoint and global error codes.
|
1498
|
-
|
1507
|
+
case _response.status_code
|
1508
|
+
when 400
|
1499
1509
|
raise ApiErrorException.new(
|
1500
1510
|
'Something\'s not quite right... Your request is invalid. Please' \
|
1501
1511
|
' fix it before trying again.',
|
1502
1512
|
_response
|
1503
1513
|
)
|
1504
|
-
|
1514
|
+
when 401
|
1505
1515
|
raise APIException.new(
|
1506
1516
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
1507
1517
|
' credentials to authenticate to the API.',
|
1508
1518
|
_response
|
1509
1519
|
)
|
1510
|
-
|
1520
|
+
when 403
|
1511
1521
|
raise ApiErrorException.new(
|
1512
1522
|
'User unauthorized to perform this action.',
|
1513
1523
|
_response
|
1514
1524
|
)
|
1515
|
-
|
1525
|
+
when 404
|
1516
1526
|
raise ApiErrorException.new(
|
1517
1527
|
'The resource specified cannot be found or does not belong to you.',
|
1518
1528
|
_response
|
1519
1529
|
)
|
1520
|
-
|
1530
|
+
when 415
|
1521
1531
|
raise ApiErrorException.new(
|
1522
1532
|
'We don\'t support that media type. If a request body is required,' \
|
1523
1533
|
' please send it to us as `application/json`.',
|
1524
1534
|
_response
|
1525
1535
|
)
|
1526
|
-
|
1536
|
+
when 429
|
1527
1537
|
raise ApiErrorException.new(
|
1528
1538
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
1529
1539
|
' slow your request rate down and try again.',
|
1530
1540
|
_response
|
1531
1541
|
)
|
1532
|
-
|
1542
|
+
when 500
|
1533
1543
|
raise ApiErrorException.new(
|
1534
1544
|
'Something unexpected happened. Please try again.',
|
1535
1545
|
_response
|
@@ -1577,41 +1587,42 @@ module Voice
|
|
1577
1587
|
_response = execute_request(_request)
|
1578
1588
|
|
1579
1589
|
# Validate response against endpoint and global error codes.
|
1580
|
-
|
1590
|
+
case _response.status_code
|
1591
|
+
when 400
|
1581
1592
|
raise ApiErrorException.new(
|
1582
1593
|
'Something\'s not quite right... Your request is invalid. Please' \
|
1583
1594
|
' fix it before trying again.',
|
1584
1595
|
_response
|
1585
1596
|
)
|
1586
|
-
|
1597
|
+
when 401
|
1587
1598
|
raise APIException.new(
|
1588
1599
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
1589
1600
|
' credentials to authenticate to the API.',
|
1590
1601
|
_response
|
1591
1602
|
)
|
1592
|
-
|
1603
|
+
when 403
|
1593
1604
|
raise ApiErrorException.new(
|
1594
1605
|
'User unauthorized to perform this action.',
|
1595
1606
|
_response
|
1596
1607
|
)
|
1597
|
-
|
1608
|
+
when 404
|
1598
1609
|
raise ApiErrorException.new(
|
1599
1610
|
'The resource specified cannot be found or does not belong to you.',
|
1600
1611
|
_response
|
1601
1612
|
)
|
1602
|
-
|
1613
|
+
when 415
|
1603
1614
|
raise ApiErrorException.new(
|
1604
1615
|
'We don\'t support that media type. If a request body is required,' \
|
1605
1616
|
' please send it to us as `application/json`.',
|
1606
1617
|
_response
|
1607
1618
|
)
|
1608
|
-
|
1619
|
+
when 429
|
1609
1620
|
raise ApiErrorException.new(
|
1610
1621
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
1611
1622
|
' slow your request rate down and try again.',
|
1612
1623
|
_response
|
1613
1624
|
)
|
1614
|
-
|
1625
|
+
when 500
|
1615
1626
|
raise ApiErrorException.new(
|
1616
1627
|
'Something unexpected happened. Please try again.',
|
1617
1628
|
_response
|
@@ -1673,41 +1684,42 @@ module Voice
|
|
1673
1684
|
_response = execute_request(_request)
|
1674
1685
|
|
1675
1686
|
# Validate response against endpoint and global error codes.
|
1676
|
-
|
1687
|
+
case _response.status_code
|
1688
|
+
when 400
|
1677
1689
|
raise ApiErrorException.new(
|
1678
1690
|
'Something\'s not quite right... Your request is invalid. Please' \
|
1679
1691
|
' fix it before trying again.',
|
1680
1692
|
_response
|
1681
1693
|
)
|
1682
|
-
|
1694
|
+
when 401
|
1683
1695
|
raise APIException.new(
|
1684
1696
|
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
1685
1697
|
' credentials to authenticate to the API.',
|
1686
1698
|
_response
|
1687
1699
|
)
|
1688
|
-
|
1700
|
+
when 403
|
1689
1701
|
raise ApiErrorException.new(
|
1690
1702
|
'User unauthorized to perform this action.',
|
1691
1703
|
_response
|
1692
1704
|
)
|
1693
|
-
|
1705
|
+
when 404
|
1694
1706
|
raise ApiErrorException.new(
|
1695
1707
|
'The resource specified cannot be found or does not belong to you.',
|
1696
1708
|
_response
|
1697
1709
|
)
|
1698
|
-
|
1710
|
+
when 415
|
1699
1711
|
raise ApiErrorException.new(
|
1700
1712
|
'We don\'t support that media type. If a request body is required,' \
|
1701
1713
|
' please send it to us as `application/json`.',
|
1702
1714
|
_response
|
1703
1715
|
)
|
1704
|
-
|
1716
|
+
when 429
|
1705
1717
|
raise ApiErrorException.new(
|
1706
1718
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
1707
1719
|
' slow your request rate down and try again.',
|
1708
1720
|
_response
|
1709
1721
|
)
|
1710
|
-
|
1722
|
+
when 500
|
1711
1723
|
raise ApiErrorException.new(
|
1712
1724
|
'Something unexpected happened. Please try again.',
|
1713
1725
|
_response
|