Class: Bandwidth::Conference

Inherits:
Object
  • Object
show all
Extended by:
ClientWrapper
Includes:
ApiItem, PlayAudioExtensions
Defined in:
lib/bandwidth/conference.rb

Overview

The Conference resource allows you create conferences, add members to it, play audio and other things related to conferencing.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ClientWrapper

wrap_client_arg

Methods included from PlayAudioExtensions

#play_recording, #speak_sentence

Methods included from ApiItem

#[], #[]=, #initialize, #to_data

Class Method Details

.create(client, data) ⇒ Conference

Create a conference.

Examples:

conference = Conference.create(client, :from => "number")

Parameters:

  • client (Client)

    optional client instance to make requests

  • data (Hash)

    data to create a conference

Returns:



27
28
29
30
31
# File 'lib/bandwidth/conference.rb', line 27

def self.create(client, data)
  headers = client.make_request(:post, client.concat_user_path(CONFERENCE_PATH), data)[1]
  id = Client.get_id_from_location_header(headers[:location])
  self.get(client, id)
end

.get(client, id) ⇒ Conference

Get information about a conference

Examples:

conference = Conference.get(client, "id")

Parameters:

  • client (Client)

    optional client instance to make requests

  • id (String)

    id of a conference

Returns:



15
16
17
18
# File 'lib/bandwidth/conference.rb', line 15

def self.get(client, id)
  item = client.make_request(:get, client.concat_user_path("#{CONFERENCE_PATH}/#{id}"))[0]
  Conference.new(item, client)
end

Instance Method Details

#completeObject

Terminate Conference



48
49
50
# File 'lib/bandwidth/conference.rb', line 48

def complete()
  update(:state => 'completed')
end

#create_member(data) ⇒ ConferenceMember

Add a member to a conference.

Examples:

member = conference.create_member(:call_id=>"id")

Parameters:

  • data (Hash)

    data to add member to a conference

Returns:



65
66
67
68
69
# File 'lib/bandwidth/conference.rb', line 65

def create_member(data)
  headers = @client.make_request(:post, @client.concat_user_path("#{CONFERENCE_PATH}/#{id}/members"), data)[1]
  id = Client.get_id_from_location_header(headers[:location])
  get_member(id)
end

#get_member(member_id) ⇒ ConferenceMember

Retrieve information about a particular conference member

Examples:

member = conference.get_member("id")

Parameters:

  • member_id (String)

    id of member

Returns:



76
77
78
79
80
81
# File 'lib/bandwidth/conference.rb', line 76

def get_member(member_id)
  member = ConferenceMember.new(@client.make_request(:get, @client.concat_user_path("#{CONFERENCE_PATH}/#{id}/members/#{member_id}"))[0],
                       @client)
  member.conference_id = id
  member
end

#get_membersArray

List all members from a conference

Examples:

members = conference.get_members()

Returns:

  • (Array)

    array of ConferenceMember instances



87
88
89
90
91
92
93
# File 'lib/bandwidth/conference.rb', line 87

def get_members()
  @client.make_request(:get, @client.concat_user_path("#{CONFERENCE_PATH}/#{id}/members"))[0].map do |i|
    member = ConferenceMember.new(i, @client)
    member.conference_id = id
    member
  end
end

#muteObject

Prevent all members from speaking



43
44
45
# File 'lib/bandwidth/conference.rb', line 43

def mute()
  update(:mute => true)
end

#play_audio(data) ⇒ Object

Play audio to a conference

Examples:

conference.play_audio(:file_url=>"http://host1")

Parameters:

  • data (Hash)

    audio options



56
57
58
# File 'lib/bandwidth/conference.rb', line 56

def play_audio(data)
  @client.make_request(:post, @client.concat_user_path("#{CONFERENCE_PATH}/#{id}/audio"), data)[0]
end

#update(data) ⇒ Object

Update a conference

Examples:

conference.update(:mute=>false)

Parameters:

  • data (Hash)

    changed data



38
39
40
# File 'lib/bandwidth/conference.rb', line 38

def update(data)
  @client.make_request(:post, @client.concat_user_path("#{CONFERENCE_PATH}/#{id}"), data)[0]
end