Class: Plivo::Resources::Conference

Inherits:
Base::Resource show all
Defined in:
lib/plivo/resources/conferences.rb

Constant Summary

Constants included from Utils

Utils::TYPE_WHITELIST

Instance Attribute Summary

Attributes inherited from Base::Resource

#id

Instance Method Summary collapse

Methods included from Utils

GetSortedQueryParamString?, compute_signatureV3?, expected_type?, expected_value?, generate_url?, getMapFromQueryString?, is_one_among_string_url?, multi_valid_param?, raise_invalid_request, valid_account?, valid_date_format?, valid_mainaccount?, valid_multiple_destination_integers?, valid_multiple_destination_nos?, valid_param?, valid_range?, valid_signature?, valid_signatureV3?, valid_subaccount?, valid_url?

Constructor Details

#initialize(client, options = nil) ⇒ Conference



5
6
7
8
9
10
# File 'lib/plivo/resources/conferences.rb', line 5

def initialize(client, options = nil)
  @_name = 'Conference'
  @_identifier_string = 'conference_name'
  super
  @_is_voice_request = true
end

Instance Method Details

#deaf_member(member_id) ⇒ Object



115
116
117
118
119
120
121
122
# File 'lib/plivo/resources/conferences.rb', line 115

def deaf_member(member_id)
  valid_param?(:member_id, member_id, Array, true)
  member_id.each do |member|
    valid_param?(:member, member, [String, Symbol, Integer, Integer], true)
  end
  perform_action('Member/' + member_id.join(',') + '/Deaf',
                 'POST', nil, true)
end

#deleteObject



12
13
14
# File 'lib/plivo/resources/conferences.rb', line 12

def delete
  perform_delete
end

#delete_member(member_id) ⇒ Object



17
18
19
20
# File 'lib/plivo/resources/conferences.rb', line 17

def delete_member(member_id)
  valid_param?(:member_id, member_id, [String, Symbol, Integer, Integer], true)
  perform_action('Member/' + member_id.to_s, 'DELETE', nil, true)
end

#kick_member(member_id) ⇒ Object



23
24
25
26
# File 'lib/plivo/resources/conferences.rb', line 23

def kick_member(member_id)
  valid_param?(:member_id, member_id, [String, Symbol, Integer, Integer], true)
  perform_action('Member/' + member_id.to_s + '/Kick', 'POST', nil, true)
end

#mute_member(member_id) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/plivo/resources/conferences.rb', line 29

def mute_member(member_id)
  valid_param?(:member_id, member_id, Array, true)
  member_id.each do |member|
    valid_param?(:member, member, [String, Symbol, Integer, Integer], true)
  end
  perform_action('Member/' + member_id.join(',') + '/Mute',
                 'POST', nil, true)
end

#play_member(member_id, url) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/plivo/resources/conferences.rb', line 49

def play_member(member_id, url)
  valid_param?(:member_id, member_id, Array, true)
  valid_param?(:url, url, String, true)
  member_id.each do |member|
    valid_param?(:member, member, [String, Symbol, Integer, Integer], true)
  end
  perform_action('Member/' + member_id.join(',') + '/Play',
                 'POST', { url: url }, true)
end

#record(options = nil) ⇒ Object

Options Hash (options):

  • :file_format (String)

    The file format of the record can be of mp3 or wav format. Defaults to mp3 format.

  • :transcription_type (String)

    The type of transcription required. The following values are allowed:

    • auto - This is the default value. Transcription is completely automated; turnaround time is about 5 minutes.

    • hybrid - Transcription is a combination of automated and human verification processes; turnaround time is about 10-15 minutes.

  • :transcription_url (String)

    The URL where the transcription is available.

  • :transcription_method (String)

    The method used to invoke the transcription_url. Defaults to POST.

  • :callback_url (String)

    The URL invoked by the API when the recording ends. The following parameters are sent to the callback_url:

    • api_id - the same API ID returned by the conference record API.

    • record_url - the URL to access the recorded file.

    • recording_id - recording ID of the recorded file.

    • conference_name - the conference name recorded.

    • recording_duration - duration in seconds of the recording.

    • recording_duration_ms - duration in milliseconds of the recording.

    • recording_start_ms - when the recording started (epoch time UTC) in milliseconds.

    • recording_end_ms - when the recording ended (epoch time UTC) in milliseconds.

  • :callback_method (String)

    The method which is used to invoke the callback_url URL. Defaults to POST.



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/plivo/resources/conferences.rb', line 151

def record(options = nil)
  return perform_action('Record', 'POST', nil, true) if options.nil?
  valid_param?(:options, options, Hash, true)

  params = {}
  i[transcription_url callback_url].each do |param|
    if options.key?(param) &&
       valid_param?(param, options[param], [String, Symbol], true)
      params[param] = options[param]
    end
  end

  i[transcription_method callback_method].each do |param|
    if options.key?(param) &&
       valid_param?(param, options[param], [String, Symbol], true, %w[GET POST])
      params[param] = options[param]
    end
  end

  if options.key?(:file_format) &&
     valid_param?(:file_format, options[:file_format],
                  [String, Symbol], true, %w[wav mp3])
    params[:file_format] = options[:file_format]
  end

  if options.key?(:transcription_type) &&
     valid_param?(:transcription_type, options[:transcription_type],
                  [String, Symbol], true, %w[auto hybrid])
    params[:transcription_type] = options[:transcription_type]
  end

  perform_action('Record', 'POST', params, true)
end

#speak_member(member_id, text, options = nil) ⇒ Object

Options Hash (options):



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/plivo/resources/conferences.rb', line 74

def speak_member(member_id, text, options = nil)
  valid_param?(:member_id, member_id, Array, true)
  valid_param?(:text, text, String, true)
  member_id.each do |member|
    valid_param?(:member, member, [String, Symbol, Integer, Integer], true)
  end

  params = { text: text }

  if options.nil?
    return perform_action('Member/' + member_id.join(',') + '/Speak',
                          'POST', params, true)
  end

  if options.key?(:voice) &&
     valid_param?(:voice, options[:voice],
                  [String, Symbol], true, %w[MAN WOMAN])
    params[:voice] = options[:voice]
  end

  if options.key?(:language) &&
     valid_param?(:language, options[:language],
                  String, true)
    params[:language] = options[:language]
  end

  perform_action('Member/' + member_id.join(',') + '/Speak',
                 'POST', params, true)
end

#stop_play_member(member_id) ⇒ Object



60
61
62
63
64
65
66
67
# File 'lib/plivo/resources/conferences.rb', line 60

def stop_play_member(member_id)
  valid_param?(:member_id, member_id, Array, true)
  member_id.each do |member|
    valid_param?(:member, member, [String, Symbol, Integer, Integer], true)
  end
  perform_action('Member/' + member_id.join(',') + '/Play',
                 'DELETE', nil, true)
end

#stop_recordObject



185
186
187
# File 'lib/plivo/resources/conferences.rb', line 185

def stop_record
  perform_action('Record', 'DELETE')
end

#stop_speak_member(member_id) ⇒ Object



105
106
107
108
109
110
111
112
# File 'lib/plivo/resources/conferences.rb', line 105

def stop_speak_member(member_id)
  valid_param?(:member_id, member_id, Array, true)
  member_id.each do |member|
    valid_param?(:member, member, [String, Symbol, Integer, Integer], true)
  end
  perform_action('Member/' + member_id.join(',') + '/Speak',
                 'DELETE', nil, true)
end

#to_json_member(member) ⇒ Object



198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/plivo/resources/conferences.rb', line 198

def to_json_member(member)
  {
    muted: member['muted'],
    member_id: member['member_id'],
    deaf: member['deaf'],
    from: member['from'],
    to: member['to'],
    caller_name: member['caller_name'],
    direction: member['direction'],
    call_uuid: member['call_uuid'],
    join_time: member['join_time']
  }.to_json
end

#to_sObject



189
190
191
192
193
194
195
196
# File 'lib/plivo/resources/conferences.rb', line 189

def to_s
  response_json = {}
  response_variables = self.instance_variables.drop(5)
  response_variables.each do |variable|
    response_json[variable.to_s[1..-1]] = self.instance_variable_get(variable)
  end
  return response_json.to_s
end

#undeaf_member(member_id) ⇒ Object



125
126
127
128
129
130
131
132
# File 'lib/plivo/resources/conferences.rb', line 125

def undeaf_member(member_id)
  valid_param?(:member_id, member_id, Array, true)
  member_id.each do |member|
    valid_param?(:member, member, [String, Symbol, Integer, Integer], true)
  end
  perform_action('Member/' + member_id.join(',') + '/Deaf',
                 'DELETE', nil, true)
end

#unmute_member(member_id) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/plivo/resources/conferences.rb', line 39

def unmute_member(member_id)
  valid_param?(:member_id, member_id, Array, true)
  member_id.each do |member|
    valid_param?(:member, member, [String, Symbol, Integer, Integer], true)
  end
  perform_action('Member/' + member_id.join(',') + '/Mute', 'DELETE')
end