class Bandwidth::Voice::APIController

APIController

Public Class Methods

new(config, http_call_back: nil) click to toggle source
Calls superclass method Bandwidth::BaseController::new
# 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

Public Instance Methods

create_call(account_id, body) click to toggle source

Creates an outbound call. @param [String] account_id Required parameter: Example: @param [CreateCallRequest] body Required parameter: Example: @return [CreateCallResponse] response from the API call

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 18
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.
  if _response.status_code == 400
    raise ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 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
create_transcribe_call_recording(account_id, call_id, recording_id, body) click to toggle source

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

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 812
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.
  if _response.status_code == 400
    raise ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 410
    raise ApiErrorException.new(
      'The media for this recording has been deleted, so we can\'t' \
      ' transcribe it',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 ApiErrorException.new(
      'Something unexpected happened. Please try again.',
      _response
    )
  end
  validate_response(_response)

  # Return appropriate response type.
  ApiResponse.new(_response)
end
delete_call_transcription(account_id, call_id, recording_id) click to toggle source

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

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 899
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.
  if _response.status_code == 400
    raise ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 ApiErrorException.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) click to toggle source

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

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 499
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.
  if _response.status_code == 400
    raise ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 ApiErrorException.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) click to toggle source

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

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 656
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.
  if _response.status_code == 400
    raise ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 ApiErrorException.new(
      'Something unexpected happened. Please try again.',
      _response
    )
  end
  validate_response(_response)

  # Return appropriate response type.
  ApiResponse.new(_response)
end
get_call(account_id, call_id) click to toggle source

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

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 98
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.
  if _response.status_code == 400
    raise ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 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
get_call_recording(account_id, call_id, recording_id) click to toggle source

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

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 417
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.
  if _response.status_code == 400
    raise ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 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
get_call_recordings(account_id, call_id) click to toggle source

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

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 336
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.
  if _response.status_code == 400
    raise ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 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
get_call_transcription(account_id, call_id, recording_id) click to toggle source

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

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 729
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.
  if _response.status_code == 400
    raise ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 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
get_conference(account_id, conference_id) click to toggle source

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

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 1066
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.
  if _response.status_code == 400
    raise ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 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
get_conference_member(account_id, conference_id, member_id) click to toggle source

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

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 1307
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.
  if _response.status_code == 400
    raise ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 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
get_conference_recording(account_id, conference_id, recording_id) click to toggle source

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

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 1470
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.
  if _response.status_code == 400
    raise ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 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
get_conference_recordings(account_id, conference_id) click to toggle source

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

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 1389
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.
  if _response.status_code == 400
    raise ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 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
get_conferences(account_id, name: nil, min_created_time: nil, max_created_time: nil, page_size: 1000, page_token: nil) click to toggle source

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

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 975
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.
  if _response.status_code == 400
    raise ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 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
get_download_call_recording(account_id, call_id, recording_id) click to toggle source

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

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 572
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 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 ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 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
get_download_conference_recording(account_id, conference_id, recording_id) click to toggle source

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

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 1552
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.
  if _response.status_code == 400
    raise ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 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
get_query_call_recordings(account_id, from: nil, to: nil, min_start_time: nil, max_start_time: nil) click to toggle source

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

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 1641
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.
  if _response.status_code == 400
    raise ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 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
modify_call(account_id, call_id, body) click to toggle source

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

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 178
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.
  if _response.status_code == 400
    raise ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 ApiErrorException.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) click to toggle source

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

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 257
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.
  if _response.status_code == 400
    raise ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 ApiErrorException.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) click to toggle source

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

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 1146
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.
  if _response.status_code == 400
    raise ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 ApiErrorException.new(
      'Something unexpected happened. Please try again.',
      _response
    )
  end
  validate_response(_response)

  # Return appropriate response type.
  ApiResponse.new(_response)
end
modify_conference_member(account_id, conference_id, call_id, body) click to toggle source

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

# File lib/bandwidth/voice_lib/voice/controllers/api_controller.rb, line 1226
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.
  if _response.status_code == 400
    raise ApiErrorException.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 ApiErrorException.new(
      'User unauthorized to perform this action.',
      _response
    )
  elsif _response.status_code == 404
    raise ApiErrorException.new(
      'The resource specified cannot be found or does not belong to you.',
      _response
    )
  elsif _response.status_code == 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
    )
  elsif _response.status_code == 429
    raise ApiErrorException.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 ApiErrorException.new(
      'Something unexpected happened. Please try again.',
      _response
    )
  end
  validate_response(_response)

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