module Twilio module TwiML # Voice TwiML Response class VoiceResponse < TwiML # Create a new def initialize() super() self.name = 'Response' yield(self) if block_given? end # Create a element # # == Parameters: # number:: phone number to dial # action:: action URL # method:: action HTTP method # timeout:: time to wait for answer # hangup_on_star:: hangup call on * press # time_limit:: max time length # caller_id:: caller ID to display # record:: record the call # trim:: trim the recording # recording_status_callback:: status callback URL # recording_status_callback_method:: status callback URL method # keyword_args:: additional attributes # # == Returns: # A element with a child element def dial( number, action: nil, method: nil, timeout: nil, hangup_on_star: nil, time_limit: nil, caller_id: nil, record: nil, trim: nil, recording_status_callback: nil, recording_status_callback_method: nil, **keyword_args) dial = Dial.new( number: number, action: action, method: method, timeout: timeout, hangup_on_star: hangup_on_star, time_limit: time_limit, caller_id: caller_id, record: record, trim: trim, recording_status_callback: recording_status_callback, recording_status_callback_method: recording_status_callback_method, **keyword_args ) yield(dial) if block_given? self.append(dial) end # Create an element # # == Parameters: # keyword_args:: attributes # # == Returns: # A element with an child element def echo(**keyword_args) self.append(Echo.new(**keyword_args)) end # Create an element # # == Parameters: # name:: friendly name # action:: action URL # method:: action URL method # wait_url:: wait URL # wait_url_method:: wait URL method # workflow_sid:: TaskRouter workflow SID # keyword_args:: additional attributes # # == Returns: # A element with an child element def enqueue( name, action: nil, method: nil, wait_url: nil, wait_url_method: nil, workflow_sid: nil, **keyword_args) enqueue = Enqueue.new( name, action: action, method: method, wait_url: wait_url, wait_url_method: wait_url_method, workflow_sid: workflow_sid, **keyword_args ) yield(enqueue) if block_given? self.append(enqueue) end # Create a element # # == Parameters: # action:: action URL # method:: action URL method # timeout:: time to wait while gathering input # finish_on_key:: finish on key press # num_digits:: digits to collect # partial_result_callback:: callback url # partial_result_callback_method:: callback method # language:: locale string # hints:: speech recognition hints # barge_in:: stop playing media upon speech # acknowledge_sound_url:: url to hit when sound starts # keyword_args:: additional attributes # # == Returns: # A element with a child element def gather( action: nil, method: nil, timeout: nil, finish_on_key: nil, num_digits: nil, partial_result_callback: nil, partial_result_callback_method: nil, language: nil, hints: nil, barge_in: nil, acknowledge_sound_url: nil, **keyword_args) gather = Gather.new( action: action, method: method, timeout: timeout, finish_on_key: finish_on_key, num_digits: num_digits, partial_result_callback: partial_result_callback, partial_result_callback_method: partial_result_callback_method, language: language, hints: hints, barge_in: barge_in, acknowledge_sound_url: acknowledge_sound_url, **keyword_args ) yield(gather) if block_given? self.append(gather) end # Create a element # # == Returns: # A element with a child element def hangup() self.append(Hangup.new) end # Create a element # # == Returns: # A element with a child element def leave() self.append(Leave.new) end # Create a element # # == Parameters: # length:: time in seconds to pause # # == Returns: # A element with a child element def pause(length: nil) self.append(Pause.new(length: length)) end # Create a element # # == Parameters: # url:: url to play # loop:: times to loop # digits:: play DTMF tones during a call # keyword_args:: additional attributes # # == Returns: # A element with a child element def play(url: nil, loop: nil, digits: nil, **keyword_args) self.append(Play.new( url: url, loop: loop, digits: digits, **keyword_args )) end # Create a element # # == Parameters: # action:: action URL # method:: action URL method # timeout:: timeout for recording # finish_on_key:: finish recording on key # max_length:: max length to record # play_beep:: play beep # trim:: trim the recording # recording_status_callback:: status callback for the recordings # recording_status_callback_method:: status callback method # transcribe:: transcribe the recording # transcribe_callback:: transcribe callback URL # keyword_args:: additional attributes # # == Returns: # A element with a child element def record( action: nil, method: nil, timeout: nil, finish_on_key: nil, max_length: nil, play_beep: nil, trim: nil, recording_status_callback: nil, recording_status_callback_method: nil, transcribe: nil, transcribe_callback: nil, **keyword_args) self.append(Record.new( action: action, method: method, timeout: timeout, finish_on_key: finish_on_key, max_length: max_length, play_beep: play_beep, trim: trim, recording_status_callback: recording_status_callback, recording_status_callback_method: recording_status_callback_method, transcribe: transcribe, transcribe_callback: transcribe_callback, **keyword_args )) end # Create a element # # == Parameters: # url:: redirect URL # method:: redirect method # keyword_args:: additional attributes # # == Returns: # A element with a child element def redirect(url, method: nil, **keyword_args) self.append(Redirect.new(url, method: method, **keyword_args)) end # Create a element # # == Parameters: # reason:: rejection reason # keyword_args:: additional attributes # # == Returns: # A element with a child element def reject(reason: nil, **keyword_args) self.append(Reject.new(reason: reason, **keyword_args)) end # Create a element # # == Parameters: # body:: message body # loop:: times to loop # language:: language of message # voice:: voice to use # keyword_args:: additional attributes # # == Returns: # A element with a child element def say(body, loop: nil, language: nil, voice: nil, **keyword_args) self.append(Say.new( body, loop: loop, language: language, voice: voice, **keyword_args )) end # Create a element # # == Parameters: # body:: body of message # to:: to phone number # from_:: from phone number # method:: action URL method # action:: action URL # status_callback:: status callback URL # keyword_args:: additional attributes # # == Returns: # A element with a child element def sms( body, to: nil, from: nil, method: nil, action: nil, status_callback: nil, **keyword_args) self.append(Sms.new( body, to: to, from: from, method: method, action: action, status_callback: status_callback, **keyword_args )) end end # element class Dial < TwiML # Create a element # # == Parameters: # number:: phone number to dial # keyword_args:: additional attributes # # == Returns: # A element def initialize(number: nil, **keyword_args) super(**keyword_args) if !(number.nil?) @value = number end yield(self) if block_given? end # Create a element # # == Parameters: # name:: name of client # method:: action URL method # url:: action URL # status_callback_event:: events to call status callback # status_callback_method:: status callback URL method # status_callback:: status callback URL # keyword_args:: additional attributes # # == Returns: # A element with a child element def client( name, method: nil, url: nil, status_callback_event: nil, status_callback_method: nil, status_callback: nil, **keyword_args) self.append(Client.new( name, method: method, url: url, status_callback_event: status_callback_event, status_callback_method: status_callback_method, status_callback: status_callback, **keyword_args )) end # Create a element # # == Parameters: # name:: name of conference # muted:: join the conference muted # start_conference_on_enter:: start the conference on enter # end_conference_on_exit:: end the conference on exit # max_participants:: max number of people in conference # beep:: play beep when joining # record:: record the conference # trim:: trim the recording # wait_method:: wait URL method # wait_url:: wait URL to play # event_callback_url:: event callback URL # status_callback_event:: events to call status callback # status_callback:: status callback URL # status_callback_method:: status callback URL method # recording_status_callback:: recording status callback URL # recording_status_callback_method:: recording status callback URL method # keyword_args:: additional attributes # # == Returns: # A element with a child element def conference( name, muted: nil, start_conference_on_enter: nil, end_conference_on_exit: nil, max_participants: nil, beep: nil, record: nil, trim: nil, wait_url: nil, wait_method: nil, event_callback_url: nil, status_callback: nil, status_callback_event: nil, status_callback_method: nil, recording_status_callback: nil, recording_status_callback_method: nil, **keyword_args) self.append(Conference.new( name, muted: muted, start_conference_on_enter: start_conference_on_enter, end_conference_on_exit: end_conference_on_exit, max_participants: max_participants, beep: beep, record: record, trim: trim, wait_url: wait_url, wait_method: wait_method, event_callback_url: event_callback_url, status_callback: status_callback, status_callback_event: status_callback_event, status_callback_method: status_callback_method, recording_status_callback: recording_status_callback, recording_status_callback_method: recording_status_callback_method, **keyword_args )) end # Create a element # # == Parameters: # number:: phone number to dial # send_digits:: play DTMF tones when the call is answered # url:: TwiML URL # method:: TwiML URL method # status_callback_event:: events to call status callback # status_callback:: status callback URL # status_callback_method:: status callback URL method # keyword_args:: additional attributes # # == Returns: # A element with a child element def number( number, send_digits: nil, url: nil, method: nil, status_callback: nil, status_callback_event: nil, status_callback_method: nil, **keyword_args) self.append(Number.new( number, send_digits: send_digits, url: url, method: method, status_callback: status_callback, status_callback_event: status_callback_event, status_callback_method: status_callback_method, **keyword_args )) end # Create a element # # == Parameters: # queue_name:: queue name # url:: action URL # method:: action URL method # reservation_sid:: TaskRouter reservation SID # post_work_activity_sid:: TaskRouter activity SID # keyword_args:: additional attributes # # == Returns: # A element with a child element def queue( queue_name, url: nil, method: nil, reservation_sid: nil, post_work_activity_sid: nil, **keyword_args) self.append(Queue.new( queue_name, url: url, method: method, reservation_sid: reservation_sid, post_work_activity_sid: post_work_activity_sid, **keyword_args )) end # Create a element # # == Parameters: # sid:: sim sid # keyword_args:: additional attributes # # == Returns: # A element with a child element def sim(sid, **keyword_args) self.append(Sim.new(sid, **keyword_args)) end # Create a element # # == Parameters: # uri:: sip url # username:: sip username # password:: sip password # url:: action URL # method:: action URL method # status_callback_event:: events to call status callback # status_callback:: status callback URL # status_callback_method:: status callback URL method # keyword_args:: additional attributes # # == Returns: # A element with a child element def sip( uri, username: nil, password: nil, url: nil, method: nil, status_callback: nil, status_callback_event: nil, status_callback_method: nil, **keyword_args) self.append(Sip.new( uri, username: username, password: password, url: url, method: method, status_callback: status_callback, status_callback_event: status_callback_event, status_callback_method: status_callback_method, **keyword_args )) end end # element class Client < TwiML # Create a element # # == Parameters: # name:: name of client # keyword_args:: additional attributes # # == Returns: # A element def initialize(name, **keyword_args) super(**keyword_args) @value = name end end # element class Conference < TwiML # Create a element # # == Parameters: # name:: name of conference # keyword_args:: additional attributes # # == Returns: # A element def initialize(name, **keyword_args) super(**keyword_args) @value = name end end # element class Number < TwiML # Create a element # # == Parameters: # number:: phone number # keyword_args:: additional attributes # # == Returns: # A element def initialize(number, **keyword_args) super(**keyword_args) @value = number end end # element class Queue < TwiML # Create a element # # == Parameters: # queue_name:: name of queues # keyword_args:: additional attributes # # == Returns: # A element def initialize(queue_name, **keyword_args) super(**keyword_args) @value = queue_name end end # element class Sim < TwiML # Create a element # # == Parameters: # sid:: sim sid # keyword_args:: additional attributes # # == Returns: # A element def initialize(sid, **keyword_args) super(**keyword_args) @value = sid end end # element class Sip < TwiML # Create a element # # == Parameters: # uri:: sip uri # keyword_args:: additional attributes # # == Returns: # A element def initialize(uri, **keyword_args) super(**keyword_args) @value = uri end end # element class Echo < TwiML # Create a element # # == Parameters: # keyword_args:: additional attributes # # == Returns: # A element def initialize(**keyword_args) super(**keyword_args) end end # element class Enqueue < TwiML # Create a element # # == Parameters: # name:: queue name # keyword_args:: additional attributes # # == Returns: # A element def initialize(name, **keyword_args) super(**keyword_args) @value = name yield(self) if block_given? end # Create a element # # == Parameters: # attributes:: attributes for a task # keyword_args:: additional attributes # # == Returns: # An element with a child element def task(attributes, **keyword_args) self.append(Task.new(attributes, **keyword_args)) end end # element class Task < TwiML # Create a element # # == Parameters: # attributes:: attributes for a task # keyword_args:: additional attributes # # == Returns: # A element def initialize(attributes, **keyword_args) super(**keyword_args) if attributes.is_a?(String) @value = attributes else @value = JSON.generate(attributes) end end end # element class Gather < TwiML # Create a element # # == Parameters: # keyword_args:: additional attributes # # == Returns: # A element def initialize(**keyword_args) super(**keyword_args) yield(self) if block_given? end # Create a element # # == Parameters: # name:: name of client # body:: message body # loop:: times to loop # language:: message language # voice:: voice to use # keyword_args:: additional attributes # # == Returns: # A element with a child element def say( body, loop: nil, language: nil, voice: nil, **keyword_args) self.append(Say.new( body, loop: loop, language: language, voice: voice, **keyword_args )) end # Create a element # # == Parameters: # url:: media URL # loop:: times to loop # digits:: digits to simulate # keyword_args:: additional attributes # # == Returns: # A element with a child element def play(url: nil, loop: nil, digits: nil, **keyword_args) self.append(Play.new( url: url, loop: loop, digits: digits, **keyword_args )) end # Create a element # # == Parameters: # length:: time to pause # # == Returns: # A element with a child element def pause(length: nil) self.append(Pause.new(length: length)) end end # element class Pause < TwiML # Create a element # # == Parameters: # keyword_args:: additional attributes # # == Returns: # A element def initialize(**keyword_args) super(**keyword_args) end end # element class Play < TwiML # Create a element # # == Parameters: # url:: media URL # keyword_args:: additional attributes # # == Returns: # A element def initialize(url: nil, **keyword_args) super(**keyword_args) @value = url end end # element class Say < TwiML # Create a element # # == Parameters: # body:: message body # keyword_args:: additional attributes # # == Returns: # A element def initialize(body, **keyword_args) super(**keyword_args) @value = body end end # element class Hangup < TwiML # Create a element # # == Parameters: # keyword_args:: additional attributes # # == Returns: # A element def initialize(**keyword_args) super(**keyword_args) end end # element class Leave < TwiML # Create a element # # == Parameters: # keyword_args:: additional attributes # # == Returns: # A element def initialize(**keyword_args) super(**keyword_args) end end # element class Record < TwiML # Create a element # # == Parameters: # keyword_args:: additional attributes # # == Returns: # A element def initialize(**keyword_args) super(**keyword_args) end end # element class Redirect < TwiML # Create a element # # == Parameters: # url:: TwiML URL # keyword_args:: additional attributes # # == Returns: # A element def initialize(url, **keyword_args) super(**keyword_args) @value = url end end # element class Reject < TwiML # Create a element # # == Parameters: # keyword_args:: additional attributes # # == Returns: # A element def initialize(**keyword_args) super(**keyword_args) end end # element class Sms < TwiML # Create a element # # == Parameters: # body:: message body # keyword_args:: additional attributes # # == Returns: # A element def initialize(body, **keyword_args) super(**keyword_args) @value = body end end end end