class Ari::Channel

Attributes

accountcode[R]
caller[R]
connected[R]
creationtime[R]
dialplan[R]
id[R]
language[R]
name[R]
state[R]

Public Class Methods

answer(options = {}) click to toggle source

POST /channels/%{channelId}/answer

Answer a channel

Parameters:

channelId (required) - Channel’s id

# File lib/ari/resources/channel.rb, line 203
def self.answer(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  path = '/channels/%{channelId}/answer' % options
  response = client(options).post(path, options)
end
continueInDialplan(options = {})
continue_in_dialplan(options = {}) click to toggle source

POST /channels/%{channelId}/continue

Exit application; continue execution in the dialplan

Parameters:

channelId (required) - Channel’s id context - The context to continue to. extension - The extension to continue to. priority - The priority to continue to. label - The label to continue to - will supersede ‘priority’ if both are provided.

# File lib/ari/resources/channel.rb, line 162
def self.continue_in_dialplan(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  path = '/channels/%{channelId}/continue' % options
  response = client(options).post(path, options)
end
Also aliased as: continueInDialplan
get(options = {}) click to toggle source

GET /channels/%{channelId}

Active channel

Parameters:

channelId (required) - Channel’s id

# File lib/ari/resources/channel.rb, line 82
def self.get(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  path = '/channels/%{channelId}' % options
  response = client(options).get(path, options)
  Channel.new(response.merge(client: options[:client]))
end
getChannelVar(options = {})
Alias for: get_channel_var
get_channel_var(options = {}) click to toggle source

GET /channels/%{channelId}/variable

Variables on a channel

Parameters:

channelId (required) - Channel’s id variable (required) - The channel variable or function to get

# File lib/ari/resources/channel.rb, line 539
def self.get_channel_var(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  raise ArgumentError.new("Parameter variable must be passed in options hash.") unless options[:variable]
  path = '/channels/%{channelId}/variable' % options
  response = client(options).get(path, options)
  Variable.new(response.merge(client: options[:client]))
end
Also aliased as: getChannelVar
hangup(options = {}) click to toggle source

DELETE /channels/%{channelId}

Active channel

Parameters:

channelId (required) - Channel’s id reason - Reason for hanging up the channel

# File lib/ari/resources/channel.rb, line 137
def self.hangup(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  path = '/channels/%{channelId}' % options
  response = client(options).delete(path, options)
rescue Ari::RequestError => e
  raise unless e.code == '404'
end
hold(options = {}) click to toggle source

POST /channels/%{channelId}/hold

Put a channel on hold

Parameters:

channelId (required) - Channel’s id

# File lib/ari/resources/channel.rb, line 330
def self.hold(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  path = '/channels/%{channelId}/hold' % options
  response = client(options).post(path, options)
end
list(options = {}) click to toggle source

GET /channels

Active channels

# File lib/ari/resources/channel.rb, line 39
def self.list(options = {})
  path = '/channels'
  response = client(options).get(path, options)
  response.map { |hash| Channel.new(hash.merge(client: options[:client])) }
end
mute(options = {}) click to toggle source

POST /channels/%{channelId}/mute

Mute a channel

Parameters:

channelId (required) - Channel’s id direction - Direction in which to mute audio

# File lib/ari/resources/channel.rb, line 289
def self.mute(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  path = '/channels/%{channelId}/mute' % options
  response = client(options).post(path, options)
end
originate(options = {}) click to toggle source

POST /channels

Active channels

Parameters:

endpoint (required) - Endpoint to call. extension - The extension to dial after the endpoint answers. Mutually exclusive with ‘app’. context - The context to dial after the endpoint answers. If omitted, uses ‘default’. Mutually exclusive with ‘app’. priority - The priority to dial after the endpoint answers. If omitted, uses 1. Mutually exclusive with ‘app’. label - The label to dial after the endpoint answers. Will supersede ‘priority’ if provided. Mutually exclusive with ‘app’. app - The application that is subscribed to the originated channel. When the channel is answered, it will be passed to this Stasis application. Mutually exclusive with ‘context’, ‘extension’, ‘priority’, and ‘label’. appArgs - The application arguments to pass to the Stasis application provided by ‘app’. Mutually exclusive with ‘context’, ‘extension’, ‘priority’, and ‘label’. callerId - CallerID to use when dialing the endpoint or extension. timeout - Timeout (in seconds) before giving up dialing, or -1 for no timeout. variables - The “variables” key in the body object holds variable key/value pairs to set on the channel on creation. Other keys in the body object are interpreted as query parameters. Ex. { “endpoint”: “SIP/Alice”, “variables”: { “CALLERID(name)”: “Alice” } } channelId - The unique id to assign the channel on creation. otherChannelId - The unique id to assign the second channel when using local channels. originator - The unique id of the channel which is originating this one.

# File lib/ari/resources/channel.rb, line 66
def self.originate(options = {})
  raise ArgumentError.new("Parameter endpoint must be passed in options hash.") unless options[:endpoint]
  path = '/channels'
  response = client(options).post(path, options)
  Channel.new(response.merge(client: options[:client]))
end
originateWithId(options = {})
Alias for: originate_with_id
originate_with_id(options = {}) click to toggle source

POST /channels/%{channelId}

Active channel

Parameters:

channelId (required) - The unique id to assign the channel on creation. endpoint (required) - Endpoint to call. extension - The extension to dial after the endpoint answers. Mutually exclusive with ‘app’. context - The context to dial after the endpoint answers. If omitted, uses ‘default’. Mutually exclusive with ‘app’. priority - The priority to dial after the endpoint answers. If omitted, uses 1. Mutually exclusive with ‘app’. label - The label to dial after the endpoint answers. Will supersede ‘priority’ if provided. Mutually exclusive with ‘app’. app - The application that is subscribed to the originated channel. When the channel is answered, it will be passed to this Stasis application. Mutually exclusive with ‘context’, ‘extension’, ‘priority’, and ‘label’. appArgs - The application arguments to pass to the Stasis application provided by ‘app’. Mutually exclusive with ‘context’, ‘extension’, ‘priority’, and ‘label’. callerId - CallerID to use when dialing the endpoint or extension. timeout - Timeout (in seconds) before giving up dialing, or -1 for no timeout. variables - The “variables” key in the body object holds variable key/value pairs to set on the channel on creation. Other keys in the body object are interpreted as query parameters. Ex. { “endpoint”: “SIP/Alice”, “variables”: { “CALLERID(name)”: “Alice” } } otherChannelId - The unique id to assign the second channel when using local channels. originator - The unique id of the channel which is originating this one.

# File lib/ari/resources/channel.rb, line 114
def self.originate_with_id(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  raise ArgumentError.new("Parameter endpoint must be passed in options hash.") unless options[:endpoint]
  path = '/channels/%{channelId}' % options
  response = client(options).post(path, options)
  Channel.new(response.merge(client: options[:client]))
end
Also aliased as: originateWithId
play(options = {}) click to toggle source

POST /channels/%{channelId}/play

Play media to a channel

Parameters:

channelId (required) - Channel’s id media (required) - Media’s URI to play. lang - For sounds, selects language for sound. offsetms - Number of media to skip before playing. skipms - Number of milliseconds to skip for forward/reverse operations. playbackId - Playback ID.

# File lib/ari/resources/channel.rb, line 460
def self.play(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  raise ArgumentError.new("Parameter media must be passed in options hash.") unless options[:media]
  path = '/channels/%{channelId}/play' % options
  response = client(options).post(path, options)
  Playback.new(response.merge(client: options[:client]))
end
playWithId(options = {})
Alias for: play_with_id
play_with_id(options = {}) click to toggle source

POST /channels/%{channelId}/play/%{playbackId}

Play media to a channel

Parameters:

channelId (required) - Channel’s id playbackId (required) - Playback ID. media (required) - Media’s URI to play. lang - For sounds, selects language for sound. offsetms - Number of media to skip before playing. skipms - Number of milliseconds to skip for forward/reverse operations.

# File lib/ari/resources/channel.rb, line 486
def self.play_with_id(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  raise ArgumentError.new("Parameter playbackId must be passed in options hash.") unless options[:playbackId]
  raise ArgumentError.new("Parameter media must be passed in options hash.") unless options[:media]
  path = '/channels/%{channelId}/play/%{playbackId}' % options
  response = client(options).post(path, options)
  Playback.new(response.merge(client: options[:client]))
end
Also aliased as: playWithId
record(options = {}) click to toggle source

POST /channels/%{channelId}/record

Record audio from a channel

Parameters:

channelId (required) - Channel’s id name (required) - Recording’s filename format (required) - Format to encode audio in maxDurationSeconds - Maximum duration of the recording, in seconds. 0 for no limit maxSilenceSeconds - Maximum duration of silence, in seconds. 0 for no limit ifExists - Action to take if a recording with the same name already exists. beep - Play beep when recording begins terminateOn - DTMF input to terminate recording

# File lib/ari/resources/channel.rb, line 516
def self.record(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  raise ArgumentError.new("Parameter name must be passed in options hash.") unless options[:name]
  raise ArgumentError.new("Parameter format must be passed in options hash.") unless options[:format]
  path = '/channels/%{channelId}/record' % options
  response = client(options).post(path, options)
  LiveRecording.new(response.merge(client: options[:client]))
end
redirect(options = {}) click to toggle source

POST /channels/%{channelId}/redirect

Inform the channel that it should redirect itself to a different location. Note that this will almost certainly cause the channel to exit the application.

Parameters:

channelId (required) - Channel’s id endpoint (required) - The endpoint to redirect the channel to

# File lib/ari/resources/channel.rb, line 183
def self.redirect(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  raise ArgumentError.new("Parameter endpoint must be passed in options hash.") unless options[:endpoint]
  path = '/channels/%{channelId}/redirect' % options
  response = client(options).post(path, options)
end
ring(options = {}) click to toggle source

POST /channels/%{channelId}/ring

Send a ringing indication to a channel

Parameters:

channelId (required) - Channel’s id

# File lib/ari/resources/channel.rb, line 222
def self.ring(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  path = '/channels/%{channelId}/ring' % options
  response = client(options).post(path, options)
end
ringStop(options = {})
Alias for: ring_stop
ring_stop(options = {}) click to toggle source

DELETE /channels/%{channelId}/ring

Send a ringing indication to a channel

Parameters:

channelId (required) - Channel’s id

# File lib/ari/resources/channel.rb, line 241
def self.ring_stop(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  path = '/channels/%{channelId}/ring' % options
  response = client(options).delete(path, options)
rescue Ari::RequestError => e
  raise unless e.code == '404'
end
Also aliased as: ringStop
sendDTMF(options = {})
Alias for: send_dtmf
send_dtmf(options = {}) click to toggle source

POST /channels/%{channelId}/dtmf

Send DTMF to a channel

Parameters:

channelId (required) - Channel’s id dtmf - DTMF To send. before - Amount of time to wait before DTMF digits (specified in milliseconds) start. between - Amount of time in between DTMF digits (specified in milliseconds). duration - Length of each DTMF digit (specified in milliseconds). after - Amount of time to wait after DTMF digits (specified in milliseconds) end.

# File lib/ari/resources/channel.rb, line 268
def self.send_dtmf(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  path = '/channels/%{channelId}/dtmf' % options
  response = client(options).post(path, options)
end
Also aliased as: sendDTMF
setChannelVar(options = {})
Alias for: set_channel_var
set_channel_var(options = {}) click to toggle source

POST /channels/%{channelId}/variable

Variables on a channel

Parameters:

channelId (required) - Channel’s id variable (required) - The channel variable or function to set value - The value to set the variable to

# File lib/ari/resources/channel.rb, line 563
def self.set_channel_var(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  raise ArgumentError.new("Parameter variable must be passed in options hash.") unless options[:variable]
  path = '/channels/%{channelId}/variable' % options
  response = client(options).post(path, options)
end
Also aliased as: setChannelVar
snoopChannel(options = {})
Alias for: snoop_channel
snoopChannelWithId(options = {})
snoop_channel(options = {}) click to toggle source

POST /channels/%{channelId}/snoop

Snoop (spy/whisper) on a channel

Parameters:

channelId (required) - Channel’s id spy - Direction of audio to spy on whisper - Direction of audio to whisper into app (required) - Application the snooping channel is placed into appArgs - The application arguments to pass to the Stasis application snoopId - Unique ID to assign to snooping channel

# File lib/ari/resources/channel.rb, line 589
def self.snoop_channel(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  raise ArgumentError.new("Parameter app must be passed in options hash.") unless options[:app]
  path = '/channels/%{channelId}/snoop' % options
  response = client(options).post(path, options)
  Channel.new(response.merge(client: options[:client]))
end
Also aliased as: snoopChannel
snoop_channel_with_id(options = {}) click to toggle source

POST /channels/%{channelId}/snoop/%{snoopId}

Snoop (spy/whisper) on a channel

Parameters:

channelId (required) - Channel’s id snoopId (required) - Unique ID to assign to snooping channel spy - Direction of audio to spy on whisper - Direction of audio to whisper into app (required) - Application the snooping channel is placed into appArgs - The application arguments to pass to the Stasis application

# File lib/ari/resources/channel.rb, line 616
def self.snoop_channel_with_id(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  raise ArgumentError.new("Parameter snoopId must be passed in options hash.") unless options[:snoopId]
  raise ArgumentError.new("Parameter app must be passed in options hash.") unless options[:app]
  path = '/channels/%{channelId}/snoop/%{snoopId}' % options
  response = client(options).post(path, options)
  Channel.new(response.merge(client: options[:client]))
end
Also aliased as: snoopChannelWithId
startMoh(options = {})
Alias for: start_moh
startSilence(options = {})
Alias for: start_silence
start_moh(options = {}) click to toggle source

POST /channels/%{channelId}/moh

Play music on hold to a channel

Parameters:

channelId (required) - Channel’s id mohClass - Music on hold class to use

# File lib/ari/resources/channel.rb, line 371
def self.start_moh(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  path = '/channels/%{channelId}/moh' % options
  response = client(options).post(path, options)
end
Also aliased as: startMoh
start_silence(options = {}) click to toggle source

POST /channels/%{channelId}/silence

Play silence to a channel

Parameters:

channelId (required) - Channel’s id

# File lib/ari/resources/channel.rb, line 413
def self.start_silence(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  path = '/channels/%{channelId}/silence' % options
  response = client(options).post(path, options)
end
Also aliased as: startSilence
stopMoh(options = {})
Alias for: stop_moh
stopSilence(options = {})
Alias for: stop_silence
stop_moh(options = {}) click to toggle source

DELETE /channels/%{channelId}/moh

Play music on hold to a channel

Parameters:

channelId (required) - Channel’s id

# File lib/ari/resources/channel.rb, line 391
def self.stop_moh(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  path = '/channels/%{channelId}/moh' % options
  response = client(options).delete(path, options)
rescue Ari::RequestError => e
  raise unless e.code == '404'
end
Also aliased as: stopMoh
stop_silence(options = {}) click to toggle source

DELETE /channels/%{channelId}/silence

Play silence to a channel

Parameters:

channelId (required) - Channel’s id

# File lib/ari/resources/channel.rb, line 433
def self.stop_silence(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  path = '/channels/%{channelId}/silence' % options
  response = client(options).delete(path, options)
rescue Ari::RequestError => e
  raise unless e.code == '404'
end
Also aliased as: stopSilence
unhold(options = {}) click to toggle source

DELETE /channels/%{channelId}/hold

Put a channel on hold

Parameters:

channelId (required) - Channel’s id

# File lib/ari/resources/channel.rb, line 349
def self.unhold(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  path = '/channels/%{channelId}/hold' % options
  response = client(options).delete(path, options)
rescue Ari::RequestError => e
  raise unless e.code == '404'
end
unmute(options = {}) click to toggle source

DELETE /channels/%{channelId}/mute

Mute a channel

Parameters:

channelId (required) - Channel’s id direction - Direction in which to unmute audio

# File lib/ari/resources/channel.rb, line 309
def self.unmute(options = {})
  raise ArgumentError.new("Parameter channelId must be passed in options hash.") unless options[:channelId]
  path = '/channels/%{channelId}/mute' % options
  response = client(options).delete(path, options)
rescue Ari::RequestError => e
  raise unless e.code == '404'
end

Public Instance Methods

answer(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 209
def answer(options = {})
  self.class.answer(options.merge(channelId: self.id, client: @client))
end
caller=(val) click to toggle source
# File lib/ari/resources/channel.rb, line 17
def caller=(val)
  @caller ||= CallerID.new(val)
end
connected=(val) click to toggle source
# File lib/ari/resources/channel.rb, line 21
def connected=(val)
  @connected ||= CallerID.new(val)
end
continue_in_dialplan(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 169
def continue_in_dialplan(options = {})
  self.class.continue_in_dialplan(options.merge(channelId: self.id, client: @client))
end
creationtime=(val) click to toggle source
# File lib/ari/resources/channel.rb, line 29
def creationtime=(val)
  @creationtime ||= Time.parse(val)
end
dialplan=(val) click to toggle source
# File lib/ari/resources/channel.rb, line 25
def dialplan=(val)
  @dialplan ||= DialplanCEP.new(val)
end
get(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 89
def get(options = {})
  self.class.get(options.merge(channelId: self.id, client: @client))
end
get_channel_var(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 548
def get_channel_var(options = {})
  self.class.get_channel_var(options.merge(channelId: self.id, client: @client))
end
hangup(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 145
def hangup(options = {})
  self.class.hangup(options.merge(channelId: self.id, client: @client))
end
hold(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 336
def hold(options = {})
  self.class.hold(options.merge(channelId: self.id, client: @client))
end
mute(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 295
def mute(options = {})
  self.class.mute(options.merge(channelId: self.id, client: @client))
end
originate_with_id(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 123
def originate_with_id(options = {})
  self.class.originate_with_id(options.merge(channelId: self.id, client: @client))
end
play(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 468
def play(options = {})
  self.class.play(options.merge(channelId: self.id, client: @client))
end
play_with_id(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 496
def play_with_id(options = {})
  self.class.play_with_id(options.merge(channelId: self.id, client: @client))
end
record(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 525
def record(options = {})
  self.class.record(options.merge(channelId: self.id, client: @client))
end
redirect(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 190
def redirect(options = {})
  self.class.redirect(options.merge(channelId: self.id, client: @client))
end
ring(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 228
def ring(options = {})
  self.class.ring(options.merge(channelId: self.id, client: @client))
end
ring_stop(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 250
def ring_stop(options = {})
  self.class.ring_stop(options.merge(channelId: self.id, client: @client))
end
send_dtmf(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 275
def send_dtmf(options = {})
  self.class.send_dtmf(options.merge(channelId: self.id, client: @client))
end
set_channel_var(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 571
def set_channel_var(options = {})
  self.class.set_channel_var(options.merge(channelId: self.id, client: @client))
end
snoop_channel(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 598
def snoop_channel(options = {})
  self.class.snoop_channel(options.merge(channelId: self.id, client: @client))
end
snoop_channel_with_id(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 626
def snoop_channel_with_id(options = {})
  self.class.snoop_channel_with_id(options.merge(channelId: self.id, client: @client))
end
start_moh(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 378
def start_moh(options = {})
  self.class.start_moh(options.merge(channelId: self.id, client: @client))
end
start_silence(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 420
def start_silence(options = {})
  self.class.start_silence(options.merge(channelId: self.id, client: @client))
end
stop_moh(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 400
def stop_moh(options = {})
  self.class.stop_moh(options.merge(channelId: self.id, client: @client))
end
stop_silence(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 442
def stop_silence(options = {})
  self.class.stop_silence(options.merge(channelId: self.id, client: @client))
end
unhold(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 357
def unhold(options = {})
  self.class.unhold(options.merge(channelId: self.id, client: @client))
end
unmute(options = {}) click to toggle source
# File lib/ari/resources/channel.rb, line 317
def unmute(options = {})
  self.class.unmute(options.merge(channelId: self.id, client: @client))
end