Class: Bandwidth::Voice::APIController

Inherits:
BaseController show all
Defined in:
lib/bandwidth/voice_lib/voice/controllers/api_controller.rb

Overview

APIController

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#execute_request, #validate_parameters, #validate_response

Constructor Details

#initialize(config, http_call_back: nil) ⇒ APIController

Returns a new instance of APIController.



10
11
12
# File 'lib/bandwidth/voice_lib/voice/controllers/api_controller.rb', line 10

def initialize(config, http_call_back: nil)
  super(config, http_call_back: http_call_back)
end

Instance Method Details

#create_call(account_id, body: nil) ⇒ ApiCallResponse

Creates an outbound call

Parameters:

  • account_id (String)

    Required parameter: Example:

  • body (ApiCreateCallRequest) (defaults to: nil)

    Optional parameter: Example:

Returns:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/bandwidth/voice_lib/voice/controllers/api_controller.rb', line 18

def create_call(,
                body: nil)
  # Prepare query url.
  _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
  _query_builder << '/api/v2/accounts/{accountId}/calls'
  _query_builder = APIHelper.append_url_with_template_parameters(
    _query_builder,
    'accountId' => 
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json',
    'content-type' => 'application/json; charset=utf-8'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.post(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  VoiceBasicAuth.apply(config, _request)
  _response = execute_request(_request)

  # Validate response against endpoint and global error codes.
  if _response.status_code == 400
    raise ApiErrorResponseException.new(
      'Something\'s not quite right... Your request is invalid. Please' \
      ' fix it before trying again.',
      _response
    )
  elsif _response.status_code == 401
    raise APIException.new(
      'Your credentials are invalid. Please use your Bandwidth dashboard' \
      ' credentials to authenticate to the API.',
      _response
    )
  elsif _response.status_code == 403
    raise ApiErrorResponseException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorResponseException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 415
    raise ApiErrorResponseException.new(
      'We don\'t support that media type. If a request body is required,' \
      ' please send it to us as `application/json`.',
      _response
    )
  elsif _response.status_code == 429
    raise ApiErrorResponseException.new(
      'You\'re sending requests to this endpoint too frequently. Please' \
      ' slow your request rate down and try again.',
      _response
    )
  elsif _response.status_code == 500
    raise ApiErrorResponseException.new(
      'Something unexpected happened. Please try again.',
      _response
    )
  end
  validate_response(_response)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  ApiResponse.new(_response, data: ApiCallResponse.from_hash(decoded))
end

#create_transcribe_recording(account_id, call_id, recording_id, body: nil) ⇒ void

This method returns an undefined value.

Requests that the specified recording be transcribed

Parameters:

  • account_id (String)

    Required parameter: Example:

  • call_id (String)

    Required parameter: Example:

  • recording_id (String)

    Required parameter: Example:

  • body (ApiTranscribeRecordingRequest) (defaults to: nil)

    Optional parameter: Example:



809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
# File 'lib/bandwidth/voice_lib/voice/controllers/api_controller.rb', line 809

def create_transcribe_recording(,
                                call_id,
                                recording_id,
                                body: nil)
  # Prepare query url.
  _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
  _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'
  _query_builder = APIHelper.append_url_with_template_parameters(
    _query_builder,
    'accountId' => ,
    'callId' => call_id,
    'recordingId' => recording_id
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'content-type' => 'application/json; charset=utf-8'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.post(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  VoiceBasicAuth.apply(config, _request)
  _response = execute_request(_request)

  # Validate response against endpoint and global error codes.
  if _response.status_code == 400
    raise ApiErrorResponseException.new(
      'Something\'s not quite right... Your request is invalid. Please' \
      ' fix it before trying again.',
      _response
    )
  elsif _response.status_code == 401
    raise APIException.new(
      'Your credentials are invalid. Please use your Bandwidth dashboard' \
      ' credentials to authenticate to the API.',
      _response
    )
  elsif _response.status_code == 403
    raise ApiErrorResponseException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorResponseException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 410
    raise ApiErrorResponseException.new(
      'The media for this recording has been deleted, so we can\'t' \
      ' transcribe it',
      _response
    )
  elsif _response.status_code == 415
    raise ApiErrorResponseException.new(
      'We don\'t support that media type. If a request body is required,' \
      ' please send it to us as `application/json`.',
      _response
    )
  elsif _response.status_code == 429
    raise ApiErrorResponseException.new(
      'You\'re sending requests to this endpoint too frequently. Please' \
      ' slow your request rate down and try again.',
      _response
    )
  elsif _response.status_code == 500
    raise ApiErrorResponseException.new(
      'Something unexpected happened. Please try again.',
      _response
    )
  end
  validate_response(_response)

  # Return appropriate response type.
  ApiResponse.new(_response)
end

#delete_recording(account_id, call_id, recording_id) ⇒ void

This method returns an undefined value.

Deletes the specified recording

Parameters:

  • account_id (String)

    Required parameter: Example:

  • call_id (String)

    Required parameter: Example:

  • recording_id (String)

    Required parameter: Example:



509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
# File 'lib/bandwidth/voice_lib/voice/controllers/api_controller.rb', line 509

def delete_recording(,
                     call_id,
                     recording_id)
  # Prepare query url.
  _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
  _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}'
  _query_builder = APIHelper.append_url_with_template_parameters(
    _query_builder,
    'accountId' => ,
    'callId' => call_id,
    'recordingId' => recording_id
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare and execute HttpRequest.
  _request = config.http_client.delete(
    _query_url
  )
  VoiceBasicAuth.apply(config, _request)
  _response = execute_request(_request)

  # Validate response against endpoint and global error codes.
  if _response.status_code == 400
    raise ApiErrorResponseException.new(
      'Something\'s not quite right... Your request is invalid. Please' \
      ' fix it before trying again.',
      _response
    )
  elsif _response.status_code == 401
    raise APIException.new(
      'Your credentials are invalid. Please use your Bandwidth dashboard' \
      ' credentials to authenticate to the API.',
      _response
    )
  elsif _response.status_code == 403
    raise ApiErrorResponseException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorResponseException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 415
    raise ApiErrorResponseException.new(
      'We don\'t support that media type. If a request body is required,' \
      ' please send it to us as `application/json`.',
      _response
    )
  elsif _response.status_code == 429
    raise ApiErrorResponseException.new(
      'You\'re sending requests to this endpoint too frequently. Please' \
      ' slow your request rate down and try again.',
      _response
    )
  elsif _response.status_code == 500
    raise ApiErrorResponseException.new(
      'Something unexpected happened. Please try again.',
      _response
    )
  end
  validate_response(_response)

  # Return appropriate response type.
  ApiResponse.new(_response)
end

#delete_recording_media(account_id, call_id, recording_id) ⇒ void

This method returns an undefined value.

Deletes the specified recording’s media

Parameters:

  • account_id (String)

    Required parameter: Example:

  • call_id (String)

    Required parameter: Example:

  • recording_id (String)

    Required parameter: Example:



655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
# File 'lib/bandwidth/voice_lib/voice/controllers/api_controller.rb', line 655

def delete_recording_media(,
                           call_id,
                           recording_id)
  # Prepare query url.
  _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
  _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media'
  _query_builder = APIHelper.append_url_with_template_parameters(
    _query_builder,
    'accountId' => ,
    'callId' => call_id,
    'recordingId' => recording_id
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare and execute HttpRequest.
  _request = config.http_client.delete(
    _query_url
  )
  VoiceBasicAuth.apply(config, _request)
  _response = execute_request(_request)

  # Validate response against endpoint and global error codes.
  if _response.status_code == 400
    raise ApiErrorResponseException.new(
      'Something\'s not quite right... Your request is invalid. Please' \
      ' fix it before trying again.',
      _response
    )
  elsif _response.status_code == 401
    raise APIException.new(
      'Your credentials are invalid. Please use your Bandwidth dashboard' \
      ' credentials to authenticate to the API.',
      _response
    )
  elsif _response.status_code == 403
    raise ApiErrorResponseException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorResponseException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 415
    raise ApiErrorResponseException.new(
      'We don\'t support that media type. If a request body is required,' \
      ' please send it to us as `application/json`.',
      _response
    )
  elsif _response.status_code == 429
    raise ApiErrorResponseException.new(
      'You\'re sending requests to this endpoint too frequently. Please' \
      ' slow your request rate down and try again.',
      _response
    )
  elsif _response.status_code == 500
    raise ApiErrorResponseException.new(
      'Something unexpected happened. Please try again.',
      _response
    )
  end
  validate_response(_response)

  # Return appropriate response type.
  ApiResponse.new(_response)
end

#delete_recording_transcription(account_id, call_id, recording_id) ⇒ void

This method returns an undefined value.

Deletes the specified recording’s transcription

Parameters:

  • account_id (String)

    Required parameter: Example:

  • call_id (String)

    Required parameter: Example:

  • recording_id (String)

    Required parameter: Example:



896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
# File 'lib/bandwidth/voice_lib/voice/controllers/api_controller.rb', line 896

def delete_recording_transcription(,
                                   call_id,
                                   recording_id)
  # Prepare query url.
  _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
  _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'
  _query_builder = APIHelper.append_url_with_template_parameters(
    _query_builder,
    'accountId' => ,
    'callId' => call_id,
    'recordingId' => recording_id
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare and execute HttpRequest.
  _request = config.http_client.delete(
    _query_url
  )
  VoiceBasicAuth.apply(config, _request)
  _response = execute_request(_request)

  # Validate response against endpoint and global error codes.
  if _response.status_code == 400
    raise ApiErrorResponseException.new(
      'Something\'s not quite right... Your request is invalid. Please' \
      ' fix it before trying again.',
      _response
    )
  elsif _response.status_code == 401
    raise APIException.new(
      'Your credentials are invalid. Please use your Bandwidth dashboard' \
      ' credentials to authenticate to the API.',
      _response
    )
  elsif _response.status_code == 403
    raise ApiErrorResponseException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorResponseException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 415
    raise ApiErrorResponseException.new(
      'We don\'t support that media type. If a request body is required,' \
      ' please send it to us as `application/json`.',
      _response
    )
  elsif _response.status_code == 429
    raise ApiErrorResponseException.new(
      'You\'re sending requests to this endpoint too frequently. Please' \
      ' slow your request rate down and try again.',
      _response
    )
  elsif _response.status_code == 500
    raise ApiErrorResponseException.new(
      'Something unexpected happened. Please try again.',
      _response
    )
  end
  validate_response(_response)

  # Return appropriate response type.
  ApiResponse.new(_response)
end

#get_call_state(account_id, call_id) ⇒ ApiCallStateResponse

Returns near-realtime metadata about the specified call

Parameters:

  • account_id (String)

    Required parameter: Example:

  • call_id (String)

    Required parameter: Example:

Returns:



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/bandwidth/voice_lib/voice/controllers/api_controller.rb', line 96

def get_call_state(,
                   call_id)
  # Prepare query url.
  _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
  _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}'
  _query_builder = APIHelper.append_url_with_template_parameters(
    _query_builder,
    'accountId' => ,
    'callId' => call_id
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.get(
    _query_url,
    headers: _headers
  )
  VoiceBasicAuth.apply(config, _request)
  _response = execute_request(_request)

  # Validate response against endpoint and global error codes.
  if _response.status_code == 400
    raise ApiErrorResponseException.new(
      'Something\'s not quite right... Your request is invalid. Please' \
      ' fix it before trying again.',
      _response
    )
  elsif _response.status_code == 401
    raise APIException.new(
      'Your credentials are invalid. Please use your Bandwidth dashboard' \
      ' credentials to authenticate to the API.',
      _response
    )
  elsif _response.status_code == 403
    raise ApiErrorResponseException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorResponseException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 415
    raise ApiErrorResponseException.new(
      'We don\'t support that media type. If a request body is required,' \
      ' please send it to us as `application/json`.',
      _response
    )
  elsif _response.status_code == 429
    raise ApiErrorResponseException.new(
      'You\'re sending requests to this endpoint too frequently. Please' \
      ' slow your request rate down and try again.',
      _response
    )
  elsif _response.status_code == 500
    raise ApiErrorResponseException.new(
      'Something unexpected happened. Please try again.',
      _response
    )
  end
  validate_response(_response)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  ApiResponse.new(_response, data: ApiCallStateResponse.from_hash(decoded))
end

#get_metadata_for_recording(account_id, call_id, recording_id) ⇒ RecordingMetadataResponse

Returns metadata for the specified recording

Parameters:

  • account_id (String)

    Required parameter: Example:

  • call_id (String)

    Required parameter: Example:

  • recording_id (String)

    Required parameter: Example:

Returns:



428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
# File 'lib/bandwidth/voice_lib/voice/controllers/api_controller.rb', line 428

def (,
                               call_id,
                               recording_id)
  # Prepare query url.
  _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
  _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}'
  _query_builder = APIHelper.append_url_with_template_parameters(
    _query_builder,
    'accountId' => ,
    'callId' => call_id,
    'recordingId' => recording_id
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.get(
    _query_url,
    headers: _headers
  )
  VoiceBasicAuth.apply(config, _request)
  _response = execute_request(_request)

  # Validate response against endpoint and global error codes.
  if _response.status_code == 400
    raise ApiErrorResponseException.new(
      'Something\'s not quite right... Your request is invalid. Please' \
      ' fix it before trying again.',
      _response
    )
  elsif _response.status_code == 401
    raise APIException.new(
      'Your credentials are invalid. Please use your Bandwidth dashboard' \
      ' credentials to authenticate to the API.',
      _response
    )
  elsif _response.status_code == 403
    raise ApiErrorResponseException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorResponseException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 415
    raise ApiErrorResponseException.new(
      'We don\'t support that media type. If a request body is required,' \
      ' please send it to us as `application/json`.',
      _response
    )
  elsif _response.status_code == 429
    raise ApiErrorResponseException.new(
      'You\'re sending requests to this endpoint too frequently. Please' \
      ' slow your request rate down and try again.',
      _response
    )
  elsif _response.status_code == 500
    raise ApiErrorResponseException.new(
      'Something unexpected happened. Please try again.',
      _response
    )
  end
  validate_response(_response)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  ApiResponse.new(_response,
                  data: RecordingMetadataResponse.from_hash(decoded))
end

#get_query_metadata_for_account(account_id, from: nil, to: nil, min_start_time: nil, max_start_time: nil) ⇒ List of RecordingMetadataResponse

Returns a list of metadata for the recordings associated with the specified account. The list can be filtered by the optional from, to, minStartTime, and maxStartTime arguments. The list is capped at 1000 entries and may be empty if no recordings match the specified criteria.

Parameters:

  • account_id (String)

    Required parameter: Example:

  • from (String) (defaults to: nil)

    Optional parameter: Example:

  • to (String) (defaults to: nil)

    Optional parameter: Example:

  • min_start_time (String) (defaults to: nil)

    Optional parameter: Example:

  • max_start_time (String) (defaults to: nil)

    Optional parameter: Example:

Returns:



1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
# File 'lib/bandwidth/voice_lib/voice/controllers/api_controller.rb', line 1054

def (,
                                   from: nil,
                                   to: nil,
                                   min_start_time: nil,
                                   max_start_time: nil)
  # Prepare query url.
  _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
  _query_builder << '/api/v2/accounts/{accountId}/recordings'
  _query_builder = APIHelper.append_url_with_template_parameters(
    _query_builder,
    'accountId' => 
  )
  _query_builder = APIHelper.append_url_with_query_parameters(
    _query_builder,
    'from' => from,
    'to' => to,
    'minStartTime' => min_start_time,
    'maxStartTime' => max_start_time
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.get(
    _query_url,
    headers: _headers
  )
  VoiceBasicAuth.apply(config, _request)
  _response = execute_request(_request)

  # Validate response against endpoint and global error codes.
  if _response.status_code == 400
    raise ApiErrorResponseException.new(
      'Something\'s not quite right... Your request is invalid. Please' \
      ' fix it before trying again.',
      _response
    )
  elsif _response.status_code == 401
    raise APIException.new(
      'Your credentials are invalid. Please use your Bandwidth dashboard' \
      ' credentials to authenticate to the API.',
      _response
    )
  elsif _response.status_code == 403
    raise ApiErrorResponseException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorResponseException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 415
    raise ApiErrorResponseException.new(
      'We don\'t support that media type. If a request body is required,' \
      ' please send it to us as `application/json`.',
      _response
    )
  elsif _response.status_code == 429
    raise ApiErrorResponseException.new(
      'You\'re sending requests to this endpoint too frequently. Please' \
      ' slow your request rate down and try again.',
      _response
    )
  elsif _response.status_code == 500
    raise ApiErrorResponseException.new(
      'Something unexpected happened. Please try again.',
      _response
    )
  end
  validate_response(_response)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  ApiResponse.new(
    _response,
    data: decoded.map { |element| RecordingMetadataResponse.from_hash(element) }
  )
end

#get_query_metadata_for_account_and_call(account_id, call_id, from: nil, to: nil, min_start_time: nil, max_start_time: nil) ⇒ List of RecordingMetadataResponse

Returns a (potentially empty) list of metadata for the recordings that took place during the specified call

Parameters:

  • account_id (String)

    Required parameter: Example:

  • call_id (String)

    Required parameter: Example:

  • from (String) (defaults to: nil)

    Optional parameter: Example:

  • to (String) (defaults to: nil)

    Optional parameter: Example:

  • min_start_time (String) (defaults to: nil)

    Optional parameter: Example:

  • max_start_time (String) (defaults to: nil)

    Optional parameter: Example:

Returns:



336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# File 'lib/bandwidth/voice_lib/voice/controllers/api_controller.rb', line 336

def (,
                                            call_id,
                                            from: nil,
                                            to: nil,
                                            min_start_time: nil,
                                            max_start_time: nil)
  # Prepare query url.
  _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
  _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings'
  _query_builder = APIHelper.append_url_with_template_parameters(
    _query_builder,
    'accountId' => ,
    'callId' => call_id
  )
  _query_builder = APIHelper.append_url_with_query_parameters(
    _query_builder,
    'from' => from,
    'to' => to,
    'minStartTime' => min_start_time,
    'maxStartTime' => max_start_time
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.get(
    _query_url,
    headers: _headers
  )
  VoiceBasicAuth.apply(config, _request)
  _response = execute_request(_request)

  # Validate response against endpoint and global error codes.
  if _response.status_code == 400
    raise ApiErrorResponseException.new(
      'Something\'s not quite right... Your request is invalid. Please' \
      ' fix it before trying again.',
      _response
    )
  elsif _response.status_code == 401
    raise APIException.new(
      'Your credentials are invalid. Please use your Bandwidth dashboard' \
      ' credentials to authenticate to the API.',
      _response
    )
  elsif _response.status_code == 403
    raise ApiErrorResponseException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorResponseException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 415
    raise ApiErrorResponseException.new(
      'We don\'t support that media type. If a request body is required,' \
      ' please send it to us as `application/json`.',
      _response
    )
  elsif _response.status_code == 429
    raise ApiErrorResponseException.new(
      'You\'re sending requests to this endpoint too frequently. Please' \
      ' slow your request rate down and try again.',
      _response
    )
  elsif _response.status_code == 500
    raise ApiErrorResponseException.new(
      'Something unexpected happened. Please try again.',
      _response
    )
  end
  validate_response(_response)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  ApiResponse.new(
    _response,
    data: decoded.map { |element| RecordingMetadataResponse.from_hash(element) }
  )
end

#get_recording_transcription(account_id, call_id, recording_id) ⇒ TranscriptionResponse

Downloads the specified transcription

Parameters:

  • account_id (String)

    Required parameter: Example:

  • call_id (String)

    Required parameter: Example:

  • recording_id (String)

    Required parameter: Example:

Returns:



728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
# File 'lib/bandwidth/voice_lib/voice/controllers/api_controller.rb', line 728

def get_recording_transcription(,
                                call_id,
                                recording_id)
  # Prepare query url.
  _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
  _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'
  _query_builder = APIHelper.append_url_with_template_parameters(
    _query_builder,
    'accountId' => ,
    'callId' => call_id,
    'recordingId' => recording_id
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.get(
    _query_url,
    headers: _headers
  )
  VoiceBasicAuth.apply(config, _request)
  _response = execute_request(_request)

  # Validate response against endpoint and global error codes.
  if _response.status_code == 400
    raise ApiErrorResponseException.new(
      'Something\'s not quite right... Your request is invalid. Please' \
      ' fix it before trying again.',
      _response
    )
  elsif _response.status_code == 401
    raise APIException.new(
      'Your credentials are invalid. Please use your Bandwidth dashboard' \
      ' credentials to authenticate to the API.',
      _response
    )
  elsif _response.status_code == 403
    raise ApiErrorResponseException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorResponseException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 415
    raise ApiErrorResponseException.new(
      'We don\'t support that media type. If a request body is required,' \
      ' please send it to us as `application/json`.',
      _response
    )
  elsif _response.status_code == 429
    raise ApiErrorResponseException.new(
      'You\'re sending requests to this endpoint too frequently. Please' \
      ' slow your request rate down and try again.',
      _response
    )
  elsif _response.status_code == 500
    raise ApiErrorResponseException.new(
      'Something unexpected happened. Please try again.',
      _response
    )
  end
  validate_response(_response)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  ApiResponse.new(_response, data: TranscriptionResponse.from_hash(decoded))
end

#get_stream_recording_media(account_id, call_id, recording_id) ⇒ Binary

Downloads the specified recording

Parameters:

  • account_id (String)

    Required parameter: Example:

  • call_id (String)

    Required parameter: Example:

  • recording_id (String)

    Required parameter: Example:

Returns:

  • (Binary)

    response from the API call



582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
# File 'lib/bandwidth/voice_lib/voice/controllers/api_controller.rb', line 582

def get_stream_recording_media(,
                               call_id,
                               recording_id)
  # Prepare query url.
  _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
  _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media'
  _query_builder = APIHelper.append_url_with_template_parameters(
    _query_builder,
    'accountId' => ,
    'callId' => call_id,
    'recordingId' => recording_id
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare and execute HttpRequest.
  _request = config.http_client.get(
    _query_url
  )
  VoiceBasicAuth.apply(config, _request)
  _response = execute_request(_request, binary: true)

  # Validate response against endpoint and global error codes.
  if _response.status_code == 400
    raise ApiErrorResponseException.new(
      'Something\'s not quite right... Your request is invalid. Please' \
      ' fix it before trying again.',
      _response
    )
  elsif _response.status_code == 401
    raise APIException.new(
      'Your credentials are invalid. Please use your Bandwidth dashboard' \
      ' credentials to authenticate to the API.',
      _response
    )
  elsif _response.status_code == 403
    raise ApiErrorResponseException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorResponseException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 415
    raise ApiErrorResponseException.new(
      'We don\'t support that media type. If a request body is required,' \
      ' please send it to us as `application/json`.',
      _response
    )
  elsif _response.status_code == 429
    raise ApiErrorResponseException.new(
      'You\'re sending requests to this endpoint too frequently. Please' \
      ' slow your request rate down and try again.',
      _response
    )
  elsif _response.status_code == 500
    raise ApiErrorResponseException.new(
      'Something unexpected happened. Please try again.',
      _response
    )
  end
  validate_response(_response)

  # Return appropriate response type.
  ApiResponse.new(_response, data: _response.raw_body)
end

#modify_call(account_id, call_id, body: nil) ⇒ void

This method returns an undefined value.

Interrupts and replaces an active call’s BXML document

Parameters:

  • account_id (String)

    Required parameter: Example:

  • call_id (String)

    Required parameter: Example:

  • body (ApiModifyCallRequest) (defaults to: nil)

    Optional parameter: Example:



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/bandwidth/voice_lib/voice/controllers/api_controller.rb', line 174

def modify_call(,
                call_id,
                body: nil)
  # Prepare query url.
  _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
  _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}'
  _query_builder = APIHelper.append_url_with_template_parameters(
    _query_builder,
    'accountId' => ,
    'callId' => call_id
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'content-type' => 'application/json; charset=utf-8'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.post(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  VoiceBasicAuth.apply(config, _request)
  _response = execute_request(_request)

  # Validate response against endpoint and global error codes.
  if _response.status_code == 400
    raise ApiErrorResponseException.new(
      'Something\'s not quite right... Your request is invalid. Please' \
      ' fix it before trying again.',
      _response
    )
  elsif _response.status_code == 401
    raise APIException.new(
      'Your credentials are invalid. Please use your Bandwidth dashboard' \
      ' credentials to authenticate to the API.',
      _response
    )
  elsif _response.status_code == 403
    raise ApiErrorResponseException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorResponseException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 415
    raise ApiErrorResponseException.new(
      'We don\'t support that media type. If a request body is required,' \
      ' please send it to us as `application/json`.',
      _response
    )
  elsif _response.status_code == 429
    raise ApiErrorResponseException.new(
      'You\'re sending requests to this endpoint too frequently. Please' \
      ' slow your request rate down and try again.',
      _response
    )
  elsif _response.status_code == 500
    raise ApiErrorResponseException.new(
      'Something unexpected happened. Please try again.',
      _response
    )
  end
  validate_response(_response)

  # Return appropriate response type.
  ApiResponse.new(_response)
end

#modify_call_recording_state(account_id, call_id, body: nil) ⇒ void

This method returns an undefined value.

Pauses or resumes a recording

Parameters:

  • account_id (String)

    Required parameter: Example:

  • call_id (String)

    Required parameter: Example:

  • body (ModifyCallRecordingState) (defaults to: nil)

    Optional parameter: Example:



253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/bandwidth/voice_lib/voice/controllers/api_controller.rb', line 253

def modify_call_recording_state(,
                                call_id,
                                body: nil)
  # Prepare query url.
  _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
  _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recording'
  _query_builder = APIHelper.append_url_with_template_parameters(
    _query_builder,
    'accountId' => ,
    'callId' => call_id
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'content-type' => 'application/json; charset=utf-8'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.put(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  VoiceBasicAuth.apply(config, _request)
  _response = execute_request(_request)

  # Validate response against endpoint and global error codes.
  if _response.status_code == 400
    raise ApiErrorResponseException.new(
      'Something\'s not quite right... Your request is invalid. Please' \
      ' fix it before trying again.',
      _response
    )
  elsif _response.status_code == 401
    raise APIException.new(
      'Your credentials are invalid. Please use your Bandwidth dashboard' \
      ' credentials to authenticate to the API.',
      _response
    )
  elsif _response.status_code == 403
    raise ApiErrorResponseException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorResponseException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 415
    raise ApiErrorResponseException.new(
      'We don\'t support that media type. If a request body is required,' \
      ' please send it to us as `application/json`.',
      _response
    )
  elsif _response.status_code == 429
    raise ApiErrorResponseException.new(
      'You\'re sending requests to this endpoint too frequently. Please' \
      ' slow your request rate down and try again.',
      _response
    )
  elsif _response.status_code == 500
    raise ApiErrorResponseException.new(
      'Something unexpected happened. Please try again.',
      _response
    )
  end
  validate_response(_response)

  # Return appropriate response type.
  ApiResponse.new(_response)
end

#modify_conference(account_id, conference_id, body: nil) ⇒ void

This method returns an undefined value.

Modify the conference state Example:

Parameters:

  • account_id (String)

    Required parameter: Example:

  • conference_id (String)

    Required parameter: Example:

  • body (CallEngineModifyConferenceRequest) (defaults to: nil)

    Optional parameter:



970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
# File 'lib/bandwidth/voice_lib/voice/controllers/api_controller.rb', line 970

def modify_conference(,
                      conference_id,
                      body: nil)
  # Prepare query url.
  _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
  _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}'
  _query_builder = APIHelper.append_url_with_template_parameters(
    _query_builder,
    'accountId' => ,
    'conferenceId' => conference_id
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'content-type' => 'application/json; charset=utf-8'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.post(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  VoiceBasicAuth.apply(config, _request)
  _response = execute_request(_request)

  # Validate response against endpoint and global error codes.
  if _response.status_code == 400
    raise ApiErrorResponseException.new(
      'Something\'s not quite right... Your request is invalid. Please' \
      ' fix it before trying again.',
      _response
    )
  elsif _response.status_code == 401
    raise APIException.new(
      'Your credentials are invalid. Please use your Bandwidth dashboard' \
      ' credentials to authenticate to the API.',
      _response
    )
  elsif _response.status_code == 403
    raise ApiErrorResponseException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorResponseException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 415
    raise ApiErrorResponseException.new(
      'We don\'t support that media type. If a request body is required,' \
      ' please send it to us as `application/json`.',
      _response
    )
  elsif _response.status_code == 429
    raise ApiErrorResponseException.new(
      'You\'re sending requests to this endpoint too frequently. Please' \
      ' slow your request rate down and try again.',
      _response
    )
  elsif _response.status_code == 500
    raise ApiErrorResponseException.new(
      'Something unexpected happened. Please try again.',
      _response
    )
  end
  validate_response(_response)

  # Return appropriate response type.
  ApiResponse.new(_response)
end