class Vonage::Voice
Public Instance Methods
Create an outbound Call.
@example
response = client.voice.create({ to: [{type: 'phone', number: '14843331234'}], from: {type: 'phone', number: '14843335555'}, answer_url: ['https://example.com/answer'] })
@option params [required, Array<Hash>] :to
Connect to a Phone (PSTN) number, SIP Endpoint, Websocket, or VBC extension.
@option params [required, Hash] :from
Connect to a Phone (PSTN) number.
@option params [Array<String>] :ncco
The Vonage Call Control Object to use for this call. Required unless **:answer_url** is provided.
@option params [Array<String>] :answer_url
The webhook endpoint where you provide the Vonage Call Control Object that governs this call. Required unless **:ncco** is provided.
@option params [String] :answer_method
The HTTP method used to send event information to answer_url.
@option params [required, Array<String>] :event_url
The webhook endpoint where call progress events are sent to.
@option params [String] :event_method
The HTTP method used to send event information to event_url.
@option params [String] :machine_detection
Configure the behavior when Vonage detects that the call is answered by voicemail.
@option params [Integer] :length_timer
Set the number of seconds that elapse before Vonage hangs up after the call state changes to in_progress.
@option params [Integer] :ringing_timer
Set the number of seconds that elapse before Vonage hangs up after the call state changes to `ringing`.
@param [Hash] params
@return [Response]
@see developer.nexmo.com/api/voice#createCall
# File lib/vonage/voice.rb, line 57 def create(params) request('/v1/calls', params: params, type: Post) end
@return [DTMF]
# File lib/vonage/voice.rb, line 254 def dtmf @dtmf ||= DTMF.new(@config) end
Earmuff an in progress call.
@example
response = client.voice.earmuff(id)
@param [String] id
@return [Response]
@see developer.nexmo.com/api/voice#updateCall
# File lib/vonage/voice.rb, line 200 def earmuff(id) update(id, action: 'earmuff') end
Get detail of a specific call.
@example
response = client.voice.get(id)
@param [String] id
@return [Response]
@see developer.nexmo.com/api/voice#getCall
# File lib/vonage/voice.rb, line 119 def get(id) request('/v1/calls/' + id) end
Hangup an in progress call.
@example
response = client.voice.hangup(id)
@param [String] id
@return [Response]
@see developer.nexmo.com/api/voice#updateCall
# File lib/vonage/voice.rb, line 155 def hangup(id) update(id, action: 'hangup') end
Get details of your calls.
@example
response = client.voice.list response.each do |item| puts "#{item.uuid} #{item.direction} #{item.status}" end
@option params [String] :status
Filter by call status.
@option params [String] :date_start
Return the records that occurred after this point in time.
@option params [String] :date_end
Return the records that occurred before this point in time.
@option params [Integer] :page_size
Return this amount of records in the response.
@option params [Integer] :record_index
Return calls from this index in the response.
@option params [String] :order
Either `ascending` or `descending` order.
@option params [String] :conversation_uuid
Return all the records associated with a specific conversation.
@option params [Boolean] :auto_advance
Set this to `false` to not auto-advance through all the pages in the record and collect all the data. The default is `true`.
@param [Hash] params
@return [ListResponse]
@see developer.nexmo.com/api/voice#getCalls
# File lib/vonage/voice.rb, line 100 def list(params = nil, auto_advance = true) if params && !params.key?(:auto_advance) params.merge!(auto_advance: true) end request('/v1/calls', params: params, response_class: ListResponse) end
Mute an in progress call.
@example
response = client.voice.mute(id)
@param [String] id
@return [Response]
@see developer.nexmo.com/api/voice#updateCall
# File lib/vonage/voice.rb, line 170 def mute(id) update(id, action: 'mute') end
@return [Stream]
# File lib/vonage/voice.rb, line 242 def stream @stream ||= Stream.new(@config) end
@return [Talk]
# File lib/vonage/voice.rb, line 248 def talk @talk ||= Talk.new(@config) end
Transfer an in progress call.
@example
destination = { type: 'ncco', url: ['https://example.com/ncco.json'] } response = client.voice.transfer(id, destination: destination)
@param [String] id @param [Hash] destination
@return [Response]
@see developer.nexmo.com/api/voice#updateCall
# File lib/vonage/voice.rb, line 236 def transfer(id, destination:) update(id, action: 'transfer', destination: destination) end
Unearmuff an in progress call.
@example
response = client.voice.unearmuff(id)
@param [String] id
@return [Response]
@see developer.nexmo.com/api/voice#updateCall
# File lib/vonage/voice.rb, line 215 def unearmuff(id) update(id, action: 'unearmuff') end
Unmute an in progress call.
@example
response = client.voice.unmute(id)
@param [String] id
@return [Response]
@see developer.nexmo.com/api/voice#updateCall
# File lib/vonage/voice.rb, line 185 def unmute(id) update(id, action: 'unmute') end
Modify an in progress call.
@example
response = client.voice.update(id, action: 'hangup')
@option params [required, String] :action
@option params [Hash] :destination
Required when **:action** is `transfer`.
@param [String] id @param [Hash] params
@return [Response]
@see developer.nexmo.com/api/voice#updateCall
# File lib/vonage/voice.rb, line 140 def update(id, params) request('/v1/calls/' + id, params: params, type: Put) end