Class: Ari::Bridge

Inherits:
Resource show all
Defined in:
lib/ari/resources/bridge.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#add_listener, client, #client, #remove_all_listeners!, #remove_listener

Methods inherited from Model

#attributes=, #initialize

Constructor Details

This class inherits a constructor from Ari::Model

Instance Attribute Details

#bridge_classObject (readonly)

Returns the value of attribute bridge_class.



15
16
17
# File 'lib/ari/resources/bridge.rb', line 15

def bridge_class
  @bridge_class
end

#bridge_typeObject (readonly)

Returns the value of attribute bridge_type.



15
16
17
# File 'lib/ari/resources/bridge.rb', line 15

def bridge_type
  @bridge_type
end

#channelsObject (readonly)

Returns the value of attribute channels.



15
16
17
# File 'lib/ari/resources/bridge.rb', line 15

def channels
  @channels
end

#creatorObject (readonly)

Returns the value of attribute creator.



15
16
17
# File 'lib/ari/resources/bridge.rb', line 15

def creator
  @creator
end

#idObject (readonly)

Returns the value of attribute id.



15
16
17
# File 'lib/ari/resources/bridge.rb', line 15

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



15
16
17
# File 'lib/ari/resources/bridge.rb', line 15

def name
  @name
end

#technologyObject (readonly)

Returns the value of attribute technology.



15
16
17
# File 'lib/ari/resources/bridge.rb', line 15

def technology
  @technology
end

Class Method Details

.add_channel(options = {}) ⇒ Object

POST /bridges/%bridgeId/addChannel

Add a channel to a bridge

Parameters:

bridgeId (required) - Bridge’s id channel (required) - Ids of channels to add to bridge role - Channel’s role in the bridge

Raises:

  • (ArgumentError)


120
121
122
123
124
125
# File 'lib/ari/resources/bridge.rb', line 120

def self.add_channel(options = {})
  raise ArgumentError.new("Parameter bridgeId must be passed in options hash.") unless options[:bridgeId]
  raise ArgumentError.new("Parameter channel must be passed in options hash.") unless options[:channel]
  path = '/bridges/%{bridgeId}/addChannel' % options
  response = client(options).post(path, options)
end

.addChannelObject

POST /bridges/%bridgeId/addChannel

Add a channel to a bridge

Parameters:

bridgeId (required) - Bridge’s id channel (required) - Ids of channels to add to bridge role - Channel’s role in the bridge

Raises:

  • (ArgumentError)


126
127
128
129
130
131
# File 'lib/ari/resources/bridge.rb', line 126

def self.add_channel(options = {})
  raise ArgumentError.new("Parameter bridgeId must be passed in options hash.") unless options[:bridgeId]
  raise ArgumentError.new("Parameter channel must be passed in options hash.") unless options[:channel]
  path = '/bridges/%{bridgeId}/addChannel' % options
  response = client(options).post(path, options)
end

.create(options = {}) ⇒ Object

POST /bridges

Active bridges

Parameters:

type - Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media). bridgeId - Unique ID to give to the bridge being created. name - Name to give to the bridge being created.



40
41
42
43
44
# File 'lib/ari/resources/bridge.rb', line 40

def self.create(options = {})
  path = '/bridges'
  response = client(options).post(path, options)
  Bridge.new(response.merge(client: options[:client]))
end

.create_or_update_with_id(options = {}) ⇒ Object

POST /bridges/%bridgeId

Individual bridge

Parameters:

type - Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media) to set. bridgeId (required) - Unique ID to give to the bridge being created. name - Set the name of the bridge.

Raises:

  • (ArgumentError)


57
58
59
60
61
62
# File 'lib/ari/resources/bridge.rb', line 57

def self.create_or_update_with_id(options = {})
  raise ArgumentError.new("Parameter bridgeId must be passed in options hash.") unless options[:bridgeId]
  path = '/bridges/%{bridgeId}' % options
  response = client(options).post(path, options)
  Bridge.new(response.merge(client: options[:client]))
end

.destroy(options = {}) ⇒ Object

DELETE /bridges/%bridgeId

Individual bridge

Parameters:

bridgeId (required) - Bridge’s id



97
98
99
100
101
102
103
# File 'lib/ari/resources/bridge.rb', line 97

def self.destroy(options = {})
  raise ArgumentError.new("Parameter bridgeId must be passed in options hash.") unless options[:bridgeId]
  path = '/bridges/%{bridgeId}' % options
  response = client(options).delete(path, options)
rescue Ari::RequestError => e
  raise unless e.code == '404'
end

.get(options = {}) ⇒ Object

GET /bridges/%bridgeId

Individual bridge

Parameters:

bridgeId (required) - Bridge’s id

Raises:

  • (ArgumentError)


77
78
79
80
81
82
# File 'lib/ari/resources/bridge.rb', line 77

def self.get(options = {})
  raise ArgumentError.new("Parameter bridgeId must be passed in options hash.") unless options[:bridgeId]
  path = '/bridges/%{bridgeId}' % options
  response = client(options).get(path, options)
  Bridge.new(response.merge(client: options[:client]))
end

.list(options = {}) ⇒ Object

GET /bridges

Active bridges



23
24
25
26
27
# File 'lib/ari/resources/bridge.rb', line 23

def self.list(options = {})
  path = '/bridges'
  response = client(options).get(path, options)
  response.map { |hash| Bridge.new(hash.merge(client: options[:client])) }
end

.play(options = {}) ⇒ Object

POST /bridges/%bridgeId/play

Play media to the participants of a bridge

Parameters:

bridgeId (required) - Bridge’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.

Raises:

  • (ArgumentError)


211
212
213
214
215
216
217
# File 'lib/ari/resources/bridge.rb', line 211

def self.play(options = {})
  raise ArgumentError.new("Parameter bridgeId must be passed in options hash.") unless options[:bridgeId]
  raise ArgumentError.new("Parameter media must be passed in options hash.") unless options[:media]
  path = '/bridges/%{bridgeId}/play' % options
  response = client(options).post(path, options)
  Playback.new(response.merge(client: options[:client]))
end

.play_with_id(options = {}) ⇒ Object

POST /bridges/%bridgeId/play/%playbackId

Play media to a bridge

Parameters:

bridgeId (required) - Bridge’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.

Raises:

  • (ArgumentError)


237
238
239
240
241
242
243
244
# File 'lib/ari/resources/bridge.rb', line 237

def self.play_with_id(options = {})
  raise ArgumentError.new("Parameter bridgeId must be passed in options hash.") unless options[:bridgeId]
  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 = '/bridges/%{bridgeId}/play/%{playbackId}' % options
  response = client(options).post(path, options)
  Playback.new(response.merge(client: options[:client]))
end

.playWithIdObject

POST /bridges/%bridgeId/play/%playbackId

Play media to a bridge

Parameters:

bridgeId (required) - Bridge’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.

Raises:

  • (ArgumentError)


245
246
247
248
249
250
251
252
# File 'lib/ari/resources/bridge.rb', line 245

def self.play_with_id(options = {})
  raise ArgumentError.new("Parameter bridgeId must be passed in options hash.") unless options[:bridgeId]
  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 = '/bridges/%{bridgeId}/play/%{playbackId}' % options
  response = client(options).post(path, options)
  Playback.new(response.merge(client: options[:client]))
end

.record(options = {}) ⇒ Object

POST /bridges/%bridgeId/record

Record audio on a bridge

Parameters:

bridgeId (required) - Bridge’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.

Raises:

  • (ArgumentError)


267
268
269
270
271
272
273
274
# File 'lib/ari/resources/bridge.rb', line 267

def self.record(options = {})
  raise ArgumentError.new("Parameter bridgeId must be passed in options hash.") unless options[:bridgeId]
  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 = '/bridges/%{bridgeId}/record' % options
  response = client(options).post(path, options)
  LiveRecording.new(response.merge(client: options[:client]))
end

.remove_channel(options = {}) ⇒ Object

POST /bridges/%bridgeId/removeChannel

Remove a channel from a bridge

Parameters:

bridgeId (required) - Bridge’s id channel (required) - Ids of channels to remove from bridge

Raises:

  • (ArgumentError)


142
143
144
145
146
147
# File 'lib/ari/resources/bridge.rb', line 142

def self.remove_channel(options = {})
  raise ArgumentError.new("Parameter bridgeId must be passed in options hash.") unless options[:bridgeId]
  raise ArgumentError.new("Parameter channel must be passed in options hash.") unless options[:channel]
  path = '/bridges/%{bridgeId}/removeChannel' % options
  response = client(options).post(path, options)
end

.removeChannelObject

POST /bridges/%bridgeId/removeChannel

Remove a channel from a bridge

Parameters:

bridgeId (required) - Bridge’s id channel (required) - Ids of channels to remove from bridge

Raises:

  • (ArgumentError)


148
149
150
151
152
153
# File 'lib/ari/resources/bridge.rb', line 148

def self.remove_channel(options = {})
  raise ArgumentError.new("Parameter bridgeId must be passed in options hash.") unless options[:bridgeId]
  raise ArgumentError.new("Parameter channel must be passed in options hash.") unless options[:channel]
  path = '/bridges/%{bridgeId}/removeChannel' % options
  response = client(options).post(path, options)
end

.start_moh(options = {}) ⇒ Object

POST /bridges/%bridgeId/moh

Play music on hold to a bridge

Parameters:

bridgeId (required) - Bridge’s id mohClass - Channel’s id

Raises:

  • (ArgumentError)


164
165
166
167
168
# File 'lib/ari/resources/bridge.rb', line 164

def self.start_moh(options = {})
  raise ArgumentError.new("Parameter bridgeId must be passed in options hash.") unless options[:bridgeId]
  path = '/bridges/%{bridgeId}/moh' % options
  response = client(options).post(path, options)
end

.startMohObject

POST /bridges/%bridgeId/moh

Play music on hold to a bridge

Parameters:

bridgeId (required) - Bridge’s id mohClass - Channel’s id

Raises:

  • (ArgumentError)


169
170
171
172
173
# File 'lib/ari/resources/bridge.rb', line 169

def self.start_moh(options = {})
  raise ArgumentError.new("Parameter bridgeId must be passed in options hash.") unless options[:bridgeId]
  path = '/bridges/%{bridgeId}/moh' % options
  response = client(options).post(path, options)
end

.stop_moh(options = {}) ⇒ Object

DELETE /bridges/%bridgeId/moh

Play music on hold to a bridge

Parameters:

bridgeId (required) - Bridge’s id



184
185
186
187
188
189
190
# File 'lib/ari/resources/bridge.rb', line 184

def self.stop_moh(options = {})
  raise ArgumentError.new("Parameter bridgeId must be passed in options hash.") unless options[:bridgeId]
  path = '/bridges/%{bridgeId}/moh' % options
  response = client(options).delete(path, options)
rescue Ari::RequestError => e
  raise unless e.code == '404'
end

.stopMohObject

DELETE /bridges/%bridgeId/moh

Play music on hold to a bridge

Parameters:

bridgeId (required) - Bridge’s id



191
192
193
194
195
196
197
# File 'lib/ari/resources/bridge.rb', line 191

def self.stop_moh(options = {})
  raise ArgumentError.new("Parameter bridgeId must be passed in options hash.") unless options[:bridgeId]
  path = '/bridges/%{bridgeId}/moh' % options
  response = client(options).delete(path, options)
rescue Ari::RequestError => e
  raise unless e.code == '404'
end

Instance Method Details

#add_channel(options = {}) ⇒ Object



128
129
130
# File 'lib/ari/resources/bridge.rb', line 128

def add_channel(options = {})
  self.class.add_channel(options.merge(bridgeId: self.id, client: @client))
end

#create_or_update_with_id(options = {}) ⇒ Object



64
65
66
# File 'lib/ari/resources/bridge.rb', line 64

def create_or_update_with_id(options = {})
  self.class.create_or_update_with_id(options.merge(bridgeId: self.id, client: @client))
end

#destroy(options = {}) ⇒ Object



105
106
107
# File 'lib/ari/resources/bridge.rb', line 105

def destroy(options = {})
  self.class.destroy(options.merge(bridgeId: self.id, client: @client))
end

#get(options = {}) ⇒ Object



84
85
86
# File 'lib/ari/resources/bridge.rb', line 84

def get(options = {})
  self.class.get(options.merge(bridgeId: self.id, client: @client))
end

#play(options = {}) ⇒ Object



219
220
221
# File 'lib/ari/resources/bridge.rb', line 219

def play(options = {})
  self.class.play(options.merge(bridgeId: self.id, client: @client))
end

#play_with_id(options = {}) ⇒ Object



247
248
249
# File 'lib/ari/resources/bridge.rb', line 247

def play_with_id(options = {})
  self.class.play_with_id(options.merge(bridgeId: self.id, client: @client))
end

#record(options = {}) ⇒ Object



276
277
278
# File 'lib/ari/resources/bridge.rb', line 276

def record(options = {})
  self.class.record(options.merge(bridgeId: self.id, client: @client))
end

#remove_channel(options = {}) ⇒ Object



150
151
152
# File 'lib/ari/resources/bridge.rb', line 150

def remove_channel(options = {})
  self.class.remove_channel(options.merge(bridgeId: self.id, client: @client))
end

#start_moh(options = {}) ⇒ Object



171
172
173
# File 'lib/ari/resources/bridge.rb', line 171

def start_moh(options = {})
  self.class.start_moh(options.merge(bridgeId: self.id, client: @client))
end

#stop_moh(options = {}) ⇒ Object



193
194
195
# File 'lib/ari/resources/bridge.rb', line 193

def stop_moh(options = {})
  self.class.stop_moh(options.merge(bridgeId: self.id, client: @client))
end