Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VT-4182_1 #175

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/plivo/resources/multipartycalls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def add_participant(role,
delay_dial=0,
max_duration=14400,
max_participants=10,
record_min_member_count=1,
wait_music_url=nil,
wait_music_method='GET',
agent_hold_music_url=nil,
Expand Down Expand Up @@ -95,6 +96,7 @@ def add_participant(role,
valid_multiple_destination_integers?(:delay_dial, delay_dial)
valid_range?(:max_duration, max_duration, false, 300, 28800)
valid_range?(:max_participants, max_participants, false, 2, 10)
valid_range?(:record_min_member_count, record_min_member_count, false, 1, 2)
valid_url?(:wait_music_url, wait_music_url, false ) unless wait_music_url.nil?
valid_param?(:wait_music_method, wait_music_method.upcase, String, false , %w[GET POST])
valid_url?(:agent_hold_music_url, agent_hold_music_url, false) unless agent_hold_music_url.nil?
Expand Down Expand Up @@ -150,6 +152,7 @@ def add_participant(role,
params[:delay_dial] = delay_dial unless delay_dial.nil?
params[:max_duration] = max_duration unless max_duration.nil?
params[:max_participants] = max_participants unless max_participants.nil?
params[:record_min_member_count] = record_min_member_count unless record_min_member_count.nil?
params[:wait_music_url] = wait_music_url unless wait_music_url.nil?
params[:wait_music_method] = wait_music_method.upcase unless wait_music_method.nil?
params[:agent_hold_music_url] = agent_hold_music_url unless agent_hold_music_url.nil?
Expand Down Expand Up @@ -426,6 +429,7 @@ def add_participant(options = {})
options[:delay_dial] = 0 unless options.key?(:delay_dial)
options[:max_duration] = 14400 unless options.key?(:max_duration)
options[:max_participants] = 10 unless options.key?(:max_participants)
options[:record_min_member_count] = 1 unless options.key?(:record_min_member_count)
options[:wait_music_method] = 'GET' unless options.key?(:wait_music_method)
options[:agent_hold_music_method] = 'GET' unless options.key?(:agent_hold_music_method)
options[:customer_hold_music_method] = 'GET' unless options.key?(:customer_hold_music_method)
Expand Down Expand Up @@ -453,7 +457,7 @@ def add_participant(options = {})
mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])

MultiPartyCall.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0]).add_participant(options[:role],options[:from],options[:to],options[:call_uuid],options[:caller_name],options[:call_status_callback_url],options[:call_status_callback_method],options[:sip_headers],options[:confirm_key],
options[:confirm_key_sound_url],options[:confirm_key_sound_method],options[:dial_music],options[:ring_timeout],options[:delay_dial],options[:max_duration], options[:max_participants],options[:wait_music_url],
options[:confirm_key_sound_url],options[:confirm_key_sound_method],options[:dial_music],options[:ring_timeout],options[:delay_dial],options[:max_duration], options[:max_participants],options[:record_min_member_count],options[:wait_music_url],
options[:wait_music_method],options[:agent_hold_music_url],options[:agent_hold_music_method],options[:customer_hold_music_url],options[:customer_hold_music_method],
options[:recording_callback_url],options[:recording_callback_method],options[:status_callback_url],options[:status_callback_method],options[:on_exit_action_url], options[:on_exit_action_method],
options[:record],options[:record_file_format],options[:status_callback_events],options[:stay_alone], options[:coach_mode],options[:mute],options[:hold],options[:start_mpc_on_enter],options[:end_mpc_on_exit],
Expand Down
8 changes: 7 additions & 1 deletion lib/plivo/xml/multipartycall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Plivo
module XML
class MultiPartyCall < Element
@nestables = []
@valid_attributes = %w[role maxDuration maxParticipants waitMusicUrl
@valid_attributes = %w[role maxDuration maxParticipants recordMinMemberCount waitMusicUrl
waitMusicMethod agentHoldMusicUrl agentHoldMusicMethod
customerHoldMusicUrl customerHoldMusicMethod record
recordFileFormat recordingCallbackUrl recordingCallbackMethod
Expand Down Expand Up @@ -37,6 +37,12 @@ def initialize(body, attributes = {})
attributes[:maxParticipants] = 10
end

if attributes[:recordMinMemberCount] && (attributes[:recordMinMemberCount]<1 || attributes[:recordMinMemberCount]>2)
raise PlivoXMLError, "invalid attribute value #{attributes[:recordMinMemberCount]} for recordMinMemberCount"
elsif !attributes[:recordMinMemberCount]
attributes[:recordMinMemberCount] = 10
end

if attributes[:waitMusicMethod] && !VALID_METHOD_VALUES.include?(attributes[:waitMusicMethod].upcase)
raise PlivoXMLError, "invalid attribute value #{attributes[:waitMusicMethod]} for waitMusicMethod"
elsif !attributes[:waitMusicMethod]
Expand Down
1 change: 1 addition & 0 deletions makeCall.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions spec/resource_multipartycalls_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def to_json_MPC_start_play(mpc)
'agent_hold_music_method': 'GET',
'wait_music_method': 'GET',
'max_participants': 10,
'record_min_member_count': 1,
'max_duration': 14400,
'ring_timeout': 45,
'dial_music': 'Real',
Expand Down
2 changes: 1 addition & 1 deletion spec/xml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,6 @@
xml = Plivo::XML::PlivoXML.new(resp)
puts xml.to_xml

expect(xml.to_xml).to eql("<?xml version=\"1.0\" encoding=\"utf-8\" ?><Response><Conference callbackMethod='POST' callbackUrl='http://foo.com/confevents/' digitsMatch='#0,90,000'>My room</Conference><Dial confirmKey='3' confirmSound='http://foo.com/sound/'><Number sendDigits='wwww2410'>18217654321</Number><User sendDigits='wwww2410'>sip:[email protected]</User></Dial><Dial action='http://foo.com/dial_action/' timeout='20'><Number>18217654321</Number></Dial><Dial><Number>15671234567</Number></Dial><DTMF>12345</DTMF><GetDigits action='http://ww.foo.com/gather_pin/' method='POST'><Speak>Enter PIN number.</Speak></GetDigits><Speak>Input not recieved.</Speak><GetInput action='http://ww.foo.com/gather_feedback/' method='POST'><Speak>Tell us more about your experience.</Speak></GetInput><Speak>Statement not recieved.</Speak><Hangup reason='rejected' schedule='60'/><Speak loop='0'>Call will hangup after a min.</Speak><Message callbackMethod='POST' callbackUrl='http://foo.com/sms_status/' dst='15671234567' src='12023222222' type='sms'>Hi, message from Plivo.</Message><Play>https://amazonaws.com/Trumpet.mp3</Play><PreAnswer><Speak>This call will cost $2 a min.</Speak></PreAnswer><Speak>Thanks for dropping by.</Speak><Record action='http://foo.com/get_recording/' redirect='false' startOnDialAnswer='true'/><Dial><Number>15551234567</Number></Dial><Speak>Leave message after the beep.</Speak><Record action='http://foo.com/get_recording/' finishOnKey='*' maxLength='30'/><Speak>Recording not received.</Speak><Speak>Your call is being transferred.</Speak><Redirect>http://foo.com/redirect/</Redirect><Speak loop='3'>Go green, go plivo.</Speak><Speak>I will wait 7 seconds starting now!</Speak><Wait length='7'/><Speak>I just waited 7 seconds.</Speak><Wait beep='true' length='120'/><Play>https://s3.amazonaws.com/abc.mp3</Play><Wait length='10'/><Speak>Hello</Speak><Wait length='10' minSilence='3000' silence='true'/><Speak>Hello, welcome to the Jungle.</Speak><MultiPartyCall agentHoldMusicMethod='GET' coachMode='true' customerHoldMusicMethod='GET' endMpcOnExit='false' enterSound='beep:1' enterSoundMethod='GET' exitSound='beep:2' exitSoundMethod='GET' hold='false' maxDuration='1000' maxParticipants='10' mute='false' onExitActionMethod='POST' record='false' recordFileFormat='mp3' recordingCallbackMethod='GET' relayDTMFInputs='false' role='Agent' startMpcOnEnter='true' startRecordingAudioMethod='GET' statusCallbackEvents='participant-speak-events, participant-digit-input-events, add-participant-api-events, participant-state-changes, mpc-state-changes' statusCallbackMethod='POST' stayAlone='false' stopRecordingAudioMethod='GET' waitMusicMethod='GET'>Nairobi</MultiPartyCall></Response>")
expect(xml.to_xml).to eql("<?xml version=\"1.0\" encoding=\"utf-8\" ?><Response><Conference callbackMethod='POST' callbackUrl='http://foo.com/confevents/' digitsMatch='#0,90,000'>My room</Conference><Dial confirmKey='3' confirmSound='http://foo.com/sound/'><Number sendDigits='wwww2410'>18217654321</Number><User sendDigits='wwww2410'>sip:[email protected]</User></Dial><Dial action='http://foo.com/dial_action/' timeout='20'><Number>18217654321</Number></Dial><Dial><Number>15671234567</Number></Dial><DTMF>12345</DTMF><GetDigits action='http://ww.foo.com/gather_pin/' method='POST'><Speak>Enter PIN number.</Speak></GetDigits><Speak>Input not recieved.</Speak><GetInput action='http://ww.foo.com/gather_feedback/' method='POST'><Speak>Tell us more about your experience.</Speak></GetInput><Speak>Statement not recieved.</Speak><Hangup reason='rejected' schedule='60'/><Speak loop='0'>Call will hangup after a min.</Speak><Message callbackMethod='POST' callbackUrl='http://foo.com/sms_status/' dst='15671234567' src='12023222222' type='sms'>Hi, message from Plivo.</Message><Play>https://amazonaws.com/Trumpet.mp3</Play><PreAnswer><Speak>This call will cost $2 a min.</Speak></PreAnswer><Speak>Thanks for dropping by.</Speak><Record action='http://foo.com/get_recording/' redirect='false' startOnDialAnswer='true'/><Dial><Number>15551234567</Number></Dial><Speak>Leave message after the beep.</Speak><Record action='http://foo.com/get_recording/' finishOnKey='*' maxLength='30'/><Speak>Recording not received.</Speak><Speak>Your call is being transferred.</Speak><Redirect>http://foo.com/redirect/</Redirect><Speak loop='3'>Go green, go plivo.</Speak><Speak>I will wait 7 seconds starting now!</Speak><Wait length='7'/><Speak>I just waited 7 seconds.</Speak><Wait beep='true' length='120'/><Play>https://s3.amazonaws.com/abc.mp3</Play><Wait length='10'/><Speak>Hello</Speak><Wait length='10' minSilence='3000' silence='true'/><Speak>Hello, welcome to the Jungle.</Speak><MultiPartyCall agentHoldMusicMethod='GET' coachMode='true' customerHoldMusicMethod='GET' endMpcOnExit='false' enterSound='beep:1' enterSoundMethod='GET' exitSound='beep:2' exitSoundMethod='GET' hold='false' maxDuration='1000' maxParticipants='10' recordMinMemberCount='1' mute='false' onExitActionMethod='POST' record='false' recordFileFormat='mp3' recordingCallbackMethod='GET' relayDTMFInputs='false' role='Agent' startMpcOnEnter='true' startRecordingAudioMethod='GET' statusCallbackEvents='participant-speak-events, participant-digit-input-events, add-participant-api-events, participant-state-changes, mpc-state-changes' statusCallbackMethod='POST' stayAlone='false' stopRecordingAudioMethod='GET' waitMusicMethod='GET'>Nairobi</MultiPartyCall></Response>")
end
end