bandwidth-sdk 2.2.2 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bandwidth.rb +2 -1
  3. data/lib/bandwidth/client.rb +9 -0
  4. data/lib/bandwidth/configuration.rb +22 -4
  5. data/lib/bandwidth/http/auth/two_factor_auth_basic_auth.rb +22 -0
  6. data/lib/bandwidth/messaging_lib/messaging.rb +1 -3
  7. data/lib/bandwidth/messaging_lib/messaging/client.rb +4 -0
  8. data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +30 -83
  9. data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +1 -1
  10. data/lib/bandwidth/messaging_lib/messaging/exceptions/{generic_client_exception.rb → messaging_exception.rb} +2 -14
  11. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +19 -0
  12. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb +44 -0
  13. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/api_controller.rb +129 -0
  14. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb +49 -0
  15. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_code_request_schema.rb +62 -0
  16. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_messaging_response.rb +35 -0
  17. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_code_response.rb +35 -0
  18. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb +71 -0
  19. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_voice_response.rb +35 -0
  20. data/lib/bandwidth/voice_lib/bxml/verbs/conference.rb +28 -0
  21. data/lib/bandwidth/voice_lib/bxml/verbs/gather.rb +8 -0
  22. data/lib/bandwidth/voice_lib/bxml/verbs/record.rb +2 -1
  23. data/lib/bandwidth/voice_lib/bxml/verbs/send_dtmf.rb +4 -1
  24. data/lib/bandwidth/voice_lib/voice.rb +2 -0
  25. data/lib/bandwidth/voice_lib/voice/client.rb +4 -0
  26. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +145 -78
  27. data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
  28. data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +20 -2
  29. data/lib/bandwidth/voice_lib/voice/models/call_engine_modify_conference_request.rb +35 -0
  30. data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +4 -1
  31. data/lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb +1 -1
  32. data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +8 -14
  33. data/lib/bandwidth/voice_lib/voice/models/status2_enum.rb +32 -0
  34. data/lib/bandwidth/voice_lib/voice/models/status_enum.rb +4 -13
  35. data/lib/bandwidth/voice_lib/voice/models/transcription.rb +1 -1
  36. metadata +18 -7
  37. data/lib/bandwidth/messaging_lib/messaging/exceptions/path_client_exception.rb +0 -49
  38. data/lib/bandwidth/messaging_lib/messaging/models/field_error.rb +0 -44
@@ -0,0 +1,35 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Bandwidth
7
+ # TwoFactorVoiceResponse Model.
8
+ class TwoFactorVoiceResponse < BaseModel
9
+ # TODO: Write general description for this method
10
+ # @return [String]
11
+ attr_accessor :call_id
12
+
13
+ # A mapping from model property names to API property names.
14
+ def self.names
15
+ @_hash = {} if @_hash.nil?
16
+ @_hash['call_id'] = 'callId'
17
+ @_hash
18
+ end
19
+
20
+ def initialize(call_id = nil)
21
+ @call_id = call_id
22
+ end
23
+
24
+ # Creates an instance of the object from a hash.
25
+ def self.from_hash(hash)
26
+ return nil unless hash
27
+
28
+ # Extract variables from the hash.
29
+ call_id = hash['callId']
30
+
31
+ # Create object from extracted values.
32
+ TwoFactorVoiceResponse.new(call_id)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,28 @@
1
+ require_relative 'xml_verb'
2
+
3
+ module Bandwidth
4
+ module Voice
5
+ # The Conference verb is used to add callees to conferences
6
+ class Conference
7
+ include XmlVerb
8
+
9
+ def to_bxml(xml)
10
+ if not call_ids_to_coach.nil?
11
+ coach_ids = call_ids_to_coach.instance_of?(String) ? call_ids_to_coach : call_ids_to_coach.join(",")
12
+ else
13
+ coach_ids = nil
14
+ end
15
+ xml.Conference(conference_name, compact_hash({
16
+ 'mute' => mute,
17
+ 'hold' => hold,
18
+ 'callIdsToCoach' => coach_ids,
19
+ 'conferenceEventUrl' => conference_event_url,
20
+ 'conferenceEventMethod' => conference_event_method,
21
+ 'username' => username,
22
+ 'password' => password,
23
+ 'tag' => tag
24
+ }))
25
+ end
26
+ end
27
+ end
28
+ end
@@ -28,8 +28,16 @@ module Bandwidth
28
28
  s.to_bxml(xml)
29
29
  end
30
30
  end
31
+ def nest_verbs_list(xml, property)
32
+ if property
33
+ property.each do |verb|
34
+ verb.to_bxml(xml)
35
+ end
36
+ end
37
+ end
31
38
  embedded_xml(xml, speak_sentence, SpeakSentence)
32
39
  embedded_xml(xml, play_audio, PlayAudio)
40
+ nest_verbs_list(xml, nested_verbs)
33
41
  end
34
42
  end
35
43
  end
@@ -20,7 +20,8 @@ module Bandwidth
20
20
  'fileFormat' => file_format,
21
21
  'transcribe' => transcribe,
22
22
  'transcriptionAvailableUrl' => transcription_available_url,
23
- 'transcriptionAvailableMethod' => transcription_available_method
23
+ 'transcriptionAvailableMethod' => transcription_available_method,
24
+ 'silenceTimeout' => silence_timeout
24
25
  }))
25
26
  end
26
27
  end
@@ -6,7 +6,10 @@ module Bandwidth
6
6
  include XmlVerb
7
7
 
8
8
  def to_bxml(xml)
9
- xml.SendDtmf(dtmf)
9
+ xml.SendDtmf(dtmf, compact_hash({
10
+ 'toneDuration' => tone_duration,
11
+ 'toneInterval' => tone_interval
12
+ }))
10
13
  end
11
14
  end
12
15
  end
@@ -12,6 +12,7 @@ require_relative 'voice/models/api_call_state_response.rb'
12
12
  require_relative 'voice/models/api_create_call_request.rb'
13
13
  require_relative 'voice/models/api_modify_call_request.rb'
14
14
  require_relative 'voice/models/api_transcribe_recording_request.rb'
15
+ require_relative 'voice/models/call_engine_modify_conference_request.rb'
15
16
  require_relative 'voice/models/modify_call_recording_state.rb'
16
17
  require_relative 'voice/models/recording_metadata_response.rb'
17
18
  require_relative 'voice/models/transcript.rb'
@@ -29,6 +30,7 @@ require_relative 'voice/models/state1_enum.rb'
29
30
  require_relative 'voice/models/state2_enum.rb'
30
31
  require_relative 'voice/models/status_enum.rb'
31
32
  require_relative 'voice/models/status1_enum.rb'
33
+ require_relative 'voice/models/status2_enum.rb'
32
34
 
33
35
  # Exceptions
34
36
  require_relative 'voice/exceptions/api_error_response_exception.rb'
@@ -19,6 +19,8 @@ module Bandwidth
19
19
  backoff_factor: 1, environment: Environment::PRODUCTION,
20
20
  messaging_basic_auth_user_name: 'TODO: Replace',
21
21
  messaging_basic_auth_password: 'TODO: Replace',
22
+ two_factor_auth_basic_auth_user_name: 'TODO: Replace',
23
+ two_factor_auth_basic_auth_password: 'TODO: Replace',
22
24
  voice_basic_auth_user_name: 'TODO: Replace',
23
25
  voice_basic_auth_password: 'TODO: Replace', config: nil)
24
26
  @config = if config.nil?
@@ -29,6 +31,8 @@ module Bandwidth
29
31
  environment: environment,
30
32
  messaging_basic_auth_user_name: messaging_basic_auth_user_name,
31
33
  messaging_basic_auth_password: messaging_basic_auth_password,
34
+ two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
35
+ two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
32
36
  voice_basic_auth_user_name: voice_basic_auth_user_name,
33
37
  voice_basic_auth_password: voice_basic_auth_password)
34
38
  else
@@ -44,20 +44,19 @@ module Voice
44
44
  # Validate response against endpoint and global error codes.
45
45
  if _response.status_code == 400
46
46
  raise ApiErrorResponseException.new(
47
- 'Something\'s not quite right... Either your request is invalid or' \
48
- ' you\'re requesting it at a bad time. Please fix it' \
49
- ' before trying again.',
47
+ 'Something\'s not quite right... Your request is invalid. Please' \
48
+ ' fix it before trying again.',
50
49
  _response
51
50
  )
52
51
  elsif _response.status_code == 401
53
52
  raise APIException.new(
54
- 'Please authenticate yourself.',
53
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
54
+ ' credentials to authenticate to the API.',
55
55
  _response
56
56
  )
57
57
  elsif _response.status_code == 403
58
58
  raise ApiErrorResponseException.new(
59
- 'Your credentials are invalid. Please use your API credentials for' \
60
- ' the Bandwidth Dashboard.',
59
+ 'User unauthorized to perform this action.',
61
60
  _response
62
61
  )
63
62
  elsif _response.status_code == 404
@@ -122,20 +121,19 @@ module Voice
122
121
  # Validate response against endpoint and global error codes.
123
122
  if _response.status_code == 400
124
123
  raise ApiErrorResponseException.new(
125
- 'Something\'s not quite right... Either your request is invalid or' \
126
- ' you\'re requesting it at a bad time. Please fix it' \
127
- ' before trying again.',
124
+ 'Something\'s not quite right... Your request is invalid. Please' \
125
+ ' fix it before trying again.',
128
126
  _response
129
127
  )
130
128
  elsif _response.status_code == 401
131
129
  raise APIException.new(
132
- 'Please authenticate yourself.',
130
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
131
+ ' credentials to authenticate to the API.',
133
132
  _response
134
133
  )
135
134
  elsif _response.status_code == 403
136
135
  raise ApiErrorResponseException.new(
137
- 'Your credentials are invalid. Please use your API credentials for' \
138
- ' the Bandwidth Dashboard.',
136
+ 'User unauthorized to perform this action.',
139
137
  _response
140
138
  )
141
139
  elsif _response.status_code == 404
@@ -203,20 +201,19 @@ module Voice
203
201
  # Validate response against endpoint and global error codes.
204
202
  if _response.status_code == 400
205
203
  raise ApiErrorResponseException.new(
206
- 'Something\'s not quite right... Either your request is invalid or' \
207
- ' you\'re requesting it at a bad time. Please fix it' \
208
- ' before trying again.',
204
+ 'Something\'s not quite right... Your request is invalid. Please' \
205
+ ' fix it before trying again.',
209
206
  _response
210
207
  )
211
208
  elsif _response.status_code == 401
212
209
  raise APIException.new(
213
- 'Please authenticate yourself.',
210
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
211
+ ' credentials to authenticate to the API.',
214
212
  _response
215
213
  )
216
214
  elsif _response.status_code == 403
217
215
  raise ApiErrorResponseException.new(
218
- 'Your credentials are invalid. Please use your API credentials for' \
219
- ' the Bandwidth Dashboard.',
216
+ 'User unauthorized to perform this action.',
220
217
  _response
221
218
  )
222
219
  elsif _response.status_code == 404
@@ -283,20 +280,19 @@ module Voice
283
280
  # Validate response against endpoint and global error codes.
284
281
  if _response.status_code == 400
285
282
  raise ApiErrorResponseException.new(
286
- 'Something\'s not quite right... Either your request is invalid or' \
287
- ' you\'re requesting it at a bad time. Please fix it' \
288
- ' before trying again.',
283
+ 'Something\'s not quite right... Your request is invalid. Please' \
284
+ ' fix it before trying again.',
289
285
  _response
290
286
  )
291
287
  elsif _response.status_code == 401
292
288
  raise APIException.new(
293
- 'Please authenticate yourself.',
289
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
290
+ ' credentials to authenticate to the API.',
294
291
  _response
295
292
  )
296
293
  elsif _response.status_code == 403
297
294
  raise ApiErrorResponseException.new(
298
- 'Your credentials are invalid. Please use your API credentials for' \
299
- ' the Bandwidth Dashboard.',
295
+ 'User unauthorized to perform this action.',
300
296
  _response
301
297
  )
302
298
  elsif _response.status_code == 404
@@ -376,20 +372,19 @@ module Voice
376
372
  # Validate response against endpoint and global error codes.
377
373
  if _response.status_code == 400
378
374
  raise ApiErrorResponseException.new(
379
- 'Something\'s not quite right... Either your request is invalid or' \
380
- ' you\'re requesting it at a bad time. Please fix it' \
381
- ' before trying again.',
375
+ 'Something\'s not quite right... Your request is invalid. Please' \
376
+ ' fix it before trying again.',
382
377
  _response
383
378
  )
384
379
  elsif _response.status_code == 401
385
380
  raise APIException.new(
386
- 'Please authenticate yourself.',
381
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
382
+ ' credentials to authenticate to the API.',
387
383
  _response
388
384
  )
389
385
  elsif _response.status_code == 403
390
386
  raise ApiErrorResponseException.new(
391
- 'Your credentials are invalid. Please use your API credentials for' \
392
- ' the Bandwidth Dashboard.',
387
+ 'User unauthorized to perform this action.',
393
388
  _response
394
389
  )
395
390
  elsif _response.status_code == 404
@@ -460,20 +455,19 @@ module Voice
460
455
  # Validate response against endpoint and global error codes.
461
456
  if _response.status_code == 400
462
457
  raise ApiErrorResponseException.new(
463
- 'Something\'s not quite right... Either your request is invalid or' \
464
- ' you\'re requesting it at a bad time. Please fix it' \
465
- ' before trying again.',
458
+ 'Something\'s not quite right... Your request is invalid. Please' \
459
+ ' fix it before trying again.',
466
460
  _response
467
461
  )
468
462
  elsif _response.status_code == 401
469
463
  raise APIException.new(
470
- 'Please authenticate yourself.',
464
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
465
+ ' credentials to authenticate to the API.',
471
466
  _response
472
467
  )
473
468
  elsif _response.status_code == 403
474
469
  raise ApiErrorResponseException.new(
475
- 'Your credentials are invalid. Please use your API credentials for' \
476
- ' the Bandwidth Dashboard.',
470
+ 'User unauthorized to perform this action.',
477
471
  _response
478
472
  )
479
473
  elsif _response.status_code == 404
@@ -536,20 +530,19 @@ module Voice
536
530
  # Validate response against endpoint and global error codes.
537
531
  if _response.status_code == 400
538
532
  raise ApiErrorResponseException.new(
539
- 'Something\'s not quite right... Either your request is invalid or' \
540
- ' you\'re requesting it at a bad time. Please fix it' \
541
- ' before trying again.',
533
+ 'Something\'s not quite right... Your request is invalid. Please' \
534
+ ' fix it before trying again.',
542
535
  _response
543
536
  )
544
537
  elsif _response.status_code == 401
545
538
  raise APIException.new(
546
- 'Please authenticate yourself.',
539
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
540
+ ' credentials to authenticate to the API.',
547
541
  _response
548
542
  )
549
543
  elsif _response.status_code == 403
550
544
  raise ApiErrorResponseException.new(
551
- 'Your credentials are invalid. Please use your API credentials for' \
552
- ' the Bandwidth Dashboard.',
545
+ 'User unauthorized to perform this action.',
553
546
  _response
554
547
  )
555
548
  elsif _response.status_code == 404
@@ -610,20 +603,19 @@ module Voice
610
603
  # Validate response against endpoint and global error codes.
611
604
  if _response.status_code == 400
612
605
  raise ApiErrorResponseException.new(
613
- 'Something\'s not quite right... Either your request is invalid or' \
614
- ' you\'re requesting it at a bad time. Please fix it' \
615
- ' before trying again.',
606
+ 'Something\'s not quite right... Your request is invalid. Please' \
607
+ ' fix it before trying again.',
616
608
  _response
617
609
  )
618
610
  elsif _response.status_code == 401
619
611
  raise APIException.new(
620
- 'Please authenticate yourself.',
612
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
613
+ ' credentials to authenticate to the API.',
621
614
  _response
622
615
  )
623
616
  elsif _response.status_code == 403
624
617
  raise ApiErrorResponseException.new(
625
- 'Your credentials are invalid. Please use your API credentials for' \
626
- ' the Bandwidth Dashboard.',
618
+ 'User unauthorized to perform this action.',
627
619
  _response
628
620
  )
629
621
  elsif _response.status_code == 404
@@ -684,20 +676,19 @@ module Voice
684
676
  # Validate response against endpoint and global error codes.
685
677
  if _response.status_code == 400
686
678
  raise ApiErrorResponseException.new(
687
- 'Something\'s not quite right... Either your request is invalid or' \
688
- ' you\'re requesting it at a bad time. Please fix it' \
689
- ' before trying again.',
679
+ 'Something\'s not quite right... Your request is invalid. Please' \
680
+ ' fix it before trying again.',
690
681
  _response
691
682
  )
692
683
  elsif _response.status_code == 401
693
684
  raise APIException.new(
694
- 'Please authenticate yourself.',
685
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
686
+ ' credentials to authenticate to the API.',
695
687
  _response
696
688
  )
697
689
  elsif _response.status_code == 403
698
690
  raise ApiErrorResponseException.new(
699
- 'Your credentials are invalid. Please use your API credentials for' \
700
- ' the Bandwidth Dashboard.',
691
+ 'User unauthorized to perform this action.',
701
692
  _response
702
693
  )
703
694
  elsif _response.status_code == 404
@@ -764,20 +755,19 @@ module Voice
764
755
  # Validate response against endpoint and global error codes.
765
756
  if _response.status_code == 400
766
757
  raise ApiErrorResponseException.new(
767
- 'Something\'s not quite right... Either your request is invalid or' \
768
- ' you\'re requesting it at a bad time. Please fix it' \
769
- ' before trying again.',
758
+ 'Something\'s not quite right... Your request is invalid. Please' \
759
+ ' fix it before trying again.',
770
760
  _response
771
761
  )
772
762
  elsif _response.status_code == 401
773
763
  raise APIException.new(
774
- 'Please authenticate yourself.',
764
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
765
+ ' credentials to authenticate to the API.',
775
766
  _response
776
767
  )
777
768
  elsif _response.status_code == 403
778
769
  raise ApiErrorResponseException.new(
779
- 'Your credentials are invalid. Please use your API credentials for' \
780
- ' the Bandwidth Dashboard.',
770
+ 'User unauthorized to perform this action.',
781
771
  _response
782
772
  )
783
773
  elsif _response.status_code == 404
@@ -848,20 +838,19 @@ module Voice
848
838
  # Validate response against endpoint and global error codes.
849
839
  if _response.status_code == 400
850
840
  raise ApiErrorResponseException.new(
851
- 'Something\'s not quite right... Either your request is invalid or' \
852
- ' you\'re requesting it at a bad time. Please fix it' \
853
- ' before trying again.',
841
+ 'Something\'s not quite right... Your request is invalid. Please' \
842
+ ' fix it before trying again.',
854
843
  _response
855
844
  )
856
845
  elsif _response.status_code == 401
857
846
  raise APIException.new(
858
- 'Please authenticate yourself.',
847
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
848
+ ' credentials to authenticate to the API.',
859
849
  _response
860
850
  )
861
851
  elsif _response.status_code == 403
862
852
  raise ApiErrorResponseException.new(
863
- 'Your credentials are invalid. Please use your API credentials for' \
864
- ' the Bandwidth Dashboard.',
853
+ 'User unauthorized to perform this action.',
865
854
  _response
866
855
  )
867
856
  elsif _response.status_code == 404
@@ -928,20 +917,99 @@ module Voice
928
917
  # Validate response against endpoint and global error codes.
929
918
  if _response.status_code == 400
930
919
  raise ApiErrorResponseException.new(
931
- 'Something\'s not quite right... Either your request is invalid or' \
932
- ' you\'re requesting it at a bad time. Please fix it' \
933
- ' before trying again.',
920
+ 'Something\'s not quite right... Your request is invalid. Please' \
921
+ ' fix it before trying again.',
934
922
  _response
935
923
  )
936
924
  elsif _response.status_code == 401
937
925
  raise APIException.new(
938
- 'Please authenticate yourself.',
926
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
927
+ ' credentials to authenticate to the API.',
939
928
  _response
940
929
  )
941
930
  elsif _response.status_code == 403
942
931
  raise ApiErrorResponseException.new(
943
- 'Your credentials are invalid. Please use your API credentials for' \
944
- ' the Bandwidth Dashboard.',
932
+ 'User unauthorized to perform this action.',
933
+ _response
934
+ )
935
+ elsif _response.status_code == 404
936
+ raise ApiErrorResponseException.new(
937
+ 'The resource specified cannot be found or does not belong to you.',
938
+ _response
939
+ )
940
+ elsif _response.status_code == 415
941
+ raise ApiErrorResponseException.new(
942
+ 'We don\'t support that media type. If a request body is required,' \
943
+ ' please send it to us as `application/json`.',
944
+ _response
945
+ )
946
+ elsif _response.status_code == 429
947
+ raise ApiErrorResponseException.new(
948
+ 'You\'re sending requests to this endpoint too frequently. Please' \
949
+ ' slow your request rate down and try again.',
950
+ _response
951
+ )
952
+ elsif _response.status_code == 500
953
+ raise ApiErrorResponseException.new(
954
+ 'Something unexpected happened. Please try again.',
955
+ _response
956
+ )
957
+ end
958
+ validate_response(_response)
959
+
960
+ # Return appropriate response type.
961
+ ApiResponse.new(_response)
962
+ end
963
+
964
+ # Modify the conference state
965
+ # @param [String] account_id Required parameter: Example:
966
+ # @param [String] conference_id Required parameter: Example:
967
+ # @param [CallEngineModifyConferenceRequest] body Optional parameter:
968
+ # Example:
969
+ # @return [void] response from the API call
970
+ def modify_conference(account_id,
971
+ conference_id,
972
+ body: nil)
973
+ # Prepare query url.
974
+ _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
975
+ _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}'
976
+ _query_builder = APIHelper.append_url_with_template_parameters(
977
+ _query_builder,
978
+ 'accountId' => account_id,
979
+ 'conferenceId' => conference_id
980
+ )
981
+ _query_url = APIHelper.clean_url _query_builder
982
+
983
+ # Prepare headers.
984
+ _headers = {
985
+ 'content-type' => 'application/json; charset=utf-8'
986
+ }
987
+
988
+ # Prepare and execute HttpRequest.
989
+ _request = config.http_client.post(
990
+ _query_url,
991
+ headers: _headers,
992
+ parameters: body.to_json
993
+ )
994
+ VoiceBasicAuth.apply(config, _request)
995
+ _response = execute_request(_request)
996
+
997
+ # Validate response against endpoint and global error codes.
998
+ if _response.status_code == 400
999
+ raise ApiErrorResponseException.new(
1000
+ 'Something\'s not quite right... Your request is invalid. Please' \
1001
+ ' fix it before trying again.',
1002
+ _response
1003
+ )
1004
+ elsif _response.status_code == 401
1005
+ raise APIException.new(
1006
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
1007
+ ' credentials to authenticate to the API.',
1008
+ _response
1009
+ )
1010
+ elsif _response.status_code == 403
1011
+ raise ApiErrorResponseException.new(
1012
+ 'User unauthorized to perform this action.',
945
1013
  _response
946
1014
  )
947
1015
  elsif _response.status_code == 404
@@ -1020,20 +1088,19 @@ module Voice
1020
1088
  # Validate response against endpoint and global error codes.
1021
1089
  if _response.status_code == 400
1022
1090
  raise ApiErrorResponseException.new(
1023
- 'Something\'s not quite right... Either your request is invalid or' \
1024
- ' you\'re requesting it at a bad time. Please fix it' \
1025
- ' before trying again.',
1091
+ 'Something\'s not quite right... Your request is invalid. Please' \
1092
+ ' fix it before trying again.',
1026
1093
  _response
1027
1094
  )
1028
1095
  elsif _response.status_code == 401
1029
1096
  raise APIException.new(
1030
- 'Please authenticate yourself.',
1097
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
1098
+ ' credentials to authenticate to the API.',
1031
1099
  _response
1032
1100
  )
1033
1101
  elsif _response.status_code == 403
1034
1102
  raise ApiErrorResponseException.new(
1035
- 'Your credentials are invalid. Please use your API credentials for' \
1036
- ' the Bandwidth Dashboard.',
1103
+ 'User unauthorized to perform this action.',
1037
1104
  _response
1038
1105
  )
1039
1106
  elsif _response.status_code == 404