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.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -0
  3. data/lib/bandwidth/api_helper.rb +20 -17
  4. data/lib/bandwidth/configuration.rb +7 -19
  5. data/lib/bandwidth/http/faraday_client.rb +1 -1
  6. data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +53 -42
  7. data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +3 -5
  8. data/lib/bandwidth/messaging_lib/messaging/exceptions/messaging_exception.rb +5 -2
  9. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_callback_message.rb +31 -11
  10. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +54 -25
  11. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +65 -32
  12. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb +23 -4
  13. data/lib/bandwidth/messaging_lib/messaging/models/deferred_result.rb +20 -4
  14. data/lib/bandwidth/messaging_lib/messaging/models/media.rb +23 -6
  15. data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +32 -14
  16. data/lib/bandwidth/messaging_lib/messaging/models/page_info.rb +28 -8
  17. data/lib/bandwidth/messaging_lib/messaging/models/tag.rb +20 -4
  18. data/lib/bandwidth/models/base_model.rb +11 -0
  19. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/base_controller.rb +3 -5
  20. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/mfa_controller.rb +21 -16
  21. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb +5 -2
  22. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/forbidden_request_exception.rb +4 -1
  23. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/unauthorized_request_exception.rb +4 -1
  24. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_code_request_schema.rb +27 -12
  25. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_messaging_response.rb +17 -2
  26. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_code_response.rb +17 -2
  27. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_request_schema.rb +29 -10
  28. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_voice_response.rb +17 -2
  29. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb +212 -210
  30. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb +3 -5
  31. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb +4 -1
  32. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb +17 -2
  33. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb +20 -4
  34. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb +28 -7
  35. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb +43 -18
  36. data/lib/bandwidth/utilities/date_time_helper.rb +2 -2
  37. data/lib/bandwidth/utilities/file_wrapper.rb +1 -2
  38. data/lib/bandwidth/voice_lib/bxml/verbs/ring.rb +2 -1
  39. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +173 -161
  40. data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +3 -5
  41. data/lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb +6 -3
  42. data/lib/bandwidth/voice_lib/voice/models/call_callback.rb +343 -0
  43. data/lib/bandwidth/voice_lib/voice/models/call_recording_metadata.rb +78 -37
  44. data/lib/bandwidth/voice_lib/voice/models/call_state.rb +94 -42
  45. data/lib/bandwidth/voice_lib/voice/models/conference_callback.rb +211 -0
  46. data/lib/bandwidth/voice_lib/voice/models/conference_member_state.rb +35 -12
  47. data/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata.rb +55 -24
  48. data/lib/bandwidth/voice_lib/voice/models/conference_state.rb +54 -17
  49. data/lib/bandwidth/voice_lib/voice/models/create_call_request.rb +173 -96
  50. data/lib/bandwidth/voice_lib/voice/models/create_call_response.rb +85 -41
  51. data/lib/bandwidth/voice_lib/voice/models/diversion.rb +80 -0
  52. data/lib/bandwidth/voice_lib/voice/models/fallback_method_enum.rb +17 -0
  53. data/lib/bandwidth/voice_lib/voice/models/machine_detection_configuration.rb +218 -0
  54. data/lib/bandwidth/voice_lib/voice/models/mode_enum.rb +20 -0
  55. data/lib/bandwidth/voice_lib/voice/models/modify_call_recording_request.rb +15 -2
  56. data/lib/bandwidth/voice_lib/voice/models/modify_call_request.rb +59 -19
  57. data/lib/bandwidth/voice_lib/voice/models/modify_conference_request.rb +55 -18
  58. data/lib/bandwidth/voice_lib/voice/models/transcribe_recording_request.rb +40 -12
  59. data/lib/bandwidth/voice_lib/voice/models/transcript.rb +20 -4
  60. data/lib/bandwidth/voice_lib/voice/models/transcription.rb +80 -0
  61. data/lib/bandwidth/voice_lib/voice/models/transcription_metadata.rb +26 -8
  62. data/lib/bandwidth/voice_lib/voice/models/transcription_response.rb +18 -1
  63. data/lib/bandwidth/voice_lib/voice.rb +7 -1
  64. data/lib/bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb +5 -4
  65. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +61 -50
  66. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +3 -5
  67. data/lib/bandwidth/web_rtc_lib/web_rtc/exceptions/error_exception.rb +5 -2
  68. data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +20 -5
  69. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +37 -14
  70. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +15 -2
  71. data/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +20 -4
  72. data/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +20 -3
  73. data/lib/bandwidth.rb +19 -18
  74. data/test/integration/test_integration.rb +110 -62
  75. 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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
58
+ when 403
58
59
  raise ApiErrorException.new(
59
60
  'User unauthorized to perform this action.',
60
61
  _response
61
62
  )
62
- elsif _response.status_code == 404
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
138
+ when 403
137
139
  raise ApiErrorException.new(
138
140
  'User unauthorized to perform this action.',
139
141
  _response
140
142
  )
141
- elsif _response.status_code == 404
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
221
+ when 403
219
222
  raise ApiErrorException.new(
220
223
  'User unauthorized to perform this action.',
221
224
  _response
222
225
  )
223
- elsif _response.status_code == 404
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
301
+ when 403
298
302
  raise ApiErrorException.new(
299
303
  'User unauthorized to perform this action.',
300
304
  _response
301
305
  )
302
- elsif _response.status_code == 404
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
379
+ when 403
375
380
  raise ApiErrorException.new(
376
381
  'User unauthorized to perform this action.',
377
382
  _response
378
383
  )
379
- elsif _response.status_code == 404
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
463
+ when 403
458
464
  raise ApiErrorException.new(
459
465
  'User unauthorized to perform this action.',
460
466
  _response
461
467
  )
462
- elsif _response.status_code == 404
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
540
+ when 403
534
541
  raise ApiErrorException.new(
535
542
  'User unauthorized to perform this action.',
536
543
  _response
537
544
  )
538
- elsif _response.status_code == 404
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
614
+ when 403
613
615
  raise ApiErrorException.new(
614
616
  'User unauthorized to perform this action.',
615
617
  _response
616
618
  )
617
- elsif _response.status_code == 404
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
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: decoded
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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
690
+ when 403
691
691
  raise ApiErrorException.new(
692
692
  'User unauthorized to perform this action.',
693
693
  _response
694
694
  )
695
- elsif _response.status_code == 404
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
770
+ when 403
770
771
  raise ApiErrorException.new(
771
772
  'User unauthorized to perform this action.',
772
773
  _response
773
774
  )
774
- elsif _response.status_code == 404
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
856
+ when 403
855
857
  raise ApiErrorException.new(
856
858
  'User unauthorized to perform this action.',
857
859
  _response
858
860
  )
859
- elsif _response.status_code == 404
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
- elsif _response.status_code == 410
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
936
+ when 403
934
937
  raise ApiErrorException.new(
935
938
  'User unauthorized to perform this action.',
936
939
  _response
937
940
  )
938
- elsif _response.status_code == 404
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
1028
+ when 403
1025
1029
  raise ApiErrorException.new(
1026
1030
  'User unauthorized to perform this action.',
1027
1031
  _response
1028
1032
  )
1029
- elsif _response.status_code == 404
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
1109
+ when 403
1105
1110
  raise ApiErrorException.new(
1106
1111
  'User unauthorized to perform this action.',
1107
1112
  _response
1108
1113
  )
1109
- elsif _response.status_code == 404
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
1192
+ when 403
1187
1193
  raise ApiErrorException.new(
1188
1194
  'User unauthorized to perform this action.',
1189
1195
  _response
1190
1196
  )
1191
- elsif _response.status_code == 404
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
1275
+ when 403
1269
1276
  raise ApiErrorException.new(
1270
1277
  'User unauthorized to perform this action.',
1271
1278
  _response
1272
1279
  )
1273
- elsif _response.status_code == 404
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
1355
+ when 403
1348
1356
  raise ApiErrorException.new(
1349
1357
  'User unauthorized to perform this action.',
1350
1358
  _response
1351
1359
  )
1352
- elsif _response.status_code == 404
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
1436
+ when 403
1428
1437
  raise ApiErrorException.new(
1429
1438
  'User unauthorized to perform this action.',
1430
1439
  _response
1431
1440
  )
1432
- elsif _response.status_code == 404
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
1520
+ when 403
1511
1521
  raise ApiErrorException.new(
1512
1522
  'User unauthorized to perform this action.',
1513
1523
  _response
1514
1524
  )
1515
- elsif _response.status_code == 404
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
1603
+ when 403
1593
1604
  raise ApiErrorException.new(
1594
1605
  'User unauthorized to perform this action.',
1595
1606
  _response
1596
1607
  )
1597
- elsif _response.status_code == 404
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
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
- if _response.status_code == 400
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
- elsif _response.status_code == 401
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
- elsif _response.status_code == 403
1700
+ when 403
1689
1701
  raise ApiErrorException.new(
1690
1702
  'User unauthorized to perform this action.',
1691
1703
  _response
1692
1704
  )
1693
- elsif _response.status_code == 404
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
- elsif _response.status_code == 415
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
- elsif _response.status_code == 429
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
- elsif _response.status_code == 500
1722
+ when 500
1711
1723
  raise ApiErrorException.new(
1712
1724
  'Something unexpected happened. Please try again.',
1713
1725
  _response