# bandwidth # # This file was automatically generated by APIMATIC v2.0 # ( https://apimatic.io ). module Bandwidth module Voice # APIController class APIController < BaseController def initialize(config, http_call_back: nil) super(config, http_call_back: http_call_back) end # Creates an outbound phone call. # @param [String] account_id Required parameter: Example: # @param [CreateCallRequest] body Required parameter: Example: # @return [CreateCallResponse] response from the API call def create_call(account_id, body) # 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' => { 'value' => account_id, 'encode' => false } ) _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. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.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: CreateCallResponse.from_hash(decoded) ) end # Returns near-realtime metadata about the specified call. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: # @return [CallState] response from the API call def get_call(account_id, 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' => { 'value' => account_id, 'encode' => false }, 'callId' => { 'value' => call_id, 'encode' => false } ) _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. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.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: CallState.from_hash(decoded) ) end # Interrupts and replaces an active call's BXML document. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: # @param [ModifyCallRequest] body Required parameter: Example: # @return [void] response from the API call def modify_call(account_id, call_id, body) # 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' => { 'value' => account_id, 'encode' => false }, 'callId' => { 'value' => call_id, 'encode' => false } ) _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. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) end validate_response(_response) # Return appropriate response type. ApiResponse.new(_response) end # Pauses or resumes a recording. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: # @param [ModifyCallRecordingRequest] body Required parameter: Example: # @return [void] response from the API call def modify_call_recording_state(account_id, call_id, body) # 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' => { 'value' => account_id, 'encode' => false }, 'callId' => { 'value' => call_id, 'encode' => false } ) _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. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) end validate_response(_response) # Return appropriate response type. ApiResponse.new(_response) end # Returns a (potentially empty) list of metadata for the recordings that # took place during the specified call. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: # @return [List of CallRecordingMetadata] response from the API call def get_call_recordings(account_id, call_id) # 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' => { 'value' => account_id, 'encode' => false }, 'callId' => { 'value' => call_id, 'encode' => false } ) _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. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.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| CallRecordingMetadata.from_hash(element) } ) end # Returns metadata for the specified recording. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: # @param [String] recording_id Required parameter: Example: # @return [CallRecordingMetadata] response from the API call def get_call_recording(account_id, 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' => { 'value' => account_id, 'encode' => false }, 'callId' => { 'value' => call_id, 'encode' => false }, 'recordingId' => { 'value' => recording_id, 'encode' => false } ) _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. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.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: CallRecordingMetadata.from_hash(decoded) ) end # Deletes the specified recording. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: # @param [String] recording_id Required parameter: Example: # @return [void] response from the API call def delete_recording(account_id, 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' => { 'value' => account_id, 'encode' => false }, 'callId' => { 'value' => call_id, 'encode' => false }, 'recordingId' => { 'value' => recording_id, 'encode' => false } ) _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. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) end validate_response(_response) # Return appropriate response type. ApiResponse.new(_response) end # Downloads the specified recording. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: # @param [String] recording_id Required parameter: Example: # @return [Mixed] response from the API call def get_download_call_recording(account_id, 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' => { 'value' => account_id, 'encode' => false }, 'callId' => { 'value' => call_id, 'encode' => false }, 'recordingId' => { 'value' => recording_id, 'encode' => false } ) _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) # Validate response against endpoint and global error codes. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) end validate_response(_response) # Return appropriate response type. ApiResponse.new( _response, data: _response.raw_body ) end # Deletes the specified recording's media. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: # @param [String] recording_id Required parameter: Example: # @return [void] response from the API call def delete_recording_media(account_id, 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' => { 'value' => account_id, 'encode' => false }, 'callId' => { 'value' => call_id, 'encode' => false }, 'recordingId' => { 'value' => recording_id, 'encode' => false } ) _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. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) end validate_response(_response) # Return appropriate response type. ApiResponse.new(_response) end # Downloads the specified transcription. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: # @param [String] recording_id Required parameter: Example: # @return [TranscriptionResponse] response from the API call def get_call_transcription(account_id, 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' => { 'value' => account_id, 'encode' => false }, 'callId' => { 'value' => call_id, 'encode' => false }, 'recordingId' => { 'value' => recording_id, 'encode' => false } ) _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. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.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 # Requests that the specified recording be transcribed. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: # @param [String] recording_id Required parameter: Example: # @param [TranscribeRecordingRequest] body Required parameter: Example: # @return [void] response from the API call def create_transcribe_call_recording(account_id, call_id, recording_id, body) # 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' => { 'value' => account_id, 'encode' => false }, 'callId' => { 'value' => call_id, 'encode' => false }, 'recordingId' => { 'value' => recording_id, 'encode' => false } ) _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. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 410 raise ApiErrorException.new( 'The media for this recording has been deleted, so we can\'t' \ ' transcribe it', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) end validate_response(_response) # Return appropriate response type. ApiResponse.new(_response) end # Deletes the specified recording's transcription. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: # @param [String] recording_id Required parameter: Example: # @return [void] response from the API call def delete_call_transcription(account_id, 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' => { 'value' => account_id, 'encode' => false }, 'callId' => { 'value' => call_id, 'encode' => false }, 'recordingId' => { 'value' => recording_id, 'encode' => false } ) _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. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) end validate_response(_response) # Return appropriate response type. ApiResponse.new(_response) end # Returns information about the conferences in the account. # @param [String] account_id Required parameter: Example: # @param [String] name Optional parameter: Example: # @param [String] min_created_time Optional parameter: Example: # @param [String] max_created_time Optional parameter: Example: # @param [Integer] page_size Optional parameter: Example:1000 # @param [String] page_token Optional parameter: Example: # @return [List of ConferenceState] response from the API call def get_conferences(account_id, name: nil, min_created_time: nil, max_created_time: nil, page_size: 1000, page_token: nil) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/conferences' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false } ) _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, 'name' => name, 'minCreatedTime' => min_created_time, 'maxCreatedTime' => max_created_time, 'pageSize' => page_size, 'pageToken' => page_token ) _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. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.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| ConferenceState.from_hash(element) } ) end # Returns information about the specified conference. # @param [String] account_id Required parameter: Example: # @param [String] conference_id Required parameter: Example: # @return [ConferenceState] response from the API call def get_conference(account_id, conference_id) # 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' => { 'value' => account_id, 'encode' => false }, 'conferenceId' => { 'value' => conference_id, 'encode' => false } ) _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. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.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: ConferenceState.from_hash(decoded) ) end # Modify the conference state. # @param [String] account_id Required parameter: Example: # @param [String] conference_id Required parameter: Example: # @param [ModifyConferenceRequest] body Required parameter: Example: # @return [void] response from the API call def modify_conference(account_id, conference_id, body) # 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' => { 'value' => account_id, 'encode' => false }, 'conferenceId' => { 'value' => conference_id, 'encode' => false } ) _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. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) end validate_response(_response) # Return appropriate response type. ApiResponse.new(_response) end # Updates settings for a particular conference member. # @param [String] account_id Required parameter: Example: # @param [String] conference_id Required parameter: Example: # @param [String] call_id Required parameter: Example: # @param [ConferenceMemberState] body Required parameter: Example: # @return [void] response from the API call def modify_conference_member(account_id, conference_id, call_id, body) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}/members/{callId}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false }, 'conferenceId' => { 'value' => conference_id, 'encode' => false }, 'callId' => { 'value' => call_id, 'encode' => false } ) _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. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) end validate_response(_response) # Return appropriate response type. ApiResponse.new(_response) end # Returns information about the specified conference member. # @param [String] account_id Required parameter: Example: # @param [String] conference_id Required parameter: Example: # @param [String] member_id Required parameter: Example: # @return [ConferenceMemberState] response from the API call def get_conference_member(account_id, conference_id, member_id) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}/members/{memberId}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false }, 'conferenceId' => { 'value' => conference_id, 'encode' => false }, 'memberId' => { 'value' => member_id, 'encode' => false } ) _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. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.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: ConferenceMemberState.from_hash(decoded) ) end # Returns a (potentially empty) list of metadata for the recordings that # took place during the specified conference # @param [String] account_id Required parameter: Example: # @param [String] conference_id Required parameter: Example: # @return [List of ConferenceRecordingMetadata] response from the API call def get_conference_recordings(account_id, conference_id) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}/recordings' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false }, 'conferenceId' => { 'value' => conference_id, 'encode' => false } ) _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. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.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| ConferenceRecordingMetadata.from_hash(element) } ) end # Returns metadata for the specified recording. # @param [String] account_id Required parameter: Example: # @param [String] conference_id Required parameter: Example: # @param [String] recording_id Required parameter: Example: # @return [CallRecordingMetadata] response from the API call def get_conference_recording(account_id, conference_id, recording_id) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false }, 'conferenceId' => { 'value' => conference_id, 'encode' => false }, 'recordingId' => { 'value' => recording_id, 'encode' => false } ) _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. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.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: CallRecordingMetadata.from_hash(decoded) ) end # Downloads the specified recording. # @param [String] account_id Required parameter: Example: # @param [String] conference_id Required parameter: Example: # @param [String] recording_id Required parameter: Example: # @return [Mixed] response from the API call def get_download_conference_recording(account_id, conference_id, recording_id) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}/media' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false }, 'conferenceId' => { 'value' => conference_id, 'encode' => false }, 'recordingId' => { 'value' => recording_id, 'encode' => false } ) _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. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) end validate_response(_response) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) unless _response.raw_body.nil? || _response.raw_body.to_s.strip.empty? ApiResponse.new( _response, data: decoded ) end # 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. # @param [String] account_id Required parameter: Example: # @param [String] from Optional parameter: Example: # @param [String] to Optional parameter: Example: # @param [String] min_start_time Optional parameter: Example: # @param [String] max_start_time Optional parameter: Example: # @return [List of CallRecordingMetadata] response from the API call def get_query_call_recordings(account_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}/recordings' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false } ) _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. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.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| CallRecordingMetadata.from_hash(element) } ) end end end end