-
=begin
-
#Bandwidth
-
-
#Bandwidth's Communication APIs
-
-
The version of the OpenAPI document: 1.0.0
-
Contact: letstalk@bandwidth.com
-
Generated by: https://openapi-generator.tech
-
OpenAPI Generator version: 7.0.0
-
-
=end
-
-
# Common files
-
1
require 'bandwidth-sdk/api_client'
-
1
require 'bandwidth-sdk/api_error'
-
1
require 'bandwidth-sdk/version'
-
1
require 'bandwidth-sdk/configuration'
-
-
# Models
-
1
require 'bandwidth-sdk/models/account_statistics'
-
1
require 'bandwidth-sdk/models/answer_callback'
-
1
require 'bandwidth-sdk/models/bridge_complete_callback'
-
1
require 'bandwidth-sdk/models/bridge_target_complete_callback'
-
1
require 'bandwidth-sdk/models/call_direction_enum'
-
1
require 'bandwidth-sdk/models/call_recording_metadata'
-
1
require 'bandwidth-sdk/models/call_state'
-
1
require 'bandwidth-sdk/models/call_state_enum'
-
1
require 'bandwidth-sdk/models/callback_method_enum'
-
1
require 'bandwidth-sdk/models/code_request'
-
1
require 'bandwidth-sdk/models/conference'
-
1
require 'bandwidth-sdk/models/conference_completed_callback'
-
1
require 'bandwidth-sdk/models/conference_created_callback'
-
1
require 'bandwidth-sdk/models/conference_member'
-
1
require 'bandwidth-sdk/models/conference_member_exit_callback'
-
1
require 'bandwidth-sdk/models/conference_member_join_callback'
-
1
require 'bandwidth-sdk/models/conference_recording_available_callback'
-
1
require 'bandwidth-sdk/models/conference_recording_metadata'
-
1
require 'bandwidth-sdk/models/conference_redirect_callback'
-
1
require 'bandwidth-sdk/models/conference_state_enum'
-
1
require 'bandwidth-sdk/models/create_call'
-
1
require 'bandwidth-sdk/models/create_call_response'
-
1
require 'bandwidth-sdk/models/create_lookup_response'
-
1
require 'bandwidth-sdk/models/create_message_request_error'
-
1
require 'bandwidth-sdk/models/deferred_result'
-
1
require 'bandwidth-sdk/models/disconnect_callback'
-
1
require 'bandwidth-sdk/models/diversion'
-
1
require 'bandwidth-sdk/models/dtmf_callback'
-
1
require 'bandwidth-sdk/models/field_error'
-
1
require 'bandwidth-sdk/models/file_format_enum'
-
1
require 'bandwidth-sdk/models/gather_callback'
-
1
require 'bandwidth-sdk/models/inbound_message_callback'
-
1
require 'bandwidth-sdk/models/inbound_message_callback_message'
-
1
require 'bandwidth-sdk/models/initiate_callback'
-
1
require 'bandwidth-sdk/models/list_message_direction_enum'
-
1
require 'bandwidth-sdk/models/list_message_item'
-
1
require 'bandwidth-sdk/models/lookup_request'
-
1
require 'bandwidth-sdk/models/lookup_result'
-
1
require 'bandwidth-sdk/models/lookup_status'
-
1
require 'bandwidth-sdk/models/lookup_status_enum'
-
1
require 'bandwidth-sdk/models/machine_detection_complete_callback'
-
1
require 'bandwidth-sdk/models/machine_detection_configuration'
-
1
require 'bandwidth-sdk/models/machine_detection_mode_enum'
-
1
require 'bandwidth-sdk/models/machine_detection_result'
-
1
require 'bandwidth-sdk/models/media'
-
1
require 'bandwidth-sdk/models/message'
-
1
require 'bandwidth-sdk/models/message_delivered_callback'
-
1
require 'bandwidth-sdk/models/message_delivered_callback_message'
-
1
require 'bandwidth-sdk/models/message_direction_enum'
-
1
require 'bandwidth-sdk/models/message_failed_callback'
-
1
require 'bandwidth-sdk/models/message_failed_callback_message'
-
1
require 'bandwidth-sdk/models/message_request'
-
1
require 'bandwidth-sdk/models/message_sending_callback'
-
1
require 'bandwidth-sdk/models/message_sending_callback_message'
-
1
require 'bandwidth-sdk/models/message_status_enum'
-
1
require 'bandwidth-sdk/models/message_type_enum'
-
1
require 'bandwidth-sdk/models/messages_list'
-
1
require 'bandwidth-sdk/models/messaging_code_response'
-
1
require 'bandwidth-sdk/models/messaging_request_error'
-
1
require 'bandwidth-sdk/models/mfa_forbidden_request_error'
-
1
require 'bandwidth-sdk/models/mfa_request_error'
-
1
require 'bandwidth-sdk/models/mfa_unauthorized_request_error'
-
1
require 'bandwidth-sdk/models/page_info'
-
1
require 'bandwidth-sdk/models/priority_enum'
-
1
require 'bandwidth-sdk/models/recording_available_callback'
-
1
require 'bandwidth-sdk/models/recording_complete_callback'
-
1
require 'bandwidth-sdk/models/recording_state_enum'
-
1
require 'bandwidth-sdk/models/redirect_callback'
-
1
require 'bandwidth-sdk/models/redirect_method_enum'
-
1
require 'bandwidth-sdk/models/stir_shaken'
-
1
require 'bandwidth-sdk/models/tag'
-
1
require 'bandwidth-sdk/models/tn_lookup_request_error'
-
1
require 'bandwidth-sdk/models/transcribe_recording'
-
1
require 'bandwidth-sdk/models/transcription'
-
1
require 'bandwidth-sdk/models/transcription_available_callback'
-
1
require 'bandwidth-sdk/models/transcription_list'
-
1
require 'bandwidth-sdk/models/transcription_metadata'
-
1
require 'bandwidth-sdk/models/transfer_answer_callback'
-
1
require 'bandwidth-sdk/models/transfer_complete_callback'
-
1
require 'bandwidth-sdk/models/transfer_disconnect_callback'
-
1
require 'bandwidth-sdk/models/update_call'
-
1
require 'bandwidth-sdk/models/update_call_recording'
-
1
require 'bandwidth-sdk/models/update_conference'
-
1
require 'bandwidth-sdk/models/update_conference_member'
-
1
require 'bandwidth-sdk/models/verify_code_request'
-
1
require 'bandwidth-sdk/models/verify_code_response'
-
1
require 'bandwidth-sdk/models/voice_api_error'
-
1
require 'bandwidth-sdk/models/voice_code_response'
-
-
# BXML
-
1
require 'bandwidth-sdk/models/bxml/root'
-
1
require 'bandwidth-sdk/models/bxml/bxml'
-
1
require 'bandwidth-sdk/models/bxml/response'
-
1
require 'bandwidth-sdk/models/bxml/verb'
-
1
require 'bandwidth-sdk/models/bxml/nestable_verb'
-
1
require 'bandwidth-sdk/models/bxml/verbs/bridge'
-
1
require 'bandwidth-sdk/models/bxml/verbs/conference'
-
1
require 'bandwidth-sdk/models/bxml/verbs/custom_param'
-
1
require 'bandwidth-sdk/models/bxml/verbs/forward'
-
1
require 'bandwidth-sdk/models/bxml/verbs/gather'
-
1
require 'bandwidth-sdk/models/bxml/verbs/hangup'
-
1
require 'bandwidth-sdk/models/bxml/verbs/pause_recording'
-
1
require 'bandwidth-sdk/models/bxml/verbs/pause'
-
1
require 'bandwidth-sdk/models/bxml/verbs/phone_number'
-
1
require 'bandwidth-sdk/models/bxml/verbs/play_audio'
-
1
require 'bandwidth-sdk/models/bxml/verbs/record'
-
1
require 'bandwidth-sdk/models/bxml/verbs/redirect'
-
1
require 'bandwidth-sdk/models/bxml/verbs/resume_recording'
-
1
require 'bandwidth-sdk/models/bxml/verbs/ring'
-
1
require 'bandwidth-sdk/models/bxml/verbs/send_dtmf'
-
1
require 'bandwidth-sdk/models/bxml/verbs/sip_uri'
-
1
require 'bandwidth-sdk/models/bxml/verbs/speak_sentence'
-
1
require 'bandwidth-sdk/models/bxml/verbs/start_gather'
-
1
require 'bandwidth-sdk/models/bxml/verbs/start_recording'
-
1
require 'bandwidth-sdk/models/bxml/verbs/start_stream'
-
1
require 'bandwidth-sdk/models/bxml/verbs/start_transcription'
-
1
require 'bandwidth-sdk/models/bxml/verbs/stop_gather'
-
1
require 'bandwidth-sdk/models/bxml/verbs/stop_recording'
-
1
require 'bandwidth-sdk/models/bxml/verbs/stop_stream'
-
1
require 'bandwidth-sdk/models/bxml/verbs/stop_transcription'
-
1
require 'bandwidth-sdk/models/bxml/verbs/stream_param'
-
1
require 'bandwidth-sdk/models/bxml/verbs/tag'
-
1
require 'bandwidth-sdk/models/bxml/verbs/transfer'
-
-
# APIs
-
1
require 'bandwidth-sdk/api/calls_api'
-
1
require 'bandwidth-sdk/api/conferences_api'
-
1
require 'bandwidth-sdk/api/mfa_api'
-
1
require 'bandwidth-sdk/api/media_api'
-
1
require 'bandwidth-sdk/api/messages_api'
-
1
require 'bandwidth-sdk/api/phone_number_lookup_api'
-
1
require 'bandwidth-sdk/api/recordings_api'
-
1
require 'bandwidth-sdk/api/statistics_api'
-
-
1
module Bandwidth
-
1
class << self
-
# Customize default settings for the SDK using block.
-
# Bandwidth.configure do |config|
-
# config.username = "xxx"
-
# config.password = "xxx"
-
# end
-
# If no block given, return the default Configuration object.
-
1
def configure
-
26
if block_given?
-
26
yield(Configuration.default)
-
else
-
Configuration.default
-
end
-
end
-
end
-
end
-
=begin
-
#Bandwidth
-
-
#Bandwidth's Communication APIs
-
-
The version of the OpenAPI document: 1.0.0
-
Contact: letstalk@bandwidth.com
-
Generated by: https://openapi-generator.tech
-
OpenAPI Generator version: 7.0.0
-
-
=end
-
-
1
require 'cgi'
-
-
1
module Bandwidth
-
1
class CallsApi
-
1
attr_accessor :api_client
-
-
1
def initialize(api_client = ApiClient.default)
-
5
@api_client = api_client
-
end
-
# Create Call
-
# Creates an outbound phone call. All calls are initially queued. Your outbound calls will initiated at a specific dequeueing rate, enabling your application to \"fire and forget\" when creating calls. Queued calls may not be modified until they are dequeued and placed, but may be removed from your queue on demand. <b>Please note:</b> Calls submitted to your queue will be placed approximately in order, but exact ordering is not guaranteed.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param create_call [CreateCall] JSON object containing information to create an outbound call
-
# @param [Hash] opts the optional parameters
-
# @return [CreateCallResponse]
-
1
def create_call(account_id, create_call, opts = {})
-
6
data, _status_code, _headers = create_call_with_http_info(account_id, create_call, opts)
-
4
data
-
end
-
-
# Create Call
-
# Creates an outbound phone call. All calls are initially queued. Your outbound calls will initiated at a specific dequeueing rate, enabling your application to \"fire and forget\" when creating calls. Queued calls may not be modified until they are dequeued and placed, but may be removed from your queue on demand. <b>Please note:</b> Calls submitted to your queue will be placed approximately in order, but exact ordering is not guaranteed.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param create_call [CreateCall] JSON object containing information to create an outbound call
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(CreateCallResponse, Integer, Hash)>] CreateCallResponse data, response status code and response headers
-
1
def create_call_with_http_info(account_id, create_call, opts = {})
-
9
if @api_client.config.debugging
-
9
@api_client.config.logger.debug 'Calling API: CallsApi.create_call ...'
-
end
-
# verify the required parameter 'account_id' is set
-
9
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling CallsApi.create_call"
-
end
-
# verify the required parameter 'create_call' is set
-
8
if @api_client.config.client_side_validation && create_call.nil?
-
1
fail ArgumentError, "Missing the required parameter 'create_call' when calling CallsApi.create_call"
-
end
-
# resource path
-
7
local_var_path = '/accounts/{accountId}/calls'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
-
-
# query parameters
-
7
query_params = opts[:query_params] || {}
-
-
# header parameters
-
7
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
7
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
# HTTP header 'Content-Type'
-
7
content_type = @api_client.select_header_content_type(['application/json'])
-
7
if !content_type.nil?
-
7
header_params['Content-Type'] = content_type
-
end
-
-
# form parameters
-
7
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
7
post_body = opts[:debug_body] || @api_client.object_to_http_body(create_call)
-
-
# return_type
-
7
return_type = opts[:debug_return_type] || 'CreateCallResponse'
-
-
# auth_names
-
7
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
7
new_options = opts.merge(
-
:operation => :"CallsApi.create_call",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
7
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
-
6
if @api_client.config.debugging
-
6
@api_client.config.logger.debug "API called: CallsApi#create_call\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
6
return data, status_code, headers
-
end
-
-
# Get Call State Information
-
# Retrieve the current state of a specific call. This information is near-realtime, so it may take a few minutes for your call to be accessible using this endpoint. **Note**: Call information is kept for 7 days after the calls are hung up. If you attempt to retrieve information for a call that is older than 7 days, you will get an HTTP 404 response.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param [Hash] opts the optional parameters
-
# @return [CallState]
-
1
def get_call_state(account_id, call_id, opts = {})
-
2
data, _status_code, _headers = get_call_state_with_http_info(account_id, call_id, opts)
-
data
-
end
-
-
# Get Call State Information
-
# Retrieve the current state of a specific call. This information is near-realtime, so it may take a few minutes for your call to be accessible using this endpoint. **Note**: Call information is kept for 7 days after the calls are hung up. If you attempt to retrieve information for a call that is older than 7 days, you will get an HTTP 404 response.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(CallState, Integer, Hash)>] CallState data, response status code and response headers
-
1
def get_call_state_with_http_info(account_id, call_id, opts = {})
-
7
if @api_client.config.debugging
-
7
@api_client.config.logger.debug 'Calling API: CallsApi.get_call_state ...'
-
end
-
# verify the required parameter 'account_id' is set
-
7
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling CallsApi.get_call_state"
-
end
-
# verify the required parameter 'call_id' is set
-
6
if @api_client.config.client_side_validation && call_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'call_id' when calling CallsApi.get_call_state"
-
end
-
# resource path
-
5
local_var_path = '/accounts/{accountId}/calls/{callId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s))
-
-
# query parameters
-
5
query_params = opts[:query_params] || {}
-
-
# header parameters
-
5
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
5
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
-
# form parameters
-
5
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
5
post_body = opts[:debug_body]
-
-
# return_type
-
5
return_type = opts[:debug_return_type] || 'CallState'
-
-
# auth_names
-
5
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
5
new_options = opts.merge(
-
:operation => :"CallsApi.get_call_state",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
5
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: CallsApi#get_call_state\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Update Call
-
# Interrupts and redirects a call to a different URL that should return a BXML document.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param update_call [UpdateCall] JSON object containing information to redirect an existing call to a new BXML document
-
# @param [Hash] opts the optional parameters
-
# @return [nil]
-
1
def update_call(account_id, call_id, update_call, opts = {})
-
3
update_call_with_http_info(account_id, call_id, update_call, opts)
-
nil
-
end
-
-
# Update Call
-
# Interrupts and redirects a call to a different URL that should return a BXML document.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param update_call [UpdateCall] JSON object containing information to redirect an existing call to a new BXML document
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
-
1
def update_call_with_http_info(account_id, call_id, update_call, opts = {})
-
8
if @api_client.config.debugging
-
8
@api_client.config.logger.debug 'Calling API: CallsApi.update_call ...'
-
end
-
# verify the required parameter 'account_id' is set
-
8
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling CallsApi.update_call"
-
end
-
# verify the required parameter 'call_id' is set
-
7
if @api_client.config.client_side_validation && call_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'call_id' when calling CallsApi.update_call"
-
end
-
# verify the required parameter 'update_call' is set
-
6
if @api_client.config.client_side_validation && update_call.nil?
-
1
fail ArgumentError, "Missing the required parameter 'update_call' when calling CallsApi.update_call"
-
end
-
# resource path
-
5
local_var_path = '/accounts/{accountId}/calls/{callId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s))
-
-
# query parameters
-
5
query_params = opts[:query_params] || {}
-
-
# header parameters
-
5
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
5
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
# HTTP header 'Content-Type'
-
5
content_type = @api_client.select_header_content_type(['application/json'])
-
5
if !content_type.nil?
-
5
header_params['Content-Type'] = content_type
-
end
-
-
# form parameters
-
5
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
5
post_body = opts[:debug_body] || @api_client.object_to_http_body(update_call)
-
-
# return_type
-
5
return_type = opts[:debug_return_type]
-
-
# auth_names
-
5
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
5
new_options = opts.merge(
-
:operation => :"CallsApi.update_call",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
5
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
-
5
if @api_client.config.debugging
-
5
@api_client.config.logger.debug "API called: CallsApi#update_call\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
5
return data, status_code, headers
-
end
-
-
# Update Call BXML
-
# Interrupts and replaces an active call's BXML document.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param body [String]
-
# @param [Hash] opts the optional parameters
-
# @return [nil]
-
1
def update_call_bxml(account_id, call_id, body, opts = {})
-
3
update_call_bxml_with_http_info(account_id, call_id, body, opts)
-
nil
-
end
-
-
# Update Call BXML
-
# Interrupts and replaces an active call's BXML document.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param body [String]
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
-
1
def update_call_bxml_with_http_info(account_id, call_id, body, opts = {})
-
5
if @api_client.config.debugging
-
5
@api_client.config.logger.debug 'Calling API: CallsApi.update_call_bxml ...'
-
end
-
# verify the required parameter 'account_id' is set
-
5
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling CallsApi.update_call_bxml"
-
end
-
# verify the required parameter 'call_id' is set
-
4
if @api_client.config.client_side_validation && call_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'call_id' when calling CallsApi.update_call_bxml"
-
end
-
# verify the required parameter 'body' is set
-
3
if @api_client.config.client_side_validation && body.nil?
-
1
fail ArgumentError, "Missing the required parameter 'body' when calling CallsApi.update_call_bxml"
-
end
-
# resource path
-
2
local_var_path = '/accounts/{accountId}/calls/{callId}/bxml'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
# HTTP header 'Content-Type'
-
2
content_type = @api_client.select_header_content_type(['application/xml'])
-
2
if !content_type.nil?
-
2
header_params['Content-Type'] = content_type
-
end
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body] || @api_client.object_to_http_body(body)
-
-
# return_type
-
2
return_type = opts[:debug_return_type]
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"CallsApi.update_call_bxml",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: CallsApi#update_call_bxml\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
end
-
end
-
=begin
-
#Bandwidth
-
-
#Bandwidth's Communication APIs
-
-
The version of the OpenAPI document: 1.0.0
-
Contact: letstalk@bandwidth.com
-
Generated by: https://openapi-generator.tech
-
OpenAPI Generator version: 7.0.0
-
-
=end
-
-
1
require 'cgi'
-
-
1
module Bandwidth
-
1
class ConferencesApi
-
1
attr_accessor :api_client
-
-
1
def initialize(api_client = ApiClient.default)
-
2
@api_client = api_client
-
end
-
# Download Conference Recording
-
# Downloads the specified recording file.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param conference_id [String] Programmable Voice API Conference ID.
-
# @param recording_id [String] Programmable Voice API Recording ID.
-
# @param [Hash] opts the optional parameters
-
# @return [File]
-
1
def download_conference_recording(account_id, conference_id, recording_id, opts = {})
-
3
data, _status_code, _headers = download_conference_recording_with_http_info(account_id, conference_id, recording_id, opts)
-
data
-
end
-
-
# Download Conference Recording
-
# Downloads the specified recording file.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param conference_id [String] Programmable Voice API Conference ID.
-
# @param recording_id [String] Programmable Voice API Recording ID.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(File, Integer, Hash)>] File data, response status code and response headers
-
1
def download_conference_recording_with_http_info(account_id, conference_id, recording_id, opts = {})
-
5
if @api_client.config.debugging
-
5
@api_client.config.logger.debug 'Calling API: ConferencesApi.download_conference_recording ...'
-
end
-
# verify the required parameter 'account_id' is set
-
5
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.download_conference_recording"
-
end
-
# verify the required parameter 'conference_id' is set
-
4
if @api_client.config.client_side_validation && conference_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.download_conference_recording"
-
end
-
# verify the required parameter 'recording_id' is set
-
3
if @api_client.config.client_side_validation && recording_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'recording_id' when calling ConferencesApi.download_conference_recording"
-
end
-
# resource path
-
2
local_var_path = '/accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}/media'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['audio/vnd.wave', 'audio/mpeg', 'application/json'])
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body]
-
-
# return_type
-
2
return_type = opts[:debug_return_type] || 'File'
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"ConferencesApi.download_conference_recording",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: ConferencesApi#download_conference_recording\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Get Conference Information
-
# Returns information about the specified conference.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param conference_id [String] Programmable Voice API Conference ID.
-
# @param [Hash] opts the optional parameters
-
# @return [Conference]
-
1
def get_conference(account_id, conference_id, opts = {})
-
2
data, _status_code, _headers = get_conference_with_http_info(account_id, conference_id, opts)
-
data
-
end
-
-
# Get Conference Information
-
# Returns information about the specified conference.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param conference_id [String] Programmable Voice API Conference ID.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(Conference, Integer, Hash)>] Conference data, response status code and response headers
-
1
def get_conference_with_http_info(account_id, conference_id, opts = {})
-
4
if @api_client.config.debugging
-
4
@api_client.config.logger.debug 'Calling API: ConferencesApi.get_conference ...'
-
end
-
# verify the required parameter 'account_id' is set
-
4
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.get_conference"
-
end
-
# verify the required parameter 'conference_id' is set
-
3
if @api_client.config.client_side_validation && conference_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.get_conference"
-
end
-
# resource path
-
2
local_var_path = '/accounts/{accountId}/conferences/{conferenceId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body]
-
-
# return_type
-
2
return_type = opts[:debug_return_type] || 'Conference'
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"ConferencesApi.get_conference",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: ConferencesApi#get_conference\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Get Conference Member
-
# Returns information about the specified conference member.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param conference_id [String] Programmable Voice API Conference ID.
-
# @param member_id [String] Programmable Voice API Conference Member ID.
-
# @param [Hash] opts the optional parameters
-
# @return [ConferenceMember]
-
1
def get_conference_member(account_id, conference_id, member_id, opts = {})
-
3
data, _status_code, _headers = get_conference_member_with_http_info(account_id, conference_id, member_id, opts)
-
data
-
end
-
-
# Get Conference Member
-
# Returns information about the specified conference member.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param conference_id [String] Programmable Voice API Conference ID.
-
# @param member_id [String] Programmable Voice API Conference Member ID.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(ConferenceMember, Integer, Hash)>] ConferenceMember data, response status code and response headers
-
1
def get_conference_member_with_http_info(account_id, conference_id, member_id, opts = {})
-
5
if @api_client.config.debugging
-
5
@api_client.config.logger.debug 'Calling API: ConferencesApi.get_conference_member ...'
-
end
-
# verify the required parameter 'account_id' is set
-
5
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.get_conference_member"
-
end
-
# verify the required parameter 'conference_id' is set
-
4
if @api_client.config.client_side_validation && conference_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.get_conference_member"
-
end
-
# verify the required parameter 'member_id' is set
-
3
if @api_client.config.client_side_validation && member_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'member_id' when calling ConferencesApi.get_conference_member"
-
end
-
# resource path
-
2
local_var_path = '/accounts/{accountId}/conferences/{conferenceId}/members/{memberId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s)).sub('{' + 'memberId' + '}', CGI.escape(member_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body]
-
-
# return_type
-
2
return_type = opts[:debug_return_type] || 'ConferenceMember'
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"ConferencesApi.get_conference_member",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: ConferencesApi#get_conference_member\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Get Conference Recording Information
-
# Returns metadata for the specified recording.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param conference_id [String] Programmable Voice API Conference ID.
-
# @param recording_id [String] Programmable Voice API Recording ID.
-
# @param [Hash] opts the optional parameters
-
# @return [ConferenceRecordingMetadata]
-
1
def get_conference_recording(account_id, conference_id, recording_id, opts = {})
-
3
data, _status_code, _headers = get_conference_recording_with_http_info(account_id, conference_id, recording_id, opts)
-
data
-
end
-
-
# Get Conference Recording Information
-
# Returns metadata for the specified recording.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param conference_id [String] Programmable Voice API Conference ID.
-
# @param recording_id [String] Programmable Voice API Recording ID.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(ConferenceRecordingMetadata, Integer, Hash)>] ConferenceRecordingMetadata data, response status code and response headers
-
1
def get_conference_recording_with_http_info(account_id, conference_id, recording_id, opts = {})
-
5
if @api_client.config.debugging
-
5
@api_client.config.logger.debug 'Calling API: ConferencesApi.get_conference_recording ...'
-
end
-
# verify the required parameter 'account_id' is set
-
5
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.get_conference_recording"
-
end
-
# verify the required parameter 'conference_id' is set
-
4
if @api_client.config.client_side_validation && conference_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.get_conference_recording"
-
end
-
# verify the required parameter 'recording_id' is set
-
3
if @api_client.config.client_side_validation && recording_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'recording_id' when calling ConferencesApi.get_conference_recording"
-
end
-
# resource path
-
2
local_var_path = '/accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body]
-
-
# return_type
-
2
return_type = opts[:debug_return_type] || 'ConferenceRecordingMetadata'
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"ConferencesApi.get_conference_recording",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: ConferencesApi#get_conference_recording\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Get Conference Recordings
-
# Returns a (potentially empty) list of metadata for the recordings that took place during the specified conference.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param conference_id [String] Programmable Voice API Conference ID.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<ConferenceRecordingMetadata>]
-
1
def list_conference_recordings(account_id, conference_id, opts = {})
-
2
data, _status_code, _headers = list_conference_recordings_with_http_info(account_id, conference_id, opts)
-
data
-
end
-
-
# Get Conference Recordings
-
# Returns a (potentially empty) list of metadata for the recordings that took place during the specified conference.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param conference_id [String] Programmable Voice API Conference ID.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(Array<ConferenceRecordingMetadata>, Integer, Hash)>] Array<ConferenceRecordingMetadata> data, response status code and response headers
-
1
def list_conference_recordings_with_http_info(account_id, conference_id, opts = {})
-
4
if @api_client.config.debugging
-
4
@api_client.config.logger.debug 'Calling API: ConferencesApi.list_conference_recordings ...'
-
end
-
# verify the required parameter 'account_id' is set
-
4
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.list_conference_recordings"
-
end
-
# verify the required parameter 'conference_id' is set
-
3
if @api_client.config.client_side_validation && conference_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.list_conference_recordings"
-
end
-
# resource path
-
2
local_var_path = '/accounts/{accountId}/conferences/{conferenceId}/recordings'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body]
-
-
# return_type
-
2
return_type = opts[:debug_return_type] || 'Array<ConferenceRecordingMetadata>'
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"ConferencesApi.list_conference_recordings",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: ConferencesApi#list_conference_recordings\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Get Conferences
-
# Returns a max of 1000 conferences, sorted by `createdTime` from oldest to newest. **NOTE:** If the number of conferences in the account is bigger than `pageSize`, a `Link` header (with format `<{url}>; rel=\"next\"`) will be returned in the response. The url can be used to retrieve the next page of conference records.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param [Hash] opts the optional parameters
-
# @option opts [String] :name Filter results by the `name` field.
-
# @option opts [String] :min_created_time Filter results to conferences which have a `createdTime` after or at `minCreatedTime` (in ISO8601 format).
-
# @option opts [String] :max_created_time Filter results to conferences which have a `createdTime` before or at `maxCreatedTime` (in ISO8601 format).
-
# @option opts [Integer] :page_size Specifies the max number of conferences that will be returned. (default to 1000)
-
# @option opts [String] :page_token Not intended for explicit use. To use pagination, follow the links in the `Link` header of the response, as indicated in the endpoint description.
-
# @return [Array<Conference>]
-
1
def list_conferences(account_id, opts = {})
-
3
data, _status_code, _headers = list_conferences_with_http_info(account_id, opts)
-
data
-
end
-
-
# Get Conferences
-
# Returns a max of 1000 conferences, sorted by `createdTime` from oldest to newest. **NOTE:** If the number of conferences in the account is bigger than `pageSize`, a `Link` header (with format `<{url}>; rel=\"next\"`) will be returned in the response. The url can be used to retrieve the next page of conference records.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param [Hash] opts the optional parameters
-
# @option opts [String] :name Filter results by the `name` field.
-
# @option opts [String] :min_created_time Filter results to conferences which have a `createdTime` after or at `minCreatedTime` (in ISO8601 format).
-
# @option opts [String] :max_created_time Filter results to conferences which have a `createdTime` before or at `maxCreatedTime` (in ISO8601 format).
-
# @option opts [Integer] :page_size Specifies the max number of conferences that will be returned. (default to 1000)
-
# @option opts [String] :page_token Not intended for explicit use. To use pagination, follow the links in the `Link` header of the response, as indicated in the endpoint description.
-
# @return [Array<(Array<Conference>, Integer, Hash)>] Array<Conference> data, response status code and response headers
-
1
def list_conferences_with_http_info(account_id, opts = {})
-
5
if @api_client.config.debugging
-
5
@api_client.config.logger.debug 'Calling API: ConferencesApi.list_conferences ...'
-
end
-
# verify the required parameter 'account_id' is set
-
5
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.list_conferences"
-
end
-
4
if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 1000
-
1
fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ConferencesApi.list_conferences, must be smaller than or equal to 1000.'
-
end
-
-
3
if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
-
1
fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ConferencesApi.list_conferences, must be greater than or equal to 1.'
-
end
-
-
# resource path
-
2
local_var_path = '/accounts/{accountId}/conferences'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
2
query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?
-
2
query_params[:'minCreatedTime'] = opts[:'min_created_time'] if !opts[:'min_created_time'].nil?
-
2
query_params[:'maxCreatedTime'] = opts[:'max_created_time'] if !opts[:'max_created_time'].nil?
-
2
query_params[:'pageSize'] = opts[:'page_size'] if !opts[:'page_size'].nil?
-
2
query_params[:'pageToken'] = opts[:'page_token'] if !opts[:'page_token'].nil?
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body]
-
-
# return_type
-
2
return_type = opts[:debug_return_type] || 'Array<Conference>'
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"ConferencesApi.list_conferences",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: ConferencesApi#list_conferences\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Update Conference
-
# Update the conference state.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param conference_id [String] Programmable Voice API Conference ID.
-
# @param update_conference [UpdateConference]
-
# @param [Hash] opts the optional parameters
-
# @return [nil]
-
1
def update_conference(account_id, conference_id, update_conference, opts = {})
-
3
update_conference_with_http_info(account_id, conference_id, update_conference, opts)
-
nil
-
end
-
-
# Update Conference
-
# Update the conference state.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param conference_id [String] Programmable Voice API Conference ID.
-
# @param update_conference [UpdateConference]
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
-
1
def update_conference_with_http_info(account_id, conference_id, update_conference, opts = {})
-
5
if @api_client.config.debugging
-
5
@api_client.config.logger.debug 'Calling API: ConferencesApi.update_conference ...'
-
end
-
# verify the required parameter 'account_id' is set
-
5
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.update_conference"
-
end
-
# verify the required parameter 'conference_id' is set
-
4
if @api_client.config.client_side_validation && conference_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.update_conference"
-
end
-
# verify the required parameter 'update_conference' is set
-
3
if @api_client.config.client_side_validation && update_conference.nil?
-
1
fail ArgumentError, "Missing the required parameter 'update_conference' when calling ConferencesApi.update_conference"
-
end
-
# resource path
-
2
local_var_path = '/accounts/{accountId}/conferences/{conferenceId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
# HTTP header 'Content-Type'
-
2
content_type = @api_client.select_header_content_type(['application/json'])
-
2
if !content_type.nil?
-
2
header_params['Content-Type'] = content_type
-
end
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body] || @api_client.object_to_http_body(update_conference)
-
-
# return_type
-
2
return_type = opts[:debug_return_type]
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"ConferencesApi.update_conference",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: ConferencesApi#update_conference\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Update Conference BXML
-
# Update the conference BXML document.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param conference_id [String] Programmable Voice API Conference ID.
-
# @param body [String]
-
# @param [Hash] opts the optional parameters
-
# @return [nil]
-
1
def update_conference_bxml(account_id, conference_id, body, opts = {})
-
3
update_conference_bxml_with_http_info(account_id, conference_id, body, opts)
-
nil
-
end
-
-
# Update Conference BXML
-
# Update the conference BXML document.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param conference_id [String] Programmable Voice API Conference ID.
-
# @param body [String]
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
-
1
def update_conference_bxml_with_http_info(account_id, conference_id, body, opts = {})
-
5
if @api_client.config.debugging
-
5
@api_client.config.logger.debug 'Calling API: ConferencesApi.update_conference_bxml ...'
-
end
-
# verify the required parameter 'account_id' is set
-
5
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.update_conference_bxml"
-
end
-
# verify the required parameter 'conference_id' is set
-
4
if @api_client.config.client_side_validation && conference_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.update_conference_bxml"
-
end
-
# verify the required parameter 'body' is set
-
3
if @api_client.config.client_side_validation && body.nil?
-
1
fail ArgumentError, "Missing the required parameter 'body' when calling ConferencesApi.update_conference_bxml"
-
end
-
# resource path
-
2
local_var_path = '/accounts/{accountId}/conferences/{conferenceId}/bxml'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
# HTTP header 'Content-Type'
-
2
content_type = @api_client.select_header_content_type(['application/xml'])
-
2
if !content_type.nil?
-
2
header_params['Content-Type'] = content_type
-
end
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body] || @api_client.object_to_http_body(body)
-
-
# return_type
-
2
return_type = opts[:debug_return_type]
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"ConferencesApi.update_conference_bxml",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: ConferencesApi#update_conference_bxml\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Update Conference Member
-
# Updates settings for a particular conference member.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param conference_id [String] Programmable Voice API Conference ID.
-
# @param member_id [String] Programmable Voice API Conference Member ID.
-
# @param update_conference_member [UpdateConferenceMember]
-
# @param [Hash] opts the optional parameters
-
# @return [nil]
-
1
def update_conference_member(account_id, conference_id, member_id, update_conference_member, opts = {})
-
4
update_conference_member_with_http_info(account_id, conference_id, member_id, update_conference_member, opts)
-
nil
-
end
-
-
# Update Conference Member
-
# Updates settings for a particular conference member.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param conference_id [String] Programmable Voice API Conference ID.
-
# @param member_id [String] Programmable Voice API Conference Member ID.
-
# @param update_conference_member [UpdateConferenceMember]
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
-
1
def update_conference_member_with_http_info(account_id, conference_id, member_id, update_conference_member, opts = {})
-
6
if @api_client.config.debugging
-
6
@api_client.config.logger.debug 'Calling API: ConferencesApi.update_conference_member ...'
-
end
-
# verify the required parameter 'account_id' is set
-
6
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.update_conference_member"
-
end
-
# verify the required parameter 'conference_id' is set
-
5
if @api_client.config.client_side_validation && conference_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.update_conference_member"
-
end
-
# verify the required parameter 'member_id' is set
-
4
if @api_client.config.client_side_validation && member_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'member_id' when calling ConferencesApi.update_conference_member"
-
end
-
# verify the required parameter 'update_conference_member' is set
-
3
if @api_client.config.client_side_validation && update_conference_member.nil?
-
1
fail ArgumentError, "Missing the required parameter 'update_conference_member' when calling ConferencesApi.update_conference_member"
-
end
-
# resource path
-
2
local_var_path = '/accounts/{accountId}/conferences/{conferenceId}/members/{memberId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s)).sub('{' + 'memberId' + '}', CGI.escape(member_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
# HTTP header 'Content-Type'
-
2
content_type = @api_client.select_header_content_type(['application/json'])
-
2
if !content_type.nil?
-
2
header_params['Content-Type'] = content_type
-
end
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body] || @api_client.object_to_http_body(update_conference_member)
-
-
# return_type
-
2
return_type = opts[:debug_return_type]
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"ConferencesApi.update_conference_member",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: ConferencesApi#update_conference_member\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
end
-
end
-
=begin
-
#Bandwidth
-
-
#Bandwidth's Communication APIs
-
-
The version of the OpenAPI document: 1.0.0
-
Contact: letstalk@bandwidth.com
-
Generated by: https://openapi-generator.tech
-
OpenAPI Generator version: 7.0.0
-
-
=end
-
-
1
require 'cgi'
-
-
1
module Bandwidth
-
1
class MediaApi
-
1
attr_accessor :api_client
-
-
1
def initialize(api_client = ApiClient.default)
-
2
@api_client = api_client
-
end
-
# Delete Media
-
# Deletes a media file from Bandwidth API server. Make sure you don't have any application scripts still using the media before you delete. If you accidentally delete a media file you can immediately upload a new file with the same name.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param media_id [String] Media ID to retrieve.
-
# @param [Hash] opts the optional parameters
-
# @return [nil]
-
1
def delete_media(account_id, media_id, opts = {})
-
2
delete_media_with_http_info(account_id, media_id, opts)
-
nil
-
end
-
-
# Delete Media
-
# Deletes a media file from Bandwidth API server. Make sure you don't have any application scripts still using the media before you delete. If you accidentally delete a media file you can immediately upload a new file with the same name.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param media_id [String] Media ID to retrieve.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
-
1
def delete_media_with_http_info(account_id, media_id, opts = {})
-
5
if @api_client.config.debugging
-
5
@api_client.config.logger.debug 'Calling API: MediaApi.delete_media ...'
-
end
-
# verify the required parameter 'account_id' is set
-
5
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling MediaApi.delete_media"
-
end
-
# verify the required parameter 'media_id' is set
-
4
if @api_client.config.client_side_validation && media_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'media_id' when calling MediaApi.delete_media"
-
end
-
# resource path
-
3
local_var_path = '/users/{accountId}/media/{mediaId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'mediaId' + '}', CGI.escape(media_id.to_s))
-
-
# query parameters
-
3
query_params = opts[:query_params] || {}
-
-
# header parameters
-
3
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
3
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
-
# form parameters
-
3
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
3
post_body = opts[:debug_body]
-
-
# return_type
-
3
return_type = opts[:debug_return_type]
-
-
# auth_names
-
3
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
3
new_options = opts.merge(
-
:operation => :"MediaApi.delete_media",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
3
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
-
3
if @api_client.config.debugging
-
3
@api_client.config.logger.debug "API called: MediaApi#delete_media\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
3
return data, status_code, headers
-
end
-
-
# Get Media
-
# Downloads a media file you previously uploaded.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param media_id [String] Media ID to retrieve.
-
# @param [Hash] opts the optional parameters
-
# @return [File]
-
1
def get_media(account_id, media_id, opts = {})
-
2
data, _status_code, _headers = get_media_with_http_info(account_id, media_id, opts)
-
data
-
end
-
-
# Get Media
-
# Downloads a media file you previously uploaded.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param media_id [String] Media ID to retrieve.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(File, Integer, Hash)>] File data, response status code and response headers
-
1
def get_media_with_http_info(account_id, media_id, opts = {})
-
6
if @api_client.config.debugging
-
6
@api_client.config.logger.debug 'Calling API: MediaApi.get_media ...'
-
end
-
# verify the required parameter 'account_id' is set
-
6
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling MediaApi.get_media"
-
end
-
# verify the required parameter 'media_id' is set
-
5
if @api_client.config.client_side_validation && media_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'media_id' when calling MediaApi.get_media"
-
end
-
# resource path
-
4
local_var_path = '/users/{accountId}/media/{mediaId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'mediaId' + '}', CGI.escape(media_id.to_s))
-
-
# query parameters
-
4
query_params = opts[:query_params] || {}
-
-
# header parameters
-
4
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
4
header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream', 'application/json'])
-
-
# form parameters
-
4
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
4
post_body = opts[:debug_body]
-
-
# return_type
-
4
return_type = opts[:debug_return_type] || 'File'
-
-
# auth_names
-
4
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
4
new_options = opts.merge(
-
:operation => :"MediaApi.get_media",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
4
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
-
3
if @api_client.config.debugging
-
3
@api_client.config.logger.debug "API called: MediaApi#get_media\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
3
return data, status_code, headers
-
end
-
-
# List Media
-
# Gets a list of your media files. No query parameters are supported.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param [Hash] opts the optional parameters
-
# @option opts [String] :continuation_token Continuation token used to retrieve subsequent media.
-
# @return [Array<Media>]
-
1
def list_media(account_id, opts = {})
-
1
data, _status_code, _headers = list_media_with_http_info(account_id, opts)
-
data
-
end
-
-
# List Media
-
# Gets a list of your media files. No query parameters are supported.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param [Hash] opts the optional parameters
-
# @option opts [String] :continuation_token Continuation token used to retrieve subsequent media.
-
# @return [Array<(Array<Media>, Integer, Hash)>] Array<Media> data, response status code and response headers
-
1
def list_media_with_http_info(account_id, opts = {})
-
3
if @api_client.config.debugging
-
3
@api_client.config.logger.debug 'Calling API: MediaApi.list_media ...'
-
end
-
# verify the required parameter 'account_id' is set
-
3
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling MediaApi.list_media"
-
end
-
# resource path
-
2
local_var_path = '/users/{accountId}/media'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
2
header_params[:'Continuation-Token'] = opts[:'continuation_token'] if !opts[:'continuation_token'].nil?
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body]
-
-
# return_type
-
2
return_type = opts[:debug_return_type] || 'Array<Media>'
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"MediaApi.list_media",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: MediaApi#list_media\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Upload Media
-
# Upload a file. You may add headers to the request in order to provide some control to your media file. If a file is uploaded with the same name as a file that already exists under this account, the previous file will be overwritten. A list of supported media types can be found [here](https://support.bandwidth.com/hc/en-us/articles/360014128994-What-MMS-file-types-are-supported-).
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param media_id [String] Media ID to retrieve.
-
# @param body [File]
-
# @param [Hash] opts the optional parameters
-
# @option opts [String] :content_type The media type of the entity-body.
-
# @option opts [String] :cache_control General-header field is used to specify directives that MUST be obeyed by all caching mechanisms along the request/response chain.
-
# @return [nil]
-
1
def upload_media(account_id, media_id, body, opts = {})
-
3
upload_media_with_http_info(account_id, media_id, body, opts)
-
nil
-
end
-
-
# Upload Media
-
# Upload a file. You may add headers to the request in order to provide some control to your media file. If a file is uploaded with the same name as a file that already exists under this account, the previous file will be overwritten. A list of supported media types can be found [here](https://support.bandwidth.com/hc/en-us/articles/360014128994-What-MMS-file-types-are-supported-).
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param media_id [String] Media ID to retrieve.
-
# @param body [File]
-
# @param [Hash] opts the optional parameters
-
# @option opts [String] :content_type The media type of the entity-body.
-
# @option opts [String] :cache_control General-header field is used to specify directives that MUST be obeyed by all caching mechanisms along the request/response chain.
-
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
-
1
def upload_media_with_http_info(account_id, media_id, body, opts = {})
-
6
if @api_client.config.debugging
-
6
@api_client.config.logger.debug 'Calling API: MediaApi.upload_media ...'
-
end
-
# verify the required parameter 'account_id' is set
-
6
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling MediaApi.upload_media"
-
end
-
# verify the required parameter 'media_id' is set
-
5
if @api_client.config.client_side_validation && media_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'media_id' when calling MediaApi.upload_media"
-
end
-
# verify the required parameter 'body' is set
-
4
if @api_client.config.client_side_validation && body.nil?
-
1
fail ArgumentError, "Missing the required parameter 'body' when calling MediaApi.upload_media"
-
end
-
# resource path
-
3
local_var_path = '/users/{accountId}/media/{mediaId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'mediaId' + '}', CGI.escape(media_id.to_s))
-
-
# query parameters
-
3
query_params = opts[:query_params] || {}
-
-
# header parameters
-
3
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
3
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
# HTTP header 'Content-Type'
-
3
content_type = @api_client.select_header_content_type(['application/json', 'application/ogg', 'application/pdf', 'application/rtf', 'application/zip', 'application/x-tar', 'application/xml', 'application/gzip', 'application/x-bzip2', 'application/x-gzip', 'application/smil', 'application/javascript', 'audio/mp4', 'audio/mpeg', 'audio/ogg', 'audio/flac', 'audio/webm', 'audio/wav', 'audio/amr', 'audio/3gpp', 'image/bmp', 'image/gif', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/svg+xml', 'image/tiff', 'image/webp', 'image/x-icon', 'text/css', 'text/csv', 'text/calendar', 'text/plain', 'text/javascript', 'text/vcard', 'text/vnd.wap.wml', 'text/xml', 'video/avi', 'video/mp4', 'video/mpeg', 'video/ogg', 'video/quicktime', 'video/webm', 'video/x-ms-wmv'])
-
3
if !content_type.nil?
-
3
header_params['Content-Type'] = content_type
-
end
-
3
header_params[:'Content-Type'] = opts[:'content_type'] if !opts[:'content_type'].nil?
-
3
header_params[:'Cache-Control'] = opts[:'cache_control'] if !opts[:'cache_control'].nil?
-
-
# form parameters
-
3
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
3
post_body = opts[:debug_body] || @api_client.object_to_http_body(body)
-
-
# return_type
-
3
return_type = opts[:debug_return_type]
-
-
# auth_names
-
3
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
3
new_options = opts.merge(
-
:operation => :"MediaApi.upload_media",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
3
data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
-
3
if @api_client.config.debugging
-
3
@api_client.config.logger.debug "API called: MediaApi#upload_media\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
3
return data, status_code, headers
-
end
-
end
-
end
-
=begin
-
#Bandwidth
-
-
#Bandwidth's Communication APIs
-
-
The version of the OpenAPI document: 1.0.0
-
Contact: letstalk@bandwidth.com
-
Generated by: https://openapi-generator.tech
-
OpenAPI Generator version: 7.0.0
-
-
=end
-
-
1
require 'cgi'
-
-
1
module Bandwidth
-
1
class MessagesApi
-
1
attr_accessor :api_client
-
-
1
def initialize(api_client = ApiClient.default)
-
2
@api_client = api_client
-
end
-
# Create Message
-
# Endpoint for sending text messages and picture messages using V2 messaging.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param message_request [MessageRequest]
-
# @param [Hash] opts the optional parameters
-
# @return [Message]
-
1
def create_message(account_id, message_request, opts = {})
-
2
data, _status_code, _headers = create_message_with_http_info(account_id, message_request, opts)
-
data
-
end
-
-
# Create Message
-
# Endpoint for sending text messages and picture messages using V2 messaging.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param message_request [MessageRequest]
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(Message, Integer, Hash)>] Message data, response status code and response headers
-
1
def create_message_with_http_info(account_id, message_request, opts = {})
-
8
if @api_client.config.debugging
-
8
@api_client.config.logger.debug 'Calling API: MessagesApi.create_message ...'
-
end
-
# verify the required parameter 'account_id' is set
-
8
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling MessagesApi.create_message"
-
end
-
# verify the required parameter 'message_request' is set
-
7
if @api_client.config.client_side_validation && message_request.nil?
-
1
fail ArgumentError, "Missing the required parameter 'message_request' when calling MessagesApi.create_message"
-
end
-
# resource path
-
6
local_var_path = '/users/{accountId}/messages'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
-
-
# query parameters
-
6
query_params = opts[:query_params] || {}
-
-
# header parameters
-
6
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
6
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
# HTTP header 'Content-Type'
-
6
content_type = @api_client.select_header_content_type(['application/json'])
-
6
if !content_type.nil?
-
6
header_params['Content-Type'] = content_type
-
end
-
-
# form parameters
-
6
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
6
post_body = opts[:debug_body] || @api_client.object_to_http_body(message_request)
-
-
# return_type
-
6
return_type = opts[:debug_return_type] || 'Message'
-
-
# auth_names
-
6
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
6
new_options = opts.merge(
-
:operation => :"MessagesApi.create_message",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
6
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
-
4
if @api_client.config.debugging
-
4
@api_client.config.logger.debug "API called: MessagesApi#create_message\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
4
return data, status_code, headers
-
end
-
-
# List Messages
-
# Returns a list of messages based on query parameters.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param [Hash] opts the optional parameters
-
# @option opts [String] :message_id The ID of the message to search for. Special characters need to be encoded using URL encoding. Message IDs could come in different formats, e.g., 9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6 and 1589228074636lm4k2je7j7jklbn2 are valid message ID formats. Note that you must include at least one query parameter.
-
# @option opts [String] :source_tn The phone number that sent the message. Accepted values are: a single full phone number a comma separated list of full phone numbers (maximum of 10) or a single partial phone number (minimum of 5 characters e.g. '%2B1919').
-
# @option opts [String] :destination_tn The phone number that received the message. Accepted values are: a single full phone number a comma separated list of full phone numbers (maximum of 10) or a single partial phone number (minimum of 5 characters e.g. '%2B1919').
-
# @option opts [MessageStatusEnum] :message_status The status of the message. One of RECEIVED QUEUED SENDING SENT FAILED DELIVERED ACCEPTED UNDELIVERED.
-
# @option opts [ListMessageDirectionEnum] :message_direction The direction of the message. One of INBOUND OUTBOUND.
-
# @option opts [String] :carrier_name The name of the carrier used for this message. Possible values include but are not limited to Verizon and TMobile. Special characters need to be encoded using URL encoding (i.e. AT&T should be passed as AT%26T).
-
# @option opts [MessageTypeEnum] :message_type The type of message. Either sms or mms.
-
# @option opts [Integer] :error_code The error code of the message.
-
# @option opts [String] :from_date_time The start of the date range to search in ISO 8601 format. Uses the message receive time. The date range to search in is currently 14 days.
-
# @option opts [String] :to_date_time The end of the date range to search in ISO 8601 format. Uses the message receive time. The date range to search in is currently 14 days.
-
# @option opts [String] :campaign_id The campaign ID of the message.
-
# @option opts [String] :sort The field and direction to sort by combined with a colon. Direction is either asc or desc.
-
# @option opts [String] :page_token A base64 encoded value used for pagination of results.
-
# @option opts [Integer] :limit The maximum records requested in search result. Default 100. The sum of limit and after cannot be more than 10000.
-
# @option opts [Boolean] :limit_total_count When set to true, the response's totalCount field will have a maximum value of 10,000. When set to false, or excluded, this will give an accurate totalCount of all messages that match the provided filters. If you are experiencing latency, try using this parameter to limit your results.
-
# @return [MessagesList]
-
1
def list_messages(account_id, opts = {})
-
1
data, _status_code, _headers = list_messages_with_http_info(account_id, opts)
-
data
-
end
-
-
# List Messages
-
# Returns a list of messages based on query parameters.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param [Hash] opts the optional parameters
-
# @option opts [String] :message_id The ID of the message to search for. Special characters need to be encoded using URL encoding. Message IDs could come in different formats, e.g., 9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6 and 1589228074636lm4k2je7j7jklbn2 are valid message ID formats. Note that you must include at least one query parameter.
-
# @option opts [String] :source_tn The phone number that sent the message. Accepted values are: a single full phone number a comma separated list of full phone numbers (maximum of 10) or a single partial phone number (minimum of 5 characters e.g. '%2B1919').
-
# @option opts [String] :destination_tn The phone number that received the message. Accepted values are: a single full phone number a comma separated list of full phone numbers (maximum of 10) or a single partial phone number (minimum of 5 characters e.g. '%2B1919').
-
# @option opts [MessageStatusEnum] :message_status The status of the message. One of RECEIVED QUEUED SENDING SENT FAILED DELIVERED ACCEPTED UNDELIVERED.
-
# @option opts [ListMessageDirectionEnum] :message_direction The direction of the message. One of INBOUND OUTBOUND.
-
# @option opts [String] :carrier_name The name of the carrier used for this message. Possible values include but are not limited to Verizon and TMobile. Special characters need to be encoded using URL encoding (i.e. AT&T should be passed as AT%26T).
-
# @option opts [MessageTypeEnum] :message_type The type of message. Either sms or mms.
-
# @option opts [Integer] :error_code The error code of the message.
-
# @option opts [String] :from_date_time The start of the date range to search in ISO 8601 format. Uses the message receive time. The date range to search in is currently 14 days.
-
# @option opts [String] :to_date_time The end of the date range to search in ISO 8601 format. Uses the message receive time. The date range to search in is currently 14 days.
-
# @option opts [String] :campaign_id The campaign ID of the message.
-
# @option opts [String] :sort The field and direction to sort by combined with a colon. Direction is either asc or desc.
-
# @option opts [String] :page_token A base64 encoded value used for pagination of results.
-
# @option opts [Integer] :limit The maximum records requested in search result. Default 100. The sum of limit and after cannot be more than 10000.
-
# @option opts [Boolean] :limit_total_count When set to true, the response's totalCount field will have a maximum value of 10,000. When set to false, or excluded, this will give an accurate totalCount of all messages that match the provided filters. If you are experiencing latency, try using this parameter to limit your results.
-
# @return [Array<(MessagesList, Integer, Hash)>] MessagesList data, response status code and response headers
-
1
def list_messages_with_http_info(account_id, opts = {})
-
3
if @api_client.config.debugging
-
3
@api_client.config.logger.debug 'Calling API: MessagesApi.list_messages ...'
-
end
-
# verify the required parameter 'account_id' is set
-
3
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling MessagesApi.list_messages"
-
end
-
# resource path
-
2
local_var_path = '/users/{accountId}/messages'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
2
query_params[:'messageId'] = opts[:'message_id'] if !opts[:'message_id'].nil?
-
2
query_params[:'sourceTn'] = opts[:'source_tn'] if !opts[:'source_tn'].nil?
-
2
query_params[:'destinationTn'] = opts[:'destination_tn'] if !opts[:'destination_tn'].nil?
-
2
query_params[:'messageStatus'] = opts[:'message_status'] if !opts[:'message_status'].nil?
-
2
query_params[:'messageDirection'] = opts[:'message_direction'] if !opts[:'message_direction'].nil?
-
2
query_params[:'carrierName'] = opts[:'carrier_name'] if !opts[:'carrier_name'].nil?
-
2
query_params[:'messageType'] = opts[:'message_type'] if !opts[:'message_type'].nil?
-
2
query_params[:'errorCode'] = opts[:'error_code'] if !opts[:'error_code'].nil?
-
2
query_params[:'fromDateTime'] = opts[:'from_date_time'] if !opts[:'from_date_time'].nil?
-
2
query_params[:'toDateTime'] = opts[:'to_date_time'] if !opts[:'to_date_time'].nil?
-
2
query_params[:'campaignId'] = opts[:'campaign_id'] if !opts[:'campaign_id'].nil?
-
2
query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
-
2
query_params[:'pageToken'] = opts[:'page_token'] if !opts[:'page_token'].nil?
-
2
query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
-
2
query_params[:'limitTotalCount'] = opts[:'limit_total_count'] if !opts[:'limit_total_count'].nil?
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body]
-
-
# return_type
-
2
return_type = opts[:debug_return_type] || 'MessagesList'
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"MessagesApi.list_messages",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: MessagesApi#list_messages\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
end
-
end
-
=begin
-
#Bandwidth
-
-
#Bandwidth's Communication APIs
-
-
The version of the OpenAPI document: 1.0.0
-
Contact: letstalk@bandwidth.com
-
Generated by: https://openapi-generator.tech
-
OpenAPI Generator version: 7.0.0
-
-
=end
-
-
1
require 'cgi'
-
-
1
module Bandwidth
-
1
class MFAApi
-
1
attr_accessor :api_client
-
-
1
def initialize(api_client = ApiClient.default)
-
2
@api_client = api_client
-
end
-
# Messaging Authentication Code
-
# Send an MFA code via text message (SMS).
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param code_request [CodeRequest] MFA code request body.
-
# @param [Hash] opts the optional parameters
-
# @return [MessagingCodeResponse]
-
1
def generate_messaging_code(account_id, code_request, opts = {})
-
2
data, _status_code, _headers = generate_messaging_code_with_http_info(account_id, code_request, opts)
-
data
-
end
-
-
# Messaging Authentication Code
-
# Send an MFA code via text message (SMS).
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param code_request [CodeRequest] MFA code request body.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(MessagingCodeResponse, Integer, Hash)>] MessagingCodeResponse data, response status code and response headers
-
1
def generate_messaging_code_with_http_info(account_id, code_request, opts = {})
-
6
if @api_client.config.debugging
-
6
@api_client.config.logger.debug 'Calling API: MFAApi.generate_messaging_code ...'
-
end
-
# verify the required parameter 'account_id' is set
-
6
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling MFAApi.generate_messaging_code"
-
end
-
# verify the required parameter 'code_request' is set
-
5
if @api_client.config.client_side_validation && code_request.nil?
-
1
fail ArgumentError, "Missing the required parameter 'code_request' when calling MFAApi.generate_messaging_code"
-
end
-
# resource path
-
4
local_var_path = '/accounts/{accountId}/code/messaging'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
-
-
# query parameters
-
4
query_params = opts[:query_params] || {}
-
-
# header parameters
-
4
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
4
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
# HTTP header 'Content-Type'
-
4
content_type = @api_client.select_header_content_type(['application/json'])
-
4
if !content_type.nil?
-
4
header_params['Content-Type'] = content_type
-
end
-
-
# form parameters
-
4
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
4
post_body = opts[:debug_body] || @api_client.object_to_http_body(code_request)
-
-
# return_type
-
4
return_type = opts[:debug_return_type] || 'MessagingCodeResponse'
-
-
# auth_names
-
4
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
4
new_options = opts.merge(
-
:operation => :"MFAApi.generate_messaging_code",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
4
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: MFAApi#generate_messaging_code\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Voice Authentication Code
-
# Send an MFA Code via a phone call.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param code_request [CodeRequest] MFA code request body.
-
# @param [Hash] opts the optional parameters
-
# @return [VoiceCodeResponse]
-
1
def generate_voice_code(account_id, code_request, opts = {})
-
2
data, _status_code, _headers = generate_voice_code_with_http_info(account_id, code_request, opts)
-
data
-
end
-
-
# Voice Authentication Code
-
# Send an MFA Code via a phone call.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param code_request [CodeRequest] MFA code request body.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(VoiceCodeResponse, Integer, Hash)>] VoiceCodeResponse data, response status code and response headers
-
1
def generate_voice_code_with_http_info(account_id, code_request, opts = {})
-
4
if @api_client.config.debugging
-
4
@api_client.config.logger.debug 'Calling API: MFAApi.generate_voice_code ...'
-
end
-
# verify the required parameter 'account_id' is set
-
4
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling MFAApi.generate_voice_code"
-
end
-
# verify the required parameter 'code_request' is set
-
3
if @api_client.config.client_side_validation && code_request.nil?
-
1
fail ArgumentError, "Missing the required parameter 'code_request' when calling MFAApi.generate_voice_code"
-
end
-
# resource path
-
2
local_var_path = '/accounts/{accountId}/code/voice'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
# HTTP header 'Content-Type'
-
2
content_type = @api_client.select_header_content_type(['application/json'])
-
2
if !content_type.nil?
-
2
header_params['Content-Type'] = content_type
-
end
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body] || @api_client.object_to_http_body(code_request)
-
-
# return_type
-
2
return_type = opts[:debug_return_type] || 'VoiceCodeResponse'
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"MFAApi.generate_voice_code",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: MFAApi#generate_voice_code\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Verify Authentication Code
-
# Verify a previously sent MFA code.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param verify_code_request [VerifyCodeRequest] MFA code verify request body.
-
# @param [Hash] opts the optional parameters
-
# @return [VerifyCodeResponse]
-
1
def verify_code(account_id, verify_code_request, opts = {})
-
2
data, _status_code, _headers = verify_code_with_http_info(account_id, verify_code_request, opts)
-
data
-
end
-
-
# Verify Authentication Code
-
# Verify a previously sent MFA code.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param verify_code_request [VerifyCodeRequest] MFA code verify request body.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(VerifyCodeResponse, Integer, Hash)>] VerifyCodeResponse data, response status code and response headers
-
1
def verify_code_with_http_info(account_id, verify_code_request, opts = {})
-
4
if @api_client.config.debugging
-
4
@api_client.config.logger.debug 'Calling API: MFAApi.verify_code ...'
-
end
-
# verify the required parameter 'account_id' is set
-
4
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling MFAApi.verify_code"
-
end
-
# verify the required parameter 'verify_code_request' is set
-
3
if @api_client.config.client_side_validation && verify_code_request.nil?
-
1
fail ArgumentError, "Missing the required parameter 'verify_code_request' when calling MFAApi.verify_code"
-
end
-
# resource path
-
2
local_var_path = '/accounts/{accountId}/code/verify'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
# HTTP header 'Content-Type'
-
2
content_type = @api_client.select_header_content_type(['application/json'])
-
2
if !content_type.nil?
-
2
header_params['Content-Type'] = content_type
-
end
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body] || @api_client.object_to_http_body(verify_code_request)
-
-
# return_type
-
2
return_type = opts[:debug_return_type] || 'VerifyCodeResponse'
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"MFAApi.verify_code",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: MFAApi#verify_code\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
end
-
end
-
=begin
-
#Bandwidth
-
-
#Bandwidth's Communication APIs
-
-
The version of the OpenAPI document: 1.0.0
-
Contact: letstalk@bandwidth.com
-
Generated by: https://openapi-generator.tech
-
OpenAPI Generator version: 7.0.0
-
-
=end
-
-
1
require 'cgi'
-
-
1
module Bandwidth
-
1
class PhoneNumberLookupApi
-
1
attr_accessor :api_client
-
-
1
def initialize(api_client = ApiClient.default)
-
2
@api_client = api_client
-
end
-
# Create Lookup
-
# Create a Phone Number Lookup Request.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param lookup_request [LookupRequest] Phone number lookup request.
-
# @param [Hash] opts the optional parameters
-
# @return [CreateLookupResponse]
-
1
def create_lookup(account_id, lookup_request, opts = {})
-
2
data, _status_code, _headers = create_lookup_with_http_info(account_id, lookup_request, opts)
-
data
-
end
-
-
# Create Lookup
-
# Create a Phone Number Lookup Request.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param lookup_request [LookupRequest] Phone number lookup request.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(CreateLookupResponse, Integer, Hash)>] CreateLookupResponse data, response status code and response headers
-
1
def create_lookup_with_http_info(account_id, lookup_request, opts = {})
-
6
if @api_client.config.debugging
-
6
@api_client.config.logger.debug 'Calling API: PhoneNumberLookupApi.create_lookup ...'
-
end
-
# verify the required parameter 'account_id' is set
-
6
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling PhoneNumberLookupApi.create_lookup"
-
end
-
# verify the required parameter 'lookup_request' is set
-
5
if @api_client.config.client_side_validation && lookup_request.nil?
-
1
fail ArgumentError, "Missing the required parameter 'lookup_request' when calling PhoneNumberLookupApi.create_lookup"
-
end
-
# resource path
-
4
local_var_path = '/accounts/{accountId}/tnlookup'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
-
-
# query parameters
-
4
query_params = opts[:query_params] || {}
-
-
# header parameters
-
4
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
4
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
# HTTP header 'Content-Type'
-
4
content_type = @api_client.select_header_content_type(['application/json'])
-
4
if !content_type.nil?
-
4
header_params['Content-Type'] = content_type
-
end
-
-
# form parameters
-
4
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
4
post_body = opts[:debug_body] || @api_client.object_to_http_body(lookup_request)
-
-
# return_type
-
4
return_type = opts[:debug_return_type] || 'CreateLookupResponse'
-
-
# auth_names
-
4
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
4
new_options = opts.merge(
-
:operation => :"PhoneNumberLookupApi.create_lookup",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
4
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: PhoneNumberLookupApi#create_lookup\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Get Lookup Request Status
-
# Get an existing Phone Number Lookup Request.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param request_id [String] The phone number lookup request ID from Bandwidth.
-
# @param [Hash] opts the optional parameters
-
# @return [LookupStatus]
-
1
def get_lookup_status(account_id, request_id, opts = {})
-
2
data, _status_code, _headers = get_lookup_status_with_http_info(account_id, request_id, opts)
-
data
-
end
-
-
# Get Lookup Request Status
-
# Get an existing Phone Number Lookup Request.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param request_id [String] The phone number lookup request ID from Bandwidth.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(LookupStatus, Integer, Hash)>] LookupStatus data, response status code and response headers
-
1
def get_lookup_status_with_http_info(account_id, request_id, opts = {})
-
5
if @api_client.config.debugging
-
5
@api_client.config.logger.debug 'Calling API: PhoneNumberLookupApi.get_lookup_status ...'
-
end
-
# verify the required parameter 'account_id' is set
-
5
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling PhoneNumberLookupApi.get_lookup_status"
-
end
-
# verify the required parameter 'request_id' is set
-
4
if @api_client.config.client_side_validation && request_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'request_id' when calling PhoneNumberLookupApi.get_lookup_status"
-
end
-
# resource path
-
3
local_var_path = '/accounts/{accountId}/tnlookup/{requestId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'requestId' + '}', CGI.escape(request_id.to_s))
-
-
# query parameters
-
3
query_params = opts[:query_params] || {}
-
-
# header parameters
-
3
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
3
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
-
# form parameters
-
3
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
3
post_body = opts[:debug_body]
-
-
# return_type
-
3
return_type = opts[:debug_return_type] || 'LookupStatus'
-
-
# auth_names
-
3
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
3
new_options = opts.merge(
-
:operation => :"PhoneNumberLookupApi.get_lookup_status",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
3
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: PhoneNumberLookupApi#get_lookup_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
end
-
end
-
=begin
-
#Bandwidth
-
-
#Bandwidth's Communication APIs
-
-
The version of the OpenAPI document: 1.0.0
-
Contact: letstalk@bandwidth.com
-
Generated by: https://openapi-generator.tech
-
OpenAPI Generator version: 7.0.0
-
-
=end
-
-
1
require 'cgi'
-
-
1
module Bandwidth
-
1
class RecordingsApi
-
1
attr_accessor :api_client
-
-
1
def initialize(api_client = ApiClient.default)
-
2
@api_client = api_client
-
end
-
# Delete Transcription
-
# Deletes the specified recording's transcription. Note: After the deletion is requested and a `204` is returned, the transcription will not be accessible anymore. However, it is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param recording_id [String] Programmable Voice API Recording ID.
-
# @param [Hash] opts the optional parameters
-
# @return [nil]
-
1
def delete_call_transcription(account_id, call_id, recording_id, opts = {})
-
3
delete_call_transcription_with_http_info(account_id, call_id, recording_id, opts)
-
nil
-
end
-
-
# Delete Transcription
-
# Deletes the specified recording's transcription. Note: After the deletion is requested and a `204` is returned, the transcription will not be accessible anymore. However, it is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param recording_id [String] Programmable Voice API Recording ID.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
-
1
def delete_call_transcription_with_http_info(account_id, call_id, recording_id, opts = {})
-
5
if @api_client.config.debugging
-
5
@api_client.config.logger.debug 'Calling API: RecordingsApi.delete_call_transcription ...'
-
end
-
# verify the required parameter 'account_id' is set
-
5
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.delete_call_transcription"
-
end
-
# verify the required parameter 'call_id' is set
-
4
if @api_client.config.client_side_validation && call_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.delete_call_transcription"
-
end
-
# verify the required parameter 'recording_id' is set
-
3
if @api_client.config.client_side_validation && recording_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.delete_call_transcription"
-
end
-
# resource path
-
2
local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body]
-
-
# return_type
-
2
return_type = opts[:debug_return_type]
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"RecordingsApi.delete_call_transcription",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: RecordingsApi#delete_call_transcription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Delete Recording
-
# Delete the recording information, media and transcription. Note: After the deletion is requested and a `204` is returned, neither the recording metadata nor the actual media nor its transcription will be accessible anymore. However, the media of the specified recording is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param recording_id [String] Programmable Voice API Recording ID.
-
# @param [Hash] opts the optional parameters
-
# @return [nil]
-
1
def delete_recording(account_id, call_id, recording_id, opts = {})
-
3
delete_recording_with_http_info(account_id, call_id, recording_id, opts)
-
nil
-
end
-
-
# Delete Recording
-
# Delete the recording information, media and transcription. Note: After the deletion is requested and a `204` is returned, neither the recording metadata nor the actual media nor its transcription will be accessible anymore. However, the media of the specified recording is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param recording_id [String] Programmable Voice API Recording ID.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
-
1
def delete_recording_with_http_info(account_id, call_id, recording_id, opts = {})
-
5
if @api_client.config.debugging
-
5
@api_client.config.logger.debug 'Calling API: RecordingsApi.delete_recording ...'
-
end
-
# verify the required parameter 'account_id' is set
-
5
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.delete_recording"
-
end
-
# verify the required parameter 'call_id' is set
-
4
if @api_client.config.client_side_validation && call_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.delete_recording"
-
end
-
# verify the required parameter 'recording_id' is set
-
3
if @api_client.config.client_side_validation && recording_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.delete_recording"
-
end
-
# resource path
-
2
local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body]
-
-
# return_type
-
2
return_type = opts[:debug_return_type]
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"RecordingsApi.delete_recording",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: RecordingsApi#delete_recording\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Delete Recording Media
-
# Deletes the specified recording's media.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param recording_id [String] Programmable Voice API Recording ID.
-
# @param [Hash] opts the optional parameters
-
# @return [nil]
-
1
def delete_recording_media(account_id, call_id, recording_id, opts = {})
-
3
delete_recording_media_with_http_info(account_id, call_id, recording_id, opts)
-
nil
-
end
-
-
# Delete Recording Media
-
# Deletes the specified recording's media.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param recording_id [String] Programmable Voice API Recording ID.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
-
1
def delete_recording_media_with_http_info(account_id, call_id, recording_id, opts = {})
-
5
if @api_client.config.debugging
-
5
@api_client.config.logger.debug 'Calling API: RecordingsApi.delete_recording_media ...'
-
end
-
# verify the required parameter 'account_id' is set
-
5
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.delete_recording_media"
-
end
-
# verify the required parameter 'call_id' is set
-
4
if @api_client.config.client_side_validation && call_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.delete_recording_media"
-
end
-
# verify the required parameter 'recording_id' is set
-
3
if @api_client.config.client_side_validation && recording_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.delete_recording_media"
-
end
-
# resource path
-
2
local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body]
-
-
# return_type
-
2
return_type = opts[:debug_return_type]
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"RecordingsApi.delete_recording_media",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: RecordingsApi#delete_recording_media\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Download Recording
-
# Downloads the specified recording.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param recording_id [String] Programmable Voice API Recording ID.
-
# @param [Hash] opts the optional parameters
-
# @return [File]
-
1
def download_call_recording(account_id, call_id, recording_id, opts = {})
-
3
data, _status_code, _headers = download_call_recording_with_http_info(account_id, call_id, recording_id, opts)
-
data
-
end
-
-
# Download Recording
-
# Downloads the specified recording.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param recording_id [String] Programmable Voice API Recording ID.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(File, Integer, Hash)>] File data, response status code and response headers
-
1
def download_call_recording_with_http_info(account_id, call_id, recording_id, opts = {})
-
5
if @api_client.config.debugging
-
5
@api_client.config.logger.debug 'Calling API: RecordingsApi.download_call_recording ...'
-
end
-
# verify the required parameter 'account_id' is set
-
5
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.download_call_recording"
-
end
-
# verify the required parameter 'call_id' is set
-
4
if @api_client.config.client_side_validation && call_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.download_call_recording"
-
end
-
# verify the required parameter 'recording_id' is set
-
3
if @api_client.config.client_side_validation && recording_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.download_call_recording"
-
end
-
# resource path
-
2
local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['audio/vnd.wave', 'audio/mpeg', 'application/json'])
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body]
-
-
# return_type
-
2
return_type = opts[:debug_return_type] || 'File'
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"RecordingsApi.download_call_recording",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: RecordingsApi#download_call_recording\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Get Call Recording
-
# Returns metadata for the specified recording.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param recording_id [String] Programmable Voice API Recording ID.
-
# @param [Hash] opts the optional parameters
-
# @return [CallRecordingMetadata]
-
1
def get_call_recording(account_id, call_id, recording_id, opts = {})
-
3
data, _status_code, _headers = get_call_recording_with_http_info(account_id, call_id, recording_id, opts)
-
data
-
end
-
-
# Get Call Recording
-
# Returns metadata for the specified recording.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param recording_id [String] Programmable Voice API Recording ID.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(CallRecordingMetadata, Integer, Hash)>] CallRecordingMetadata data, response status code and response headers
-
1
def get_call_recording_with_http_info(account_id, call_id, recording_id, opts = {})
-
8
if @api_client.config.debugging
-
8
@api_client.config.logger.debug 'Calling API: RecordingsApi.get_call_recording ...'
-
end
-
# verify the required parameter 'account_id' is set
-
8
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.get_call_recording"
-
end
-
# verify the required parameter 'call_id' is set
-
7
if @api_client.config.client_side_validation && call_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.get_call_recording"
-
end
-
# verify the required parameter 'recording_id' is set
-
6
if @api_client.config.client_side_validation && recording_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.get_call_recording"
-
end
-
# resource path
-
5
local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s))
-
-
# query parameters
-
5
query_params = opts[:query_params] || {}
-
-
# header parameters
-
5
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
5
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
-
# form parameters
-
5
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
5
post_body = opts[:debug_body]
-
-
# return_type
-
5
return_type = opts[:debug_return_type] || 'CallRecordingMetadata'
-
-
# auth_names
-
5
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
5
new_options = opts.merge(
-
:operation => :"RecordingsApi.get_call_recording",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
5
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: RecordingsApi#get_call_recording\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Get Transcription
-
# Downloads the specified transcription. If the transcribed recording was multi-channel, then there will be 2 transcripts. The caller/called party transcript will be the first item while [`<PlayAudio>`](/docs/voice/bxml/playAudio) and [`<SpeakSentence>`](/docs/voice/bxml/speakSentence) transcript will be the second item. During a [`<Transfer>`](/docs/voice/bxml/transfer) the A-leg transcript will be the first item while the B-leg transcript will be the second item.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param recording_id [String] Programmable Voice API Recording ID.
-
# @param [Hash] opts the optional parameters
-
# @return [TranscriptionList]
-
1
def get_call_transcription(account_id, call_id, recording_id, opts = {})
-
3
data, _status_code, _headers = get_call_transcription_with_http_info(account_id, call_id, recording_id, opts)
-
data
-
end
-
-
# Get Transcription
-
# Downloads the specified transcription. If the transcribed recording was multi-channel, then there will be 2 transcripts. The caller/called party transcript will be the first item while [`<PlayAudio>`](/docs/voice/bxml/playAudio) and [`<SpeakSentence>`](/docs/voice/bxml/speakSentence) transcript will be the second item. During a [`<Transfer>`](/docs/voice/bxml/transfer) the A-leg transcript will be the first item while the B-leg transcript will be the second item.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param recording_id [String] Programmable Voice API Recording ID.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(TranscriptionList, Integer, Hash)>] TranscriptionList data, response status code and response headers
-
1
def get_call_transcription_with_http_info(account_id, call_id, recording_id, opts = {})
-
5
if @api_client.config.debugging
-
5
@api_client.config.logger.debug 'Calling API: RecordingsApi.get_call_transcription ...'
-
end
-
# verify the required parameter 'account_id' is set
-
5
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.get_call_transcription"
-
end
-
# verify the required parameter 'call_id' is set
-
4
if @api_client.config.client_side_validation && call_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.get_call_transcription"
-
end
-
# verify the required parameter 'recording_id' is set
-
3
if @api_client.config.client_side_validation && recording_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.get_call_transcription"
-
end
-
# resource path
-
2
local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body]
-
-
# return_type
-
2
return_type = opts[:debug_return_type] || 'TranscriptionList'
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"RecordingsApi.get_call_transcription",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: RecordingsApi#get_call_transcription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Get Call Recordings
-
# 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 account_id [String] Your Bandwidth Account ID.
-
# @param [Hash] opts the optional parameters
-
# @option opts [String] :to Filter results by the `to` field.
-
# @option opts [String] :from Filter results by the `from` field.
-
# @option opts [String] :min_start_time Filter results to recordings which have a `startTime` after or including `minStartTime` (in ISO8601 format).
-
# @option opts [String] :max_start_time Filter results to recordings which have a `startTime` before `maxStartTime` (in ISO8601 format).
-
# @return [Array<CallRecordingMetadata>]
-
1
def list_account_call_recordings(account_id, opts = {})
-
1
data, _status_code, _headers = list_account_call_recordings_with_http_info(account_id, opts)
-
data
-
end
-
-
# Get Call Recordings
-
# 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 account_id [String] Your Bandwidth Account ID.
-
# @param [Hash] opts the optional parameters
-
# @option opts [String] :to Filter results by the `to` field.
-
# @option opts [String] :from Filter results by the `from` field.
-
# @option opts [String] :min_start_time Filter results to recordings which have a `startTime` after or including `minStartTime` (in ISO8601 format).
-
# @option opts [String] :max_start_time Filter results to recordings which have a `startTime` before `maxStartTime` (in ISO8601 format).
-
# @return [Array<(Array<CallRecordingMetadata>, Integer, Hash)>] Array<CallRecordingMetadata> data, response status code and response headers
-
1
def list_account_call_recordings_with_http_info(account_id, opts = {})
-
3
if @api_client.config.debugging
-
3
@api_client.config.logger.debug 'Calling API: RecordingsApi.list_account_call_recordings ...'
-
end
-
# verify the required parameter 'account_id' is set
-
3
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.list_account_call_recordings"
-
end
-
# resource path
-
2
local_var_path = '/accounts/{accountId}/recordings'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
2
query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?
-
2
query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?
-
2
query_params[:'minStartTime'] = opts[:'min_start_time'] if !opts[:'min_start_time'].nil?
-
2
query_params[:'maxStartTime'] = opts[:'max_start_time'] if !opts[:'max_start_time'].nil?
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body]
-
-
# return_type
-
2
return_type = opts[:debug_return_type] || 'Array<CallRecordingMetadata>'
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"RecordingsApi.list_account_call_recordings",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: RecordingsApi#list_account_call_recordings\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# List Call Recordings
-
# Returns a (potentially empty) list of metadata for the recordings that took place during the specified call.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<CallRecordingMetadata>]
-
1
def list_call_recordings(account_id, call_id, opts = {})
-
2
data, _status_code, _headers = list_call_recordings_with_http_info(account_id, call_id, opts)
-
data
-
end
-
-
# List Call Recordings
-
# Returns a (potentially empty) list of metadata for the recordings that took place during the specified call.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(Array<CallRecordingMetadata>, Integer, Hash)>] Array<CallRecordingMetadata> data, response status code and response headers
-
1
def list_call_recordings_with_http_info(account_id, call_id, opts = {})
-
4
if @api_client.config.debugging
-
4
@api_client.config.logger.debug 'Calling API: RecordingsApi.list_call_recordings ...'
-
end
-
# verify the required parameter 'account_id' is set
-
4
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.list_call_recordings"
-
end
-
# verify the required parameter 'call_id' is set
-
3
if @api_client.config.client_side_validation && call_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.list_call_recordings"
-
end
-
# resource path
-
2
local_var_path = '/accounts/{accountId}/calls/{callId}/recordings'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body]
-
-
# return_type
-
2
return_type = opts[:debug_return_type] || 'Array<CallRecordingMetadata>'
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"RecordingsApi.list_call_recordings",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: RecordingsApi#list_call_recordings\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Create Transcription Request
-
# Generate the transcription for a specific recording. Transcription can succeed only for recordings of length greater than 500 milliseconds and less than 4 hours.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param recording_id [String] Programmable Voice API Recording ID.
-
# @param transcribe_recording [TranscribeRecording]
-
# @param [Hash] opts the optional parameters
-
# @return [nil]
-
1
def transcribe_call_recording(account_id, call_id, recording_id, transcribe_recording, opts = {})
-
4
transcribe_call_recording_with_http_info(account_id, call_id, recording_id, transcribe_recording, opts)
-
nil
-
end
-
-
# Create Transcription Request
-
# Generate the transcription for a specific recording. Transcription can succeed only for recordings of length greater than 500 milliseconds and less than 4 hours.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param recording_id [String] Programmable Voice API Recording ID.
-
# @param transcribe_recording [TranscribeRecording]
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
-
1
def transcribe_call_recording_with_http_info(account_id, call_id, recording_id, transcribe_recording, opts = {})
-
6
if @api_client.config.debugging
-
6
@api_client.config.logger.debug 'Calling API: RecordingsApi.transcribe_call_recording ...'
-
end
-
# verify the required parameter 'account_id' is set
-
6
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.transcribe_call_recording"
-
end
-
# verify the required parameter 'call_id' is set
-
5
if @api_client.config.client_side_validation && call_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.transcribe_call_recording"
-
end
-
# verify the required parameter 'recording_id' is set
-
4
if @api_client.config.client_side_validation && recording_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.transcribe_call_recording"
-
end
-
# verify the required parameter 'transcribe_recording' is set
-
3
if @api_client.config.client_side_validation && transcribe_recording.nil?
-
1
fail ArgumentError, "Missing the required parameter 'transcribe_recording' when calling RecordingsApi.transcribe_call_recording"
-
end
-
# resource path
-
2
local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s))
-
-
# query parameters
-
2
query_params = opts[:query_params] || {}
-
-
# header parameters
-
2
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
2
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
# HTTP header 'Content-Type'
-
2
content_type = @api_client.select_header_content_type(['application/json'])
-
2
if !content_type.nil?
-
2
header_params['Content-Type'] = content_type
-
end
-
-
# form parameters
-
2
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
2
post_body = opts[:debug_body] || @api_client.object_to_http_body(transcribe_recording)
-
-
# return_type
-
2
return_type = opts[:debug_return_type]
-
-
# auth_names
-
2
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
2
new_options = opts.merge(
-
:operation => :"RecordingsApi.transcribe_call_recording",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
2
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: RecordingsApi#transcribe_call_recording\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
-
# Update Recording
-
# Pause or resume a recording on an active phone call.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param update_call_recording [UpdateCallRecording]
-
# @param [Hash] opts the optional parameters
-
# @return [nil]
-
1
def update_call_recording_state(account_id, call_id, update_call_recording, opts = {})
-
3
update_call_recording_state_with_http_info(account_id, call_id, update_call_recording, opts)
-
nil
-
end
-
-
# Update Recording
-
# Pause or resume a recording on an active phone call.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param call_id [String] Programmable Voice API Call ID.
-
# @param update_call_recording [UpdateCallRecording]
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
-
1
def update_call_recording_state_with_http_info(account_id, call_id, update_call_recording, opts = {})
-
6
if @api_client.config.debugging
-
6
@api_client.config.logger.debug 'Calling API: RecordingsApi.update_call_recording_state ...'
-
end
-
# verify the required parameter 'account_id' is set
-
6
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.update_call_recording_state"
-
end
-
# verify the required parameter 'call_id' is set
-
5
if @api_client.config.client_side_validation && call_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.update_call_recording_state"
-
end
-
# verify the required parameter 'update_call_recording' is set
-
4
if @api_client.config.client_side_validation && update_call_recording.nil?
-
1
fail ArgumentError, "Missing the required parameter 'update_call_recording' when calling RecordingsApi.update_call_recording_state"
-
end
-
# resource path
-
3
local_var_path = '/accounts/{accountId}/calls/{callId}/recording'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s))
-
-
# query parameters
-
3
query_params = opts[:query_params] || {}
-
-
# header parameters
-
3
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
3
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
# HTTP header 'Content-Type'
-
3
content_type = @api_client.select_header_content_type(['application/json'])
-
3
if !content_type.nil?
-
3
header_params['Content-Type'] = content_type
-
end
-
-
# form parameters
-
3
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
3
post_body = opts[:debug_body] || @api_client.object_to_http_body(update_call_recording)
-
-
# return_type
-
3
return_type = opts[:debug_return_type]
-
-
# auth_names
-
3
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
3
new_options = opts.merge(
-
:operation => :"RecordingsApi.update_call_recording_state",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
3
data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
-
3
if @api_client.config.debugging
-
3
@api_client.config.logger.debug "API called: RecordingsApi#update_call_recording_state\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
3
return data, status_code, headers
-
end
-
end
-
end
-
=begin
-
#Bandwidth
-
-
#Bandwidth's Communication APIs
-
-
The version of the OpenAPI document: 1.0.0
-
Contact: letstalk@bandwidth.com
-
Generated by: https://openapi-generator.tech
-
OpenAPI Generator version: 7.0.0
-
-
=end
-
-
1
require 'cgi'
-
-
1
module Bandwidth
-
1
class StatisticsApi
-
1
attr_accessor :api_client
-
-
1
def initialize(api_client = ApiClient.default)
-
2
@api_client = api_client
-
end
-
# Get Account Statistics
-
# Returns details about the current state of the account.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param [Hash] opts the optional parameters
-
# @return [AccountStatistics]
-
1
def get_statistics(account_id, opts = {})
-
1
data, _status_code, _headers = get_statistics_with_http_info(account_id, opts)
-
data
-
end
-
-
# Get Account Statistics
-
# Returns details about the current state of the account.
-
# @param account_id [String] Your Bandwidth Account ID.
-
# @param [Hash] opts the optional parameters
-
# @return [Array<(AccountStatistics, Integer, Hash)>] AccountStatistics data, response status code and response headers
-
1
def get_statistics_with_http_info(account_id, opts = {})
-
5
if @api_client.config.debugging
-
5
@api_client.config.logger.debug 'Calling API: StatisticsApi.get_statistics ...'
-
end
-
# verify the required parameter 'account_id' is set
-
5
if @api_client.config.client_side_validation && account_id.nil?
-
1
fail ArgumentError, "Missing the required parameter 'account_id' when calling StatisticsApi.get_statistics"
-
end
-
# resource path
-
4
local_var_path = '/accounts/{accountId}/statistics'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
-
-
# query parameters
-
4
query_params = opts[:query_params] || {}
-
-
# header parameters
-
4
header_params = opts[:header_params] || {}
-
# HTTP header 'Accept' (if needed)
-
4
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
-
-
# form parameters
-
4
form_params = opts[:form_params] || {}
-
-
# http body (model)
-
4
post_body = opts[:debug_body]
-
-
# return_type
-
4
return_type = opts[:debug_return_type] || 'AccountStatistics'
-
-
# auth_names
-
4
auth_names = opts[:debug_auth_names] || ['Basic']
-
-
4
new_options = opts.merge(
-
:operation => :"StatisticsApi.get_statistics",
-
:header_params => header_params,
-
:query_params => query_params,
-
:form_params => form_params,
-
:body => post_body,
-
:auth_names => auth_names,
-
:return_type => return_type
-
)
-
-
4
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
-
2
if @api_client.config.debugging
-
2
@api_client.config.logger.debug "API called: StatisticsApi#get_statistics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
-
end
-
2
return data, status_code, headers
-
end
-
end
-
end
-
=begin
-
#Bandwidth
-
-
#Bandwidth's Communication APIs
-
-
The version of the OpenAPI document: 1.0.0
-
Contact: letstalk@bandwidth.com
-
Generated by: https://openapi-generator.tech
-
OpenAPI Generator version: 7.0.0
-
-
=end
-
-
1
require 'date'
-
1
require 'json'
-
1
require 'logger'
-
1
require 'tempfile'
-
1
require 'time'
-
1
require 'faraday'
-
1
require 'faraday/multipart' if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
-
-
1
module Bandwidth
-
1
class ApiClient
-
# The Configuration object holding settings to be used in the API client.
-
1
attr_accessor :config
-
-
# Defines the headers to be used in HTTP requests of all API calls by default.
-
#
-
# @return [Hash]
-
1
attr_accessor :default_headers
-
-
# Initializes the ApiClient
-
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
-
1
def initialize(config = Configuration.default)
-
27
@config = config
-
27
@user_agent = "OpenAPI-Generator/#{VERSION}/ruby"
-
@default_headers = {
-
27
'Content-Type' => 'application/json',
-
'User-Agent' => @user_agent
-
}
-
end
-
-
1
def self.default
-
19
@@default ||= ApiClient.new
-
end
-
-
# Call an API with given options.
-
#
-
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
-
# the data deserialized from response body (could be nil), response status code and response headers.
-
1
def call_api(http_method, path, opts = {})
-
begin
-
109
response = connection(opts).public_send(http_method.to_sym.downcase) do |req|
-
109
build_request(http_method, path, req, opts)
-
end
-
-
107
if config.debugging
-
102
config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
-
end
-
-
107
unless response.success?
-
18
if response.status == 0 && response.respond_to?(:return_message)
-
# Errors from libcurl will be made visible here
-
fail ApiError.new(code: 0,
-
message: response.return_message)
-
else
-
18
fail ApiError.new(code: response.status,
-
response_headers: response.headers,
-
response_body: response.body),
-
response.reason_phrase
-
end
-
end
-
rescue Faraday::TimeoutError
-
1
fail ApiError.new('Connection timed out')
-
rescue Faraday::ConnectionFailed
-
1
fail ApiError.new('Connection failed')
-
end
-
-
89
if opts[:return_type]
-
57
data = deserialize(response, opts[:return_type])
-
else
-
32
data = nil
-
end
-
89
return data, response.status, response.headers
-
end
-
-
# Builds the HTTP request
-
#
-
# @param [String] http_method HTTP method/verb (e.g. POST)
-
# @param [String] path URL path (e.g. /account/new)
-
# @option opts [Hash] :header_params Header parameters
-
# @option opts [Hash] :query_params Query parameters
-
# @option opts [Hash] :form_params Query parameters
-
# @option opts [Object] :body HTTP body (JSON/XML)
-
# @return [Faraday::Request] A Faraday Request
-
1
def build_request(http_method, path, request, opts = {})
-
109
url = build_request_url(path, opts)
-
109
http_method = http_method.to_sym.downcase
-
-
109
header_params = @default_headers.merge(opts[:header_params] || {})
-
109
query_params = opts[:query_params] || {}
-
109
form_params = opts[:form_params] || {}
-
-
109
update_params_for_auth! header_params, query_params, opts[:auth_names]
-
-
109
if [:post, :patch, :put, :delete].include?(http_method)
-
60
req_body = build_request_body(header_params, form_params, opts[:body])
-
60
if config.debugging
-
56
config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
-
end
-
end
-
109
request.headers = header_params
-
109
request.body = req_body
-
-
# Overload default options only if provided
-
109
request.options.params_encoder = config.params_encoder if config.params_encoder
-
109
request.options.timeout = config.timeout if config.timeout
-
-
109
request.url url
-
109
request.params = query_params
-
109
download_file(request) if opts[:return_type] == 'File' || opts[:return_type] == 'Binary'
-
109
request
-
end
-
-
# Builds the HTTP request body
-
#
-
# @param [Hash] header_params Header parameters
-
# @param [Hash] form_params Query parameters
-
# @param [Object] body HTTP body (JSON/XML)
-
# @return [String] HTTP body data in the form of string
-
1
def build_request_body(header_params, form_params, body)
-
# http form
-
62
if header_params['Content-Type'] == 'application/x-www-form-urlencoded'
-
1
data = URI.encode_www_form(form_params)
-
61
elsif header_params['Content-Type'] == 'multipart/form-data'
-
1
data = {}
-
1
form_params.each do |key, value|
-
3
case value
-
when ::File, ::Tempfile
-
# TODO hardcode to application/octet-stream, need better way to detect content type
-
1
data[key] = Faraday::FilePart.new(value.path, 'application/octet-stream', value.path)
-
when ::Array, nil
-
# let Faraday handle Array and nil parameters
-
1
data[key] = value
-
else
-
1
data[key] = value.to_s
-
end
-
end
-
60
elsif body
-
50
data = body.is_a?(String) ? body : body.to_json
-
else
-
10
data = nil
-
end
-
62
data
-
end
-
-
1
def download_file(request)
-
11
@stream = []
-
-
# handle streaming Responses
-
11
request.options.on_data = Proc.new do |chunk, overall_received_bytes|
-
11
@stream << chunk
-
end
-
end
-
-
1
def connection(opts)
-
109
opts[:header_params]['Content-Type'] == 'multipart/form-data' ? connection_multipart : connection_regular
-
end
-
-
1
def connection_multipart
-
1
@connection_multipart ||= build_connection do |conn|
-
1
conn.request :multipart
-
1
conn.request :url_encoded
-
end
-
end
-
-
1
def connection_regular
-
108
@connection_regular ||= build_connection
-
end
-
-
1
def build_connection
-
10
Faraday.new(url: config.base_url, ssl: ssl_options, proxy: config.proxy) do |conn|
-
10
basic_auth(conn)
-
10
config.configure_middleware(conn)
-
10
yield(conn) if block_given?
-
10
conn.adapter(Faraday.default_adapter)
-
10
config.configure_connection(conn)
-
end
-
end
-
-
1
def ssl_options
-
{
-
10
ca_file: config.ssl_ca_file,
-
verify: config.ssl_verify,
-
verify_mode: config.ssl_verify_mode,
-
client_cert: config.ssl_client_cert,
-
client_key: config.ssl_client_key
-
}
-
end
-
-
1
def basic_auth(conn)
-
11
if config.username && config.password
-
1
if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
-
1
conn.request(:authorization, :basic, config.username, config.password)
-
else
-
conn.request(:basic_auth, config.username, config.password)
-
end
-
end
-
end
-
-
# Check if the given MIME is a JSON MIME.
-
# JSON MIME examples:
-
# application/json
-
# application/json; charset=UTF8
-
# APPLICATION/JSON
-
# */*
-
# @param [String] mime MIME
-
# @return [Boolean] True if the MIME is application/json
-
1
def json_mime?(mime)
-
229
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
-
end
-
-
# Deserialize the response to the given return type.
-
#
-
# @param [Response] response HTTP response
-
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
-
1
def deserialize(response, return_type)
-
59
body = response.body
-
-
# handle file downloading - return the File instance processed in request callbacks
-
# note that response body is empty when the file is written in chunks in request on_body callback
-
59
if return_type == 'File'
-
10
if @config.return_binary_data == true
-
# return byte stream
-
8
encoding = body.encoding
-
8
return @stream.join.force_encoding(encoding)
-
else
-
# return file instead of binary data
-
2
content_disposition = response.headers['Content-Disposition']
-
2
if content_disposition && content_disposition =~ /filename=/i
-
1
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
-
1
prefix = sanitize_filename(filename)
-
else
-
1
prefix = 'download-'
-
end
-
2
prefix = prefix + '-' unless prefix.end_with?('-')
-
2
encoding = body.encoding
-
2
@tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
-
2
@tempfile.write(@stream.join.force_encoding(encoding))
-
2
@tempfile.close
-
2
@config.logger.info "Temp file written to #{@tempfile.path}, please copy the file to a proper folder "\
-
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
-
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
-
"explicitly with `tempfile.delete`"
-
2
return @tempfile
-
end
-
end
-
-
49
return nil if body.nil? || body.empty?
-
-
# return response body directly for String return type
-
49
return body if return_type == 'String'
-
-
# ensuring a default content type
-
49
content_type = response.headers['Content-Type'] || 'application/json'
-
-
49
fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
-
-
begin
-
49
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
-
rescue JSON::ParserError => e
-
2
if %w(String Date Time).include?(return_type)
-
1
data = body
-
else
-
1
raise e
-
end
-
end
-
-
48
convert_to_type data, return_type
-
end
-
-
# Convert data to the given return type.
-
# @param [Object] data Data to be converted
-
# @param [String] return_type Return type
-
# @return [Mixed] Data in a particular type
-
1
def convert_to_type(data, return_type)
-
1349
return nil if data.nil?
-
1349
case return_type
-
when 'String'
-
2
data.to_s
-
when 'Integer'
-
5
data.to_i
-
when 'Float'
-
1
data.to_f
-
when 'Boolean'
-
1
data == true
-
when 'Time'
-
# parse date time (expecting ISO 8601 format)
-
1
Time.parse data
-
when 'Date'
-
# parse date time (expecting ISO 8601 format)
-
2
Date.parse data
-
when 'Object'
-
# generic object (usually a Hash), return directly
-
1
data
-
when /\AArray<(.+)>\z/
-
# e.g. Array<Pet>
-
13
sub_type = $1
-
1302
data.map { |item| convert_to_type(item, sub_type) }
-
when /\AHash\<String, (.+)\>\z/
-
# e.g. Hash<String, Integer>
-
2
sub_type = $1
-
2
{}.tap do |hash|
-
4
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
-
end
-
else
-
# models (e.g. Pet) or oneOf
-
1321
klass = Bandwidth.const_get(return_type)
-
1321
klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
-
end
-
end
-
-
# Sanitize filename by removing path.
-
# e.g. ../../sun.gif becomes sun.gif
-
#
-
# @param [String] filename the filename to be sanitized
-
# @return [String] the sanitized filename
-
1
def sanitize_filename(filename)
-
10
filename.gsub(/.*[\/\\]/, '')
-
end
-
-
1
def build_request_url(path, opts = {})
-
# Add leading and trailing slashes to path
-
110
path = "/#{path}".gsub(/\/+/, '/')
-
110
@config.base_url(opts[:operation]) + path
-
end
-
-
# Update header and query params based on authentication settings.
-
#
-
# @param [Hash] header_params Header parameters
-
# @param [Hash] query_params Query parameters
-
# @param [String] auth_names Authentication scheme name
-
1
def update_params_for_auth!(header_params, query_params, auth_names)
-
109
Array(auth_names).each do |auth_name|
-
109
auth_setting = @config.auth_settings[auth_name]
-
109
next unless auth_setting
-
109
case auth_setting[:in]
-
109
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
-
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
-
else fail ArgumentError, 'Authentication token must be in `query` or `header`'
-
end
-
end
-
end
-
-
# Sets user agent in HTTP header
-
#
-
# @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
-
1
def user_agent=(user_agent)
-
1
@user_agent = user_agent
-
1
@default_headers['User-Agent'] = @user_agent
-
end
-
-
# Return Accept header based on an array of accepts provided.
-
# @param [Array] accepts array for Accept
-
# @return [String] the Accept header (e.g. application/json)
-
1
def select_header_accept(accepts)
-
107
return nil if accepts.nil? || accepts.empty?
-
# use JSON when present, otherwise use all of the provided
-
224
json_accept = accepts.find { |s| json_mime?(s) }
-
105
json_accept || accepts.join(',')
-
end
-
-
# Return Content-Type header based on an array of content types provided.
-
# @param [Array] content_types array for Content-Type
-
# @return [String] the Content-Type header (e.g. application/json)
-
1
def select_header_content_type(content_types)
-
# return nil by default
-
53
return if content_types.nil? || content_types.empty?
-
# use JSON when present, otherwise use the first one
-
104
json_content_type = content_types.find { |s| json_mime?(s) }
-
51
json_content_type || content_types.first
-
end
-
-
# Convert object (array, hash, object, etc) to JSON string.
-
# @param [Object] model object to be converted into JSON string
-
# @return [String] JSON string representation of the object
-
1
def object_to_http_body(model)
-
48
return model if model.nil? || model.is_a?(String)
-
41
local_body = nil
-
41
if model.is_a?(Array)
-
4
local_body = model.map { |m| object_to_hash(m) }
-
else
-
40
local_body = object_to_hash(model)
-
end
-
41
local_body.to_json
-
end
-
-
# Convert object(non-array) to hash.
-
# @param [Object] obj object to be converted into JSON string
-
# @return [String] JSON string representation of the object
-
1
def object_to_hash(obj)
-
46
if obj.respond_to?(:to_hash)
-
41
obj.to_hash
-
else
-
5
obj
-
end
-
end
-
-
# Build parameter value according to the given collection format.
-
# @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
-
1
def build_collection_param(param, collection_format)
-
6
case collection_format
-
when :csv
-
1
param.join(',')
-
when :ssv
-
1
param.join(' ')
-
when :tsv
-
1
param.join("\t")
-
when :pipes
-
1
param.join('|')
-
when :multi
-
# return the array directly as typhoeus will handle it as expected
-
1
param
-
else
-
1
fail "unknown collection format: #{collection_format.inspect}"
-
end
-
end
-
end
-
end
-
=begin
-
#Bandwidth
-
-
#Bandwidth's Communication APIs
-
-
The version of the OpenAPI document: 1.0.0
-
Contact: letstalk@bandwidth.com
-
Generated by: https://openapi-generator.tech
-
OpenAPI Generator version: 7.0.0
-
-
=end
-
-
1
module Bandwidth
-
1
class ApiError < StandardError
-
1
attr_reader :code, :response_headers, :response_body
-
-
# Usage examples:
-
# ApiError.new
-
# ApiError.new("message")
-
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
-
# ApiError.new(:code => 404, :message => "Not Found")
-
1
def initialize(arg = nil)
-
23
if arg.is_a? Hash
-
19
if arg.key?(:message) || arg.key?('message')
-
1
super(arg[:message] || arg['message'])
-
else
-
18
super arg
-
end
-
-
19
arg.each do |k, v|
-
55
instance_variable_set "@#{k}", v
-
end
-
else
-
4
super arg
-
4
@message = arg
-
end
-
end
-
-
# Override to_s to display a friendly error message
-
1
def to_s
-
1
message
-
end
-
-
1
def message
-
5
if @message.nil?
-
1
msg = 'Error message: the server returns an error'
-
else
-
4
msg = @message
-
end
-
-
5
msg += "\nHTTP status code: #{code}" if code
-
5
msg += "\nResponse headers: #{response_headers}" if response_headers
-
5
msg += "\nResponse body: #{response_body}" if response_body
-
-
5
msg
-
end
-
end
-
end
-
=begin
-
#Bandwidth
-
-
#Bandwidth's Communication APIs
-
-
The version of the OpenAPI document: 1.0.0
-
Contact: letstalk@bandwidth.com
-
Generated by: https://openapi-generator.tech
-
OpenAPI Generator version: 7.0.0
-
-
=end
-
-
1
module Bandwidth
-
1
class Configuration
-
# Defines url scheme
-
1
attr_accessor :scheme
-
-
# Defines url host
-
1
attr_accessor :host
-
-
# Defines url base path
-
1
attr_accessor :base_path
-
-
# Define server configuration index
-
1
attr_accessor :server_index
-
-
# Define server operation configuration index
-
1
attr_accessor :server_operation_index
-
-
# Default server variables
-
1
attr_accessor :server_variables
-
-
# Default server operation variables
-
1
attr_accessor :server_operation_variables
-
-
# Defines API keys used with API Key authentications.
-
#
-
# @return [Hash] key: parameter name, value: parameter value (API key)
-
#
-
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
-
# config.api_key['api_key'] = 'xxx'
-
1
attr_accessor :api_key
-
-
# Defines API key prefixes used with API Key authentications.
-
#
-
# @return [Hash] key: parameter name, value: API key prefix
-
#
-
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
-
# config.api_key_prefix['api_key'] = 'Token'
-
1
attr_accessor :api_key_prefix
-
-
# Defines the username used with HTTP basic authentication.
-
#
-
# @return [String]
-
1
attr_accessor :username
-
-
# Defines the password used with HTTP basic authentication.
-
#
-
# @return [String]
-
1
attr_accessor :password
-
-
# Defines the access token (Bearer) used with OAuth2.
-
1
attr_accessor :access_token
-
-
# Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
-
# Overrides the access_token if set
-
# @return [Proc]
-
1
attr_accessor :access_token_getter
-
-
# Set this to return data as binary instead of downloading a temp file. When enabled (set to true)
-
# HTTP responses with return type `File` will be returned as a stream of binary data.
-
# Default to false.
-
1
attr_accessor :return_binary_data
-
-
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
-
# details will be logged with `logger.debug` (see the `logger` attribute).
-
# Default to false.
-
#
-
# @return [true, false]
-
1
attr_accessor :debugging
-
-
# Defines the logger used for debugging.
-
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
-
#
-
# @return [#debug]
-
1
attr_accessor :logger
-
-
# Defines the temporary folder to store downloaded files
-
# (for API endpoints that have file response).
-
# Default to use `Tempfile`.
-
#
-
# @return [String]
-
1
attr_accessor :temp_folder_path
-
-
# The time limit for HTTP request in seconds.
-
# Default to 0 (never times out).
-
1
attr_accessor :timeout
-
-
# Set this to false to skip client side validation in the operation.
-
# Default to true.
-
# @return [true, false]
-
1
attr_accessor :client_side_validation
-
-
### TLS/SSL setting
-
# Set this to false to skip verifying SSL certificate when calling API from https server.
-
# Default to true.
-
#
-
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
-
#
-
# @return [true, false]
-
1
attr_accessor :ssl_verify
-
-
### TLS/SSL setting
-
# Any `OpenSSL::SSL::` constant (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL.html)
-
#
-
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
-
#
-
1
attr_accessor :ssl_verify_mode
-
-
### TLS/SSL setting
-
# Set this to customize the certificate file to verify the peer.
-
#
-
# @return [String] the path to the certificate file
-
1
attr_accessor :ssl_ca_file
-
-
### TLS/SSL setting
-
# Client certificate file (for client certificate)
-
1
attr_accessor :ssl_client_cert
-
-
### TLS/SSL setting
-
# Client private key file (for client certificate)
-
1
attr_accessor :ssl_client_key
-
-
### Proxy setting
-
# HTTP Proxy settings
-
1
attr_accessor :proxy
-
-
# Set this to customize parameters encoder of array parameter.
-
# Default to nil. Faraday uses NestedParamsEncoder when nil.
-
#
-
# @see The params_encoder option of Faraday. Related source code:
-
# https://github.com/lostisland/faraday/tree/main/lib/faraday/encoders
-
1
attr_accessor :params_encoder
-
-
-
1
attr_accessor :inject_format
-
-
1
attr_accessor :force_ending_format
-
-
1
def initialize
-
36
@scheme = 'http'
-
36
@host = 'localhost'
-
36
@base_path = ''
-
36
@server_index = nil
-
36
@server_operation_index = {}
-
36
@server_variables = {}
-
36
@server_operation_variables = {}
-
36
@api_key = {}
-
36
@api_key_prefix = {}
-
36
@client_side_validation = true
-
36
@ssl_verify = true
-
36
@ssl_verify_mode = nil
-
36
@ssl_ca_file = nil
-
36
@ssl_client_cert = nil
-
36
@ssl_client_key = nil
-
41
@middlewares = Hash.new { |h, k| h[k] = [] }
-
36
@configure_connection_blocks = []
-
36
@timeout = 60
-
# return data as binary instead of file
-
36
@return_binary_data = false
-
36
@params_encoder = nil
-
36
@debugging = false
-
36
@inject_format = false
-
36
@force_ending_format = false
-
36
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
-
-
36
yield(self) if block_given?
-
end
-
-
# The default Configuration object.
-
1
def self.default
-
43
@@default ||= Configuration.new
-
end
-
-
1
def configure
-
1
yield(self) if block_given?
-
end
-
-
1
def scheme=(scheme)
-
# remove :// from scheme
-
2
@scheme = scheme.sub(/:\/\//, '')
-
end
-
-
1
def host=(host)
-
# remove http(s):// and anything after a slash
-
2
@host = host.sub(/https?:\/\//, '').split('/').first
-
end
-
-
1
def base_path=(base_path)
-
# Add leading and trailing slashes to base_path
-
2
@base_path = "/#{base_path}".gsub(/\/+/, '/')
-
2
@base_path = '' if @base_path == '/'
-
end
-
-
# Returns base URL for specified operation based on server settings
-
1
def base_url(operation = nil)
-
125
if operation_server_settings.key?(operation) then
-
111
index = server_operation_index.fetch(operation, server_index)
-
111
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
-
else
-
14
server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil)
-
end
-
end
-
-
# Gets API key (with prefix if set).
-
# @param [String] param_name the parameter name of API key auth
-
1
def api_key_with_prefix(param_name, param_alias = nil)
-
2
key = @api_key[param_name]
-
2
key = @api_key.fetch(param_alias, key) unless param_alias.nil?
-
2
if @api_key_prefix[param_name]
-
1
"#{@api_key_prefix[param_name]} #{key}"
-
else
-
1
key
-
end
-
end
-
-
# Gets access_token using access_token_getter or uses the static access_token
-
1
def access_token_with_refresh
-
2
return access_token if access_token_getter.nil?
-
1
access_token_getter.call
-
end
-
-
# Gets Basic Auth token string
-
1
def basic_auth_token
-
111
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
-
end
-
-
# Returns Auth Settings hash for api client.
-
1
def auth_settings
-
{
-
110
'Basic' =>
-
{
-
type: 'basic',
-
in: 'header',
-
key: 'Authorization',
-
value: basic_auth_token
-
},
-
}
-
end
-
-
# Returns an array of Server setting
-
1
def server_settings
-
[
-
{
-
1
url: "",
-
description: "No description provided",
-
}
-
]
-
end
-
-
1
def operation_server_settings
-
{
-
237
"CallsApi.create_call": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"CallsApi.get_call_state": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"CallsApi.update_call": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"CallsApi.update_call_bxml": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"ConferencesApi.download_conference_recording": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"ConferencesApi.get_conference": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"ConferencesApi.get_conference_member": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"ConferencesApi.get_conference_recording": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"ConferencesApi.list_conference_recordings": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"ConferencesApi.list_conferences": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"ConferencesApi.update_conference": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"ConferencesApi.update_conference_bxml": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"ConferencesApi.update_conference_member": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"MFAApi.generate_messaging_code": [
-
{
-
url: "https://mfa.bandwidth.com/api/v1",
-
description: "Production",
-
}
-
],
-
"MFAApi.generate_voice_code": [
-
{
-
url: "https://mfa.bandwidth.com/api/v1",
-
description: "Production",
-
}
-
],
-
"MFAApi.verify_code": [
-
{
-
url: "https://mfa.bandwidth.com/api/v1",
-
description: "Production",
-
}
-
],
-
"MediaApi.delete_media": [
-
{
-
url: "https://messaging.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"MediaApi.get_media": [
-
{
-
url: "https://messaging.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"MediaApi.list_media": [
-
{
-
url: "https://messaging.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"MediaApi.upload_media": [
-
{
-
url: "https://messaging.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"MessagesApi.create_message": [
-
{
-
url: "https://messaging.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"MessagesApi.list_messages": [
-
{
-
url: "https://messaging.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"PhoneNumberLookupApi.create_lookup": [
-
{
-
url: "https://numbers.bandwidth.com/api/v1",
-
description: "Production",
-
}
-
],
-
"PhoneNumberLookupApi.get_lookup_status": [
-
{
-
url: "https://numbers.bandwidth.com/api/v1",
-
description: "Production",
-
}
-
],
-
"RecordingsApi.delete_call_transcription": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"RecordingsApi.delete_recording": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"RecordingsApi.delete_recording_media": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"RecordingsApi.download_call_recording": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"RecordingsApi.get_call_recording": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"RecordingsApi.get_call_transcription": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"RecordingsApi.list_account_call_recordings": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"RecordingsApi.list_call_recordings": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"RecordingsApi.transcribe_call_recording": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"RecordingsApi.update_call_recording_state": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
"StatisticsApi.get_statistics": [
-
{
-
url: "https://voice.bandwidth.com/api/v2",
-
description: "Production",
-
}
-
],
-
}
-
end
-
-
# Returns URL based on server settings
-
#
-
# @param index array index of the server settings
-
# @param variables hash of variable and the corresponding value
-
1
def server_url(index, variables = {}, servers = nil)
-
114
servers = server_settings if servers == nil
-
-
# check array index out of bound
-
114
if (index.nil? || index < 0 || index >= servers.size)
-
2
fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}"
-
end
-
-
112
server = servers[index]
-
112
url = server[:url]
-
-
112
return url unless server.key? :variables
-
-
# go through variable and assign a value
-
2
server[:variables].each do |name, variable|
-
3
if variables.key?(name)
-
2
if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
-
1
url.gsub! "{" + name.to_s + "}", variables[name]
-
else
-
1
fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
-
end
-
else
-
# use default value
-
1
url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
-
end
-
end
-
-
1
url
-
end
-
-
# Configure Faraday connection directly.
-
#
-
# ```
-
# c.configure_faraday_connection do |conn|
-
# conn.use Faraday::HttpCache, shared_cache: false, logger: logger
-
# conn.response :logger, nil, headers: true, bodies: true, log_level: :debug do |logger|
-
# logger.filter(/(Authorization: )(.*)/, '\1[REDACTED]')
-
# end
-
# end
-
#
-
# c.configure_faraday_connection do |conn|
-
# conn.adapter :typhoeus
-
# end
-
# ```
-
#
-
# @param block [Proc] `#call`able object that takes one arg, the connection
-
1
def configure_faraday_connection(&block)
-
1
@configure_connection_blocks << block
-
end
-
-
1
def configure_connection(conn)
-
11
@configure_connection_blocks.each do |block|
-
1
block.call(conn)
-
end
-
end
-
-
# Adds middleware to the stack
-
1
def use(*middleware)
-
1
set_faraday_middleware(:use, *middleware)
-
end
-
-
# Adds request middleware to the stack
-
1
def request(*middleware)
-
1
set_faraday_middleware(:request, *middleware)
-
end
-
-
# Adds response middleware to the stack
-
1
def response(*middleware)
-
2
set_faraday_middleware(:response, *middleware)
-
end
-
-
# Adds Faraday middleware setting information to the stack
-
#
-
# @example Use the `set_faraday_middleware` method to set middleware information
-
# config.set_faraday_middleware(:request, :retry, max: 3, methods: [:get, :post], retry_statuses: [503])
-
# config.set_faraday_middleware(:response, :logger, nil, { bodies: true, log_level: :debug })
-
# config.set_faraday_middleware(:use, Faraday::HttpCache, store: Rails.cache, shared_cache: false)
-
# config.set_faraday_middleware(:insert, 0, FaradayMiddleware::FollowRedirects, { standards_compliant: true, limit: 1 })
-
# config.set_faraday_middleware(:swap, 0, Faraday::Response::Logger)
-
# config.set_faraday_middleware(:delete, Faraday::Multipart::Middleware)
-
#
-
# @see https://github.com/lostisland/faraday/blob/v2.3.0/lib/faraday/rack_builder.rb#L92-L143
-
1
def set_faraday_middleware(operation, key, *args, &block)
-
6
unless [:request, :response, :use, :insert, :insert_before, :insert_after, :swap, :delete].include?(operation)
-
1
fail ArgumentError, "Invalid faraday middleware operation #{operation}. Must be" \
-
" :request, :response, :use, :insert, :insert_before, :insert_after, :swap or :delete."
-
end
-
-
5
@middlewares[operation] << [key, args, block]
-
end
-
1
ruby2_keywords(:set_faraday_middleware) if respond_to?(:ruby2_keywords, true)
-
-
# Set up middleware on the connection
-
1
def configure_middleware(connection)
-
12
return if @middlewares.empty?
-
-
2
[:request, :response, :use, :insert, :insert_before, :insert_after, :swap].each do |operation|
-
14
next unless @middlewares.key?(operation)
-
-
1
@middlewares[operation].each do |key, args, block|
-
1
connection.builder.send(operation, key, *args, &block)
-
end
-
end
-
-
2
if @middlewares.key?(:delete)
-
1
@middlewares[:delete].each do |key, _args, _block|
-
1
connection.builder.delete(key)
-
end
-
end
-
end
-
end
-
end
-
=begin
-
#Bandwidth
-
-
#Bandwidth's Communication APIs
-
-
The version of the OpenAPI document: 1.0.0
-
Contact: letstalk@bandwidth.com
-
Generated by: https://openapi-generator.tech
-
OpenAPI Generator version: 7.0.0
-
-
=end
-
-
1
require 'date'
-
1
require 'time'
-
-
1
module Bandwidth
-
1
class CallState
-
# The application id associated with the call.
-
1
attr_accessor :application_id
-
-
# The account id associated with the call.
-
1
attr_accessor :account_id
-
-
# The programmable voice API call ID.
-
1
attr_accessor :call_id
-
-
# The A-leg call id, set only if this call is the B-leg of a [`<Transfer>`](/docs/voice/bxml/transfer).
-
1
attr_accessor :parent_call_id
-
-
# The phone number that received the call, in E.164 format (e.g. +15555555555), or if the call was to a SIP URI, the SIP URI.
-
1
attr_accessor :to
-
-
# The phone number that made the call, in E.164 format (e.g. +15555555555).
-
1
attr_accessor :from
-
-
1
attr_accessor :direction
-
-
# The current state of the call. Current possible values are `queued`, `initiated`, `answered` and `disconnected`. Additional states may be added in the future, so your application must be tolerant of unknown values.
-
1
attr_accessor :state
-
-
# For inbound calls, the Bandwidth STIR/SHAKEN implementation will verify the information provided in the inbound invite request `Identity` header. The verification status is stored in the call state `stirShaken` property as follows. | Property | Description | |:------------------|:------------| | verstat | (optional) The verification status indicating whether the verification was successful or not. Possible values are `TN-Verification-Passed` or `TN-Verification-Failed`. | | attestationIndicator | (optional) The attestation level verified by Bandwidth. Possible values are `A` (full), `B` (partial) or `C` (gateway). | | originatingId | (optional) A unique origination identifier. | Note that these are common properties but that the `stirShaken` object is free form and can contain other key-value pairs. More information: [Understanding STIR/SHAKEN](https://www.bandwidth.com/regulations/stir-shaken).
-
1
attr_accessor :stir_shaken
-
-
# The value of the `Identity` header from the inbound invite request. Only present for inbound calls and if the account is configured to forward this header.
-
1
attr_accessor :identity
-
-
# The time this call was placed in queue.
-
1
attr_accessor :enqueued_time
-
-
# The time the call was initiated, in ISO 8601 format. `null` if the call is still in your queue.
-
1
attr_accessor :start_time
-
-
# Populated once the call has been answered, with the time in ISO 8601 format.
-
1
attr_accessor :answer_time
-
-
# Populated once the call has ended, with the time in ISO 8601 format.
-
1
attr_accessor :end_time
-
-
# | Cause | Description | |:------|:------------| | `hangup`| One party hung up the call, a [`<Hangup>`](../../bxml/verbs/hangup.md) verb was executed, or there was no more BXML to execute; it indicates that the call ended normally. | | `busy` | Callee was busy. | | `timeout` | Call wasn't answered before the `callTimeout` was reached. | | `cancel` | Call was cancelled by its originator while it was ringing. | | `rejected` | Call was rejected by the callee. | | `callback-error` | BXML callback couldn't be delivered to your callback server. | | `invalid-bxml` | Invalid BXML was returned in response to a callback. | | `application-error` | An unsupported action was tried on the call, e.g. trying to play a .ogg audio. | | `account-limit` | Account rate limits were reached. | | `node-capacity-exceeded` | System maximum capacity was reached. | | `error` | Some error not described in any of the other causes happened on the call. | | `unknown` | Unknown error happened on the call. | Note: This list is not exhaustive and other values can appear in the future.
-
1
attr_accessor :disconnect_cause
-
-
# Populated only if the call ended with an error, with text explaining the reason.
-
1
attr_accessor :error_message
-
-
# Populated only if the call ended with an error, with a Bandwidth internal id that references the error event.
-
1
attr_accessor :error_id
-
-
# The last time the call had a state update, in ISO 8601 format.
-
1
attr_accessor :last_update
-
-
1
class EnumAttributeValidator
-
1
attr_reader :datatype
-
1
attr_reader :allowable_values
-
-
1
def initialize(datatype, allowable_values)
-
3
@allowable_values = allowable_values.map do |value|
-
3
case datatype.to_s
-
when /Integer/i
-
1
value.to_i
-
when /Float/i
-
1
value.to_f
-
else
-
1
value
-
end
-
end
-
end
-
-
1
def valid?(value)
-
6
!value || allowable_values.include?(value)
-
end
-
end
-
-
# Attribute mapping from ruby-style variable name to JSON key.
-
1
def self.attribute_map
-
278
{
-
:'application_id' => :'applicationId',
-
:'account_id' => :'accountId',
-
:'call_id' => :'callId',
-
:'parent_call_id' => :'parentCallId',
-
:'to' => :'to',
-
:'from' => :'from',
-
:'direction' => :'direction',
-
:'state' => :'state',
-
:'stir_shaken' => :'stirShaken',
-
:'identity' => :'identity',
-
:'enqueued_time' => :'enqueuedTime',
-
:'start_time' => :'startTime',
-
:'answer_time' => :'answerTime',
-
:'end_time' => :'endTime',
-
:'disconnect_cause' => :'disconnectCause',
-
:'error_message' => :'errorMessage',
-
:'error_id' => :'errorId',
-
:'last_update' => :'lastUpdate'
-
}
-
end
-
-
# Returns all the JSON keys this model knows about
-
1
def self.acceptable_attributes
-
1
attribute_map.values
-
end
-
-
# Attribute type mapping.
-
1
def self.openapi_types
-
3
{
-
:'application_id' => :'String',
-
:'account_id' => :'String',
-
:'call_id' => :'String',
-
:'parent_call_id' => :'String',
-
:'to' => :'String',
-
:'from' => :'String',
-
:'direction' => :'CallDirectionEnum',
-
:'state' => :'String',
-
:'stir_shaken' => :'Hash<String, String>',
-
:'identity' => :'String',
-
:'enqueued_time' => :'Time',
-
:'start_time' => :'Time',
-
:'answer_time' => :'Time',
-
:'end_time' => :'Time',
-
:'disconnect_cause' => :'String',
-
:'error_message' => :'String',
-
:'error_id' => :'String',
-
:'last_update' => :'Time'
-
}
-
end
-
-
# List of attributes with nullable: true
-
1
def self.openapi_nullable
-
20
Set.new([
-
:'parent_call_id',
-
:'stir_shaken',
-
:'identity',
-
:'enqueued_time',
-
:'start_time',
-
:'answer_time',
-
:'end_time',
-
:'disconnect_cause',
-
:'error_message',
-
:'error_id',
-
])
-
end
-
-
# Initializes the object
-
# @param [Hash] attributes Model attributes in the form of hash
-
1
def initialize(attributes = {})
-
11
if (!attributes.is_a?(Hash))
-
1
fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CallState` initialize method'
-
end
-
-
# check to see if the attribute exists and convert string to symbol for hash key
-
10
attributes = attributes.each_with_object({}) { |(k, v), h|
-
81
if (!self.class.attribute_map.key?(k.to_sym))
-
1
fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CallState`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
-
end
-
80
h[k.to_sym] = v
-
}
-
-
9
if attributes.key?(:'application_id')
-
5
self.application_id = attributes[:'application_id']
-
end
-
-
9
if attributes.key?(:'account_id')
-
5
self.account_id = attributes[:'account_id']
-
end
-
-
9
if attributes.key?(:'call_id')
-
5
self.call_id = attributes[:'call_id']
-
end
-
-
9
if attributes.key?(:'parent_call_id')
-
3
self.parent_call_id = attributes[:'parent_call_id']
-
end
-
-
9
if attributes.key?(:'to')
-
5
self.to = attributes[:'to']
-
end
-
-
9
if attributes.key?(:'from')
-
5
self.from = attributes[:'from']
-
end
-
-
9
if attributes.key?(:'direction')
-
5
self.direction = attributes[:'direction']
-
end
-
-
9
if attributes.key?(:'state')
-
5
self.state = attributes[:'state']
-
end
-
-
9
if attributes.key?(:'stir_shaken')
-
5
if (value = attributes[:'stir_shaken']).is_a?(Hash)
-
5
self.stir_shaken = value
-
end
-
end
-
-
9
if attributes.key?(:'identity')
-
3
self.identity = attributes[:'identity']
-
end
-
-
9
if attributes.key?(:'enqueued_time')
-
5
self.enqueued_time = attributes[:'enqueued_time']
-
end
-
-
9
if attributes.key?(:'start_time')
-
5
self.start_time = attributes[:'start_time']
-
end
-
-
9
if attributes.key?(:'answer_time')
-
3
self.answer_time = attributes[:'answer_time']
-
end
-
-
9
if attributes.key?(:'end_time')
-
4
self.end_time = attributes[:'end_time']
-
end
-
-
9
if attributes.key?(:'disconnect_cause')
-
4
self.disconnect_cause = attributes[:'disconnect_cause']
-
end
-
-
9
if attributes.key?(:'error_message')
-
4
self.error_message = attributes[:'error_message']
-
end
-
-
9
if attributes.key?(:'error_id')
-
4
self.error_id = attributes[:'error_id']
-
end
-
-
9
if attributes.key?(:'last_update')
-
5
self.last_update = attributes[:'last_update']
-
end
-
end
-
-
# Show invalid properties with the reasons. Usually used together with valid?
-
# @return Array for valid properties with the reasons
-
1
def list_invalid_properties
-
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
-
invalid_properties = Array.new
-
invalid_properties
-
end
-
-
# Check to see if the all the properties in the model are valid
-
# @return true if the model is valid
-
1
def valid?
-
warn '[DEPRECATED] the `valid?` method is obsolete'
-
true
-
end
-
-
# Checks equality by comparing each attribute.
-
# @param [Object] Object to be compared
-
1
def ==(o)
-
2
return true if self.equal?(o)
-
2
self.class == o.class &&
-
application_id == o.application_id &&
-
account_id == o.account_id &&
-
call_id == o.call_id &&
-
parent_call_id == o.parent_call_id &&
-
to == o.to &&
-
from == o.from &&
-
direction == o.direction &&
-
state == o.state &&
-
stir_shaken == o.stir_shaken &&
-
identity == o.identity &&
-
enqueued_time == o.enqueued_time &&
-
start_time == o.start_time &&
-
answer_time == o.answer_time &&
-
end_time == o.end_time &&
-
disconnect_cause == o.disconnect_cause &&
-
error_message == o.error_message &&
-
error_id == o.error_id &&
-
last_update == o.last_update
-
end
-
-
# @see the `==` method
-
# @param [Object] Object to be compared
-
1
def eql?(o)
-
2
self == o
-
end
-
-
# Calculates hash code according to all attributes.
-
# @return [Integer] Hash code
-
1
def hash
-
1
[application_id, account_id, call_id, parent_call_id, to, from, direction, state, stir_shaken, identity, enqueued_time, start_time, answer_time, end_time, disconnect_cause, error_message, error_id, last_update].hash
-
end
-
-
# Builds the object from hash
-
# @param [Hash] attributes Model attributes in the form of hash
-
# @return [Object] Returns the model itself
-
1
def self.build_from_hash(attributes)
-
3
return nil unless attributes.is_a?(Hash)
-
3
attributes = attributes.transform_keys(&:to_sym)
-
3
transformed_hash = {}
-
3
openapi_types.each_pair do |key, type|
-
54
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
-
2
transformed_hash["#{key}"] = nil
-
52
elsif type =~ /\AArray<(.*)>/i
-
# check to ensure the input is an array given that the attribute
-
# is documented as an array but the input is not
-
if attributes[attribute_map[key]].is_a?(Array)
-
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
-
end
-
52
elsif !attributes[attribute_map[key]].nil?
-
42
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
-
end
-
end
-
3
new(transformed_hash)
-
end
-
-
# Deserializes the data based on type
-
# @param string type Data type
-
# @param string value Value to be deserialized
-
# @return [Object] Deserialized data
-
1
def self._deserialize(type, value)
-
48
case type.to_sym
-
when :Time
-
12
Time.parse(value)
-
when :Date
-
Date.parse(value)
-
when :String
-
30
value.to_s
-
when :Integer
-
value.to_i
-
when :Float
-
value.to_f
-
when :Boolean
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
-
true
-
else
-
false
-
end
-
when :Object
-
# generic object (usually a Hash), return directly
-
value
-
when /\AArray<(?<inner_type>.+)>\z/
-
inner_type = Regexp.last_match[:inner_type]
-
value.map { |v| _deserialize(inner_type, v) }
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
-
3
k_type = Regexp.last_match[:k_type]
-
3
v_type = Regexp.last_match[:v_type]
-
3
{}.tap do |hash|
-
3
value.each do |k, v|
-
3
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
-
end
-
end
-
else # model
-
# models (e.g. Pet) or oneOf
-
3
klass = Bandwidth.const_get(type)
-
3
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
-
end
-
end
-
-
# Returns the string representation of the object
-
# @return [String] String presentation of the object
-
1
def to_s
-
1
to_hash.to_s
-
end
-
-
# to_body is an alias to to_hash (backward compatibility)
-
# @return [Hash] Returns the object in the form of hash
-
1
def to_body
-
1
to_hash
-
end
-
-
# Returns the object in the form of hash
-
# @return [Hash] Returns the object in the form of hash
-
1
def to_hash
-
2
hash = {}
-
2
self.class.attribute_map.each_pair do |attr, param|
-
36
value = self.send(attr)
-
36
if value.nil?
-
20
is_nullable = self.class.openapi_nullable.include?(attr)
-
20
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
-
end
-
-
18
hash[param] = _to_hash(value)
-
end
-
2
hash
-
end
-
-
# Outputs non-array value in the form of hash
-
# For object, use to_hash. Otherwise, just return the value
-
# @param [Object] value Any valid value
-
# @return [Hash] Returns the value in the form of hash
-
1
def _to_hash(value)
-
21
if value.is_a?(Array)
-
value.compact.map { |v| _to_hash(v) }
-
21
elsif value.is_a?(Hash)
-
1
{}.tap do |hash|
-
4
value.each { |k, v| hash[k] = _to_hash(v) }
-
end
-
20
elsif value.respond_to? :to_hash
-
value.to_hash
-
else
-
20
value
-
end
-
end
-
end
-
end
-
=begin
-
#Bandwidth
-
-
#Bandwidth's Communication APIs
-
-
The version of the OpenAPI document: 1.0.0
-
Contact: letstalk@bandwidth.com
-
Generated by: https://openapi-generator.tech
-
OpenAPI Generator version: 7.0.0
-
-
=end
-
-
1
require 'date'
-
1
require 'time'
-
-
1
module Bandwidth
-
1
class CallStateEnum
-
1
ACTIVE = 'active'.freeze
-
1
COMPLETED = 'completed'.freeze
-
-
1
def self.all_vars
-
1
@all_vars ||= [ACTIVE, COMPLETED].freeze
-
end
-
-
# Builds the enum from string
-
# @param [String] The enum value in the form of the string
-
# @return [String] The enum value
-
1
def self.build_from_hash(value)
-
1
new.build_from_hash(value)
-
end
-
-
# Builds the enum from string
-
# @param [String] The enum value in the form of the string
-
# @return [String] The enum value
-
1
def build_from_hash(value)
-
1
return value if CallStateEnum.all_vars.include?(value)
-
1
raise "Invalid ENUM value #{value} for class #CallStateEnum"
-
end
-
end
-
end
-
=begin
-
#Bandwidth
-
-
#Bandwidth's Communication APIs
-
-
The version of the OpenAPI document: 1.0.0
-
Contact: letstalk@bandwidth.com
-
Generated by: https://openapi-generator.tech
-
OpenAPI Generator version: 7.0.0
-
-
=end
-
-
1
require 'date'
-
1
require 'time'
-
-
1
module Bandwidth
-
1
class DeferredResult
-
1
attr_accessor :result
-
-
1
attr_accessor :set_or_expired
-
-
# Attribute mapping from ruby-style variable name to JSON key.
-
1
def self.attribute_map
-
28
{
-
:'result' => :'result',
-
:'set_or_expired' => :'setOrExpired'
-
}
-
end
-
-
# Returns all the JSON keys this model knows about
-
1
def self.acceptable_attributes
-
1
attribute_map.values
-
end
-
-
# Attribute type mapping.
-
1
def self.openapi_types
-
2
{
-
:'result' => :'Object',
-
:'set_or_expired' => :'Boolean'
-
}
-
end
-
-
# List of attributes with nullable: true
-
1
def self.openapi_nullable
-
2
Set.new([
-
])
-
end
-
-
# Initializes the object
-
# @param [Hash] attributes Model attributes in the form of hash
-
1
def initialize(attributes = {})
-
11
if (!attributes.is_a?(Hash))
-
1
fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::DeferredResult` initialize method'
-
end
-
-
# check to see if the attribute exists and convert string to symbol for hash key
-
10
attributes = attributes.each_with_object({}) { |(k, v), h|
-
10
if (!self.class.attribute_map.key?(k.to_sym))
-
1
fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::DeferredResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
-
end
-
9
h[k.to_sym] = v
-
}
-
-
9
if attributes.key?(:'result')
-
4
self.result = attributes[:'result']
-
end
-
-
9
if attributes.key?(:'set_or_expired')
-
5
self.set_or_expired = attributes[:'set_or_expired']
-
end
-
end
-
-
# Show invalid properties with the reasons. Usually used together with valid?
-
# @return Array for valid properties with the reasons
-
1
def list_invalid_properties
-
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
-
invalid_properties = Array.new
-
invalid_properties
-
end
-
-
# Check to see if the all the properties in the model are valid
-
# @return true if the model is valid
-
1
def valid?
-
warn '[DEPRECATED] the `valid?` method is obsolete'
-
true
-
end
-
-
# Checks equality by comparing each attribute.
-
# @param [Object] Object to be compared
-
1
def ==(o)
-
2
return true if self.equal?(o)
-
2
self.class == o.class &&
-
result == o.result &&
-
set_or_expired == o.set_or_expired
-
end
-
-
# @see the `==` method
-
# @param [Object] Object to be compared
-
1
def eql?(o)
-
2
self == o
-
end
-
-
# Calculates hash code according to all attributes.
-
# @return [Integer] Hash code
-
1
def hash
-
1
[result, set_or_expired].hash
-
end
-
-
# Builds the object from hash
-
# @param [Hash] attributes Model attributes in the form of hash
-
# @return [Object] Returns the model itself
-
1
def self.build_from_hash(attributes)
-
2
return nil unless attributes.is_a?(Hash)
-
2
attributes = attributes.transform_keys(&:to_sym)
-
2
transformed_hash = {}
-
2
openapi_types.each_pair do |key, type|
-
4
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
-
transformed_hash["#{key}"] = nil
-
4
elsif type =~ /\AArray<(.*)>/i
-
# check to ensure the input is an array given that the attribute
-
# is documented as an array but the input is not
-
if attributes[attribute_map[key]].is_a?(Array)
-
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
-
end
-
4
elsif !attributes[attribute_map[key]].nil?
-
2
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
-
end
-
end
-
2
new(transformed_hash)
-
end
-
-
# Deserializes the data based on type
-
# @param string type Data type
-
# @param string value Value to be deserialized
-
# @return [Object] Deserialized data
-
1
def self._deserialize(type, value)
-
2
case type.to_sym
-
when :Time
-
Time.parse(value)
-
when :Date
-
Date.parse(value)
-
when :String
-
value.to_s
-
when :Integer
-
value.to_i
-
when :Float
-
value.to_f
-
when :Boolean
-
1
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
-
1
true
-
else
-
false
-
end
-
when :Object
-
# generic object (usually a Hash), return directly
-
1
value
-
when /\AArray<(?<inner_type>.+)>\z/
-
inner_type = Regexp.last_match[:inner_type]
-
value.map { |v| _deserialize(inner_type, v) }
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
-
k_type = Regexp.last_match[:k_type]
-
v_type = Regexp.last_match[:v_type]
-
{}.tap do |hash|
-
value.each do |k, v|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
-
end
-
end
-
else # model
-
# models (e.g. Pet) or oneOf
-
klass = Bandwidth.const_get(type)
-
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
-
end
-
end
-
-
# Returns the string representation of the object
-
# @return [String] String presentation of the object
-
1
def to_s
-
1
to_hash.to_s
-
end
-
-
# to_body is an alias to to_hash (backward compatibility)
-
# @return [Hash] Returns the object in the form of hash
-
1
def to_body
-
1
to_hash
-
end
-
-
# Returns the object in the form of hash
-
# @return [Hash] Returns the object in the form of hash
-
1
def to_hash
-
3
hash = {}
-
3
self.class.attribute_map.each_pair do |attr, param|
-
6
value = self.send(attr)
-
6
if value.nil?
-
1
is_nullable = self.class.openapi_nullable.include?(attr)
-
1
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
-
end
-
-
5
hash[param] = _to_hash(value)
-
end
-
3
hash
-
end
-
-
# Outputs non-array value in the form of hash
-
# For object, use to_hash. Otherwise, just return the value
-
# @param [Object] value Any valid value
-
# @return [Hash] Returns the value in the form of hash
-
1
def _to_hash(value)
-
7
if value.is_a?(Array)
-
value.compact.map { |v| _to_hash(v) }
-
7
elsif value.is_a?(Hash)
-
2
{}.tap do |hash|
-
4
value.each { |k, v| hash[k] = _to_hash(v) }
-
end
-
5
elsif value.respond_to? :to_hash
-
value.to_hash
-
else
-
5
value
-
end
-
end
-
end
-
end
-
=begin
-
#Bandwidth
-
-
#Bandwidth's Communication APIs
-
-
The version of the OpenAPI document: 1.0.0
-
Contact: letstalk@bandwidth.com
-
Generated by: https://openapi-generator.tech
-
OpenAPI Generator version: 7.0.0
-
-
=end
-
-
1
require 'date'
-
1
require 'time'
-
-
1
module Bandwidth
-
1
class Message
-
# The id of the message.
-
1
attr_accessor :id
-
-
# The Bandwidth phone number associated with the message.
-
1
attr_accessor :owner
-
-
# The application ID associated with the message.
-
1
attr_accessor :application_id
-
-
# The datetime stamp of the message in ISO 8601
-
1
attr_accessor :time
-
-
# The number of segments the original message from the user is broken into before sending over to carrier networks.
-
1
attr_accessor :segment_count
-
-
1
attr_accessor :direction
-
-
# The phone number recipients of the message.
-
1
attr_accessor :to
-
-
# The phone number the message was sent from.
-
1
attr_accessor :from
-
-
# The list of media URLs sent in the message. Including a `filename` field in the `Content-Disposition` header of the media linked with a URL will set the displayed file name. This is a best practice to ensure that your media has a readable file name.
-
1
attr_accessor :media
-
-
# The contents of the message.
-
1
attr_accessor :text
-
-
# The custom string set by the user.
-
1
attr_accessor :tag
-
-
1
attr_accessor :priority
-
-
# The expiration date-time set by the user.
-
1
attr_accessor :expiration
-
-
1
class EnumAttributeValidator
-
1
attr_reader :datatype
-
1
attr_reader :allowable_values
-
-
1
def initialize(datatype, allowable_values)
-
3
@allowable_values = allowable_values.map do |value|
-
3
case datatype.to_s
-
when /Integer/i
-
1
value.to_i
-
when /Float/i
-
1
value.to_f
-
else
-
1
value
-
end
-
end
-
end
-
-
1
def valid?(value)
-
6
!value || allowable_values.include?(value)
-
end
-
end
-
-
# Attribute mapping from ruby-style variable name to JSON key.
-
1
def self.attribute_map
-
339
{
-
:'id' => :'id',
-
:'owner' => :'owner',
-
:'application_id' => :'applicationId',
-
:'time' => :'time',
-
:'segment_count' => :'segmentCount',
-
:'direction' => :'direction',
-
:'to' => :'to',
-
:'from' => :'from',
-
:'media' => :'media',
-
:'text' => :'text',
-
:'tag' => :'tag',
-
:'priority' => :'priority',
-
:'expiration' => :'expiration'
-
}
-
end
-
-
# Returns all the JSON keys this model knows about
-
1
def self.acceptable_attributes
-
1
attribute_map.values
-
end
-
-
# Attribute type mapping.
-
1
def self.openapi_types
-
5
{
-
:'id' => :'String',
-
:'owner' => :'String',
-
:'application_id' => :'String',
-
:'time' => :'Time',
-
:'segment_count' => :'Integer',
-
:'direction' => :'MessageDirectionEnum',
-
:'to' => :'Array<String>',
-
:'from' => :'String',
-
:'media' => :'Array<String>',
-
:'text' => :'String',
-
:'tag' => :'String',
-
:'priority' => :'PriorityEnum',
-
:'expiration' => :'Time'
-
}
-
end
-
-
# List of attributes with nullable: true
-
1
def self.openapi_nullable
-
13
Set.new([
-
])
-
end
-
-
# Initializes the object
-
# @param [Hash] attributes Model attributes in the form of hash
-
1
def initialize(attributes = {})
-
13
if (!attributes.is_a?(Hash))
-
1
fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::Message` initialize method'
-
end
-
-
# check to see if the attribute exists and convert string to symbol for hash key
-
12
attributes = attributes.each_with_object({}) { |(k, v), h|
-
86
if (!self.class.attribute_map.key?(k.to_sym))
-
1
fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::Message`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
-
end
-
85
h[k.to_sym] = v
-
}
-
-
11
if attributes.key?(:'id')
-
7
self.id = attributes[:'id']
-
end
-
-
11
if attributes.key?(:'owner')
-
7
self.owner = attributes[:'owner']
-
end
-
-
11
if attributes.key?(:'application_id')
-
7
self.application_id = attributes[:'application_id']
-
end
-
-
11
if attributes.key?(:'time')
-
7
self.time = attributes[:'time']
-
end
-
-
11
if attributes.key?(:'segment_count')
-
7
self.segment_count = attributes[:'segment_count']
-
end
-
-
11
if attributes.key?(:'direction')
-
7
self.direction = attributes[:'direction']
-
end
-
-
11
if attributes.key?(:'to')
-
7
if (value = attributes[:'to']).is_a?(Array)
-
7
self.to = value
-
end
-
end
-
-
11
if attributes.key?(:'from')
-
7
self.from = attributes[:'from']
-
end
-
-
11
if attributes.key?(:'media')
-
5
if (value = attributes[:'media']).is_a?(Array)
-
5
self.media = value
-
end
-
end
-
-
11
if attributes.key?(:'text')
-
7
self.text = attributes[:'text']
-
end
-
-
11
if attributes.key?(:'tag')
-
7
self.tag = attributes[:'tag']
-
end
-
-
11
if attributes.key?(:'priority')
-
5
self.priority = attributes[:'priority']
-
end
-
-
11
if attributes.key?(:'expiration')
-
5
self.expiration = attributes[:'expiration']
-
end
-
end
-
-
# Show invalid properties with the reasons. Usually used together with valid?
-
# @return Array for valid properties with the reasons
-
1
def list_invalid_properties
-
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
-
invalid_properties = Array.new
-
invalid_properties
-
end
-
-
# Check to see if the all the properties in the model are valid
-
# @return true if the model is valid
-
1
def valid?
-
warn '[DEPRECATED] the `valid?` method is obsolete'
-
true
-
end
-
-
# Custom attribute writer method with validation
-
# @param [Object] to Value to be assigned
-
1
def to=(to)
-
7
if to.nil?
-
fail ArgumentError, 'to cannot be nil'
-
end
-
-
7
@to = to
-
end
-
-
# Custom attribute writer method with validation
-
# @param [Object] media Value to be assigned
-
1
def media=(media)
-
5
if media.nil?
-
fail ArgumentError, 'media cannot be nil'
-
end
-
-
5
@media = media
-
end
-
-
# Checks equality by comparing each attribute.
-
# @param [Object] Object to be compared
-
1
def ==(o)
-
2
return true if self.equal?(o)
-
2
self.class == o.class &&
-
id == o.id &&
-
owner == o.owner &&
-
application_id == o.application_id &&
-
time == o.time &&
-
segment_count == o.segment_count &&
-
direction == o.direction &&
-
to == o.to &&
-
from == o.from &&
-
media == o.media &&
-
text == o.text &&
-
tag == o.tag &&
-
priority == o.priority &&
-
expiration == o.expiration
-
end
-
-
# @see the `==` method
-
# @param [Object] Object to be compared
-
1
def eql?(o)
-
2
self == o
-
end
-
-
# Calculates hash code according to all attributes.
-
# @return [Integer] Hash code
-
1
def hash
-
1
[id, owner, application_id, time, segment_count, direction, to, from, media, text, tag, priority, expiration].hash
-
end
-
-
# Builds the object from hash
-
# @param [Hash] attributes Model attributes in the form of hash
-
# @return [Object] Returns the model itself
-
1
def self.build_from_hash(attributes)
-
5
return nil unless attributes.is_a?(Hash)
-
5
attributes = attributes.transform_keys(&:to_sym)
-
5
transformed_hash = {}
-
5
openapi_types.each_pair do |key, type|
-
65
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
-
transformed_hash["#{key}"] = nil
-
65
elsif type =~ /\AArray<(.*)>/i
-
# check to ensure the input is an array given that the attribute
-
# is documented as an array but the input is not
-
10
if attributes[attribute_map[key]].is_a?(Array)
-
16
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
-
end
-
55
elsif !attributes[attribute_map[key]].nil?
-
51
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
-
end
-
end
-
5
new(transformed_hash)
-
end
-
-
# Deserializes the data based on type
-
# @param string type Data type
-
# @param string value Value to be deserialized
-
# @return [Object] Deserialized data
-
1
def self._deserialize(type, value)
-
59
case type.to_sym
-
when :Time
-
8
Time.parse(value)
-
when :Date
-
Date.parse(value)
-
when :String
-
38
value.to_s
-
when :Integer
-
5
value.to_i
-
when :Float
-
value.to_f
-
when :Boolean
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
-
true
-
else
-
false
-
end
-
when :Object
-
# generic object (usually a Hash), return directly
-
value
-
when /\AArray<(?<inner_type>.+)>\z/
-
inner_type = Regexp.last_match[:inner_type]
-
value.map { |v| _deserialize(inner_type, v) }
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
-
k_type = Regexp.last_match[:k_type]
-
v_type = Regexp.last_match[:v_type]
-
{}.tap do |hash|
-
value.each do |k, v|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
-
end
-
end
-
else # model
-
# models (e.g. Pet) or oneOf
-
8
klass = Bandwidth.const_get(type)
-
8
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
-
end
-
end
-
-
# Returns the string representation of the object
-
# @return [String] String presentation of the object
-
1
def to_s
-
1
to_hash.to_s
-
end
-
-
# to_body is an alias to to_hash (backward compatibility)
-
# @return [Hash] Returns the object in the form of hash
-
1
def to_body
-
1
to_hash
-
end
-
-
# Returns the object in the form of hash
-
# @return [Hash] Returns the object in the form of hash
-
1
def to_hash
-
2
hash = {}
-
2
self.class.attribute_map.each_pair do |attr, param|
-
26
value = self.send(attr)
-
26
if value.nil?
-
13
is_nullable = self.class.openapi_nullable.include?(attr)
-
13
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
-
end
-
-
13
hash[param] = _to_hash(value)
-
end
-
2
hash
-
end
-
-
# Outputs non-array value in the form of hash
-
# For object, use to_hash. Otherwise, just return the value
-
# @param [Object] value Any valid value
-
# @return [Hash] Returns the value in the form of hash
-
1
def _to_hash(value)
-
15
if value.is_a?(Array)
-
4
value.compact.map { |v| _to_hash(v) }
-
13
elsif value.is_a?(Hash)
-
{}.tap do |hash|
-
value.each { |k, v| hash[k] = _to_hash(v) }
-
end
-
13
elsif value.respond_to? :to_hash
-
value.to_hash
-
else
-
13
value
-
end
-
end
-
end
-
end
-
=begin
-
#Bandwidth
-
-
#Bandwidth's Communication APIs
-
-
The version of the OpenAPI document: 1.0.0
-
Contact: letstalk@bandwidth.com
-
Generated by: https://openapi-generator.tech
-
OpenAPI Generator version: 7.0.0
-
-
=end
-
-
1
require 'date'
-
1
require 'time'
-
-
1
module Bandwidth
-
1
class VerifyCodeRequest
-
# The phone number to send the mfa code to.
-
1
attr_accessor :to
-
-
# An optional field to denote what scope or action the mfa code is addressing. If not supplied, defaults to \"2FA\".
-
1
attr_accessor :scope
-
-
# The time period, in minutes, to validate the mfa code. By setting this to 3 minutes, it will mean any code generated within the last 3 minutes are still valid. The valid range for expiration time is between 0 and 15 minutes, exclusively and inclusively, respectively.
-
1
attr_accessor :expiration_time_in_minutes
-
-
# The generated mfa code to check if valid.
-
1
attr_accessor :code
-
-
# Attribute mapping from ruby-style variable name to JSON key.
-
1
def self.attribute_map
-
73
{
-
:'to' => :'to',
-
:'scope' => :'scope',
-
:'expiration_time_in_minutes' => :'expirationTimeInMinutes',
-
:'code' => :'code'
-
}
-
end
-
-
# Returns all the JSON keys this model knows about
-
1
def self.acceptable_attributes
-
1
attribute_map.values
-
end
-
-
# Attribute type mapping.
-
1
def self.openapi_types
-
1
{
-
:'to' => :'String',
-
:'scope' => :'String',
-
:'expiration_time_in_minutes' => :'Float',
-
:'code' => :'String'
-
}
-
end
-
-
# List of attributes with nullable: true
-
1
def self.openapi_nullable
-
1
Set.new([
-
])
-
end
-
-
# Initializes the object
-
# @param [Hash] attributes Model attributes in the form of hash
-
1
def initialize(attributes = {})
-
18
if (!attributes.is_a?(Hash))
-
1
fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::VerifyCodeRequest` initialize method'
-
end
-
-
# check to see if the attribute exists and convert string to symbol for hash key
-
17
attributes = attributes.each_with_object({}) { |(k, v), h|
-
50
if (!self.class.attribute_map.key?(k.to_sym))
-
1
fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::VerifyCodeRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
-
end
-
49
h[k.to_sym] = v
-
}
-
-
16
if attributes.key?(:'to')
-
16
self.to = attributes[:'to']
-
else
-
self.to = nil
-
end
-
-
14
if attributes.key?(:'scope')
-
8
self.scope = attributes[:'scope']
-
end
-
-
14
if attributes.key?(:'expiration_time_in_minutes')
-
14
self.expiration_time_in_minutes = attributes[:'expiration_time_in_minutes']
-
else
-
self.expiration_time_in_minutes = nil
-
end
-
-
11
if attributes.key?(:'code')
-
11
self.code = attributes[:'code']
-
else
-
self.code = nil
-
end
-
end
-
-
# Show invalid properties with the reasons. Usually used together with valid?
-
# @return Array for valid properties with the reasons
-
1
def list_invalid_properties
-
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
-
invalid_properties = Array.new
-
if @to.nil?
-
invalid_properties.push('invalid value for "to", to cannot be nil.')
-
end
-
-
pattern = Regexp.new(/^\+[1-9]\d{1,14}$/)
-
if @to !~ pattern
-
invalid_properties.push("invalid value for \"to\", must conform to the pattern #{pattern}.")
-
end
-
-
if @expiration_time_in_minutes.nil?
-
invalid_properties.push('invalid value for "expiration_time_in_minutes", expiration_time_in_minutes cannot be nil.')
-
end
-
-
if @expiration_time_in_minutes > 15
-
invalid_properties.push('invalid value for "expiration_time_in_minutes", must be smaller than or equal to 15.')
-
end
-
-
if @expiration_time_in_minutes < 1
-
invalid_properties.push('invalid value for "expiration_time_in_minutes", must be greater than or equal to 1.')
-
end
-
-
if @code.nil?
-
invalid_properties.push('invalid value for "code", code cannot be nil.')
-
end
-
-
if @code.to_s.length > 8
-
invalid_properties.push('invalid value for "code", the character length must be smaller than or equal to 8.')
-
end
-
-
if @code.to_s.length < 4
-
invalid_properties.push('invalid value for "code", the character length must be great than or equal to 4.')
-
end
-
-
invalid_properties
-
end
-
-
# Check to see if the all the properties in the model are valid
-
# @return true if the model is valid
-
1
def valid?
-
warn '[DEPRECATED] the `valid?` method is obsolete'
-
return false if @to.nil?
-
return false if @to !~ Regexp.new(/^\+[1-9]\d{1,14}$/)
-
return false if @expiration_time_in_minutes.nil?
-
return false if @expiration_time_in_minutes > 15
-
return false if @expiration_time_in_minutes < 1
-
return false if @code.nil?
-
return false if @code.to_s.length > 8
-
return false if @code.to_s.length < 4
-
true
-
end
-
-
# Custom attribute writer method with validation
-
# @param [Object] to Value to be assigned
-
1
def to=(to)
-
16
if to.nil?
-
1
fail ArgumentError, 'to cannot be nil'
-
end
-
-
15
pattern = Regexp.new(/^\+[1-9]\d{1,14}$/)
-
15
if to !~ pattern
-
1
fail ArgumentError, "invalid value for \"to\", must conform to the pattern #{pattern}."
-
end
-
-
14
@to = to
-
end
-
-
# Custom attribute writer method with validation
-
# @param [Object] expiration_time_in_minutes Value to be assigned
-
1
def expiration_time_in_minutes=(expiration_time_in_minutes)
-
14
if expiration_time_in_minutes.nil?
-
1
fail ArgumentError, 'expiration_time_in_minutes cannot be nil'
-
end
-
-
13
if expiration_time_in_minutes > 15
-
1
fail ArgumentError, 'invalid value for "expiration_time_in_minutes", must be smaller than or equal to 15.'
-
end
-
-
12
if expiration_time_in_minutes < 1
-
1
fail ArgumentError, 'invalid value for "expiration_time_in_minutes", must be greater than or equal to 1.'
-
end
-
-
11
@expiration_time_in_minutes = expiration_time_in_minutes
-
end
-
-
# Custom attribute writer method with validation
-
# @param [Object] code Value to be assigned
-
1
def code=(code)
-
11
if code.nil?
-
1
fail ArgumentError, 'code cannot be nil'
-
end
-
-
10
if code.to_s.length > 8
-
1
fail ArgumentError, 'invalid value for "code", the character length must be smaller than or equal to 8.'
-
end
-
-
9
if code.to_s.length < 4
-
1
fail ArgumentError, 'invalid value for "code", the character length must be great than or equal to 4.'
-
end
-
-
8
@code = code
-
end
-
-
# Checks equality by comparing each attribute.
-
# @param [Object] Object to be compared
-
1
def ==(o)
-
1
return true if self.equal?(o)
-
1
self.class == o.class &&
-
to == o.to &&
-
scope == o.scope &&
-
expiration_time_in_minutes == o.expiration_time_in_minutes &&
-
code == o.code
-
end
-
-
# @see the `==` method
-
# @param [Object] Object to be compared
-
1
def eql?(o)
-
1
self == o
-
end
-
-
# Calculates hash code according to all attributes.
-
# @return [Integer] Hash code
-
1
def hash
-
1
[to, scope, expiration_time_in_minutes, code].hash
-
end
-
-
# Builds the object from hash
-
# @param [Hash] attributes Model attributes in the form of hash
-
# @return [Object] Returns the model itself
-
1
def self.build_from_hash(attributes)
-
1
return nil unless attributes.is_a?(Hash)
-
1
attributes = attributes.transform_keys(&:to_sym)
-
1
transformed_hash = {}
-
1
openapi_types.each_pair do |key, type|
-
4
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
-
transformed_hash["#{key}"] = nil
-
4
elsif type =~ /\AArray<(.*)>/i
-
# check to ensure the input is an array given that the attribute
-
# is documented as an array but the input is not
-
if attributes[attribute_map[key]].is_a?(Array)
-
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
-
end
-
4
elsif !attributes[attribute_map[key]].nil?
-
4
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
-
end
-
end
-
1
new(transformed_hash)
-
end
-
-
# Deserializes the data based on type
-
# @param string type Data type
-
# @param string value Value to be deserialized
-
# @return [Object] Deserialized data
-
1
def self._deserialize(type, value)
-
4
case type.to_sym
-
when :Time
-
Time.parse(value)
-
when :Date
-
Date.parse(value)
-
when :String
-
3
value.to_s
-
when :Integer
-
value.to_i
-
when :Float
-
1
value.to_f
-
when :Boolean
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
-
true
-
else
-
false
-
end
-
when :Object
-
# generic object (usually a Hash), return directly
-
value
-
when /\AArray<(?<inner_type>.+)>\z/
-
inner_type = Regexp.last_match[:inner_type]
-
value.map { |v| _deserialize(inner_type, v) }
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
-
k_type = Regexp.last_match[:k_type]
-
v_type = Regexp.last_match[:v_type]
-
{}.tap do |hash|
-
value.each do |k, v|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
-
end
-
end
-
else # model
-
# models (e.g. Pet) or oneOf
-
klass = Bandwidth.const_get(type)
-
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
-
end
-
end
-
-
# Returns the string representation of the object
-
# @return [String] String presentation of the object
-
1
def to_s
-
1
to_hash.to_s
-
end
-
-
# to_body is an alias to to_hash (backward compatibility)
-
# @return [Hash] Returns the object in the form of hash
-
1
def to_body
-
1
to_hash
-
end
-
-
# Returns the object in the form of hash
-
# @return [Hash] Returns the object in the form of hash
-
1
def to_hash
-
4
hash = {}
-
4
self.class.attribute_map.each_pair do |attr, param|
-
16
value = self.send(attr)
-
16
if value.nil?
-
is_nullable = self.class.openapi_nullable.include?(attr)
-
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
-
end
-
-
16
hash[param] = _to_hash(value)
-
end
-
4
hash
-
end
-
-
# Outputs non-array value in the form of hash
-
# For object, use to_hash. Otherwise, just return the value
-
# @param [Object] value Any valid value
-
# @return [Hash] Returns the value in the form of hash
-
1
def _to_hash(value)
-
16
if value.is_a?(Array)
-
value.compact.map { |v| _to_hash(v) }
-
16
elsif value.is_a?(Hash)
-
{}.tap do |hash|
-
value.each { |k, v| hash[k] = _to_hash(v) }
-
end
-
16
elsif value.respond_to? :to_hash
-
value.to_hash
-
else
-
16
value
-
end
-
end
-
end
-
end
-
=begin
-
#Bandwidth
-
-
#Bandwidth's Communication APIs
-
-
The version of the OpenAPI document: 1.0.0
-
Contact: letstalk@bandwidth.com
-
Generated by: https://openapi-generator.tech
-
OpenAPI Generator version: 7.0.0
-
-
=end
-
-
1
module Bandwidth
-
1
VERSION = ENV.fetch('GEM_VERSION')
-
end
-
# Unit tests for Bandwidth::CallsApi
-
1
describe 'CallsApi' do
-
# call info
-
5
let(:call_id) { 'c-15ac29a2-006c67ad-060f-4b98-b148-b753d6e5e2ce' }
-
3
let(:enqueued_time) { '2023-06-23T18:43:51.248Z' }
-
2
let(:call_url) { "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}" }
-
2
let(:call_timeout) { 30.0 }
-
2
let(:callback_timeout) { 15.0 }
-
2
let(:display_name) { 'Ruby SDK' }
-
2
let(:answer_method) { Bandwidth::CallbackMethodEnum::POST }
-
2
let(:answer_url) { BASE_CALLBACK_URL + '/callbacks/answer' }
-
2
let(:answer_fallback_url) { BASE_CALLBACK_URL + '/callbacks/answer' }
-
2
let(:answer_fallback_method) { Bandwidth::CallbackMethodEnum::POST }
-
2
let(:disconnect_method) { Bandwidth::CallbackMethodEnum::GET }
-
2
let(:disconnect_url) { BASE_CALLBACK_URL + '/callbacks/disconnect' }
-
2
let(:priority) { 5 }
-
2
let(:direction) { Bandwidth::CallDirectionEnum::OUTBOUND }
-
2
let(:state) { 'disconnected' }
-
2
let(:stir_shaken) { {} }
-
2
let(:start_time) { '2023-06-23T19:11:06.049Z' }
-
2
let(:end_time) { '2023-06-23T19:11:06.175Z' }
-
2
let(:disconnect_cause) { 'rejected' }
-
2
let(:error_message) { 'Destination not found' }
-
2
let(:error_id) { '779941c4-6482-461d-b370-177b4ad0b5a7' }
-
2
let(:last_update) { '2023-06-23T19:11:06.175Z' }
-
2
let(:tag) { 'test tag' }
-
-
# stubs
-
2
let(:create_call_headers_stub) { { 'content-type' => 'application/json' } }
-
2
let(:create_call_body_stub) { "{\"applicationId\":\"#{BW_VOICE_APPLICATION_ID}\",\"accountId\":\"#{BW_ACCOUNT_ID}\",\"callId\":\"#{call_id}\",\"to\":\"#{USER_NUMBER}\",\"from\":\"#{BW_NUMBER}\",\"enqueuedTime\":\"#{enqueued_time}\",\"callUrl\":\"#{call_url}\",\"callTimeout\":#{call_timeout},\"callbackTimeout\":#{callback_timeout},\"tag\":\"#{tag}\",\"answerMethod\":\"#{answer_method}\",\"answerUrl\":\"#{answer_url}\",\"answerFallbackUrl\":\"#{answer_fallback_url}\",\"answerFallbackMethod\":\"#{answer_fallback_method}\",\"disconnectMethod\":\"#{disconnect_method}\",\"disconnectUrl\":\"#{disconnect_url}\",\"priority\":#{priority}}" }
-
1
let(:create_call_bad_request_stub) { '{"type":"validation","description":"Invalid to: must be a valid SIP URI or an E164 TN"}' }
-
2
let(:get_call_state_headers_stub) { { 'content-type' => 'application/json' } }
-
2
let(:get_call_state_body_stub) { "{\"applicationId\":\"#{BW_VOICE_APPLICATION_ID}\",\"accountId\":\"#{BW_ACCOUNT_ID}\",\"callId\":\"#{call_id}\",\"to\":\"#{USER_NUMBER}\",\"from\":\"#{BW_NUMBER}\",\"direction\":\"#{direction}\",\"state\":\"#{state}\",\"stirShaken\":#{stir_shaken},\"enqueuedTime\":\"#{enqueued_time}\",\"startTime\":\"#{start_time}\",\"endTime\":\"#{end_time}\",\"disconnectCause\":\"#{disconnect_cause}\",\"errorMessage\":\"#{error_message}\",\"errorId\":\"#{error_id}\",\"lastUpdate\":\"#{last_update}\"}" }
-
1
let(:get_call_state_not_found_stub) { '{"type":"validation","description":"Call does-not-exist was not found."}' }
-
1
let(:get_call_state_unauthorized_stub) { '{"type":"authentication-error","description":"The credentials provided were invalid"}' }
-
1
let(:get_call_state_forbidden_stub) { '{"type":"authorization-error","description":"Access is denied"}' }
-
2
let(:update_call_headers_stub) { { 'content-length' => '0' } }
-
-
1
before(:all) do
-
1
Bandwidth.configure do |config|
-
1
config.debugging = true
-
end
-
1
@calls_api_instance = Bandwidth::CallsApi.new
-
end
-
-
1
describe 'test an instance of CallsApi' do
-
1
it 'should create an instance of CallsApi' do
-
1
expect(@calls_api_instance).to be_instance_of(Bandwidth::CallsApi)
-
end
-
end
-
-
# Create Call
-
1
describe '#create_call' do
-
1
it 'creates a call with amd' do
-
1
stub_request(:post, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls").
-
to_return(status: 201, headers: create_call_headers_stub, body: create_call_body_stub)
-
-
1
amd_config = Bandwidth::MachineDetectionConfiguration.new(
-
mode: 'async',
-
detection_timeout: 5.0,
-
silence_timeout: 5.0,
-
speech_threshold: 5.0,
-
speech_end_threshold: 5.0,
-
delay_result: true,
-
callback_url: BASE_CALLBACK_URL + '/machineDetection',
-
callback_method: Bandwidth::CallbackMethodEnum::POST
-
)
-
-
1
call_body = Bandwidth::CreateCall.new(
-
application_id: BW_VOICE_APPLICATION_ID,
-
to: USER_NUMBER,
-
from: BW_NUMBER,
-
display_name: display_name,
-
answer_url: answer_url,
-
answer_fallback_url: answer_fallback_url,
-
answer_method: answer_method,
-
disconnect_url: disconnect_url,
-
disconnect_method: disconnect_method,
-
machine_detection: amd_config,
-
call_timeout: call_timeout,
-
callback_timeout: callback_timeout,
-
tag: tag
-
)
-
-
1
data, status_code, headers = @calls_api_instance.create_call_with_http_info(BW_ACCOUNT_ID, call_body)
-
-
1
expect(status_code).to eq(201)
-
1
expect(headers).to eq(create_call_headers_stub)
-
1
expect(data).to be_instance_of(Bandwidth::CreateCallResponse)
-
1
expect(data.application_id).to eq(BW_VOICE_APPLICATION_ID)
-
1
expect(data.account_id).to eq(BW_ACCOUNT_ID)
-
1
expect(data.call_id).to eq(call_id)
-
1
expect(data.to).to eq(USER_NUMBER)
-
1
expect(data.from).to eq(BW_NUMBER)
-
1
expect(data.enqueued_time).to eq(Time.parse(enqueued_time))
-
1
expect(data.call_url).to eq(call_url)
-
1
expect(data.call_timeout).to eq(call_timeout)
-
1
expect(data.callback_timeout).to eq(callback_timeout)
-
1
expect(data.tag).to eq(tag)
-
1
expect(data.answer_method).to eq(answer_method)
-
1
expect(data.answer_url).to eq(answer_url)
-
1
expect(data.answer_fallback_method).to eq(answer_fallback_method)
-
1
expect(data.answer_fallback_url).to eq(answer_fallback_url)
-
1
expect(data.disconnect_method).to eq(disconnect_method)
-
1
expect(data.disconnect_url).to eq(disconnect_url)
-
1
expect(data.priority).to eq(priority)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
@calls_api_instance.create_call(nil, {})
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing create_call' do
-
1
expect {
-
1
@calls_api_instance.create_call(BW_ACCOUNT_ID, nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Get Call State Information
-
1
describe '#get_call_state' do
-
1
it 'gets the call state' do
-
1
stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}").
-
to_return(status: 200, headers: get_call_state_headers_stub, body: get_call_state_body_stub)
-
-
1
data, status_code, headers = @calls_api_instance.get_call_state_with_http_info(BW_ACCOUNT_ID, call_id)
-
-
1
expect(status_code).to eq(200)
-
1
expect(headers).to eq(get_call_state_headers_stub)
-
1
expect(data).to be_instance_of(Bandwidth::CallState)
-
1
expect(data.application_id).to eq(BW_VOICE_APPLICATION_ID)
-
1
expect(data.account_id).to eq(BW_ACCOUNT_ID)
-
1
expect(data.call_id).to eq(call_id)
-
1
expect(data.to).to eq(USER_NUMBER)
-
1
expect(data.from).to eq(BW_NUMBER)
-
1
expect(data.direction).to eq(direction)
-
1
expect(data.stir_shaken).to eq(stir_shaken)
-
1
expect(data.state).to eq(state)
-
1
expect(data.enqueued_time).to eq(Time.parse(enqueued_time))
-
1
expect(data.start_time).to eq(Time.parse(start_time))
-
1
expect(data.end_time).to eq(Time.parse(end_time))
-
1
expect(data.disconnect_cause).to eq(disconnect_cause)
-
1
expect(data.error_message).to eq(error_message)
-
1
expect(data.error_id).to eq(error_id)
-
1
expect(data.last_update).to eq(Time.parse(last_update))
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @calls_api_instance.get_call_state(nil, '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing call_id' do
-
1
expect {
-
1
@calls_api_instance.get_call_state(BW_ACCOUNT_ID, nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Update Call
-
1
describe '#update_call' do
-
1
it 'creates and updates a call' do
-
1
stub_request(:post, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}").
-
to_return(status: 200, headers: update_call_headers_stub)
-
-
1
update_call_body = Bandwidth::UpdateCall.new(
-
state: Bandwidth::CallStateEnum::ACTIVE,
-
redirect_url: MANTECA_BASE_URL + '/bxml/pause'
-
)
-
-
1
data, status_code, headers = @calls_api_instance.update_call_with_http_info(BW_ACCOUNT_ID, call_id, update_call_body)
-
-
1
expect(status_code).to eq(200)
-
1
expect(headers).to eq(update_call_headers_stub)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @calls_api_instance.update_call(nil, '', {})
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing call_id' do
-
1
expect {
-
1
@calls_api_instance.update_call(BW_ACCOUNT_ID, nil, {})
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing update_call' do
-
1
expect {
-
1
@calls_api_instance.update_call(BW_ACCOUNT_ID, '', nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Update Call BXML
-
1
describe '#update_call_bxml' do
-
1
it 'updates a call using bxml' do
-
1
stub_request(:put, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/bxml").
-
to_return(status: 204)
-
-
1
update_bxml = '<?xml version="1.0" encoding="UTF-8"?><Bxml><SpeakSentence locale="en_US" gender="female" voice="susan">This is a test bxml response</SpeakSentence><Pause duration="3"/></Bxml>'
-
-
1
data, status_code, headers = @calls_api_instance.update_call_bxml_with_http_info(BW_ACCOUNT_ID, call_id, update_bxml)
-
-
1
expect(status_code).to eq(204)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
@calls_api_instance.update_call_bxml(nil, '', {})
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing call_id' do
-
1
expect {
-
1
@calls_api_instance.update_call_bxml(BW_ACCOUNT_ID, nil, {})
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing body' do
-
1
expect {
-
1
@calls_api_instance.update_call_bxml(BW_ACCOUNT_ID, '', nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::ConferencesApi
-
1
describe 'ConferencesApi' do
-
# conference info
-
5
let(:test_id) { 'ruby-3.1.3_macOS_conference_1687791527' }
-
10
let(:conference_id) { 'conf-3f758f24-6711b6d2-0d44-495d-afc8-2555c3ce5f4f' }
-
3
let(:created_time) { '2023-06-26T14:58:49.471Z' }
-
3
let(:conference_event_url) { 'https://amazonaws.com/prod/conferenceEvents' }
-
3
let(:conference_event_method) { 'POST' }
-
4
let(:call_id) { 'c-3f758f24-cd77b08f-97c2-4311-965a-a1ac8ed8f340' }
-
4
let(:recording_id) { 'r-fbe05094-7bf4b314-91fe-4bdd-a39b-500cdc873d3a' }
-
3
let(:start_time) { '2023-06-26T14:58:51.195Z' }
-
3
let(:end_time) { '2023-06-26T14:58:57.502Z' }
-
3
let(:duration) { 'PT6.3S' }
-
3
let(:channels) { 1 }
-
3
let(:file_format) { Bandwidth::FileFormatEnum::WAV }
-
3
let(:status) { 'complete' }
-
3
let(:member_url) { "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/members/#{call_id}" }
-
3
let(:media_url) { "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/recordings/#{recording_id}/media" }
-
2
let(:active_members) { "[{\"callId\":\"#{call_id}\",\"conferenceId\":\"#{conference_id}\",\"memberUrl\":\"#{member_url}\",\"mute\":false,\"hold\":false,\"callIdsToCoach\":[]}]" }
-
-
# stubs
-
2
let(:list_conferences_headers_stub) { { 'content-type' => 'application/json' } }
-
2
let(:list_conferences_body_stub) { "[{\"id\":\"#{conference_id}\",\"name\":\"#{test_id}\",\"createdTime\":\"#{created_time}\",\"conferenceEventUrl\":\"#{conference_event_url}\",\"conferenceEventMethod\":\"#{conference_event_method}\",\"tag\":\"#{test_id}\"}]" }
-
2
let(:get_conference_headers_stub) { { 'content-type' => 'application/json' } }
-
2
let(:get_conference_body_stub) { "{\"id\":\"#{conference_id}\",\"name\":\"#{test_id}\",\"createdTime\":\"#{created_time}\",\"conferenceEventUrl\":\"#{conference_event_url}\",\"conferenceEventMethod\":\"#{conference_event_method}\",\"tag\":\"#{test_id}\",\"activeMembers\":#{active_members}}" }
-
2
let(:get_conference_member_headers_stub) { { 'content-type' => 'application/json' } }
-
2
let(:get_conference_member_body_stub) { "{\"callId\":\"#{call_id}\",\"conferenceId\":\"#{conference_id}\",\"memberUrl\":\"#{member_url}\",\"mute\":false,\"hold\":false,\"callIdsToCoach\":[]}" }
-
2
let(:list_conference_recordings_headers_stub) { { 'content-type' => 'application/json' } }
-
2
let(:list_conference_recordings_body_stub) { "[{\"accountId\":\"#{BW_ACCOUNT_ID}\",\"conferenceId\":\"#{conference_id}\",\"name\":\"#{test_id}\",\"recordingId\":\"#{recording_id}\",\"duration\":\"#{duration}\",\"channels\":#{channels},\"startTime\":\"#{start_time}\",\"endTime\":\"#{end_time}\",\"fileFormat\":\"#{file_format}\",\"status\":\"#{status}\",\"mediaUrl\":\"#{media_url}\"}]" }
-
2
let(:get_conference_recording_headers_stub) { { 'content-type' => 'application/json' } }
-
2
let(:get_conference_recording_body_stub) { "{\"accountId\":\"#{BW_ACCOUNT_ID}\",\"conferenceId\":\"#{conference_id}\",\"name\":\"#{test_id}\",\"recordingId\":\"#{recording_id}\",\"duration\":\"#{duration}\",\"channels\":#{channels},\"startTime\":\"#{start_time}\",\"endTime\":\"#{end_time}\",\"fileFormat\":\"#{file_format}\",\"status\":\"#{status}\",\"mediaUrl\":\"#{media_url}\"}" }
-
2
let(:download_conference_recording_body_stub) { 'RIFFWAVEfmtLISTINFOISFTLavf58.45.100data' }
-
2
let(:download_conference_recording_headers_stub) { { 'content-type' => 'audio/vnd.wave', 'content-length' => "#{download_conference_recording_body_stub.length}" } }
-
-
1
before(:all) do
-
1
Bandwidth.configure do |config|
-
1
config.return_binary_data = true
-
1
config.debugging = true
-
end
-
1
@conferences_api_instance = Bandwidth::ConferencesApi.new
-
end
-
-
1
describe 'test an instance of ConferencesApi' do
-
1
it 'should create an instance of ConferencesApi' do
-
1
expect(@conferences_api_instance).to be_instance_of(Bandwidth::ConferencesApi)
-
end
-
end
-
-
# Download Conference Recording
-
1
describe 'download_conference_recording test' do
-
1
it 'should work' do
-
1
stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/recordings/#{recording_id}/media").
-
to_return(status: 200, headers: download_conference_recording_headers_stub, body: download_conference_recording_body_stub)
-
-
1
data, status_code, headers = @conferences_api_instance.download_conference_recording_with_http_info(BW_ACCOUNT_ID, conference_id, recording_id)
-
-
1
expect(status_code).to eq(200)
-
1
expect(headers).to eq(download_conference_recording_headers_stub)
-
1
expect(data).to eq(download_conference_recording_body_stub)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @conferences_api_instance.download_conference_recording(nil, '', '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing conference_id' do
-
1
expect {
-
1
@conferences_api_instance.download_conference_recording(BW_ACCOUNT_ID, nil, '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing recording_id' do
-
1
expect {
-
1
@conferences_api_instance.download_conference_recording(BW_ACCOUNT_ID, '', nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Get Conference Information
-
1
describe 'get_conference' do
-
1
it 'get a conference by id' do
-
1
stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}").
-
to_return(status: 200, headers: get_conference_headers_stub, body: get_conference_body_stub)
-
-
1
data, status_code, headers = @conferences_api_instance.get_conference_with_http_info(BW_ACCOUNT_ID, conference_id)
-
-
1
expect(status_code).to eq(200)
-
1
expect(headers).to eq(get_conference_headers_stub)
-
1
expect(data).to be_instance_of(Bandwidth::Conference)
-
1
expect(data.id).to eq(conference_id)
-
1
expect(data.name).to eq(test_id)
-
1
expect(data.tag).to eq(test_id)
-
1
expect(data.created_time).to eq(Time.parse(created_time))
-
1
expect(data.conference_event_url).to eq(conference_event_url)
-
1
expect(data.conference_event_method).to eq(conference_event_method)
-
1
expect(data.active_members).to be_instance_of(Array)
-
1
expect(data.active_members[0]).to be_instance_of(Bandwidth::ConferenceMember)
-
1
expect(data.active_members[0].call_id).to eq(call_id)
-
1
expect(data.active_members[0].conference_id).to eq(conference_id)
-
1
expect(data.active_members[0].member_url).to eq(member_url)
-
1
expect(data.active_members[0].mute).to be false
-
1
expect(data.active_members[0].hold).to be false
-
1
expect(data.active_members[0].call_ids_to_coach).to eq([])
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @conferences_api_instance.get_conference(nil, '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing conference_id' do
-
1
expect {
-
1
@conferences_api_instance.get_conference(BW_ACCOUNT_ID, nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Get Conference Member
-
1
describe 'get_conference_member' do
-
1
it 'gets a conference member by call id' do
-
1
stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/members/#{call_id}").
-
to_return(status: 200, headers: get_conference_member_headers_stub, body: get_conference_member_body_stub)
-
-
1
data, status_code, headers = @conferences_api_instance.get_conference_member_with_http_info(BW_ACCOUNT_ID, conference_id, call_id)
-
-
1
expect(status_code).to eq(200)
-
1
expect(headers).to eq(get_conference_member_headers_stub)
-
1
expect(data).to be_instance_of(Bandwidth::ConferenceMember)
-
1
expect(data.conference_id).to eq(conference_id)
-
1
expect(data.call_id).to eq(call_id)
-
1
expect(data.member_url).to eq(member_url)
-
1
expect(data.mute).to be false
-
1
expect(data.hold).to be false
-
1
expect(data.call_ids_to_coach).to eq([])
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @conferences_api_instance.get_conference_member(nil, '', '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing conference_id' do
-
1
expect {
-
1
@conferences_api_instance.get_conference_member(BW_ACCOUNT_ID, nil, '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing member_id' do
-
1
expect {
-
1
@conferences_api_instance.get_conference_member(BW_ACCOUNT_ID, '', nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Get Conference Recording Information
-
1
describe 'get_conference_recording' do
-
1
it 'gets a conference recording by id' do
-
1
stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/recordings/#{recording_id}").
-
to_return(status: 200, headers: get_conference_recording_headers_stub, body: get_conference_recording_body_stub)
-
-
1
data, status_code, headers = @conferences_api_instance.get_conference_recording_with_http_info(BW_ACCOUNT_ID, conference_id, recording_id)
-
-
1
expect(status_code).to eq(200)
-
1
expect(headers).to eq(get_conference_recording_headers_stub)
-
1
expect(data).to be_instance_of(Bandwidth::ConferenceRecordingMetadata)
-
1
expect(data.account_id).to eq(BW_ACCOUNT_ID)
-
1
expect(data.conference_id).to eq(conference_id)
-
1
expect(data.name).to eq(test_id)
-
1
expect(data.recording_id).to eq(recording_id)
-
1
expect(data.duration).to eq(duration)
-
1
expect(data.channels).to eq(channels)
-
1
expect(data.start_time).to eq(Time.parse(start_time))
-
1
expect(data.end_time).to eq(Time.parse(end_time))
-
1
expect(data.file_format).to eq(Bandwidth::FileFormatEnum::WAV)
-
1
expect(data.status).to eq('complete')
-
1
expect(data.media_url).to eq(media_url)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @conferences_api_instance.get_conference_recording(nil, '', '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing conference_id' do
-
1
expect {
-
1
@conferences_api_instance.get_conference_recording(BW_ACCOUNT_ID, nil, '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing recording_id' do
-
1
expect {
-
1
@conferences_api_instance.get_conference_recording(BW_ACCOUNT_ID, '', nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Get Conference Recordings
-
1
describe 'list_conference_recordings' do
-
1
it 'lists recordings for a conference' do
-
1
stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/recordings").
-
to_return(status: 200, headers: list_conference_recordings_headers_stub, body: list_conference_recordings_body_stub)
-
-
1
data, status_code, headers = @conferences_api_instance.list_conference_recordings_with_http_info(BW_ACCOUNT_ID, conference_id)
-
-
1
expect(status_code).to eq(200)
-
1
expect(headers).to eq(list_conference_recordings_headers_stub)
-
1
expect(data).to be_instance_of(Array)
-
1
expect(data[0]).to be_instance_of(Bandwidth::ConferenceRecordingMetadata)
-
1
expect(data[0].account_id).to eq(BW_ACCOUNT_ID)
-
1
expect(data[0].conference_id).to eq(conference_id)
-
1
expect(data[0].name).to eq(test_id)
-
1
expect(data[0].recording_id).to eq(recording_id)
-
1
expect(data[0].duration).to eq(duration)
-
1
expect(data[0].channels).to eq(channels)
-
1
expect(data[0].start_time).to eq(Time.parse(start_time))
-
1
expect(data[0].end_time).to eq(Time.parse(end_time))
-
1
expect(data[0].file_format).to eq(Bandwidth::FileFormatEnum::WAV)
-
1
expect(data[0].status).to eq('complete')
-
1
expect(data[0].media_url).to eq(media_url)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @conferences_api_instance.list_conference_recordings(nil, '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing conference_id' do
-
1
expect {
-
1
@conferences_api_instance.list_conference_recordings(BW_ACCOUNT_ID, nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Get Conferences
-
1
describe 'list_conferences' do
-
1
it 'list all conferences' do
-
1
stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences?name=#{test_id}").
-
to_return(status: 200, headers: list_conferences_headers_stub, body: list_conferences_body_stub)
-
-
conference_opts = {
-
1
name: test_id
-
}
-
-
1
data, status_code, headers = @conferences_api_instance.list_conferences_with_http_info(BW_ACCOUNT_ID, conference_opts)
-
-
1
expect(status_code).to eq(200)
-
1
expect(headers).to eq(list_conferences_headers_stub)
-
1
expect(data).to be_instance_of(Array)
-
1
expect(data[0]).to be_instance_of(Bandwidth::Conference)
-
1
expect(data[0].id).to eq(conference_id)
-
1
expect(data[0].name).to eq(test_id)
-
1
expect(data[0].tag).to eq(test_id)
-
1
expect(data[0].created_time).to eq(Time.parse(created_time))
-
1
expect(data[0].conference_event_url).to eq(conference_event_url)
-
1
expect(data[0].conference_event_method).to eq(conference_event_method)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @conferences_api_instance.list_conferences(nil, {})
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for an invalid page_size' do
-
1
expect {
-
1
@conferences_api_instance.list_conferences(BW_ACCOUNT_ID, { page_size: 1001 })
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for an invalid page_size' do
-
1
expect {
-
1
@conferences_api_instance.list_conferences(BW_ACCOUNT_ID, { page_size: 0 })
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Update Conference
-
1
describe 'update_conference' do
-
1
it 'updates a conference' do
-
1
stub_request(:post, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}").
-
to_return(status: 204)
-
-
1
update_conference_body = Bandwidth::UpdateConference.new(
-
status: Bandwidth::ConferenceStateEnum::ACTIVE,
-
redirect_url: BASE_CALLBACK_URL + '/bxml/pause',
-
redirect_method: Bandwidth::RedirectMethodEnum::POST,
-
username: 'username',
-
password: 'password',
-
redirect_fallback_url: BASE_CALLBACK_URL + '/bxml/pause',
-
redirect_fallback_method: Bandwidth::RedirectMethodEnum::POST,
-
fallback_username: 'username',
-
fallback_password: 'password'
-
)
-
-
1
data, status_code, headers = @conferences_api_instance.update_conference_with_http_info(BW_ACCOUNT_ID, conference_id, update_conference_body)
-
1
expect(status_code).to eq(204)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @conferences_api_instance.update_conference(nil, '', '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing conference_id' do
-
1
expect {
-
1
@conferences_api_instance.update_conference(BW_ACCOUNT_ID, nil, '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing update_conference' do
-
1
expect {
-
1
@conferences_api_instance.update_conference(BW_ACCOUNT_ID, '', nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Update Conference BXML
-
1
describe 'update_conference_bxml' do
-
1
it 'updates a conference using bxml' do
-
1
stub_request(:put, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/bxml").
-
to_return(status: 204)
-
-
1
update_bxml = '<?xml version="1.0" encoding="UTF-8"?><Bxml><StartRecording/><SpeakSentence locale="en_US" gender="female" voice="susan">This should be a conference recording.</SpeakSentence><StopRecording/></Bxml>'
-
-
1
data, status_code, headers = @conferences_api_instance.update_conference_bxml_with_http_info(BW_ACCOUNT_ID, conference_id, update_bxml)
-
1
expect(status_code).to eq(204)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @conferences_api_instance.update_conference_bxml(nil, '', '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing conference_id' do
-
1
expect {
-
1
@conferences_api_instance.update_conference_bxml(BW_ACCOUNT_ID, nil, '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing body' do
-
1
expect {
-
1
@conferences_api_instance.update_conference_bxml(BW_ACCOUNT_ID, '', nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Update Conference Member
-
1
describe 'update_conference_member' do
-
1
it 'updates a conference member by call id' do
-
1
stub_request(:put, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/members/#{call_id}").
-
to_return(status: 204)
-
-
1
update_conference_member = Bandwidth::UpdateConferenceMember.new(
-
mute: false
-
)
-
-
1
data, status_code, headers = @conferences_api_instance.update_conference_member_with_http_info(BW_ACCOUNT_ID, conference_id, call_id, update_conference_member)
-
1
expect(status_code).to eq(204)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @conferences_api_instance.update_conference_member(nil, '', '', {})
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing conference_id' do
-
1
expect {
-
1
@conferences_api_instance.update_conference_member(BW_ACCOUNT_ID, nil, '', {})
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing member_id' do
-
1
expect {
-
1
@conferences_api_instance.update_conference_member(BW_ACCOUNT_ID, '', nil, {})
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing update_conference_member' do
-
1
expect {
-
1
@conferences_api_instance.update_conference_member(BW_ACCOUNT_ID, '', '', nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::MediaApi
-
1
describe 'MediaApi' do
-
# media info
-
5
let(:media_name) { 'ruby_binary_media' + SecureRandom.uuid }
-
4
let(:media_data) { '123456' }
-
2
let(:content_url) { "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/media/#{media_name}" }
-
-
# stubs
-
2
let(:get_media_headers_stub) { { 'content-type' => 'application/json' } }
-
2
let(:list_media_body_stub) { "[{\"contentLength\":#{media_data.length},\"mediaName\":\"#{media_name}\",\"content\":\"#{content_url}\"}]" }
-
2
let(:list_media_headers_stub) { { 'content-type' => 'application/json' } }
-
-
1
before(:all) do
-
1
Bandwidth.configure do |config|
-
1
config.return_binary_data = true
-
1
config.debugging = true
-
end
-
1
@media_api_instance = Bandwidth::MediaApi.new
-
end
-
-
1
describe 'test an instance of MediaApi' do
-
1
it 'should create an instance of MediaApi' do
-
1
expect(@media_api_instance).to be_instance_of(Bandwidth::MediaApi)
-
end
-
end
-
-
# Delete Media
-
1
describe 'delete_media' do
-
1
it 'deletes the binary media' do
-
1
stub_request(:delete, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/media/#{media_name}").
-
to_return(status: 204)
-
-
1
data, status_code, headers = @media_api_instance.delete_media_with_http_info(BW_ACCOUNT_ID, media_name)
-
-
1
expect(status_code).to eq(204)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @media_api_instance.delete_media(nil, '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing media_id' do
-
1
expect {
-
1
@media_api_instance.delete_media(BW_ACCOUNT_ID, nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Get Media
-
1
describe 'get_media' do
-
1
it 'gets uploaded binary media' do
-
1
stub_request(:get, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/media/#{media_name}").
-
to_return(status: 200, headers: get_media_headers_stub, body: media_data)
-
-
1
data, status_code, headers = @media_api_instance.get_media_with_http_info(BW_ACCOUNT_ID, media_name)
-
-
1
expect(status_code).to eq(200)
-
1
expect(headers).to eq(get_media_headers_stub)
-
1
expect(data).to eq(media_data)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @media_api_instance.get_media(nil, '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing media_id' do
-
1
expect {
-
1
@media_api_instance.get_media(BW_ACCOUNT_ID, nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# List Media
-
1
describe 'list_media' do
-
1
it 'lists media' do
-
1
stub_request(:get, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/media").
-
to_return(status: 200, headers: list_media_headers_stub, body: list_media_body_stub)
-
-
1
data, status_code, headers = @media_api_instance.list_media_with_http_info(BW_ACCOUNT_ID)
-
-
1
expect(status_code).to eq(200)
-
1
expect(headers).to eq(list_media_headers_stub)
-
1
expect(data).to be_instance_of(Array)
-
1
expect(data[0]).to be_instance_of(Bandwidth::Media)
-
1
expect(data[0].content_length).to eq(media_data.length)
-
1
expect(data[0].media_name).to eq(media_name)
-
1
expect(data[0].content).to eq(content_url)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @media_api_instance.list_media(nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Upload Media
-
1
describe 'upload_media' do
-
1
it 'uploads binary media' do
-
1
stub_request(:put, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/media/#{media_name}").
-
to_return(status: 204)
-
-
1
data, status_code, headers = @media_api_instance.upload_media_with_http_info(BW_ACCOUNT_ID, media_name, media_data)
-
1
expect(status_code).to eq(204)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @media_api_instance.upload_media(nil, '', '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing media_id' do
-
1
expect {
-
1
@media_api_instance.upload_media(BW_ACCOUNT_ID, nil, '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing body' do
-
1
expect {
-
1
@media_api_instance.upload_media(BW_ACCOUNT_ID, '', nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::MessagesApi
-
1
describe 'MessagesApi' do
-
# message info
-
3
let(:mms_id) { '1687899647358cu2t57tczmbzcu2s' }
-
3
let(:sms_id) { '1687899647634s46mhdt7ifq5hnjl' }
-
4
let(:time) { '2023-06-27T21:00:47.358063Z' }
-
4
let(:segment_count) { 1 }
-
3
let(:direction) { Bandwidth::MessageDirectionEnum::OUT }
-
4
let(:text) { 'test text' }
-
2
let(:media_url) { 'https://cdn2.thecatapi.com/images/MTY3ODIyMQ.jpg' }
-
3
let(:tag) { 'test tag' }
-
2
let(:priority) { Bandwidth::PriorityEnum::HIGH }
-
2
let(:expiration_time) { (Time.now + 60).round.to_datetime.rfc3339 }
-
2
let(:total_count) { 2 }
-
2
let(:next_page_token) { 'YWZ0ZXI9MTAwJmxpbWl0PTEwMA' }
-
2
let(:list_message_direction) { Bandwidth::ListMessageDirectionEnum::OUTBOUND }
-
2
let(:list_message_status) { Bandwidth::MessageStatusEnum::SENT }
-
2
let(:list_message_type_mms) { Bandwidth::MessageTypeEnum::MMS }
-
2
let(:list_message_type_sms) { Bandwidth::MessageTypeEnum::SMS }
-
2
let(:mms_length) { 45151 }
-
2
let(:attachment_count) { 1 }
-
2
let(:recipient_count) { 1 }
-
2
let(:mms_error_code) { 0 }
-
2
let(:sms_error_code) { 4720 }
-
2
let(:carrier_name) { 'Other' }
-
2
let(:next_page_url) { "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/messages?messageDirection=#{list_message_direction}&sourceTn=%2B#{BW_NUMBER[1..-1]}&pageToken=#{next_page_token}" }
-
-
# stubs
-
2
let(:create_message_mms_headers_stub) { { 'content-type' => 'application/json' } }
-
2
let(:create_message_mms_body_stub) { "{\"id\":\"#{mms_id}\",\"owner\":\"#{BW_NUMBER}\",\"applicationId\":\"#{BW_MESSAGING_APPLICATION_ID}\",\"time\":\"#{time}\",\"segmentCount\":#{segment_count},\"direction\":\"#{direction}\",\"to\":[\"#{USER_NUMBER}\"],\"from\":\"#{BW_NUMBER}\",\"text\":\"#{text}\",\"media\":[\"#{media_url}\"],\"tag\":\"#{tag}\"}" }
-
2
let(:create_message_sms_headers_stub) { { 'content-type' => 'application/json' } }
-
2
let(:create_message_sms_body_stub) { "{\"id\":\"#{sms_id}\",\"owner\":\"#{BW_NUMBER}\",\"applicationId\":\"#{BW_MESSAGING_APPLICATION_ID}\",\"time\":\"#{time}\",\"segmentCount\":#{segment_count},\"direction\":\"#{direction}\",\"to\":[\"#{USER_NUMBER}\"],\"from\":\"#{BW_NUMBER}\",\"text\":\"#{text}\",\"tag\":\"#{tag}\",\"priority\":\"#{priority}\",\"expiration\":\"#{expiration_time}\"}" }
-
2
let(:list_messages_body_stub) { "{\"totalCount\":#{total_count},\"pageInfo\":{\"nextPage\":\"#{next_page_url}\",\"nextPageToken\":\"#{next_page_token}\"},\"messages\":[{\"messageId\":\"#{mms_id}\",\"accountId\":\"#{BW_ACCOUNT_ID}\",\"sourceTn\":\"#{BW_NUMBER}\",\"destinationTn\":\"#{USER_NUMBER}\",\"messageStatus\":\"#{list_message_status}\",\"messageDirection\":\"#{list_message_direction}\",\"messageType\":\"#{list_message_type_mms}\",\"segmentCount\":#{segment_count},\"messageLength\":#{mms_length},\"messageSize\":#{mms_length},\"attachmentCount\":#{attachment_count},\"recipientCount\":#{recipient_count},\"errorCode\":#{mms_error_code},\"carrierName\":null,\"campaignClass\":null,\"campaignId\":null,\"receiveTime\":\"#{time}\"},{\"messageId\":\"#{sms_id}\",\"accountId\":\"#{BW_ACCOUNT_ID}\",\"sourceTn\":\"#{BW_NUMBER}\",\"destinationTn\":\"#{USER_NUMBER}\",\"messageStatus\":\"#{list_message_status}\",\"messageDirection\":\"#{list_message_direction}\",\"messageType\":\"#{list_message_type_sms}\",\"segmentCount\":#{segment_count},\"messageLength\":#{text.length},\"messageSize\":null,\"attachmentCount\":null,\"recipientCount\":null,\"errorCode\":#{sms_error_code},\"carrierName\":\"#{carrier_name}\",\"campaignClass\":null,\"campaignId\":null,\"receiveTime\":\"#{time}\"}]}" }
-
2
let(:list_messages_headers_stub) { { 'content-type' => 'application/json', 'content-length' => "#{list_messages_body_stub.length}" } }
-
-
1
before(:all) do
-
1
Bandwidth.configure do |config|
-
1
config.debugging = true
-
end
-
1
@messaging_api_instance = Bandwidth::MessagesApi.new
-
end
-
-
1
describe 'test an instance of MessagesApi' do
-
1
it 'should create an instance of MessagesApi' do
-
1
expect(@messaging_api_instance).to be_instance_of(Bandwidth::MessagesApi)
-
end
-
end
-
-
# Create Message
-
1
describe 'create_message' do
-
1
it 'creates an mms message' do
-
1
stub_request(:post, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/messages").
-
to_return(status: 202, headers: create_message_mms_headers_stub, body: create_message_mms_body_stub)
-
-
1
message_request = Bandwidth::MessageRequest.new(
-
application_id: BW_MESSAGING_APPLICATION_ID,
-
to: [USER_NUMBER],
-
from: BW_NUMBER,
-
text: text,
-
media: [media_url],
-
tag: tag
-
)
-
-
1
data, status_code, headers = @messaging_api_instance.create_message_with_http_info(BW_ACCOUNT_ID, message_request)
-
-
1
expect(status_code).to eq(202)
-
1
expect(headers).to eq(create_message_mms_headers_stub)
-
1
expect(data).to be_instance_of(Bandwidth::Message)
-
1
expect(data.id).to eq(mms_id)
-
1
expect(data.owner).to eq(BW_NUMBER)
-
1
expect(data.application_id).to eq(BW_MESSAGING_APPLICATION_ID)
-
1
expect(data.time).to eq(Time.parse(time))
-
1
expect(data.segment_count).to eq(segment_count)
-
1
expect(data.direction).to eq(direction)
-
1
expect(data.to).to eq([USER_NUMBER])
-
1
expect(data.from).to eq(BW_NUMBER)
-
1
expect(data.text).to eq(text)
-
1
expect(data.media).to eq([media_url])
-
1
expect(data.tag).to eq(tag)
-
end
-
-
1
it 'creates an sms message' do
-
1
stub_request(:post, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/messages").
-
to_return(status: 202, headers: create_message_sms_headers_stub, body: create_message_sms_body_stub)
-
-
1
message_request = Bandwidth::MessageRequest.new(
-
application_id: BW_MESSAGING_APPLICATION_ID,
-
to: [USER_NUMBER],
-
from: BW_NUMBER,
-
text: text,
-
tag: tag,
-
priority: priority,
-
expiration: expiration_time
-
)
-
-
1
data, status_code, headers = @messaging_api_instance.create_message_with_http_info(BW_ACCOUNT_ID, message_request)
-
-
1
expect(status_code).to eq(202)
-
1
expect(headers).to eq(create_message_sms_headers_stub)
-
1
expect(data).to be_instance_of(Bandwidth::Message)
-
1
expect(data.id).to eq(sms_id)
-
1
expect(data.owner).to eq(BW_NUMBER)
-
1
expect(data.application_id).to eq(BW_MESSAGING_APPLICATION_ID)
-
1
expect(data.time).to eq(Time.parse(time))
-
1
expect(data.segment_count).to eq(segment_count)
-
1
expect(data.direction).to eq(direction)
-
1
expect(data.to).to eq([USER_NUMBER])
-
1
expect(data.from).to eq(BW_NUMBER)
-
1
expect(data.text).to eq(text)
-
1
expect(data.tag).to eq(tag)
-
1
expect(data.priority).to eq(priority)
-
1
expect(data.expiration).to eq(Time.parse(expiration_time))
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @messaging_api_instance.create_message(nil, {})
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing message_request' do
-
1
expect {
-
1
@messaging_api_instance.create_message(BW_ACCOUNT_ID, nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# List Messages
-
1
describe 'list_messages' do
-
1
it 'lists messages' do
-
1
stub_request(:get, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/messages?messageDirection=#{list_message_direction}&sourceTn=%2B#{BW_NUMBER[1..-1]}").
-
to_return(status: 200, headers: list_messages_headers_stub, body: list_messages_body_stub)
-
-
get_opts = {
-
1
:source_tn => BW_NUMBER,
-
:message_direction => list_message_direction
-
}
-
-
1
data, status_code, headers = @messaging_api_instance.list_messages_with_http_info(BW_ACCOUNT_ID, get_opts)
-
-
1
expect(status_code).to eq(200)
-
1
expect(headers).to eq(list_messages_headers_stub)
-
1
expect(data).to be_instance_of(Bandwidth::MessagesList)
-
1
expect(data.total_count).to eq(total_count)
-
1
expect(data.page_info.next_page).to eq(next_page_url)
-
1
expect(data.page_info.next_page_token).to eq(next_page_token)
-
1
expect(data.messages.length).to eq(total_count)
-
1
expect(data.messages).to be_instance_of(Array)
-
1
expect(data.messages[0]).to be_instance_of(Bandwidth::ListMessageItem)
-
1
expect(data.messages[0].message_id).to eq(mms_id)
-
1
expect(data.messages[0].account_id).to eq(BW_ACCOUNT_ID)
-
1
expect(data.messages[0].source_tn).to eq(BW_NUMBER)
-
1
expect(data.messages[0].destination_tn).to eq(USER_NUMBER)
-
1
expect(data.messages[0].message_status).to eq(list_message_status)
-
1
expect(data.messages[0].message_direction).to eq(list_message_direction)
-
1
expect(data.messages[0].message_type).to eq(list_message_type_mms)
-
1
expect(data.messages[0].segment_count).to eq(segment_count)
-
1
expect(data.messages[0].error_code).to eq(mms_error_code)
-
1
expect(data.messages[0].receive_time).to eq(Time.parse(time))
-
1
expect(data.messages[0].carrier_name).to eq(nil)
-
1
expect(data.messages[0].message_size).to eq(mms_length)
-
1
expect(data.messages[0].message_length).to eq(mms_length)
-
1
expect(data.messages[0].attachment_count).to eq(attachment_count)
-
1
expect(data.messages[0].recipient_count).to eq(recipient_count)
-
1
expect(data.messages[0].campaign_class).to eq(nil)
-
1
expect(data.messages[0].campaign_id).to eq(nil)
-
1
expect(data.messages[1]).to be_instance_of(Bandwidth::ListMessageItem)
-
1
expect(data.messages[1].message_id).to eq(sms_id)
-
1
expect(data.messages[1].account_id).to eq(BW_ACCOUNT_ID)
-
1
expect(data.messages[1].source_tn).to eq(BW_NUMBER)
-
1
expect(data.messages[1].destination_tn).to eq(USER_NUMBER)
-
1
expect(data.messages[1].message_status).to eq(list_message_status)
-
1
expect(data.messages[1].message_direction).to eq(list_message_direction)
-
1
expect(data.messages[1].message_type).to eq(list_message_type_sms)
-
1
expect(data.messages[1].segment_count).to eq(segment_count)
-
1
expect(data.messages[1].error_code).to eq(sms_error_code)
-
1
expect(data.messages[1].receive_time).to eq(Time.parse(time))
-
1
expect(data.messages[1].carrier_name).to eq(carrier_name)
-
1
expect(data.messages[1].message_size).to eq(nil)
-
1
expect(data.messages[1].message_length).to eq(text.length)
-
1
expect(data.messages[1].attachment_count).to eq(nil)
-
1
expect(data.messages[1].recipient_count).to eq(nil)
-
1
expect(data.messages[1].campaign_class).to eq(nil)
-
1
expect(data.messages[1].campaign_id).to eq(nil)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @messaging_api_instance.list_messages(nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::MFAApi
-
1
describe 'MFAApi' do
-
# mfa info
-
3
let(:message) { 'Your temporary {NAME} {SCOPE} code is: {CODE}' }
-
2
let(:message_id) { '1687965513364hx26ky4mpkll3m5a' }
-
2
let(:call_id) { 'c-28bba681-cffc7d67-904e-42c8-85c5-b5589ea583b4' }
-
3
let(:digits) { 6 }
-
-
# stubs
-
2
let(:generate_messaging_code_body_stub) { "{\"messageId\": \"#{message_id}\"}" }
-
2
let(:generate_messaging_code_headers_stub) { { 'content-type' => 'application/json', 'content-length' => "#{generate_messaging_code_body_stub.length}" } }
-
2
let(:generate_voice_code_body_stub) { "{\"callId\": \"#{call_id}\"}" }
-
2
let(:generate_voice_code_headers_stub) { { 'content-type' => 'application/json', 'content-length' => "#{generate_voice_code_body_stub.length}" } }
-
2
let(:verify_code_body_stub) { '{"valid": false}' }
-
2
let(:verify_code_headers_stub) { { 'content-type' => 'application/json', 'content-length' => "#{verify_code_body_stub.length}" } }
-
-
1
before(:all) do
-
1
Bandwidth.configure do |config|
-
1
config.debugging = true
-
end
-
1
@mfa_api_instance = Bandwidth::MFAApi.new
-
end
-
-
1
describe 'test an instance of MFAApi' do
-
1
it 'should create an instance of MFAApi' do
-
1
expect(@mfa_api_instance).to be_instance_of(Bandwidth::MFAApi)
-
end
-
end
-
-
# Messaging Authentication Code
-
1
describe 'generate_messaging_code' do
-
1
it 'generates messaging mfa code' do
-
1
stub_request(:post, "https://mfa.bandwidth.com/api/v1/accounts/#{BW_ACCOUNT_ID}/code/messaging").
-
to_return(status: 200, headers: generate_messaging_code_headers_stub, body: generate_messaging_code_body_stub)
-
-
1
req_schema = Bandwidth::CodeRequest.new(
-
to: USER_NUMBER,
-
from: BW_NUMBER,
-
application_id: BW_MESSAGING_APPLICATION_ID,
-
message: message,
-
digits: digits
-
)
-
-
1
data, status_code, headers = @mfa_api_instance.generate_messaging_code_with_http_info(BW_ACCOUNT_ID, req_schema)
-
-
1
expect(status_code).to eq(200)
-
1
expect(data).to be_instance_of(Bandwidth::MessagingCodeResponse)
-
1
expect(data.message_id).to eq(message_id)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @mfa_api_instance.generate_messaging_code(nil, {})
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing code_request' do
-
1
expect {
-
1
@mfa_api_instance.generate_messaging_code(BW_ACCOUNT_ID, nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Voice Authentication Code
-
1
describe 'generate_voice_code' do
-
1
it 'generates voice mfa code' do
-
1
stub_request(:post, "https://mfa.bandwidth.com/api/v1/accounts/#{BW_ACCOUNT_ID}/code/voice").
-
to_return(status: 200, headers: generate_voice_code_headers_stub, body: generate_voice_code_body_stub)
-
-
1
req_schema = Bandwidth::CodeRequest.new(
-
to: USER_NUMBER,
-
from: BW_NUMBER,
-
application_id: BW_VOICE_APPLICATION_ID,
-
message: message,
-
digits: digits
-
)
-
-
1
data, status_code, headers = @mfa_api_instance.generate_voice_code_with_http_info(BW_ACCOUNT_ID, req_schema)
-
-
1
expect(status_code).to eq(200)
-
1
expect(data).to be_instance_of(Bandwidth::VoiceCodeResponse)
-
1
expect(data.call_id).to eq(call_id)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @mfa_api_instance.generate_voice_code(nil, {})
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing code_request' do
-
1
expect {
-
1
@mfa_api_instance.generate_voice_code(BW_ACCOUNT_ID, nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Verify Authentication Code
-
1
describe 'verify_code' do
-
1
it 'verifies mfa code' do
-
1
stub_request(:post, "https://mfa.bandwidth.com/api/v1/accounts/#{BW_ACCOUNT_ID}/code/verify").
-
to_return(status: 200, headers: verify_code_headers_stub, body: verify_code_body_stub)
-
-
1
req_schema = Bandwidth::VerifyCodeRequest.new(
-
to: '+1000' + rand(1...10000000).to_s,
-
scope: '2FA',
-
expiration_time_in_minutes: 3,
-
code: '12345'
-
)
-
-
1
data, status_code, headers = @mfa_api_instance.verify_code_with_http_info(BW_ACCOUNT_ID, req_schema)
-
-
1
expect(status_code).to eq(200)
-
1
expect(data).to be_instance_of(Bandwidth::VerifyCodeResponse)
-
1
expect(data.valid).to be false
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @mfa_api_instance.verify_code(nil, {})
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing cvarify_ode_request' do
-
1
expect {
-
1
@mfa_api_instance.verify_code(BW_ACCOUNT_ID, nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::PhoneNumberLookupApi
-
1
describe 'PhoneNumberLookupApi' do
-
# lookup info
-
3
let(:request_id) { '21e6d818-eaa9-4ca9-b1d8-d6085f5c79d4' }
-
2
let(:status_in_progress) { Bandwidth::LookupStatusEnum::IN_PROGRESS }
-
2
let(:status_complete) { Bandwidth::LookupStatusEnum::COMPLETE }
-
2
let(:response_code) { 0 }
-
2
let(:message) { 'NOERROR' }
-
2
let(:formatted) { "(#{BW_NUMBER[2..4]}) #{BW_NUMBER[5..7]}-#{BW_NUMBER[7..-1]}" }
-
2
let(:country) { 'US' }
-
2
let(:line_type) { 'Mobile' }
-
2
let(:line_provider) { 'AdHoc P2P - Bandwidth - SVR' }
-
-
# stubs
-
2
let(:create_lookup_headers_stub) { { 'content-type' => 'application/json' } }
-
2
let(:create_lookup_body_stub) { "{\"requestId\":\"#{request_id}\",\"status\":\"#{status_in_progress}\"}" }
-
2
let(:get_lookup_status_headers_stub) { { 'content-type' => 'application/json' } }
-
2
let(:get_lookup_status_body_stub) { "{\"requestId\":\"#{request_id}\",\"status\":\"#{status_complete}\",\"result\":[{\"Response Code\":#{response_code},\"Message\":\"#{message}\",\"E.164 Format\":\"#{BW_NUMBER}\",\"Formatted\":\"#{formatted}\",\"Country\":\"#{country}\",\"Line Type\":\"#{line_type}\",\"Line Provider\":\"#{line_provider}\"}]}" }
-
-
1
before(:all) do
-
1
Bandwidth.configure do |config|
-
1
config.debugging = true
-
end
-
1
@phone_number_lookup_api_instance = Bandwidth::PhoneNumberLookupApi.new
-
end
-
-
1
describe 'test an instance of PhoneNumberLookupApi' do
-
1
it 'should create an instance of PhoneNumberLookupApi' do
-
1
expect(@phone_number_lookup_api_instance).to be_instance_of(Bandwidth::PhoneNumberLookupApi)
-
end
-
end
-
-
# Create Lookup
-
1
describe 'create_lookup' do
-
1
it 'creates a tn lookup request' do
-
1
stub_request(:post, "https://numbers.bandwidth.com/api/v1/accounts/#{BW_ACCOUNT_ID}/tnlookup").
-
to_return(status: 202, headers: create_lookup_headers_stub, body: create_lookup_body_stub)
-
-
1
tn_body = Bandwidth::LookupRequest.new(
-
tns: [BW_NUMBER]
-
)
-
1
data, status_code, headers = @phone_number_lookup_api_instance.create_lookup_with_http_info(BW_ACCOUNT_ID, tn_body)
-
-
1
expect(status_code).to eq(202)
-
1
expect(headers).to eq(create_lookup_headers_stub)
-
1
expect(data).to be_instance_of(Bandwidth::CreateLookupResponse)
-
1
expect(data.request_id).to eq(request_id)
-
1
expect(data.status).to eq(status_in_progress)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @phone_number_lookup_api_instance.create_lookup(nil, {})
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing lookup_request' do
-
1
expect {
-
1
@phone_number_lookup_api_instance.create_lookup(BW_ACCOUNT_ID, nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Get Lookup Status
-
1
describe 'get_lookup_status' do
-
1
it 'gets lookup status' do
-
1
stub_request(:get, "https://numbers.bandwidth.com/api/v1/accounts/#{BW_ACCOUNT_ID}/tnlookup/#{request_id}").
-
to_return(status: 200, headers: get_lookup_status_headers_stub, body: get_lookup_status_body_stub)
-
-
1
data, status_code, headers = @phone_number_lookup_api_instance.get_lookup_status_with_http_info(BW_ACCOUNT_ID, request_id)
-
-
1
expect(status_code).to eq(200)
-
1
expect(headers).to eq(get_lookup_status_headers_stub)
-
1
expect(data).to be_instance_of(Bandwidth::LookupStatus)
-
1
expect(data.request_id).to eq(request_id)
-
1
expect(data.status).to eq(status_complete)
-
1
expect(data.result).to be_instance_of(Array)
-
1
expect(data.result[0]).to be_instance_of(Bandwidth::LookupResult)
-
1
expect(data.result[0].response_code).to eq(response_code)
-
1
expect(data.result[0].message).to eq(message)
-
1
expect(data.result[0].e_164_format).to eq(BW_NUMBER)
-
1
expect(data.result[0].formatted).to eq(formatted)
-
1
expect(data.result[0].country).to eq(country)
-
1
expect(data.result[0].line_type).to eq(line_type)
-
1
expect(data.result[0].line_provider).to eq(line_provider)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @phone_number_lookup_api_instance.get_lookup_status(nil, '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing request_id' do
-
1
expect {
-
1
@phone_number_lookup_api_instance.get_lookup_status(BW_ACCOUNT_ID, nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::RecordingsApi
-
1
describe 'RecordingsApi' do
-
# recording info
-
11
let(:call_id) { 'c-3f758f24-40c0bd9f-0a8e-4ab6-88d4-c88a2e961c7d' }
-
10
let(:recording_id) { 'r-fbe05094-87f9b821-e110-4bfb-ac57-82b2bf2bb3d5' }
-
4
let(:duration) { 'PT4.478S' }
-
4
let(:direction) { Bandwidth::CallDirectionEnum::OUTBOUND }
-
4
let(:channels) { 1 }
-
4
let(:start_time) { '2023-06-26T14:58:51.195Z' }
-
4
let(:end_time) { '2023-06-26T14:58:57.502Z' }
-
4
let(:file_format) { Bandwidth::FileFormatEnum::WAV }
-
4
let(:status) { 'complete' }
-
4
let(:media_url) { "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/recordings/#{recording_id}/media" }
-
2
let(:text) { 'Now a recording, a long pause.' }
-
2
let(:confidence) { 0.975 }
-
2
let(:test_id) { 'test id' }
-
-
# stubs
-
2
let(:download_call_recording_body_stub) { 'RIFFFWAVEfmtLISTINFOISFTLavf58.45.100data' }
-
2
let(:download_call_recording_headers_stub) { { 'content-type' => 'audio/vnd.wave', 'content-length' => "#{download_call_recording_body_stub.length}" } }
-
2
let(:get_call_recording_headers_stub) { { 'content-type' => 'application/json' } }
-
2
let(:get_call_recording_body_stub) { "{\"applicationId\":\"#{BW_VOICE_APPLICATION_ID}\",\"accountId\":\"#{BW_ACCOUNT_ID}\",\"callId\":\"#{call_id}\",\"recordingId\":\"#{recording_id}\",\"to\":\"#{USER_NUMBER}\",\"from\":\"#{BW_NUMBER}\",\"duration\":\"#{duration}\",\"direction\":\"#{direction}\",\"channels\":#{channels},\"startTime\":\"#{start_time}\",\"endTime\":\"#{end_time}\",\"fileFormat\":\"#{file_format}\",\"status\":\"#{status}\",\"mediaUrl\":\"#{media_url}\"}" }
-
2
let(:get_call_transcription_headers_stub) { { 'content-type' => 'application/json' } }
-
2
let(:get_call_transcription_body_stub) { "{\"transcripts\":[{\"text\":\"#{text}\",\"confidence\":#{confidence}}]}" }
-
2
let(:list_account_call_recordings_headers_stub) { { 'content-type' => 'application/json' } }
-
2
let(:list_account_call_recordings_body_stub) { "[{\"applicationId\":\"#{BW_VOICE_APPLICATION_ID}\",\"accountId\":\"#{BW_ACCOUNT_ID}\",\"callId\":\"#{call_id}\",\"recordingId\":\"#{recording_id}\",\"to\":\"#{USER_NUMBER}\",\"from\":\"#{BW_NUMBER}\",\"duration\":\"#{duration}\",\"direction\":\"#{direction}\",\"channels\":#{channels},\"startTime\":\"#{start_time}\",\"endTime\":\"#{end_time}\",\"fileFormat\":\"#{file_format}\",\"status\":\"#{status}\",\"mediaUrl\":\"#{media_url}\"}]" }
-
2
let(:list_call_recordings_headers_stub) { { 'content-type' => 'application/json' } }
-
2
let(:list_call_recordings_body_stub) { "[{\"applicationId\":\"#{BW_VOICE_APPLICATION_ID}\",\"accountId\":\"#{BW_ACCOUNT_ID}\",\"callId\":\"#{call_id}\",\"recordingId\":\"#{recording_id}\",\"to\":\"#{USER_NUMBER}\",\"from\":\"#{BW_NUMBER}\",\"duration\":\"#{duration}\",\"direction\":\"#{direction}\",\"channels\":#{channels},\"startTime\":\"#{start_time}\",\"endTime\":\"#{end_time}\",\"fileFormat\":\"#{file_format}\",\"status\":\"#{status}\",\"mediaUrl\":\"#{media_url}\"}]" }
-
2
let(:update_call_recording_state_headers_stub) { { 'content-length' => '0' } }
-
-
1
before(:all) do
-
1
Bandwidth.configure do |config|
-
1
config.return_binary_data = true
-
1
config.debugging = true
-
end
-
1
@recordings_api_instance = Bandwidth::RecordingsApi.new
-
end
-
-
1
describe 'test an instance of RecordingsApi' do
-
1
it 'should create an instance of RecordingsApi' do
-
1
expect(@recordings_api_instance).to be_instance_of(Bandwidth::RecordingsApi)
-
end
-
end
-
-
# Delete Transcription
-
1
describe 'delete_call_transcription' do
-
1
it 'deletes the completed call recording transcription' do
-
1
stub_request(:delete, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/recordings/#{recording_id}/transcription").
-
to_return(status: 204)
-
-
1
data, status_code, headers = @recordings_api_instance.delete_call_transcription_with_http_info(BW_ACCOUNT_ID, call_id, recording_id)
-
-
1
expect(status_code).to eq(204)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @recordings_api_instance.delete_call_transcription(nil, '', '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing call_id' do
-
1
expect {
-
1
@recordings_api_instance.delete_call_transcription(BW_ACCOUNT_ID, nil, '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing recording_id' do
-
1
expect {
-
1
@recordings_api_instance.delete_call_transcription(BW_ACCOUNT_ID, '', nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Delete Recording
-
1
describe 'delete_recording' do
-
1
it 'deletes the completed call recording data' do
-
1
stub_request(:delete, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/recordings/#{recording_id}").
-
to_return(status: 204)
-
-
1
data, status_code, headers = @recordings_api_instance.delete_recording_with_http_info(BW_ACCOUNT_ID, call_id, recording_id)
-
-
1
expect(status_code).to eq(204)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @recordings_api_instance.delete_recording(nil, '', '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing call_id' do
-
1
expect {
-
1
@recordings_api_instance.delete_recording(BW_ACCOUNT_ID, nil, '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing recording_id' do
-
1
expect {
-
1
@recordings_api_instance.delete_recording(BW_ACCOUNT_ID, '', nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Delete Recording Media
-
1
describe 'delete_recording_media' do
-
1
it 'deletes the completed call recording media' do
-
1
stub_request(:delete, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/recordings/#{recording_id}/media").
-
to_return(status: 204)
-
-
1
data, status_code, headers = @recordings_api_instance.delete_recording_media_with_http_info(BW_ACCOUNT_ID, call_id, recording_id)
-
-
1
expect(status_code).to eq(204)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @recordings_api_instance.delete_recording_media(nil, '', '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing call_id' do
-
1
expect {
-
1
@recordings_api_instance.delete_recording_media(BW_ACCOUNT_ID, nil, '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing recording_id' do
-
1
expect {
-
1
@recordings_api_instance.delete_recording_media(BW_ACCOUNT_ID, '', nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Download Recording
-
1
describe 'download_call_recording' do
-
1
it 'downloads a call recording by id' do
-
1
stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/recordings/#{recording_id}/media").
-
to_return(status: 200, headers: download_call_recording_headers_stub, body: download_call_recording_body_stub)
-
-
1
data, status_code, headers = @recordings_api_instance.download_call_recording_with_http_info(BW_ACCOUNT_ID, call_id, recording_id)
-
-
1
expect(status_code).to eq(200)
-
1
expect(headers).to eq(download_call_recording_headers_stub)
-
1
expect(data).to eq(download_call_recording_body_stub)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @recordings_api_instance.download_call_recording(nil, '', '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing call_id' do
-
1
expect {
-
1
@recordings_api_instance.download_call_recording(BW_ACCOUNT_ID, nil, '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing recording_id' do
-
1
expect {
-
1
@recordings_api_instance.download_call_recording(BW_ACCOUNT_ID, '', nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Get Call Recording
-
1
describe 'get_call_recording' do
-
1
it 'gets a call recording by id' do
-
1
stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/recordings/#{recording_id}").
-
to_return(status: 200, headers: get_call_recording_headers_stub, body: get_call_recording_body_stub)
-
-
1
data, status_code, headers = @recordings_api_instance.get_call_recording_with_http_info(BW_ACCOUNT_ID, call_id, recording_id)
-
-
1
expect(status_code).to eq(200)
-
1
expect(headers).to eq(get_call_recording_headers_stub)
-
1
expect(data).to be_instance_of(Bandwidth::CallRecordingMetadata)
-
1
expect(data.application_id).to eq(BW_VOICE_APPLICATION_ID)
-
1
expect(data.account_id).to eq(BW_ACCOUNT_ID)
-
1
expect(data.call_id).to eq(call_id)
-
1
expect(data.recording_id).to eq(recording_id)
-
1
expect(data.to).to eq(USER_NUMBER)
-
1
expect(data.from).to eq(BW_NUMBER)
-
1
expect(data.duration).to eq(duration)
-
1
expect(data.direction).to eq(direction)
-
1
expect(data.channels).to eq(channels)
-
1
expect(data.start_time).to eq(Time.parse(start_time))
-
1
expect(data.end_time).to eq(Time.parse(end_time))
-
1
expect(data.file_format).to eq(file_format)
-
1
expect(data.status).to eq(status)
-
1
expect(data.media_url).to eq(media_url)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @recordings_api_instance.get_call_recording(nil, '', '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing call_id' do
-
1
expect {
-
1
@recordings_api_instance.get_call_recording(BW_ACCOUNT_ID, nil, '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing recording_id' do
-
1
expect {
-
1
@recordings_api_instance.get_call_recording(BW_ACCOUNT_ID, '', nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Get Transcription
-
1
describe 'get_call_transcription' do
-
1
it 'gets the completed call recording transcription' do
-
1
stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/recordings/#{recording_id}/transcription").
-
to_return(status: 200, headers: get_call_transcription_headers_stub, body: get_call_transcription_body_stub)
-
-
1
data, status_code, headers = @recordings_api_instance.get_call_transcription_with_http_info(BW_ACCOUNT_ID, call_id, recording_id)
-
-
1
expect(status_code).to eq(200)
-
1
expect(data).to be_instance_of(Bandwidth::TranscriptionList)
-
1
expect(data.transcripts).to be_instance_of(Array)
-
1
expect(data.transcripts[0]).to be_instance_of(Bandwidth::Transcription)
-
1
expect(data.transcripts[0].text).to eq(text)
-
1
expect(data.transcripts[0].confidence).to eq(confidence)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @recordings_api_instance.get_call_transcription(nil, '', '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing call_id' do
-
1
expect {
-
1
@recordings_api_instance.get_call_transcription(BW_ACCOUNT_ID, nil, '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing recording_id' do
-
1
expect {
-
1
@recordings_api_instance.get_call_transcription(BW_ACCOUNT_ID, '', nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Get Call Recordings
-
1
describe 'list_account_call_recordings' do
-
1
it 'lists account call recordings' do
-
1
stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/recordings").
-
to_return(status: 200, headers: list_account_call_recordings_headers_stub, body: list_account_call_recordings_body_stub)
-
-
1
data, status_code, headers = @recordings_api_instance.list_account_call_recordings_with_http_info(BW_ACCOUNT_ID)
-
-
1
expect(status_code).to eq(200)
-
1
expect(data).to be_instance_of(Array)
-
1
expect(data[0]).to be_instance_of(Bandwidth::CallRecordingMetadata)
-
1
expect(data[0].application_id).to eq(BW_VOICE_APPLICATION_ID)
-
1
expect(data[0].account_id).to eq(BW_ACCOUNT_ID)
-
1
expect(data[0].call_id).to eq(call_id)
-
1
expect(data[0].recording_id).to eq(recording_id)
-
1
expect(data[0].to).to eq(USER_NUMBER)
-
1
expect(data[0].from).to eq(BW_NUMBER)
-
1
expect(data[0].duration).to eq(duration)
-
1
expect(data[0].direction).to eq(direction)
-
1
expect(data[0].channels).to eq(channels)
-
1
expect(data[0].start_time).to eq(Time.parse(start_time))
-
1
expect(data[0].end_time).to eq(Time.parse(end_time))
-
1
expect(data[0].file_format).to eq(file_format)
-
1
expect(data[0].status).to eq(status)
-
1
expect(data[0].media_url).to eq(media_url)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @recordings_api_instance.list_account_call_recordings(nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# List Call Recordings
-
1
describe 'list_call_recordings' do
-
1
it 'lists all recordings for a single call' do
-
1
stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/recordings").
-
to_return(status: 200, headers: list_call_recordings_headers_stub, body: list_call_recordings_body_stub)
-
-
1
data, status_code, headers = @recordings_api_instance.list_call_recordings_with_http_info(BW_ACCOUNT_ID, call_id)
-
-
1
expect(status_code).to eq(200)
-
1
expect(data).to be_instance_of(Array)
-
1
expect(data[0].application_id).to eq(BW_VOICE_APPLICATION_ID)
-
1
expect(data[0].account_id).to eq(BW_ACCOUNT_ID)
-
1
expect(data[0].call_id).to eq(call_id)
-
1
expect(data[0].recording_id).to eq(recording_id)
-
1
expect(data[0].to).to eq(USER_NUMBER)
-
1
expect(data[0].from).to eq(BW_NUMBER)
-
1
expect(data[0].duration).to eq(duration)
-
1
expect(data[0].direction).to eq(direction)
-
1
expect(data[0].channels).to eq(channels)
-
1
expect(data[0].start_time).to eq(Time.parse(start_time))
-
1
expect(data[0].end_time).to eq(Time.parse(end_time))
-
1
expect(data[0].file_format).to eq(file_format)
-
1
expect(data[0].status).to eq(status)
-
1
expect(data[0].media_url).to eq(media_url)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @recordings_api_instance.list_call_recordings(nil, '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing call_id' do
-
1
expect {
-
1
@recordings_api_instance.list_call_recordings(BW_ACCOUNT_ID, nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Create Transcription Request
-
1
describe 'transcribe_call_recording' do
-
1
it 'creates a transcription request' do
-
1
stub_request(:post, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/recordings/#{recording_id}/transcription").
-
to_return(status: 204)
-
-
1
transcribe_recording = Bandwidth::TranscribeRecording.new(
-
callback_url: BASE_CALLBACK_URL + '/transcriptions',
-
tag: test_id
-
)
-
-
1
data, status_code, headers = @recordings_api_instance.transcribe_call_recording_with_http_info(BW_ACCOUNT_ID, call_id, recording_id, transcribe_recording)
-
-
1
expect(status_code).to eq(204)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @recordings_api_instance.transcribe_call_recording(nil, '', '', '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing call_id' do
-
1
expect {
-
1
@recordings_api_instance.transcribe_call_recording(BW_ACCOUNT_ID, nil, '', '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing recording_id' do
-
1
expect {
-
1
@recordings_api_instance.transcribe_call_recording(BW_ACCOUNT_ID, '', nil, '')
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing transcribe_recording' do
-
1
expect {
-
1
@recordings_api_instance.transcribe_call_recording(BW_ACCOUNT_ID, '', '', nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
# Update Recording
-
1
describe 'update_call_recording_state' do
-
1
it 'updates and ends the manteca call recording' do
-
1
stub_request(:put, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/recording").
-
to_return(status: 200, headers: update_call_recording_state_headers_stub)
-
-
1
pause_recording = Bandwidth::UpdateCallRecording.new(
-
state: Bandwidth::RecordingStateEnum::PAUSED
-
)
-
-
1
data, status_code, headers = @recordings_api_instance.update_call_recording_state_with_http_info(BW_ACCOUNT_ID, call_id, pause_recording)
-
-
1
expect(status_code).to eq(200)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @recordings_api_instance.update_call_recording_state(nil, '', {})
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing call_id' do
-
1
expect {
-
1
@recordings_api_instance.update_call_recording_state(BW_ACCOUNT_ID, nil, {})
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError for a missing update_call_recording' do
-
1
expect {
-
1
@recordings_api_instance.update_call_recording_state(BW_ACCOUNT_ID, '', nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::StatisticsApi
-
1
describe 'StatisticsApi' do
-
# statistics info
-
2
let(:current_call_queue_size) { 0 }
-
2
let(:max_call_queue_size) { 7500 }
-
-
# stubs
-
2
let(:get_statistics_headers_stub) { { 'content-type' => 'application/json' } }
-
2
let(:get_statistics_body_stub) { "{\"currentCallQueueSize\":#{current_call_queue_size},\"maxCallQueueSize\":#{max_call_queue_size}}" }
-
-
1
before(:all) do
-
1
Bandwidth.configure do |config|
-
1
config.debugging = true
-
end
-
1
@statistics_api_instance = Bandwidth::StatisticsApi.new
-
end
-
-
1
describe 'test an instance of StatisticsApi' do
-
1
it 'should create an instance of StatisticsApi' do
-
1
expect(@statistics_api_instance).to be_instance_of(Bandwidth::StatisticsApi)
-
end
-
end
-
-
# Get Account Statistics
-
1
describe 'get_statistics' do
-
1
it 'gets account statistics' do
-
1
stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/statistics").
-
to_return(status: 200, headers: get_statistics_headers_stub, body: get_statistics_body_stub)
-
-
1
data, status_code, headers = @statistics_api_instance.get_statistics_with_http_info(BW_ACCOUNT_ID)
-
-
1
expect(status_code).to eq(200)
-
1
expect(headers).to eq(get_statistics_headers_stub)
-
1
expect(data).to be_instance_of(Bandwidth::AccountStatistics)
-
1
expect(data.current_call_queue_size).to eq(current_call_queue_size)
-
1
expect(data.max_call_queue_size).to eq(max_call_queue_size)
-
end
-
-
1
it 'causes an ArgumentError for a missing account_id' do
-
1
expect {
-
1
resp = @statistics_api_instance.get_statistics(nil)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::ApiClient
-
1
describe Bandwidth::ApiClient do
-
17
let(:api_client_default) { Bandwidth::ApiClient.new }
-
11
let(:config) { Bandwidth::Configuration.new }
-
2
let(:faraday_connection) { Faraday::Connection.new }
-
11
let(:api_client) { Bandwidth::ApiClient.new(config) }
-
2
let(:named_media_headers) { { 'content-disposition' => 'filename=test', 'content-type' => 'text/plain' } }
-
4
let(:media_data) { '123456' }
-
3
let(:media_headers) { { 'content-type' => 'text/plain' } }
-
3
let(:json_headers) { { 'content-type' => 'application/json' } }
-
2
let(:multipart_headers) { { 'Content-Type' => 'multipart/form-data' } }
-
2
let(:form_encoded_headers) { { 'Content-Type' => 'application/x-www-form-urlencoded' } }
-
2
let(:error_data) { '{"error": true}' }
-
-
1
describe '#call_api' do
-
1
it 'calls api and returns a tempfile with name from content-disposition header' do
-
1
stub_request(:get, 'https://messaging.bandwidth.com/api/v2/path').
-
to_return(status: 200, headers: media_headers, body: media_data)
-
-
opts = {
-
1
operation: :"MediaApi.get_media",
-
header_params: {},
-
query_params: {},
-
form_params: {},
-
body: nil,
-
auth_names: ['Basic'],
-
return_type: 'File'
-
}
-
1
data, status_code, headers = api_client.call_api(:GET, 'path', opts)
-
-
1
expect(status_code).to eq(200)
-
1
expect(headers).to eq(media_headers)
-
1
expect(data).to be_a(Tempfile)
-
end
-
-
1
it 'calls api and returns a tempfile' do
-
1
stub_request(:get, 'https://messaging.bandwidth.com/api/v2/path').
-
to_return(status: 200, headers: named_media_headers, body: media_data)
-
-
opts = {
-
1
operation: :"MediaApi.get_media",
-
header_params: {},
-
query_params: {},
-
form_params: {},
-
body: nil,
-
auth_names: ['Basic'],
-
return_type: 'File'
-
}
-
1
data, status_code, headers = api_client.call_api(:GET, 'path', opts)
-
-
1
expect(status_code).to eq(200)
-
1
expect(headers).to eq(named_media_headers)
-
1
expect(data).to be_a(Tempfile)
-
end
-
-
1
it 'calls api and returns binary data' do
-
1
stub_request(:get, 'https://messaging.bandwidth.com/api/v2/path').
-
to_return(status: 200, headers: media_headers, body: media_data)
-
-
1
api_client.config.return_binary_data = true
-
1
api_client.config.debugging = true
-
-
opts = {
-
1
operation: :"MediaApi.get_media",
-
header_params: {},
-
query_params: {},
-
form_params: {},
-
body: nil,
-
auth_names: ['Basic'],
-
return_type: 'File'
-
}
-
1
data, status_code, headers = api_client.call_api(:GET, 'path', opts)
-
-
1
expect(status_code).to eq(200)
-
1
expect(headers).to eq(media_headers)
-
1
expect(data).to eq(media_data)
-
end
-
-
1
it 'calls api and returns a hash' do
-
1
stub_request(:get, 'https://messaging.bandwidth.com/api/v2/path').
-
to_return(status: 200, headers: json_headers, body: '{"id": 1}')
-
-
opts = {
-
1
operation: :"MessagesApi.list_messages",
-
header_params: {},
-
query_params: {},
-
form_params: {},
-
body: nil,
-
auth_names: ['Basic'],
-
return_type: 'Hash<String, Integer>'
-
}
-
1
data, status_code, headers = api_client.call_api(:GET, 'path', opts)
-
-
1
expect(status_code).to eq(200)
-
1
expect(headers).to eq(json_headers)
-
1
expect(data).to eq({ id: 1 })
-
end
-
-
1
it 'posts data and returns nothing' do
-
1
stub_request(:post, 'https://messaging.bandwidth.com/api/v2/path').
-
to_return(status: 204)
-
-
1
api_client.config.debugging = true
-
-
opts = {
-
1
operation: :"MediaApi.upload_media",
-
header_params: {},
-
query_params: {},
-
form_params: {},
-
body: { id: 1 },
-
auth_names: ['Basic'],
-
return_type: nil
-
}
-
1
data, status_code, headers = api_client.call_api(:POST, 'path', opts)
-
-
1
expect(status_code).to eq(204)
-
1
expect(data).to be nil
-
end
-
-
1
it 'posts multipart/form-data and returns nothing' do
-
1
stub_request(:post, 'https://messaging.bandwidth.com/api/v2/path').
-
to_return(status: 204)
-
-
opts = {
-
1
operation: :"MediaApi.upload_media",
-
header_params: multipart_headers,
-
query_params: {},
-
form_params: { file: Tempfile.new('filename'), array: [1, 2, 3], string: '123' },
-
body: nil,
-
auth_names: ['Basic'],
-
return_type: nil
-
}
-
1
data, status_code, headers = api_client.call_api(:POST, 'path', opts)
-
-
1
expect(status_code).to eq(204)
-
1
expect(data).to be nil
-
end
-
-
1
it 'calls api and handles HTTP error' do
-
1
stub_request(:post, 'https://messaging.bandwidth.com/api/v2/path').
-
to_return(status: 400, headers: json_headers, body: error_data)
-
-
opts = {
-
1
operation: :"MediaApi.upload_media",
-
header_params: {},
-
query_params: {},
-
form_params: {},
-
body: { id: 1 },
-
auth_names: ['Basic'],
-
return_type: nil
-
}
-
-
1
expect {
-
1
api_client.call_api(:POST, 'path', opts)
-
}.to raise_error { |e|
-
1
expect(e).to be_instance_of(Bandwidth::ApiError)
-
1
expect(e.code).to eq(400)
-
1
expect(e.response_headers).to eq(json_headers)
-
1
expect(e.response_body).to eq('{"error": true}')
-
}
-
end
-
-
1
it 'calls api and handles timeout error' do
-
1
stub_request(:post, 'https://messaging.bandwidth.com/api/v2/path').
-
to_raise(Faraday::TimeoutError)
-
-
opts = {
-
1
operation: :"MediaApi.upload_media",
-
header_params: {},
-
query_params: {},
-
form_params: {},
-
body: { id: 1 },
-
auth_names: ['Basic'],
-
return_type: nil
-
}
-
-
1
expect {
-
1
api_client.call_api(:POST, 'path', opts)
-
}.to raise_error { |e|
-
1
expect(e).to be_instance_of(Bandwidth::ApiError)
-
1
expect(e.message).to eq('Connection timed out')
-
}
-
end
-
-
1
it 'calls api and handles connection error' do
-
1
stub_request(:post, 'https://messaging.bandwidth.com/api/v2/path').
-
to_raise(Faraday::ConnectionFailed)
-
-
opts = {
-
1
operation: :"MediaApi.upload_media",
-
header_params: {},
-
query_params: {},
-
form_params: {},
-
body: { id: 1 },
-
auth_names: ['Basic'],
-
return_type: nil
-
}
-
-
1
expect {
-
1
api_client.call_api(:POST, 'path', opts)
-
}.to raise_error { |e|
-
1
expect(e).to be_instance_of(Bandwidth::ApiError)
-
1
expect(e.message).to eq('Connection failed')
-
}
-
end
-
end
-
-
1
describe '#build_request_body' do
-
1
it 'builds application/x-www-form-urlencoded' do
-
1
expect(api_client_default.build_request_body(form_encoded_headers, { id: 1 }, nil)).to eq('id=1')
-
end
-
-
1
it 'builds empty body' do
-
1
expect(api_client_default.build_request_body({}, {}, nil)).to be nil
-
end
-
end
-
-
1
describe '#deserialize' do
-
1
it 'throws on invalid JSON when expecting JSON' do
-
1
headers = { 'Content-Type' => 'application/json' }
-
1
response = double('response', headers: headers, body: '{id 1}')
-
1
expect {
-
1
api_client_default.deserialize(response, 'Hash<String, Integer>')
-
}.to raise_error(JSON::ParserError, 'unexpected token at \'{id 1}]\'')
-
end
-
-
1
it 'rescues invalid JSON when expecting non-JSON' do
-
1
headers = { 'Content-Type' => 'application/json' }
-
1
response = double('response', headers: headers, body: '2022-06-16')
-
1
data = api_client_default.deserialize(response, 'Date')
-
1
expect(data).to eq(Date.parse('2022-06-16'))
-
end
-
end
-
-
1
describe '#basic_auth' do
-
1
it 'sets basic auth for the connection' do
-
1
api_client.config.username = 'username'
-
1
api_client.config.password = 'password'
-
1
api_client.basic_auth(faraday_connection)
-
1
expect(api_client.config.username).to eq('username')
-
1
expect(api_client.config.password).to eq('password')
-
end
-
end
-
-
1
describe '#json_mime?' do
-
1
it 'checks if the given MIME is a JSON MIME' do
-
1
expect(api_client_default.json_mime?(nil)).to eq false
-
1
expect(api_client_default.json_mime?('')).to eq false
-
-
1
expect(api_client_default.json_mime?('application/json')).to eq true
-
1
expect(api_client_default.json_mime?('application/json; charset=UTF8')).to eq true
-
1
expect(api_client_default.json_mime?('APPLICATION/JSON')).to eq true
-
-
1
expect(api_client_default.json_mime?('application/xml')).to eq false
-
1
expect(api_client_default.json_mime?('text/plain')).to eq false
-
1
expect(api_client_default.json_mime?('application/jsonp')).to eq false
-
end
-
end
-
-
1
describe '#convert_to_type' do
-
1
it 'conversts data to the given return type' do
-
1
expect(api_client_default.convert_to_type(1, 'String')).to eq('1')
-
1
expect(api_client_default.convert_to_type('1', 'Integer')).to eq(1)
-
1
expect(api_client_default.convert_to_type('1', 'Float')).to eq(1.0)
-
1
expect(api_client_default.convert_to_type(1, 'Boolean')).to be false
-
1
expect(api_client_default.convert_to_type('2022-06-16T13:15:07.160Z', 'Time')).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
-
1
expect(api_client_default.convert_to_type('2022-06-16', 'Date')).to eq(Date.parse('2022-06-16'))
-
1
expect(api_client_default.convert_to_type({ id: 1 }, 'Object')).to eq({ id: 1 })
-
1
expect(api_client_default.convert_to_type([[12, 34], [56]], 'Array<Array<Integer>>')).to eq([[12, 34], [56]])
-
1
expect(api_client_default.convert_to_type({ "id": 'test' }, 'Hash<String, String>')).to eq({ id: 'test' })
-
1
expect(api_client_default.convert_to_type({ set_or_expired: true }, 'DeferredResult')).to be_instance_of(Bandwidth::DeferredResult)
-
end
-
end
-
-
1
describe '#sanitize_filename' do
-
1
it 'sanitizes a filename by removing the path' do
-
1
expect(api_client_default.sanitize_filename('sun')).to eq('sun')
-
1
expect(api_client_default.sanitize_filename('sun.gif')).to eq('sun.gif')
-
1
expect(api_client_default.sanitize_filename('../sun.gif')).to eq('sun.gif')
-
1
expect(api_client_default.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
-
1
expect(api_client_default.sanitize_filename('./sun.gif')).to eq('sun.gif')
-
1
expect(api_client_default.sanitize_filename('..\sun.gif')).to eq('sun.gif')
-
1
expect(api_client_default.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
-
1
expect(api_client_default.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
-
1
expect(api_client_default.sanitize_filename('.\sun.gif')).to eq('sun.gif')
-
end
-
end
-
-
1
describe '#build_request_url' do
-
1
it 'adds leading and trailing slashes to path' do
-
1
expect(api_client_default.build_request_url('test/path')).to eq('http://localhost/test/path')
-
end
-
end
-
-
1
describe '#update_params_for_auth' do
-
1
it 'updates header and query params based on authentication settings' do
-
-
end
-
end
-
-
1
describe '#user_agent=' do
-
1
it 'sets user agent in HTTP header' do
-
1
api_client_default.user_agent = 'test-user-agent'
-
1
expect(api_client_default.default_headers['User-Agent']).to eq('test-user-agent')
-
end
-
end
-
-
1
describe '#select_header_accept' do
-
1
it 'returns Accept header based on an array of accepts provided' do
-
1
expect(api_client_default.select_header_accept(nil)).to be_nil
-
1
expect(api_client_default.select_header_accept([])).to be_nil
-
-
1
expect(api_client_default.select_header_accept(['application/json'])).to eq('application/json')
-
1
expect(api_client_default.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
-
1
expect(api_client_default.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
-
-
1
expect(api_client_default.select_header_accept(['application/xml'])).to eq('application/xml')
-
1
expect(api_client_default.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
-
end
-
end
-
-
1
describe '#select_header_content_type' do
-
1
it 'returns Content-Type header based on an array of content types provided' do
-
1
expect(api_client_default.select_header_content_type(nil)).to be_nil
-
1
expect(api_client_default.select_header_content_type([])).to be_nil
-
-
1
expect(api_client_default.select_header_content_type(['application/json'])).to eq('application/json')
-
1
expect(api_client_default.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
-
1
expect(api_client_default.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
-
1
expect(api_client_default.select_header_content_type(['application/xml'])).to eq('application/xml')
-
1
expect(api_client_default.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
-
end
-
end
-
-
1
describe '#object_to_http_body' do
-
1
it 'converts array to JSON string' do
-
1
model = [1, 2, 3]
-
1
expect(api_client_default.object_to_http_body(model)).to eq('[1,2,3]')
-
end
-
-
1
it 'converts hash to JSON string' do
-
1
model = { id: 1 }
-
1
expect(api_client_default.object_to_http_body(model)).to eq('{"id":1}')
-
end
-
end
-
-
1
describe '#object_to_hash' do
-
1
it 'returns object when object cannot be converted to hash' do
-
1
model = Object.new
-
1
model.instance_variable_set(:@id, 1)
-
1
expect(api_client_default.object_to_hash(model)).to be_instance_of(Object)
-
1
expect(api_client_default.object_to_hash(model).instance_variable_get('@id')).to eq(1)
-
end
-
-
1
it 'returns hash when object can be converted to hash' do
-
1
model = Bandwidth::DeferredResult.new({
-
set_or_expired: true
-
})
-
1
expected = { setOrExpired: true }
-
1
expect(api_client_default.object_to_hash(model)).to eq(expected)
-
end
-
end
-
-
1
describe '#build_collection_param' do
-
1
it 'builds parameter value according to the given collection format' do
-
1
param = ['aa', 'bb', 'cc']
-
1
expect(api_client_default.build_collection_param(param, :csv)).to eq('aa,bb,cc')
-
1
expect(api_client_default.build_collection_param(param, :ssv)).to eq('aa bb cc')
-
1
expect(api_client_default.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
-
1
expect(api_client_default.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
-
1
expect(api_client_default.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
-
1
expect {
-
1
api_client_default.build_collection_param(param, :INVALID)
-
}.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
-
end
-
end
-
end
-
# Unit tests for Bandwidth::ApiError
-
1
describe Bandwidth::ApiError do
-
1
describe '#initialize' do
-
1
it 'initializes an instance of ApiError with message' do
-
1
api_error = Bandwidth::ApiError.new({ message: 'test' })
-
1
expect(api_error.message).to eq('test')
-
end
-
end
-
-
1
describe '#to_s' do
-
1
it 'returns message when to_s is called' do
-
1
api_error = Bandwidth::ApiError.new('test')
-
1
expect(api_error.to_s).to eq('test')
-
end
-
end
-
-
1
describe '#message' do
-
1
it 'returns default error message when none supplied' do
-
1
api_error = Bandwidth::ApiError.new
-
1
expect(api_error.message).to eq('Error message: the server returns an error')
-
end
-
end
-
end
-
1
require 'uri'
-
-
# Unit tests for Bandwidth::Configuration
-
1
describe Bandwidth::Configuration do
-
26
let(:config) { Bandwidth::Configuration.new }
-
4
let(:faraday_connection) { Faraday::Connection.new }
-
2
let(:uri) { URI.parse(BASE_CALLBACK_URL + '/path') }
-
5
let(:token) { 'abcd1234' }
-
1
let(:server) { [
-
{
-
2
url: 'https://voice.bandwidth.com/api/{enum_var}/{default_var}',
-
description: 'Production',
-
variables: {
-
enum_var: {
-
enum_values: ['v1', 'v2', 'v3'],
-
default_value: 'v2'
-
},
-
default_var: {
-
default_value: 'default_value'
-
}
-
}
-
}
-
] }
-
-
1
describe '#configure' do
-
1
it 'configures a Configuration instance using a a block' do
-
1
config.configure do |c|
-
1
c.scheme = uri.scheme
-
1
c.host = uri.host
-
1
c.base_path = uri.path
-
end
-
1
expect(config.scheme).to eq(uri.scheme)
-
1
expect(config.host).to eq(uri.host)
-
1
expect(config.base_path).to eq(uri.path)
-
end
-
end
-
-
1
describe 'custom attribute writers' do
-
1
it '#scheme=' do
-
1
config.scheme = 'scheme://'
-
1
expect(config.scheme).to eq('scheme')
-
end
-
-
1
it '#host=' do
-
1
config.host = 'https://hostname'
-
1
expect(config.host).to eq('hostname')
-
end
-
-
1
it '#base_path=' do
-
1
config.base_path = 'basepath'
-
1
expect(config.base_path).to eq('/basepath')
-
end
-
end
-
-
1
describe '#base_url' do
-
1
it 'returns default value when invalid operation is passed' do
-
1
expect(config.base_url('invalid_operation')).to eq('http://localhost')
-
end
-
-
1
it 'returns proper base URL when server index is set' do
-
1
operation, server = config.operation_server_settings.first
-
1
expect(config.base_url(operation)).to eq(server[0][:url])
-
end
-
-
1
it 'should have the default value' do
-
1
expect(config.base_url).to eq('http://localhost')
-
end
-
-
1
it 'returns default value when invalid operation is passed' do
-
1
expect(config.base_url('invalid_operation')).to eq('http://localhost')
-
end
-
-
1
it 'throws argument error when attempting to use a server index that is out of bounds' do
-
1
config.server_operation_index = {
-
:'MediaApi.upload_media' => 10
-
}
-
1
expect {
-
1
config.base_url(:'MediaApi.upload_media')
-
}.to raise_error(ArgumentError, 'Invalid index 10 when selecting the server. Must not be nil and must be less than 1')
-
end
-
end
-
-
1
describe '#api_key_with_prefix' do
-
1
it 'gets API key without prefix' do
-
1
config.api_key['Authorization'] = token
-
1
expect(config.api_key_with_prefix('Authorization')).to eq(token)
-
end
-
-
1
it 'gets API key wit prefix' do
-
1
config.api_key_prefix['Authorization'] = 'Token'
-
1
config.api_key['Authorization'] = token
-
1
expect(config.api_key_with_prefix('Authorization')).to eq("Token #{token}")
-
end
-
end
-
-
1
describe '#access_token_with_refresh' do
-
1
it 'gets the static access_token when no access_token_getter is defined' do
-
1
config.access_token = token
-
1
expect(config.access_token_with_refresh).to eq(token)
-
end
-
-
1
it 'gets access_token using access_token_getter' do
-
2
config.access_token_getter = proc { token }
-
1
expect(config.access_token_with_refresh).to eq(token)
-
end
-
end
-
-
1
describe '#basic_auth_token' do
-
1
it 'gets Basic Auth token string' do
-
1
config.username = 'username'
-
1
config.password = 'password'
-
1
expect(config.basic_auth_token).to eq('Basic dXNlcm5hbWU6cGFzc3dvcmQ=')
-
end
-
end
-
-
1
describe '#auth_settings' do
-
1
it 'returns Auth Settings hash for api client' do
-
1
basic_auth = config.auth_settings['Basic']
-
1
expect(basic_auth[:type]).to eq('basic')
-
1
expect(basic_auth[:in]).to eq('header')
-
1
expect(basic_auth[:key]).to eq('Authorization')
-
1
expect(basic_auth[:value]).to eq('Basic Og==')
-
end
-
end
-
-
1
describe '#server_url' do
-
1
it 'returns URL with enum variable substitued' do
-
1
expect(config.server_url(0, { enum_var: 'v3' }, server)).to eq('https://voice.bandwidth.com/api/v3/default_value')
-
end
-
-
1
it 'causes an ArgumentError by passing an invalid index' do
-
1
expect {
-
1
config.server_url(100)
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError by passing an invalid value to an enum variable' do
-
1
expect {
-
1
config.server_url(0, { enum_var: 'v4' }, server)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
1
describe 'configure faraday connection' do
-
1
it '#configure_faraday_connection #configure_connection' do
-
1
config.configure_faraday_connection do |c|
-
1
config.username = 'username'
-
end
-
1
config.configure_connection(faraday_connection)
-
1
expect(config.username).to eq('username')
-
end
-
end
-
-
1
describe '#set_faraday_middleware' do
-
1
it '#use' do
-
1
config.use(Faraday::Request::UrlEncoded)
-
1
expect(config.instance_variable_get('@middlewares')[:use]).to eq([[Faraday::Request::UrlEncoded, [], nil]])
-
end
-
-
1
it '#request' do
-
1
config.request(:retry, max: 3, methods: [:get, :post], retry_statuses: [503])
-
1
expect(config.instance_variable_get('@middlewares')[:request]).to eq([[:retry, [{ :max => 3, :methods => [:get, :post], :retry_statuses => [503] }], nil]])
-
end
-
-
1
it '#response' do
-
1
config.response(:logger, nil, { bodies: true, log_level: :debug })
-
1
expect(config.instance_variable_get('@middlewares')[:response]).to eq([[:logger, [nil, { :bodies => true, :log_level => :debug }], nil]])
-
end
-
-
1
it 'causes an ArgumentError by passing an invalid middleware operation' do
-
1
expect {
-
1
config.set_faraday_middleware(:invalid_operation, Faraday::Request::UrlEncoded)
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
1
describe '#configure_middleware' do
-
1
it 'builds connection using supplied response middleware' do
-
1
config.response(:logger)
-
1
config.configure_middleware(faraday_connection)
-
1
expect(faraday_connection.builder.handlers).to include(Faraday::Response::Logger)
-
end
-
-
1
it 'builds connection using deleted middleware' do
-
1
config.set_faraday_middleware(:delete, Faraday::Request::UrlEncoded)
-
1
config.configure_middleware(faraday_connection)
-
1
expect(faraday_connection.builder.handlers).to eq([])
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::Bxml
-
1
describe 'Bandwidth::Bxml::Bxml' do
-
3
let(:instance) { Bandwidth::Bxml::Bxml.new }
-
-
1
describe 'test an instance of Bxml' do
-
1
it 'validates instance of Bxml' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::Bxml)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Root)
-
end
-
-
1
it 'test the to_bxml method of the Bxml instance' do
-
1
expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Bxml/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::NestableVerb
-
1
describe 'Bandwidth::Bxml::NestableVerb' do
-
2
let(:instance) { Bandwidth::Bxml::NestableVerb.new('Test') }
-
-
1
describe 'test an instance of NestableVerb' do
-
1
it 'validates instance of NestableVerb' do
-
1
expect(instance).to be_a(Bandwidth::Bxml::NestableVerb)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::Response
-
1
describe 'Bandwidth::Bxml::Response' do
-
3
let(:instance) { Bandwidth::Bxml::Response.new }
-
-
1
describe 'test an instance of Response' do
-
1
it 'validates instance of Response' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::Response)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Root)
-
end
-
-
1
it 'test the to_bxml method of the Response instance' do
-
1
expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Response/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::Verb
-
1
describe 'Bandwidth::Bxml::Verb' do
-
3
let(:instance) { Bandwidth::Bxml::Verb.new('Test') }
-
-
1
describe 'test an instance of Verb' do
-
1
it 'validates instance of Verb' do
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the Verb instance' do
-
1
expected = "\n<Test/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::Bridge
-
1
describe 'Bandwidth::Bxml::Bridge' do
-
1
let(:initial_attributes) {
-
{
-
3
bridge_complete_url: 'https://initial.com',
-
bridge_complete_method: 'POST',
-
bridge_complete_fallback_url: 'https://initial.com',
-
bridge_complete_fallback_method: 'POST',
-
bridge_target_complete_url: 'https://initial.com',
-
bridge_target_complete_method: 'POST',
-
bridge_target_complete_fallback_url: 'https://initial.com',
-
bridge_target_complete_fallback_method: 'POST',
-
username: 'initial_username',
-
password: 'initial_password',
-
fallback_username: 'initial_fallback_username',
-
fallback_password: 'initial_fallback_password',
-
tag: 'initial_tag'
-
}
-
}
-
-
1
let(:new_attributes) {
-
{
-
1
bridge_complete_url: 'https://new.com',
-
bridge_complete_method: 'GET',
-
bridge_complete_fallback_url: 'https://new.com',
-
bridge_complete_fallback_method: 'GET',
-
bridge_target_complete_url: 'https://new.com',
-
bridge_target_complete_method: 'GET',
-
bridge_target_complete_fallback_url: 'https://new.com',
-
bridge_target_complete_fallback_method: 'GET',
-
username: 'new_username',
-
password: 'new_password',
-
fallback_username: 'new_fallback_username',
-
fallback_password: 'new_fallback_password',
-
tag: 'new_tag'
-
}
-
}
-
-
4
let(:instance) { Bandwidth::Bxml::Bridge.new('c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d', initial_attributes) }
-
-
1
describe 'test an instance of Bridge' do
-
1
it 'validates instance of Bridge' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::Bridge)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the Bridge instance' do
-
1
expected = "\n<Bridge bridgeCompleteUrl=\"https://initial.com\" bridgeCompleteMethod=\"POST\" bridgeCompleteFallbackUrl=\"https://initial.com\" bridgeCompleteFallbackMethod=\"POST\" bridgeTargetCompleteUrl=\"https://initial.com\" bridgeTargetCompleteMethod=\"POST\" bridgeTargetCompleteFallbackUrl=\"https://initial.com\" bridgeTargetCompleteFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\">c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d</Bridge>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the Bridge instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<Bridge bridgeCompleteUrl=\"https://new.com\" bridgeCompleteMethod=\"GET\" bridgeCompleteFallbackUrl=\"https://new.com\" bridgeCompleteFallbackMethod=\"GET\" bridgeTargetCompleteUrl=\"https://new.com\" bridgeTargetCompleteMethod=\"GET\" bridgeTargetCompleteFallbackUrl=\"https://new.com\" bridgeTargetCompleteFallbackMethod=\"GET\" username=\"new_username\" password=\"new_password\" fallbackUsername=\"new_fallback_username\" fallbackPassword=\"new_fallback_password\" tag=\"new_tag\">c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d</Bridge>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::Conference
-
1
describe 'Bandwidth::Bxml::Conference' do
-
1
let(:initial_attributes) {
-
{
-
3
mute: true,
-
hold: true,
-
call_ids_to_coach: 'initial',
-
conference_event_url: 'https://initial.com',
-
conference_event_method: 'POST',
-
conference_event_fallback_url: 'https://initial.com',
-
conference_event_fallback_method: 'POST',
-
username: 'initial_username',
-
password: 'initial_password',
-
fallback_username: 'initial_fallback_username',
-
fallback_password: 'initial_fallback_password',
-
tag: 'initial_tag',
-
callback_timeout: 5.0
-
}
-
}
-
-
1
let(:new_attributes) {
-
{
-
1
mute: false,
-
hold: false,
-
call_ids_to_coach: 'new',
-
conference_event_url: 'https://new.com',
-
conference_event_method: 'GET',
-
conference_event_fallback_url: 'https://new.com',
-
conference_event_fallback_method: 'GET',
-
username: 'new_username',
-
password: 'new_password',
-
fallback_username: 'new_fallback_username',
-
fallback_password: 'new_fallback_password',
-
tag: 'new_tag',
-
callback_timeout: 10.0
-
}
-
}
-
-
4
let(:instance) { Bandwidth::Bxml::Conference.new('conference_name', initial_attributes) }
-
-
1
describe 'test an instance of Conference' do
-
1
it 'validates instance of Conference' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::Conference)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the Conference instance' do
-
1
expected = "\n<Conference mute=\"true\" hold=\"true\" callIdsToCoach=\"initial\" conferenceEventUrl=\"https://initial.com\" conferenceEventMethod=\"POST\" conferenceEventFallbackUrl=\"https://initial.com\" conferenceEventFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" callbackTimeout=\"5.0\">conference_name</Conference>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the Conference instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<Conference mute=\"false\" hold=\"false\" callIdsToCoach=\"new\" conferenceEventUrl=\"https://new.com\" conferenceEventMethod=\"GET\" conferenceEventFallbackUrl=\"https://new.com\" conferenceEventFallbackMethod=\"GET\" username=\"new_username\" password=\"new_password\" fallbackUsername=\"new_fallback_username\" fallbackPassword=\"new_fallback_password\" tag=\"new_tag\" callbackTimeout=\"10.0\">conference_name</Conference>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::CustomParam
-
1
describe 'Bandwidth::Bxml::CustomParam' do
-
1
let(:initial_attributes) {
-
{
-
3
name: 'initial_name',
-
value: 'initial_value'
-
}
-
}
-
-
1
let(:new_attributes) {
-
{
-
1
name: 'new_name',
-
value: 'new_value'
-
}
-
}
-
-
4
let(:instance) { Bandwidth::Bxml::CustomParam.new(initial_attributes) }
-
-
1
describe 'test an instance of CustomParam' do
-
1
it 'validates instance of CustomParam' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::CustomParam)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the CustomParam instance' do
-
1
expected = "\n<CustomParam name=\"initial_name\" value=\"initial_value\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the CustomParam instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<CustomParam name=\"new_name\" value=\"new_value\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::Forward
-
1
describe 'Bandwidth::Bxml::Forward' do
-
1
let(:initial_attributes) {
-
{
-
3
to: '+19195551234',
-
from: '+19195554321',
-
call_timeout: 5,
-
diversion_treatment: 'propogate',
-
diversion_reason: 'user-busy',
-
uui: '93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt'
-
}
-
}
-
-
1
let(:new_attributes) {
-
{
-
1
to: '+19195554321',
-
from: '+19195551234',
-
call_timeout: 10,
-
diversion_treatment: 'stack',
-
diversion_reason: 'no-answer',
-
uui: '4fa28015d8ede84bd1a493d6f3c0be5845960b74;encoding=base64,fdsa;encoding=jwt'
-
}
-
}
-
-
4
let(:instance) { Bandwidth::Bxml::Forward.new(initial_attributes) }
-
-
1
describe 'test an instance of Forward' do
-
1
it 'validates instance of Forward' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::Forward)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the Forward instance' do
-
1
expected = "\n<Forward to=\"+19195551234\" from=\"+19195554321\" callTimeout=\"5\" diversionTreatment=\"propogate\" diversionReason=\"user-busy\" uui=\"93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the Forward instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<Forward to=\"+19195554321\" from=\"+19195551234\" callTimeout=\"10\" diversionTreatment=\"stack\" diversionReason=\"no-answer\" uui=\"4fa28015d8ede84bd1a493d6f3c0be5845960b74;encoding=base64,fdsa;encoding=jwt\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::Gather
-
1
describe 'Bandwidth::Bxml::Gather' do
-
1
let(:initial_attributes) {
-
{
-
6
gather_url: 'https://initial.com',
-
gather_method: 'POST',
-
gather_fallback_url: 'https://initial.com',
-
gather_fallback_method: 'POST',
-
username: 'initial_username',
-
password: 'initial_password',
-
fallback_username: 'initial_fallback_username',
-
fallback_password: 'initial_fallback_password',
-
tag: 'initial_tag',
-
terminating_digits: '5',
-
max_digits: 5,
-
inter_digit_timeout: 5,
-
first_digit_timeout: 5,
-
repeat_count: 5
-
}
-
}
-
-
1
let(:new_attributes) {
-
{
-
1
gather_url: 'https://new.com',
-
gather_method: 'POST',
-
gather_fallback_url: 'https://new.com',
-
gather_fallback_method: 'GET',
-
username: 'new_username',
-
password: 'new_password',
-
fallback_username: 'new_fallback_username',
-
fallback_password: 'new_fallback_password',
-
tag: 'new_tag',
-
terminating_digits: '10',
-
max_digits: 10,
-
inter_digit_timeout: 10,
-
first_digit_timeout: 10,
-
repeat_count: 10
-
}
-
}
-
-
4
let (:play_audio) { Bandwidth::Bxml::PlayAudio.new('https://audio.url/audio1.wav') }
-
2
let (:speak_sentence) { Bandwidth::Bxml::SpeakSentence.new('<lang xml:lang="es-MX">Hola</lang>ruby speak sentence <emphasis>SSML test</emphasis>') }
-
-
4
let(:instance) { Bandwidth::Bxml::Gather.new([], initial_attributes) }
-
4
let(:instance_nested) { Bandwidth::Bxml::Gather.new([play_audio], initial_attributes) }
-
-
1
describe 'test an instance of Gather' do
-
1
it 'validates instance of Gather' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::Gather)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the Gather instance' do
-
1
expected = "\n<Gather gatherUrl=\"https://initial.com\" gatherMethod=\"POST\" gatherFallbackUrl=\"https://initial.com\" gatherFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" terminatingDigits=\"5\" maxDigits=\"5\" interDigitTimeout=\"5\" firstDigitTimeout=\"5\" repeat_count=\"5\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the Gather instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<Gather gatherUrl=\"https://new.com\" gatherMethod=\"POST\" gatherFallbackUrl=\"https://new.com\" gatherFallbackMethod=\"GET\" username=\"new_username\" password=\"new_password\" fallbackUsername=\"new_fallback_username\" fallbackPassword=\"new_fallback_password\" tag=\"new_tag\" terminatingDigits=\"10\" maxDigits=\"10\" interDigitTimeout=\"10\" firstDigitTimeout=\"10\" repeat_count=\"10\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
-
1
describe 'test an instance of Gather with nested verbs' do
-
1
it 'validates instance of Gather' do
-
1
expect(instance_nested).to be_instance_of(Bandwidth::Bxml::Gather)
-
1
expect(instance_nested).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the nested Gather instance' do
-
1
expected = "\n<Gather gatherUrl=\"https://initial.com\" gatherMethod=\"POST\" gatherFallbackUrl=\"https://initial.com\" gatherFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" terminatingDigits=\"5\" maxDigits=\"5\" interDigitTimeout=\"5\" firstDigitTimeout=\"5\" repeat_count=\"5\">\n <PlayAudio>https://audio.url/audio1.wav</PlayAudio>\n</Gather>\n"
-
1
expect(instance_nested.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the add_verb method of the nested Gather instance' do
-
1
expected_single = "\n<Gather gatherUrl=\"https://initial.com\" gatherMethod=\"POST\" gatherFallbackUrl=\"https://initial.com\" gatherFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" terminatingDigits=\"5\" maxDigits=\"5\" interDigitTimeout=\"5\" firstDigitTimeout=\"5\" repeat_count=\"5\">\n <PlayAudio>https://audio.url/audio1.wav</PlayAudio>\n <SpeakSentence><lang xml:lang=\"es-MX\">Hola</lang>ruby speak sentence <emphasis>SSML test</emphasis></SpeakSentence>\n</Gather>\n"
-
1
instance_nested.add_audio_verb(speak_sentence)
-
1
expect(instance_nested.to_bxml).to eq(expected_single)
-
-
1
expected_multiple = "\n<Gather gatherUrl=\"https://initial.com\" gatherMethod=\"POST\" gatherFallbackUrl=\"https://initial.com\" gatherFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" terminatingDigits=\"5\" maxDigits=\"5\" interDigitTimeout=\"5\" firstDigitTimeout=\"5\" repeat_count=\"5\">\n <PlayAudio>https://audio.url/audio1.wav</PlayAudio>\n <SpeakSentence><lang xml:lang=\"es-MX\">Hola</lang>ruby speak sentence <emphasis>SSML test</emphasis></SpeakSentence>\n <SpeakSentence><lang xml:lang=\"es-MX\">Hola</lang>ruby speak sentence <emphasis>SSML test</emphasis></SpeakSentence>\n <PlayAudio>https://audio.url/audio1.wav</PlayAudio>\n</Gather>\n"
-
1
instance_nested.add_audio_verb([speak_sentence, play_audio])
-
1
expect(instance_nested.to_bxml).to eq(expected_multiple)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::Hangup
-
1
describe 'Bandwidth::Bxml::Hangup' do
-
3
let(:instance) { Bandwidth::Bxml::Hangup.new }
-
-
1
describe 'test an instance of Hangup' do
-
1
it 'validates instance of Hangup' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::Hangup)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the Hangup instance' do
-
1
expected = "\n<Hangup/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::PauseRecording
-
1
describe 'Bandwidth::Bxml::PauseRecording' do
-
3
let(:instance) { Bandwidth::Bxml::PauseRecording.new }
-
-
1
describe 'test an instance of PauseRecording' do
-
1
it 'validates instance of PauseRecording' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::PauseRecording)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the PauseRecording instance' do
-
1
expected = "\n<PauseRecording/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::Pause
-
1
describe 'Bandwidth::Bxml::Pause' do
-
1
let(:initial_attributes) {
-
3
{
-
duration: 5
-
}
-
}
-
-
1
let(:new_attributes) {
-
1
{
-
duration: 10
-
}
-
}
-
-
4
let(:instance) { Bandwidth::Bxml::Pause.new(initial_attributes) }
-
-
1
describe 'test an instance of Pause' do
-
1
it 'validates instance of Pause' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::Pause)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the Pause instance' do
-
1
expected = "\n<Pause duration=\"5\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the Pause instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<Pause duration=\"10\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::PhoneNumber
-
1
describe 'Bandwidth::Bxml::PhoneNumber' do
-
1
let(:initial_attributes) {
-
{
-
3
transfer_answer_url: 'https://initial.com',
-
transfer_answer_method: 'POST',
-
transfer_answer_fallback_url: 'https://initial.com',
-
transfer_answer_fallback_method: 'POST',
-
transfer_disconnect_url: 'https://initial.com',
-
transfer_disconnect_method: 'POST',
-
username: 'initial_username',
-
password: 'initial_password',
-
fallback_username: 'initial_fallback_username',
-
fallback_password: 'initial_fallback_password',
-
tag: 'initial_tag'
-
}
-
}
-
-
1
let(:new_attributes) {
-
{
-
1
transfer_answer_url: 'https://new.com',
-
transfer_answer_method: 'GET',
-
transfer_answer_fallback_url: 'https://new.com',
-
transfer_answer_fallback_method: 'GET',
-
transfer_disconnect_url: 'https://new.com',
-
transfer_disconnect_method: 'GET',
-
username: 'new_username',
-
password: 'new_password',
-
fallback_username: 'new_fallback_username',
-
fallback_password: 'new_fallback_password',
-
tag: 'new_tag'
-
}
-
}
-
-
4
let(:instance) { Bandwidth::Bxml::PhoneNumber.new('+19195551234', initial_attributes) }
-
-
1
describe 'test an instance of PhoneNumber' do
-
1
it 'validates instance of PhoneNumber' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::PhoneNumber)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the PhoneNumber instance' do
-
1
expected = "\n<PhoneNumber transferAnswerUrl=\"https://initial.com\" transferAnswerMethod=\"POST\" transferAnswerFallbackUrl=\"https://initial.com\" transferAnswerFallbackMethod=\"POST\" transferDisconnectUrl=\"https://initial.com\" transferDisconnectMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\">+19195551234</PhoneNumber>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the PhoneNumber instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<PhoneNumber transferAnswerUrl=\"https://new.com\" transferAnswerMethod=\"GET\" transferAnswerFallbackUrl=\"https://new.com\" transferAnswerFallbackMethod=\"GET\" transferDisconnectUrl=\"https://new.com\" transferDisconnectMethod=\"GET\" username=\"new_username\" password=\"new_password\" fallbackUsername=\"new_fallback_username\" fallbackPassword=\"new_fallback_password\" tag=\"new_tag\">+19195551234</PhoneNumber>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::PlayAudio
-
1
describe 'Bandwidth::Bxml::PlayAudio' do
-
1
let(:initial_attributes) {
-
{
-
3
username: 'initial_username',
-
password: 'initial_password'
-
}
-
}
-
-
1
let(:new_attributes) {
-
{
-
1
username: 'new_username',
-
password: 'new_password'
-
}
-
}
-
-
4
let(:instance) { Bandwidth::Bxml::PlayAudio.new('https://audio.url/audio1.wav', initial_attributes) }
-
-
1
describe 'test an instance of PlayAudio' do
-
1
it 'validates instance of PlayAudio' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::PlayAudio)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the PlayAudio instance' do
-
1
expected = "\n<PlayAudio username=\"initial_username\" password=\"initial_password\">https://audio.url/audio1.wav</PlayAudio>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the PlayAudio instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<PlayAudio username=\"new_username\" password=\"new_password\">https://audio.url/audio1.wav</PlayAudio>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::Record
-
1
describe 'Bandwidth::Bxml::Record' do
-
1
let(:initial_attributes) {
-
{
-
3
record_complete_url: 'https://initial.com',
-
record_complete_method: 'POST',
-
record_complete_fallback_url: 'https://initial.com',
-
record_complete_fallback_method: 'POST',
-
recording_available_url: 'https://initial.com',
-
recording_available_method: 'POST',
-
transcribe: true,
-
transcription_available_url: 'https://initial.com',
-
transcription_available_method: 'POST',
-
username: 'initial_username',
-
password: 'initial_password',
-
fallback_username: 'initial_fallback_username',
-
fallback_password: 'initial_fallback_password',
-
tag: 'initial_tag',
-
terminating_digits: '5',
-
max_duration: 5,
-
silence_timeout: 5,
-
file_format: 'wav'
-
}
-
}
-
-
1
let(:new_attributes) {
-
{
-
1
record_complete_url: 'https://new.com',
-
record_complete_method: 'GET',
-
record_complete_fallback_url: 'https://new.com',
-
record_complete_fallback_method: 'GET',
-
recording_available_url: 'https://new.com',
-
recording_available_method: 'GET',
-
transcribe: true,
-
transcription_available_url: 'https://new.com',
-
transcription_available_method: 'GET',
-
username: 'new_username',
-
password: 'new_password',
-
fallback_username: 'new_fallback_username',
-
fallback_password: 'new_fallback_password',
-
tag: 'new_tag',
-
terminating_digits: '0',
-
max_duration: 10,
-
silence_timeout: 10,
-
file_format: 'mp3'
-
}
-
}
-
-
4
let(:instance) { Bandwidth::Bxml::Record.new(initial_attributes) }
-
-
1
describe 'test an instance of Record' do
-
1
it 'validates instance of Record' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::Record)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the Record instance' do
-
1
expected = "\n<Record recordCompleteUrl=\"https://initial.com\" recordCompleteMethod=\"POST\" recordCompleteFallbackUrl=\"https://initial.com\" recordCompleteFallbackMethod=\"POST\" recordingAvailableUrl=\"https://initial.com\" recordingAvailableMethod=\"POST\" transcribe=\"true\" transcriptionAvailableUrl=\"https://initial.com\" transcriptionAvailableMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" terminatingDigits=\"5\" maxDuration=\"5\" silenceTimeout=\"5\" fileFormat=\"wav\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the Record instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<Record recordCompleteUrl=\"https://new.com\" recordCompleteMethod=\"GET\" recordCompleteFallbackUrl=\"https://new.com\" recordCompleteFallbackMethod=\"GET\" recordingAvailableUrl=\"https://new.com\" recordingAvailableMethod=\"GET\" transcribe=\"true\" transcriptionAvailableUrl=\"https://new.com\" transcriptionAvailableMethod=\"GET\" username=\"new_username\" password=\"new_password\" fallbackUsername=\"new_fallback_username\" fallbackPassword=\"new_fallback_password\" tag=\"new_tag\" terminatingDigits=\"0\" maxDuration=\"10\" silenceTimeout=\"10\" fileFormat=\"mp3\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::Redirect
-
1
describe 'Bandwidth::Bxml::Redirect' do
-
1
let(:initial_attributes) {
-
{
-
3
redirect_url: 'https://initial.com',
-
redirect_method: 'POST',
-
redirect_fallback_url: 'https://initial.com',
-
redirect_fallback_method: 'POST',
-
username: 'initial_username',
-
password: 'initial_password',
-
fallback_username: 'initial_fallback_username',
-
fallback_password: 'initial_fallback_password',
-
tag: 'initial_tag'
-
}
-
}
-
-
1
let(:new_attributes) {
-
{
-
1
redirect_url: 'https://new.com',
-
redirect_method: 'GET',
-
redirect_fallback_url: 'https://new.com',
-
redirect_fallback_method: 'GET',
-
username: 'new_username',
-
password: 'new_password',
-
fallback_username: 'new_fallback_username',
-
fallback_password: 'new_fallback_password',
-
tag: 'new_tag'
-
}
-
}
-
-
4
let(:instance) { Bandwidth::Bxml::Redirect.new(initial_attributes) }
-
-
1
describe 'test an instance of Redirect' do
-
1
it 'validates instance of Redirect' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::Redirect)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the Redirect instance' do
-
1
expected = "\n<Redirect redirectUrl=\"https://initial.com\" redirectMethod=\"POST\" redirectFallbackUrl=\"https://initial.com\" redirectFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the Redirect instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<Redirect redirectUrl=\"https://new.com\" redirectMethod=\"GET\" redirectFallbackUrl=\"https://new.com\" redirectFallbackMethod=\"GET\" username=\"new_username\" password=\"new_password\" fallbackUsername=\"new_fallback_username\" fallbackPassword=\"new_fallback_password\" tag=\"new_tag\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::ResumeRecording
-
1
describe 'Bandwidth::Bxml::ResumeRecording' do
-
3
let(:instance) { Bandwidth::Bxml::ResumeRecording.new }
-
-
1
describe 'test an instance of ResumeRecording' do
-
1
it 'validates instance of ResumeRecording' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::ResumeRecording)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the ResumeRecording instance' do
-
1
expected = "\n<ResumeRecording/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::Ring
-
1
describe 'Bandwidth::Bxml::Ring' do
-
1
let(:initial_attributes) {
-
3
{
-
duration: 5.0,
-
answer_call: true
-
}
-
}
-
-
1
let(:new_attributes) {
-
1
{
-
duration: 10.0,
-
answer_call: false
-
}
-
}
-
-
4
let(:instance) { Bandwidth::Bxml::Ring.new(initial_attributes) }
-
-
1
describe 'test an instance of Ring' do
-
1
it 'validates instance of Ring' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::Ring)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the Ring instance' do
-
1
expected = "\n<Ring duration=\"5.0\" answerCall=\"true\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the Ring instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<Ring duration=\"10.0\" answerCall=\"false\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::SendDtmf
-
1
describe 'Bandwidth::Bxml::SendDtmf' do
-
1
let(:initial_attributes) {
-
3
{
-
tone_duration: 5,
-
tone_interval: 5
-
}
-
}
-
-
1
let(:new_attributes) {
-
1
{
-
tone_duration: 10,
-
tone_interval: 10
-
}
-
}
-
-
4
let(:instance) { Bandwidth::Bxml::SendDtmf.new('1234', initial_attributes) }
-
-
1
describe 'test an instance of SendDtmf' do
-
1
it 'validates instance of SendDtmf' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::SendDtmf)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the SendDtmf instance' do
-
1
expected = "\n<SendDtmf toneDuration=\"5\" toneInterval=\"5\">1234</SendDtmf>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the SendDtmf instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<SendDtmf toneDuration=\"10\" toneInterval=\"10\">1234</SendDtmf>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::SipUri
-
1
describe 'Bandwidth::Bxml::SipUri' do
-
1
let(:initial_attributes) {
-
{
-
3
uui: 'abc123',
-
transfer_answer_url: 'https://initial.com',
-
transfer_answer_method: 'POST',
-
transfer_answer_fallback_url: 'https://initial.com',
-
transfer_answer_fallback_method: 'POST',
-
transfer_disconnect_url: 'https://initial.com',
-
transfer_disconnect_method: 'POST',
-
username: 'initial_username',
-
password: 'initial_password',
-
fallback_username: 'initial_fallback_username',
-
fallback_password: 'initial_fallback_password',
-
tag: 'initial_tag'
-
}
-
}
-
-
1
let(:new_attributes) {
-
{
-
1
uui: '123abc',
-
transfer_answer_url: 'https://new.com',
-
transfer_answer_method: 'GET',
-
transfer_answer_fallback_url: 'https://new.com',
-
transfer_answer_fallback_method: 'GET',
-
transfer_disconnect_url: 'https://new.com',
-
transfer_disconnect_method: 'GET',
-
username: 'new_username',
-
password: 'new_password',
-
fallback_username: 'new_fallback_username',
-
fallback_password: 'new_fallback_password',
-
tag: 'new_tag'
-
}
-
}
-
-
4
let(:instance) { Bandwidth::Bxml::SipUri.new('sip:1-999-123-4567@voip-provider.example.net', initial_attributes) }
-
-
1
describe 'test an instance of SipUri' do
-
1
it 'validates instance of SipUri' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::SipUri)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the SipUri instance' do
-
1
expected = "\n<SipUri uui=\"abc123\" transferAnswerUrl=\"https://initial.com\" transferAnswerMethod=\"POST\" transferAnswerFallbackUrl=\"https://initial.com\" transferAnswerFallbackMethod=\"POST\" transferDisconnectUrl=\"https://initial.com\" transferDisconnectMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\">sip:1-999-123-4567@voip-provider.example.net</SipUri>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the SipUri instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<SipUri uui=\"123abc\" transferAnswerUrl=\"https://new.com\" transferAnswerMethod=\"GET\" transferAnswerFallbackUrl=\"https://new.com\" transferAnswerFallbackMethod=\"GET\" transferDisconnectUrl=\"https://new.com\" transferDisconnectMethod=\"GET\" username=\"new_username\" password=\"new_password\" fallbackUsername=\"new_fallback_username\" fallbackPassword=\"new_fallback_password\" tag=\"new_tag\">sip:1-999-123-4567@voip-provider.example.net</SipUri>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::SpeakSentence
-
1
describe 'Bandwidth::Bxml::SpeakSentence' do
-
1
let(:initial_attributes) {
-
{
-
3
voice: 'julie',
-
gender: 'female',
-
locale: 'en_US'
-
}
-
}
-
-
1
let(:new_attributes) {
-
{
-
1
voice: 'simon',
-
gender: 'male',
-
locale: 'en_UK'
-
}
-
}
-
-
4
let(:instance) { Bandwidth::Bxml::SpeakSentence.new('<lang xml:lang="es-MX">Hola</lang>ruby speak sentence <emphasis>SSML test</emphasis>', initial_attributes) }
-
-
1
describe 'test an instance of SpeakSentence' do
-
1
it 'validates instance of SpeakSentence' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::SpeakSentence)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the SpeakSentence instance' do
-
1
expected = "\n<SpeakSentence voice=\"julie\" gender=\"female\" locale=\"en_US\"><lang xml:lang=\"es-MX\">Hola</lang>ruby speak sentence <emphasis>SSML test</emphasis></SpeakSentence>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the SpeakSentence instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<SpeakSentence voice=\"simon\" gender=\"male\" locale=\"en_UK\"><lang xml:lang=\"es-MX\">Hola</lang>ruby speak sentence <emphasis>SSML test</emphasis></SpeakSentence>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::StartGather
-
1
describe 'Bandwidth::Bxml::StartGather' do
-
1
let(:initial_attributes) {
-
{
-
3
dtmf_url: 'https://initial.com',
-
dtmf_method: 'POST',
-
username: 'initial_username',
-
password: 'initial_password',
-
tag: 'initial_tag'
-
}
-
}
-
-
1
let(:new_attributes) {
-
{
-
1
dtmf_url: 'https://new.com',
-
dtmf_method: 'GET',
-
username: 'new_username',
-
password: 'new_password',
-
tag: 'new_tag'
-
}
-
}
-
-
4
let(:instance) { Bandwidth::Bxml::StartGather.new(initial_attributes) }
-
-
1
describe 'test an instance of StartGather' do
-
1
it 'validates instance of StartGather' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::StartGather)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the StartGather instance' do
-
1
expected = "\n<StartGather dtmfUrl=\"https://initial.com\" dtmfMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" tag=\"initial_tag\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the StartGather instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<StartGather dtmfUrl=\"https://new.com\" dtmfMethod=\"GET\" username=\"new_username\" password=\"new_password\" tag=\"new_tag\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::StartRecording
-
1
describe 'Bandwidth::Bxml::StartRecording' do
-
1
let(:initial_attributes) {
-
{
-
3
recording_available_url: 'https://initial.com',
-
recording_available_method: 'POST',
-
transcribe: true,
-
transcription_available_url: 'https://initial.com',
-
transcription_available_method: 'POST',
-
username: 'initial_username',
-
password: 'initial_password',
-
tag: 'initial_tag',
-
file_format: 'wav',
-
multi_channel: true
-
}
-
}
-
-
1
let(:new_attributes) {
-
{
-
1
recording_available_url: 'https://new.com',
-
recording_available_method: 'GET',
-
transcribe: false,
-
transcription_available_url: 'https://new.com',
-
transcription_available_method: 'GET',
-
username: 'new_username',
-
password: 'new_password',
-
tag: 'new_tag',
-
file_format: 'mp3',
-
multi_channel: false
-
}
-
}
-
-
4
let(:instance) { Bandwidth::Bxml::StartRecording.new(initial_attributes) }
-
-
1
describe 'test an instance of StartRecording' do
-
1
it 'validates instance of StartRecording' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::StartRecording)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the StartRecording instance' do
-
1
expected = "\n<StartRecording recordingAvailableUrl=\"https://initial.com\" recordingAvailableMethod=\"POST\" transcribe=\"true\" transcriptionAvailableUrl=\"https://initial.com\" transcriptionAvailableMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" tag=\"initial_tag\" fileFormat=\"wav\" multiChannel=\"true\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the StartRecording instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<StartRecording recordingAvailableUrl=\"https://new.com\" recordingAvailableMethod=\"GET\" transcribe=\"false\" transcriptionAvailableUrl=\"https://new.com\" transcriptionAvailableMethod=\"GET\" username=\"new_username\" password=\"new_password\" tag=\"new_tag\" fileFormat=\"mp3\" multiChannel=\"false\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::StartStream
-
1
describe 'Bandwidth::Bxml::StartStream' do
-
1
let(:initial_attributes) {
-
{
-
6
name: 'initial_name',
-
tracks: 'inbound',
-
destination: 'https://initial.com',
-
stream_event_url: 'https://initial.com',
-
stream_event_method: 'POST',
-
username: 'initial_username',
-
password: 'initial_password'
-
}
-
}
-
-
1
let(:new_attributes) {
-
{
-
1
name: 'new_name',
-
tracks: 'outbound',
-
destination: 'https://new.com',
-
stream_event_url: 'https://new.com',
-
stream_event_method: 'GET',
-
username: 'new_username',
-
password: 'new_password'
-
}
-
}
-
-
4
let (:stream_param_1) { Bandwidth::Bxml::StreamParam.new({ name: 'stream_param_name_1', value: 'stream_param_value_1' }) }
-
2
let (:stream_param_2) { Bandwidth::Bxml::StreamParam.new({ name: 'stream_param_name_2', value: 'stream_param_value_2' }) }
-
-
4
let(:instance) { Bandwidth::Bxml::StartStream.new([], initial_attributes) }
-
4
let(:instance_nested) { Bandwidth::Bxml::StartStream.new([stream_param_1], initial_attributes) }
-
-
1
describe 'test an instance of StartStream' do
-
1
it 'validates instance of StartStream' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::StartStream)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the StartStream instance' do
-
1
expected = "\n<StartStream name=\"initial_name\" tracks=\"inbound\" destination=\"https://initial.com\" streamEventUrl=\"https://initial.com\" streamEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the StartStream instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<StartStream name=\"new_name\" tracks=\"outbound\" destination=\"https://new.com\" streamEventUrl=\"https://new.com\" streamEventMethod=\"GET\" username=\"new_username\" password=\"new_password\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
-
1
describe 'test an instance of StartStream with nested verbs' do
-
1
it 'validates instance of StartStream' do
-
1
expect(instance_nested).to be_instance_of(Bandwidth::Bxml::StartStream)
-
1
expect(instance_nested).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the nested StartStream instance' do
-
1
expected = "\n<StartStream name=\"initial_name\" tracks=\"inbound\" destination=\"https://initial.com\" streamEventUrl=\"https://initial.com\" streamEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\">\n <StreamParam name=\"stream_param_name_1\" value=\"stream_param_value_1\"/>\n</StartStream>\n"
-
1
expect(instance_nested.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the add_stream_param method of the nested StartStream instance' do
-
1
expected_single = "\n<StartStream name=\"initial_name\" tracks=\"inbound\" destination=\"https://initial.com\" streamEventUrl=\"https://initial.com\" streamEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\">\n <StreamParam name=\"stream_param_name_1\" value=\"stream_param_value_1\"/>\n <StreamParam name=\"stream_param_name_2\" value=\"stream_param_value_2\"/>\n</StartStream>\n"
-
1
instance_nested.add_stream_param(stream_param_2)
-
1
expect(instance_nested.to_bxml).to eq(expected_single)
-
-
1
expected_multiple = "\n<StartStream name=\"initial_name\" tracks=\"inbound\" destination=\"https://initial.com\" streamEventUrl=\"https://initial.com\" streamEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\">\n <StreamParam name=\"stream_param_name_1\" value=\"stream_param_value_1\"/>\n <StreamParam name=\"stream_param_name_2\" value=\"stream_param_value_2\"/>\n <StreamParam name=\"stream_param_name_2\" value=\"stream_param_value_2\"/>\n <StreamParam name=\"stream_param_name_2\" value=\"stream_param_value_2\"/>\n</StartStream>\n"
-
1
instance_nested.add_stream_param([stream_param_2, stream_param_2])
-
1
expect(instance_nested.to_bxml).to eq(expected_multiple)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::StartTranscription
-
1
describe 'Bandwidth::Bxml::StartTranscription' do
-
1
let(:initial_attributes) {
-
{
-
6
name: 'initial_name',
-
tracks: 'inbound',
-
transcription_event_url: 'https://initial.com',
-
transcription_event_method: 'POST',
-
username: 'initial_username',
-
password: 'initial_password',
-
destination: 'https://initial.com',
-
stabilized: true
-
}
-
}
-
-
1
let(:new_attributes) {
-
{
-
1
name: 'new_name',
-
tracks: 'outbound',
-
transcription_event_url: 'https://new.com',
-
transcription_event_method: 'GET',
-
username: 'new_username',
-
password: 'new_password',
-
destination: 'https://new.com',
-
stabilized: false
-
}
-
}
-
-
4
let (:custom_param_1) { Bandwidth::Bxml::CustomParam.new({ name: 'custom_param_name_1', value: 'custom_param_value_1' }) }
-
2
let (:custom_param_2) { Bandwidth::Bxml::CustomParam.new({ name: 'custom_param_name_2', value: 'custom_param_value_2' }) }
-
-
4
let(:instance) { Bandwidth::Bxml::StartTranscription.new([], initial_attributes) }
-
4
let(:instance_nested) { Bandwidth::Bxml::StartTranscription.new([custom_param_1], initial_attributes) }
-
-
1
describe 'test an instance of StartTranscription' do
-
1
it 'validates instance of StartTranscription' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::StartTranscription)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the StartTranscription instance' do
-
1
expected = "\n<StartTranscription name=\"initial_name\" tracks=\"inbound\" transcriptionEventUrl=\"https://initial.com\" transcriptionEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" destination=\"https://initial.com\" stabilized=\"true\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the StartTranscription instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<StartTranscription name=\"new_name\" tracks=\"outbound\" transcriptionEventUrl=\"https://new.com\" transcriptionEventMethod=\"GET\" username=\"new_username\" password=\"new_password\" destination=\"https://new.com\" stabilized=\"false\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
-
1
describe 'test an instance of StartTranscription with nested verbs' do
-
1
it 'validates instance of StartTranscription' do
-
1
expect(instance_nested).to be_instance_of(Bandwidth::Bxml::StartTranscription)
-
1
expect(instance_nested).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the nested StartTranscription instance' do
-
1
expected = "\n<StartTranscription name=\"initial_name\" tracks=\"inbound\" transcriptionEventUrl=\"https://initial.com\" transcriptionEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" destination=\"https://initial.com\" stabilized=\"true\">\n <CustomParam name=\"custom_param_name_1\" value=\"custom_param_value_1\"/>\n</StartTranscription>\n"
-
1
expect(instance_nested.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the add_custom_param method of the nested StartTranscription instance' do
-
1
expected_single = "\n<StartTranscription name=\"initial_name\" tracks=\"inbound\" transcriptionEventUrl=\"https://initial.com\" transcriptionEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" destination=\"https://initial.com\" stabilized=\"true\">\n <CustomParam name=\"custom_param_name_1\" value=\"custom_param_value_1\"/>\n <CustomParam name=\"custom_param_name_2\" value=\"custom_param_value_2\"/>\n</StartTranscription>\n"
-
1
instance_nested.add_custom_param(custom_param_2)
-
1
expect(instance_nested.to_bxml).to eq(expected_single)
-
-
1
expected_multiple = "\n<StartTranscription name=\"initial_name\" tracks=\"inbound\" transcriptionEventUrl=\"https://initial.com\" transcriptionEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" destination=\"https://initial.com\" stabilized=\"true\">\n <CustomParam name=\"custom_param_name_1\" value=\"custom_param_value_1\"/>\n <CustomParam name=\"custom_param_name_2\" value=\"custom_param_value_2\"/>\n <CustomParam name=\"custom_param_name_2\" value=\"custom_param_value_2\"/>\n <CustomParam name=\"custom_param_name_2\" value=\"custom_param_value_2\"/>\n</StartTranscription>\n"
-
1
instance_nested.add_custom_param([custom_param_2, custom_param_2])
-
1
expect(instance_nested.to_bxml).to eq(expected_multiple)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::StopGather
-
1
describe 'Bandwidth::Bxml::StopGather' do
-
3
let(:instance) { Bandwidth::Bxml::StopGather.new }
-
-
1
describe 'test an instance of StopGather' do
-
1
it 'validates instance of StopGather' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::StopGather)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the StopGather instance' do
-
1
expected = "\n<StopGather/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::StopRecording
-
1
describe 'Bandwidth::Bxml::StopRecording' do
-
3
let(:instance) { Bandwidth::Bxml::StopRecording.new }
-
-
1
describe 'test an instance of StopRecording' do
-
1
it 'validates instance of StopRecording' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::StopRecording)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the StopRecording instance' do
-
1
expected = "\n<StopRecording/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::StopStream
-
1
describe 'Bandwidth::Bxml::StopStream' do
-
1
let(:initial_attributes) {
-
{
-
3
name: 'initial_name'
-
}
-
}
-
-
1
let(:new_attributes) {
-
{
-
1
name: 'new_name'
-
}
-
}
-
-
4
let(:instance) { Bandwidth::Bxml::StopStream.new(initial_attributes) }
-
-
1
describe 'test an instance of StopStream' do
-
1
it 'validates instance of StopStream' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::StopStream)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the StopStream instance' do
-
1
expected = "\n<StopStream name=\"initial_name\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the StopStream instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<StopStream name=\"new_name\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::StopTranscription
-
1
describe 'Bandwidth::Bxml::StopTranscription' do
-
1
let(:initial_attributes) {
-
{
-
3
name: 'initial_name'
-
}
-
}
-
-
1
let(:new_attributes) {
-
{
-
1
name: 'new_name'
-
}
-
}
-
-
4
let(:instance) { Bandwidth::Bxml::StopTranscription.new(initial_attributes) }
-
-
1
describe 'test an instance of StopTranscription' do
-
1
it 'validates instance of StopTranscription' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::StopTranscription)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the StopTranscription instance' do
-
1
expected = "\n<StopTranscription name=\"initial_name\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the StopTranscription instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<StopTranscription name=\"new_name\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::StreamParam
-
1
describe 'Bandwidth::Bxml::StreamParam' do
-
1
let(:initial_attributes) {
-
{
-
3
name: 'initial_name',
-
value: 'initial_value'
-
}
-
}
-
-
1
let(:new_attributes) {
-
{
-
1
name: 'new_name',
-
value: 'new_value'
-
}
-
}
-
-
4
let(:instance) { Bandwidth::Bxml::StreamParam.new(initial_attributes) }
-
-
1
describe 'test an instance of StreamParam' do
-
1
it 'validates instance of StreamParam' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::StreamParam)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the StreamParam instance' do
-
1
expected = "\n<StreamParam name=\"initial_name\" value=\"initial_value\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the StreamParam instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<StreamParam name=\"new_name\" value=\"new_value\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::Tag
-
1
describe 'Bandwidth::Bxml::Tag' do
-
3
let(:instance) { Bandwidth::Bxml::Tag.new('test_tag') }
-
-
1
describe 'test an instance of Tag' do
-
1
it 'validates instance of Tag' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::Tag)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the Tag instance' do
-
1
expected = "\n<Tag>test_tag</Tag>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Bxml::Transfer
-
1
describe 'Bandwidth::Bxml::Transfer' do
-
1
let(:initial_attributes) {
-
{
-
6
transfer_caller_id: '+19195551234',
-
call_timeout: 5,
-
transfer_complete_url: 'https://initial.com',
-
transfer_complete_method: 'POST',
-
transfer_complete_fallback_url: 'https://initial.com',
-
transfer_complete_fallback_method: 'POST',
-
username: 'initial_username',
-
password: 'initial_password',
-
fallback_username: 'initial_fallback_username',
-
fallback_password: 'initial_fallback_password',
-
tag: 'initial_tag',
-
diversion_treatment: 'propogate',
-
diversion_reason: 'user-busy'
-
}
-
}
-
-
1
let(:new_attributes) {
-
{
-
1
transfer_caller_id: '+19195554321',
-
call_timeout: 10,
-
transfer_complete_url: 'https://new.com',
-
transfer_complete_method: 'POST',
-
transfer_complete_fallback_url: 'https://new.com',
-
transfer_complete_fallback_method: 'POST',
-
username: 'new_username',
-
password: 'new_password',
-
fallback_username: 'new_fallback_username',
-
fallback_password: 'new_fallback_password',
-
tag: 'new_tag',
-
diversion_treatment: 'stack',
-
diversion_reason: 'no-answer'
-
}
-
}
-
-
4
let(:phone_number) { Bandwidth::Bxml::PhoneNumber.new('+19195551234') }
-
2
let(:sip_uri) { Bandwidth::Bxml::SipUri.new('sip:1-999-123-4567@voip-provider.example.net') }
-
-
4
let(:instance) { Bandwidth::Bxml::Transfer.new([], initial_attributes) }
-
4
let(:instance_nested) { Bandwidth::Bxml::Transfer.new([phone_number], initial_attributes) }
-
-
1
describe 'test an instance of Transfer' do
-
1
it 'validates instance of Transfer' do
-
1
expect(instance).to be_instance_of(Bandwidth::Bxml::Transfer)
-
1
expect(instance).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the Transfer instance' do
-
1
expected = "\n<Transfer transferCallerId=\"+19195551234\" callTimeout=\"5\" transferCompleteUrl=\"https://initial.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"https://initial.com\" transferCompleteFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" diversionTreatment=\"propogate\" diversionReason=\"user-busy\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the set_attributes method of the Transfer instance' do
-
1
instance.set_attributes(new_attributes)
-
1
expected = "\n<Transfer transferCallerId=\"+19195554321\" callTimeout=\"10\" transferCompleteUrl=\"https://new.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"https://new.com\" transferCompleteFallbackMethod=\"POST\" username=\"new_username\" password=\"new_password\" fallbackUsername=\"new_fallback_username\" fallbackPassword=\"new_fallback_password\" tag=\"new_tag\" diversionTreatment=\"stack\" diversionReason=\"no-answer\"/>\n"
-
1
expect(instance.to_bxml).to eq(expected)
-
end
-
end
-
-
1
describe 'test an instance of Transfer with nested verbs' do
-
1
it 'validates instance of Transfer' do
-
1
expect(instance_nested).to be_instance_of(Bandwidth::Bxml::Transfer)
-
1
expect(instance_nested).to be_a(Bandwidth::Bxml::Verb)
-
end
-
-
1
it 'tests the to_bxml method of the nested Transfer instance' do
-
1
expected = "\n<Transfer transferCallerId=\"+19195551234\" callTimeout=\"5\" transferCompleteUrl=\"https://initial.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"https://initial.com\" transferCompleteFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" diversionTreatment=\"propogate\" diversionReason=\"user-busy\">\n <PhoneNumber>+19195551234</PhoneNumber>\n</Transfer>\n"
-
1
expect(instance_nested.to_bxml).to eq(expected)
-
end
-
-
1
it 'tests the add_verb method of the nested Transfer instance' do
-
1
expected_single = "\n<Transfer transferCallerId=\"+19195551234\" callTimeout=\"5\" transferCompleteUrl=\"https://initial.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"https://initial.com\" transferCompleteFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" diversionTreatment=\"propogate\" diversionReason=\"user-busy\">\n <PhoneNumber>+19195551234</PhoneNumber>\n <SipUri>sip:1-999-123-4567@voip-provider.example.net</SipUri>\n</Transfer>\n"
-
1
instance_nested.add_transfer_recipient(sip_uri)
-
1
expect(instance_nested.to_bxml).to eq(expected_single)
-
-
1
expected_multiple = "\n<Transfer transferCallerId=\"+19195551234\" callTimeout=\"5\" transferCompleteUrl=\"https://initial.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"https://initial.com\" transferCompleteFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" diversionTreatment=\"propogate\" diversionReason=\"user-busy\">\n <PhoneNumber>+19195551234</PhoneNumber>\n <SipUri>sip:1-999-123-4567@voip-provider.example.net</SipUri>\n <SipUri>sip:1-999-123-4567@voip-provider.example.net</SipUri>\n <PhoneNumber>+19195551234</PhoneNumber>\n</Transfer>\n"
-
1
instance_nested.add_transfer_recipient([sip_uri, phone_number])
-
1
expect(instance_nested.to_bxml).to eq(expected_multiple)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::CallStateEnum
-
1
describe Bandwidth::CallStateEnum do
-
2
let(:instance) { Bandwidth::CallStateEnum.new }
-
-
1
describe 'test an instance of CallStateEnum' do
-
1
it 'creates an instance of CallStateEnum' do
-
1
expect(instance).to be_instance_of(Bandwidth::CallStateEnum)
-
end
-
-
1
it 'raises an error for an invalid enum value' do
-
1
expect {
-
1
Bandwidth::CallStateEnum.build_from_hash('invalid')
-
}.to raise_error(RuntimeError)
-
end
-
end
-
end
-
# Unit tests for Bandwidth::CallState
-
1
describe Bandwidth::CallState do
-
4
let(:call_state_default) { Bandwidth::CallState.new }
-
3
let(:call_state_values) { Bandwidth::CallState.new({
-
application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
-
account_id: '9900000',
-
call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
-
parent_call_id: 'c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
-
to: '+19195551234',
-
from: '+19195554321',
-
direction: 'inbound',
-
state: 'disconnected',
-
stir_shaken: {
-
'verstat': 'TN-Verification-Passed',
-
'attestationIndicator': 'A',
-
'originatingId': 'abc123'
-
},
-
identity: 'eyJhbGciOiJFUzI1NiI',
-
enqueued_time: '2022-06-16T13:15:07.160Z',
-
start_time: '2022-06-16T13:15:07.160Z',
-
answer_time: '2022-06-16T13:15:18.126Z',
-
end_time: '2022-06-16T13:15:18.314Z',
-
disconnect_cause: 'hangup',
-
error_message: nil,
-
error_id: nil,
-
last_update: '2022-06-16T13:15:18.314Z'
-
}) }
-
-
1
describe '#initialize' do
-
1
it 'causes an ArgumentError by passing an Array to the initialize method' do
-
1
expect {
-
1
Bandwidth::CallState.new([])
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
-
1
expect {
-
1
Bandwidth::CallState.new({ invalid: true })
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
1
describe '#acceptable_attributes' do
-
1
it 'expects acceptable JSON attributes to be those in the attribute map' do
-
1
expect(Bandwidth::CallState.acceptable_attributes).to eq(Bandwidth::CallState.attribute_map.values)
-
end
-
end
-
-
1
describe 'EnumAttributeValidator' do
-
1
it 'validates string enum' do
-
1
validator = Bandwidth::CallState::EnumAttributeValidator.new(String, ['valid'])
-
1
expect(validator.valid?('valid')).to be true
-
1
expect(validator.valid?('invalid')).to be false
-
end
-
-
1
it 'validates integer enum' do
-
1
validator = Bandwidth::CallState::EnumAttributeValidator.new(Integer, [1])
-
1
expect(validator.valid?(1)).to be true
-
1
expect(validator.valid?('invalid')).to be false
-
end
-
-
1
it 'validates float enum' do
-
1
validator = Bandwidth::CallState::EnumAttributeValidator.new(Float, [1.0])
-
1
expect(validator.valid?(1.0)).to be true
-
1
expect(validator.valid?('invalid')).to be false
-
end
-
end
-
-
1
describe '#build_from_hash' do
-
1
it 'validates instance of CallState created by the build_from_hash method' do
-
1
call_state_from_hash = Bandwidth::CallState.build_from_hash({
-
applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
-
accountId: '9900000',
-
callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
-
parentCallId: 'c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
-
to: '+19195551234',
-
from: '+19195554321',
-
direction: 'inbound',
-
state: 'disconnected',
-
stirShaken: {
-
'verstat': 'TN-Verification-Passed',
-
'attestationIndicator': 'A',
-
'originatingId': 'abc123'
-
},
-
identity: 'eyJhbGciOiJFUzI1NiI',
-
enqueuedTime: '2022-06-16T13:15:07.160Z',
-
startTime: '2022-06-16T13:15:07.160Z',
-
answerTime: '2022-06-16T13:15:18.126Z',
-
endTime: '2022-06-16T13:15:18.314Z',
-
disconnectCause: 'hangup',
-
errorMessage: nil,
-
errorId: nil,
-
lastUpdate: '2022-06-16T13:15:18.314Z'
-
})
-
1
expect(call_state_from_hash).to be_instance_of(Bandwidth::CallState)
-
1
expect(call_state_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
-
1
expect(call_state_from_hash.account_id).to eq('9900000')
-
1
expect(call_state_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
-
1
expect(call_state_from_hash.parent_call_id).to eq('c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
-
1
expect(call_state_from_hash.to).to eq('+19195551234')
-
1
expect(call_state_from_hash.from).to eq('+19195554321')
-
1
expect(call_state_from_hash.direction).to eq('inbound')
-
1
expect(call_state_from_hash.state).to eq('disconnected')
-
1
expect(call_state_from_hash.stir_shaken).to eq({
-
'verstat' => 'TN-Verification-Passed',
-
'attestationIndicator' => 'A',
-
'originatingId' => 'abc123'
-
})
-
1
expect(call_state_from_hash.identity).to eq('eyJhbGciOiJFUzI1NiI')
-
1
expect(call_state_from_hash.enqueued_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
-
1
expect(call_state_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
-
1
expect(call_state_from_hash.answer_time).to eq(Time.parse('2022-06-16T13:15:18.126Z'))
-
1
expect(call_state_from_hash.end_time).to eq(Time.parse('2022-06-16T13:15:18.314Z'))
-
1
expect(call_state_from_hash.disconnect_cause).to eq('hangup')
-
1
expect(call_state_from_hash.error_message).to eq(nil)
-
1
expect(call_state_from_hash.error_id).to eq(nil)
-
1
expect(call_state_from_hash.last_update).to eq(Time.parse('2022-06-16T13:15:18.314Z'))
-
end
-
end
-
-
1
describe '#hash' do
-
1
it 'returns a hash code according to attributes' do
-
1
expect(call_state_default.hash).to be_instance_of(Integer)
-
end
-
end
-
-
1
describe '#to_s' do
-
1
it 'returns a string representation of the object' do
-
1
expect(call_state_default.to_s).to eq('{}')
-
end
-
end
-
-
1
describe '#eq? #==' do
-
1
it 'returns true/false when comparing objects' do
-
1
expect(call_state_default.eql?(Bandwidth::CallState.new)).to be true
-
1
expect(call_state_default.eql?(call_state_values)).to be false
-
end
-
end
-
-
1
describe '#to_body #to_hash' do
-
1
it 'returns a hash representation of the object' do
-
1
expect(call_state_values.to_body).to eq({
-
applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
-
accountId: '9900000',
-
callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
-
parentCallId: 'c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
-
to: '+19195551234',
-
from: '+19195554321',
-
direction: 'inbound',
-
state: 'disconnected',
-
stirShaken: {
-
'verstat': 'TN-Verification-Passed',
-
'attestationIndicator': 'A',
-
'originatingId': 'abc123'
-
},
-
identity: 'eyJhbGciOiJFUzI1NiI',
-
enqueuedTime: '2022-06-16T13:15:07.160Z',
-
startTime: '2022-06-16T13:15:07.160Z',
-
answerTime: '2022-06-16T13:15:18.126Z',
-
endTime: '2022-06-16T13:15:18.314Z',
-
disconnectCause: 'hangup',
-
errorMessage: nil,
-
errorId: nil,
-
lastUpdate: '2022-06-16T13:15:18.314Z'
-
})
-
end
-
end
-
end
-
# Unit tests for Bandwidth::DeferredResult
-
1
describe Bandwidth::DeferredResult do
-
3
let(:deferred_result_default) { Bandwidth::DeferredResult.new }
-
4
let(:deferred_result_values) { Bandwidth::DeferredResult.new({
-
result: { key: 'value' },
-
set_or_expired: true
-
}) }
-
-
1
describe '#initialize' do
-
1
it 'causes an ArgumentError by passing an Array to the initialize method' do
-
1
expect {
-
1
Bandwidth::DeferredResult.new([])
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
-
1
expect {
-
1
Bandwidth::DeferredResult.new({ invalid: true })
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
1
describe '#acceptable_attributes' do
-
1
it 'expects acceptable JSON attributes to be those in the attribute map' do
-
1
expect(Bandwidth::DeferredResult.acceptable_attributes).to eq(Bandwidth::DeferredResult.attribute_map.values)
-
end
-
end
-
-
1
describe '#openapi_nullable' do
-
1
it 'expects nullable attributes to be an empty set' do
-
1
expect(Bandwidth::DeferredResult.openapi_nullable).to eq(Set.new([]))
-
end
-
end
-
-
1
describe '#build_from_hash' do
-
1
it 'validates instance of DeferredResult created by the build_from_hash method' do
-
1
deferred_result_from_hash = Bandwidth::DeferredResult.build_from_hash({
-
result: { key: 'value' },
-
setOrExpired: true
-
})
-
1
expect(deferred_result_from_hash).to be_instance_of(Bandwidth::DeferredResult)
-
1
expect(deferred_result_from_hash.result).to eq({ key: 'value' })
-
1
expect(deferred_result_from_hash.set_or_expired).to be true
-
end
-
end
-
-
1
describe '#hash' do
-
1
it 'returns a hash code according to attributes' do
-
1
expect(deferred_result_default.hash).to be_instance_of(Integer)
-
end
-
end
-
-
1
describe '#to_s' do
-
1
it 'returns a string representation of the object' do
-
1
expect(deferred_result_values.to_s).to eq('{:result=>{:key=>"value"}, :setOrExpired=>true}')
-
end
-
end
-
-
1
describe '#eq? #==' do
-
1
it 'returns true/false when comparing objects' do
-
1
expect(deferred_result_default.eql?(Bandwidth::DeferredResult.new)).to be true
-
1
expect(deferred_result_default.eql?(deferred_result_values)).to be false
-
end
-
end
-
-
1
describe '#to_body #to_hash' do
-
1
it 'returns a hash representation of the object' do
-
1
expect(deferred_result_values.to_body).to eq({
-
result: { key: 'value' },
-
setOrExpired: true
-
})
-
end
-
end
-
end
-
# Unit tests for Bandwidth::Message
-
1
describe Bandwidth::Message do
-
4
let(:message_default) { Bandwidth::Message.new }
-
3
let(:message_values) { Bandwidth::Message.new({
-
id: '1589228074636lm4k2je7j7jklbn2',
-
owner: '+19195554321',
-
application_id: '93de2206-9669-4e07-948d-329f4b722ee2',
-
time: '2022-06-16T13:15:07.160Z',
-
segment_count: 2,
-
direction: Bandwidth::MessageDirectionEnum::IN,
-
to: ['+19195551234'],
-
from: '+19195554321',
-
media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'],
-
text: 'Hello world',
-
tag: 'custom tag',
-
priority: 'default',
-
expiration: '2022-06-16T13:45:07.160Z'
-
}) }
-
-
1
describe '#initialize' do
-
1
it 'causes an ArgumentError by passing an Array to the initialize method' do
-
1
expect {
-
1
Bandwidth::Message.new([])
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
-
1
expect {
-
1
Bandwidth::Message.new({ invalid: true })
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
1
describe '#acceptable_attributes' do
-
1
it 'expects acceptable JSON attributes to be those in the attribute map' do
-
1
expect(Bandwidth::Message.acceptable_attributes).to eq(Bandwidth::Message.attribute_map.values)
-
end
-
end
-
-
1
describe 'enum validation' do
-
1
it 'works' do
-
-
end
-
end
-
-
1
describe 'EnumAttributeValidator' do
-
1
it 'validates string enum' do
-
1
validator = Bandwidth::Message::EnumAttributeValidator.new(String, ['valid'])
-
1
expect(validator.valid?('valid')).to be true
-
1
expect(validator.valid?('invalid')).to be false
-
end
-
-
1
it 'validates integer enum' do
-
1
validator = Bandwidth::Message::EnumAttributeValidator.new(Integer, [1])
-
1
expect(validator.valid?(1)).to be true
-
1
expect(validator.valid?('invalid')).to be false
-
end
-
-
1
it 'validates float enum' do
-
1
validator = Bandwidth::Message::EnumAttributeValidator.new(Float, [1.0])
-
1
expect(validator.valid?(1.0)).to be true
-
1
expect(validator.valid?('invalid')).to be false
-
end
-
end
-
-
1
describe '#build_from_hash' do
-
1
it 'validates instance of Message created by the build_from_hash method' do
-
1
message_from_hash = Bandwidth::Message.build_from_hash({
-
id: '1589228074636lm4k2je7j7jklbn2',
-
owner: '+19195554321',
-
applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
-
time: '2022-06-16T13:15:07.160Z',
-
segmentCount: 2,
-
direction: Bandwidth::MessageDirectionEnum::IN,
-
to: ['+19195551234'],
-
from: '+19195554321',
-
media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'],
-
text: 'Hello world',
-
tag: 'custom tag',
-
priority: 'default',
-
expiration: '2022-06-16T13:45:07.160Z'
-
})
-
1
expect(message_from_hash).to be_instance_of(Bandwidth::Message)
-
1
expect(message_from_hash.id).to eq('1589228074636lm4k2je7j7jklbn2')
-
1
expect(message_from_hash.owner).to eq('+19195554321')
-
1
expect(message_from_hash.application_id).to eq('93de2206-9669-4e07-948d-329f4b722ee2')
-
1
expect(message_from_hash.time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
-
1
expect(message_from_hash.segment_count).to eq(2)
-
1
expect(message_from_hash.direction).to eq(Bandwidth::MessageDirectionEnum::IN)
-
1
expect(message_from_hash.to).to eq(['+19195551234'])
-
1
expect(message_from_hash.from).to eq('+19195554321')
-
1
expect(message_from_hash.media).to eq(['https://dev.bandwidth.com/images/bandwidth-logo.png'])
-
1
expect(message_from_hash.text).to eq('Hello world')
-
1
expect(message_from_hash.tag).to eq('custom tag')
-
1
expect(message_from_hash.priority).to eq('default')
-
1
expect(message_from_hash.expiration).to eq(Time.parse('2022-06-16T13:45:07.160Z'))
-
end
-
end
-
-
1
describe '#hash' do
-
1
it 'returns a hash code according to attributes' do
-
1
expect(message_default.hash).to be_instance_of(Integer)
-
end
-
end
-
-
1
describe '#to_s' do
-
1
it 'returns a string representation of the object' do
-
1
expect(message_default.to_s).to eq('{}')
-
end
-
end
-
-
1
describe '#eq? #==' do
-
1
it 'returns true/false when comparing objects' do
-
1
expect(message_default.eql?(Bandwidth::Message.new)).to be true
-
1
expect(message_default.eql?(message_values)).to be false
-
end
-
end
-
-
1
describe '#to_body #to_hash' do
-
1
it 'returns a hash representation of the object' do
-
1
expect(message_values.to_body).to eq({
-
id: '1589228074636lm4k2je7j7jklbn2',
-
owner: '+19195554321',
-
applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
-
time: '2022-06-16T13:15:07.160Z',
-
segmentCount: 2,
-
direction: Bandwidth::MessageDirectionEnum::IN,
-
to: ['+19195551234'],
-
from: '+19195554321',
-
media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'],
-
text: 'Hello world',
-
tag: 'custom tag',
-
priority: 'default',
-
expiration: '2022-06-16T13:45:07.160Z'
-
})
-
end
-
end
-
end
-
# Unit tests for Bandwidth::VerifyCodeRequest
-
1
describe Bandwidth::VerifyCodeRequest do
-
5
let(:verify_code_request_values) { Bandwidth::VerifyCodeRequest.new({
-
to: '+19195551234',
-
scope: '2FA',
-
expiration_time_in_minutes: 1.0,
-
code: '123456'
-
}) }
-
-
1
describe '#initialize' do
-
1
it 'causes an ArgumentError by passing an Array to the initialize method' do
-
1
expect {
-
1
Bandwidth::VerifyCodeRequest.new([])
-
}.to raise_error(ArgumentError)
-
end
-
-
1
it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
-
1
expect {
-
1
Bandwidth::VerifyCodeRequest.new({ invalid: true })
-
}.to raise_error(ArgumentError)
-
end
-
end
-
-
1
describe '#acceptable_attributes' do
-
1
it 'expects acceptable JSON attributes to be those in the attribute map' do
-
1
expect(Bandwidth::VerifyCodeRequest.acceptable_attributes).to eq(Bandwidth::VerifyCodeRequest.attribute_map.values)
-
end
-
end
-
-
1
describe '#openapi_nullable' do
-
1
it 'expects nullable attributes to be an empty set' do
-
1
expect(Bandwidth::VerifyCodeRequest.openapi_nullable).to eq(Set.new([]))
-
end
-
end
-
-
1
describe '#build_from_hash' do
-
1
it 'validates instance of VerifyCodeRequest created by the build_from_hash method' do
-
1
verify_code_request_from_hash = Bandwidth::VerifyCodeRequest.build_from_hash({
-
to: '+19195551234',
-
scope: '2FA',
-
expirationTimeInMinutes: 1.0,
-
code: '123456'
-
})
-
1
expect(verify_code_request_from_hash).to be_instance_of(Bandwidth::VerifyCodeRequest)
-
1
expect(verify_code_request_from_hash.to).to eq('+19195551234')
-
1
expect(verify_code_request_from_hash.scope).to eq('2FA')
-
1
expect(verify_code_request_from_hash.expiration_time_in_minutes).to eq(1.0)
-
1
expect(verify_code_request_from_hash.code).to eq('123456')
-
end
-
end
-
-
1
describe '#hash' do
-
1
it 'returns a hash code according to attributes' do
-
1
expect(verify_code_request_values.hash).to be_instance_of(Integer)
-
end
-
end
-
-
1
describe '#to_s' do
-
1
it 'returns a string representation of the object' do
-
1
expect(verify_code_request_values.to_s).to eq('{:to=>"+19195551234", :scope=>"2FA", :expirationTimeInMinutes=>1.0, :code=>"123456"}')
-
end
-
end
-
-
1
describe '#eq? #==' do
-
1
it 'returns true/false when comparing objects' do
-
1
verify_code_request_equal = Bandwidth::VerifyCodeRequest.new({
-
to: '+19195551234',
-
scope: '2FA',
-
expiration_time_in_minutes: 1.0,
-
code: '123456'
-
})
-
1
expect(verify_code_request_equal.eql?(verify_code_request_values)).to be true
-
end
-
end
-
-
1
describe '#to_body #to_hash' do
-
1
it 'returns a hash representation of the object' do
-
1
expect(verify_code_request_values.to_body).to eq({
-
to: '+19195551234',
-
scope: '2FA',
-
expirationTimeInMinutes: 1.0,
-
code: '123456'
-
})
-
end
-
end
-
-
1
describe 'custom attribute writers' do
-
1
it '#to=' do
-
1
expect {
-
1
Bandwidth::VerifyCodeRequest.new({ to: nil })
-
}.to raise_error(ArgumentError, 'to cannot be nil')
-
-
1
expect {
-
1
Bandwidth::VerifyCodeRequest.new({ to: 'invalid' })
-
}.to raise_error(ArgumentError, 'invalid value for "to", must conform to the pattern (?-mix:^\+[1-9]\d{1,14}$).')
-
end
-
-
1
it '#expiration_time_in_minutes=' do
-
1
expect {
-
1
Bandwidth::VerifyCodeRequest.new({ to: '+19195551234', expiration_time_in_minutes: nil })
-
}.to raise_error(ArgumentError, 'expiration_time_in_minutes cannot be nil')
-
-
1
expect {
-
1
Bandwidth::VerifyCodeRequest.new({ to: '+19195551234', expiration_time_in_minutes: 16 })
-
}.to raise_error(ArgumentError, 'invalid value for "expiration_time_in_minutes", must be smaller than or equal to 15.')
-
-
1
expect {
-
1
Bandwidth::VerifyCodeRequest.new({ to: '+19195551234', expiration_time_in_minutes: 0 })
-
}.to raise_error(ArgumentError, 'invalid value for "expiration_time_in_minutes", must be greater than or equal to 1.')
-
end
-
-
1
it '#code=' do
-
1
expect {
-
1
Bandwidth::VerifyCodeRequest.new({ to: '+19195551234', expiration_time_in_minutes: 1, code: nil })
-
}.to raise_error(ArgumentError, 'code cannot be nil')
-
-
1
expect {
-
1
Bandwidth::VerifyCodeRequest.new({ to: '+19195551234', expiration_time_in_minutes: 1, code: '123456789' })
-
}.to raise_error(ArgumentError, 'invalid value for "code", the character length must be smaller than or equal to 8.')
-
-
1
expect {
-
1
Bandwidth::VerifyCodeRequest.new({ to: '+19195551234', expiration_time_in_minutes: 1, code: '123' })
-
}.to raise_error(ArgumentError, 'invalid value for "code", the character length must be great than or equal to 4.')
-
end
-
end
-
end