twilio
Version:
A Twilio helper library
462 lines (425 loc) • 14.8 kB
JavaScript
;
/* jshint ignore:start */
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
/* jshint ignore:end */
var builder = require('xmlbuilder'); /* jshint ignore:line */
/* jshint ignore:start */
/**
* <Response> TwiML for Voice
*/
/* jshint ignore:end */
function VoiceResponse() {
this.response = builder.create('Response').dec('1.0', 'UTF-8');
}
/* jshint ignore:start */
/**
* <Dial> TwiML Verb
*
* @param {object} attributes - ...
* @param {url} [attributes.action] Action URL
* @param {http_method} [attributes.method] Action URL method
* @param {integer} [attributes.timeout] Time to wait for answer
* @param {boolean} [attributes.hangupOnStar] Hangup call on star press
* @param {integer} [attributes.timeLimit] Max time length
* @param {string} [attributes.callerId] Caller ID to display
* @param {record.trim} [attributes.record] Record the call
* @param {record.trim} [attributes.trim] Trim the recording
* @param {url} [attributes.recordingStatusCallback] Recording status callback URL
* @param {http_method} [attributes.recordingStatusCallbackMethod] Recording status callback URL method
* @param {boolean} [attributes.answerOnBridge] Preserve the ringing behavior of the inbound call until the Dialed call picks up
* @param {dial.ring_tone} [attributes.ringTone] Ringtone allows you to override the ringback tone that Twilio will play back to the caller while executing the Dial
* @param {string} [number] Phone number to dial
*
* @returns Dial
*/
/* jshint ignore:end */
VoiceResponse.prototype.dial = function dial(attributes, number) {
return new Dial(this.response.ele('Dial', attributes, number));
};
/* jshint ignore:start */
/**
* <Echo> TwiML Verb
*
* @param {object} attributes - TwiML attributes
*/
/* jshint ignore:end */
VoiceResponse.prototype.echo = function echo(attributes) {
this.response.ele('Echo', attributes);
};
/* jshint ignore:start */
/**
* <Enqueue> TwiML Noun
*
* @param {object} attributes - ...
* @param {url} [attributes.action] Action URL
* @param {http_method} [attributes.method] Action URL method
* @param {url} [attributes.waitUrl] Wait URL
* @param {http_method} [attributes.waitUrlMethod] Wait URL method
* @param {string} [attributes.workflowSid] TaskRouter Workflow SID
* @param {string} [name] Friendly name
*
* @returns Enqueue
*/
/* jshint ignore:end */
VoiceResponse.prototype.enqueue = function enqueue(attributes, name) {
return new Enqueue(this.response.ele('Enqueue', attributes, name));
};
/* jshint ignore:start */
/**
* <Gather> TwiML Verb
*
* @param {object} attributes - ...
* @param {gather.input} [attributes.input] Input type Twilio should accept
* @param {url} [attributes.action] Action URL
* @param {http_method} [attributes.method] Action URL method
* @param {integer} [attributes.timeout] Time to wait to gather input
* @param {string} [attributes.speechTimeout] Time to wait to gather speech input and it should be either auto or a positive integer.
* @param {integer} [attributes.maxSpeechTime] Max allowed time for speech input
* @param {boolean} [attributes.profanityFilter] Profanity Filter on speech
* @param {string} [attributes.finishOnKey] Finish gather on key
* @param {integer} [attributes.numDigits] Number of digits to collect
* @param {url} [attributes.partialResultCallback] Partial result callback URL
* @param {http_method} [attributes.partialResultCallbackMethod] Partial result callback URL method
* @param {say.language} [attributes.language] Language to use
* @param {string} [attributes.hints] Speech recognition hints
* @param {boolean} [attributes.bargeIn] Stop playing media upon speech
*
* @returns Gather
*/
/* jshint ignore:end */
VoiceResponse.prototype.gather = function gather(attributes) {
return new Gather(this.response.ele('Gather', attributes));
};
/* jshint ignore:start */
/**
* <Hangup> TwiML Verb
*
* @param {object} attributes - TwiML attributes
*/
/* jshint ignore:end */
VoiceResponse.prototype.hangup = function hangup(attributes) {
this.response.ele('Hangup', attributes);
};
/* jshint ignore:start */
/**
* <Leave> TwiML Verb
*
* @param {object} attributes - TwiML attributes
*/
/* jshint ignore:end */
VoiceResponse.prototype.leave = function leave(attributes) {
this.response.ele('Leave', attributes);
};
/* jshint ignore:start */
/**
* <Pause> TwiML Verb
*
* @param {object} attributes - ...
* @param {integer} [attributes.length] Length in seconds to pause
*/
/* jshint ignore:end */
VoiceResponse.prototype.pause = function pause(attributes) {
this.response.ele('Pause', attributes);
};
/* jshint ignore:start */
/**
* <Play> TwiML Verb
*
* @param {object} attributes - ...
* @param {integer} [attributes.loop] Times to loop media
* @param {string} [attributes.digits] Play DTMF tones for digits
* @param {url} [url] Media URL
*/
/* jshint ignore:end */
VoiceResponse.prototype.play = function play(attributes, url) {
this.response.ele('Play', attributes, url);
};
/* jshint ignore:start */
/**
* <Queue> TwiML Noun
*
* @param {object} attributes - ...
* @param {url} [attributes.url] Action URL
* @param {http_method} [attributes.method] Action URL method
* @param {string} [attributes.reservationSid] TaskRouter Reservation SID
* @param {string} [attributes.postWorkActivitySid] TaskRouter Activity SID
* @param {string} name Queue name
*/
/* jshint ignore:end */
VoiceResponse.prototype.queue = function queue(attributes, name) {
this.response.ele('Queue', attributes, name);
};
/* jshint ignore:start */
/**
* <Record> TwiML Verb
*
* @param {object} attributes - ...
* @param {url} [attributes.action] Action URL
* @param {http_method} [attributes.method] Action URL method
* @param {integer} [attributes.timeout] Timeout to begin recording
* @param {string} [attributes.finishOnKey] Finish recording on key
* @param {integer} [attributes.maxLength] Max time to record in seconds
* @param {boolean} [attributes.playBeep] Play beep
* @param {conference.trim} [attributes.trim] Trim the recording
* @param {url} [attributes.recordingStatusCallback] Status callback URL
* @param {http_method} [attributes.recordingStatusCallbackMethod] Status callback URL method
* @param {boolean} [attributes.transcribe] Transcribe the recording
* @param {url} [attributes.transcribeCallback] Transcribe callback URL
*/
/* jshint ignore:end */
VoiceResponse.prototype.record = function record(attributes) {
this.response.ele('Record', attributes);
};
/* jshint ignore:start */
/**
* <Redirect> TwiML Verb
*
* @param {object} attributes - ...
* @param {http_method} [attributes.method] Redirect URL method
* @param {url} url Redirect URL
*/
/* jshint ignore:end */
VoiceResponse.prototype.redirect = function redirect(attributes, url) {
this.response.ele('Redirect', attributes, url);
};
/* jshint ignore:start */
/**
* <Reject> TwiML Verb
*
* @param {object} attributes - ...
* @param {reject.reason} [attributes.reason] Rejection reason
*/
/* jshint ignore:end */
VoiceResponse.prototype.reject = function reject(attributes) {
this.response.ele('Reject', attributes);
};
/* jshint ignore:start */
/**
* <Say> TwiML Verb
*
* @param {object} attributes - ...
* @param {say.voice} [attributes.voice] Voice to use
* @param {integer} [attributes.loop] Times to loop message
* @param {say.language} [attributes.language] Message langauge
* @param {string} message Message to say
*/
/* jshint ignore:end */
VoiceResponse.prototype.say = function say(attributes, message) {
this.response.ele('Say', attributes, message);
};
/* jshint ignore:start */
/**
* <Sms> TwiML Noun
*
* @param {object} attributes - ...
* @param {phone_number} [attributes.to] Number to send message to
* @param {phone_number} [attributes.from] Number to send message from
* @param {url} [attributes.action] Action URL
* @param {http_method} [attributes.method] Action URL method
* @param {url} [attributes.statusCallback] Status callback URL
* @param {string} message Message body
*/
/* jshint ignore:end */
VoiceResponse.prototype.sms = function sms(attributes, message) {
this.response.ele('Sms', attributes, message);
};
/* jshint ignore:start */
/**
* Convert to TwiML
*
* @returns TwiML XML
*/
/* jshint ignore:end */
VoiceResponse.prototype.toString = function toString() {
return this.response.end();
};
/* jshint ignore:start */
/**
* <Gather> TwiML Verb
*
* @param {object} gather gather <Gather> TwiML Verb
*/
/* jshint ignore:end */
function Gather(gather) {
this.gather = gather;
}
/* jshint ignore:start */
/**
* <Say> TwiML Verb
*
* @param {object} attributes - ...
* @param {say.voice} [attributes.voice] Voice to use
* @param {integer} [attributes.loop] Times to loop message
* @param {say.language} [attributes.language] Message langauge
* @param {string} message Message to say
*/
/* jshint ignore:end */
Gather.prototype.say = function say(attributes, message) {
this.gather.ele('Say', attributes, message);
};
/* jshint ignore:start */
/**
* <Pause> TwiML Verb
*
* @param {object} attributes - ...
* @param {integer} [attributes.length] Length in seconds to pause
*/
/* jshint ignore:end */
Gather.prototype.pause = function pause(attributes) {
this.gather.ele('Pause', attributes);
};
/* jshint ignore:start */
/**
* <Play> TwiML Verb
*
* @param {object} attributes - ...
* @param {integer} [attributes.loop] Times to loop media
* @param {string} [attributes.digits] Play DTMF tones for digits
* @param {url} [url] Media URL
*/
/* jshint ignore:end */
Gather.prototype.play = function play(attributes, url) {
this.gather.ele('Play', attributes, url);
};
/* jshint ignore:start */
/**
* <Enqueue> TwiML Noun
*
* @param {object} enqueue enqueue <Enqueue> TwiML Noun
*/
/* jshint ignore:end */
function Enqueue(enqueue) {
this.enqueue = enqueue;
}
/* jshint ignore:start */
/**
* <Task> TwiML Noun
*
* @param {object} attributes - TwiML attributes
* @param {string} body TaskRouter task attributes
*/
/* jshint ignore:end */
Enqueue.prototype.task = function task(attributes, body) {
this.enqueue.ele('Task', attributes, body);
};
/* jshint ignore:start */
/**
* <Dial> TwiML Verb
*
* @param {object} dial dial <Dial> TwiML Verb
*/
/* jshint ignore:end */
function Dial(dial) {
this.dial = dial;
}
/* jshint ignore:start */
/**
* <Client> TwiML Noun
*
* @param {object} attributes - ...
* @param {url} [attributes.url] Client URL
* @param {http_method} [attributes.method] Client URL Method
* @param {sip.event} [attributes.statusCallbackEvent] Events to trigger status callback
* @param {url} [attributes.statusCallback] Status Callback URL
* @param {http_method} [attributes.statusCallbackMethod] Status Callback URL Method
* @param {string} name Client name
*/
/* jshint ignore:end */
Dial.prototype.client = function client(attributes, name) {
this.dial.ele('Client', attributes, name);
};
/* jshint ignore:start */
/**
* <Conference> TwiML Noun
*
* @param {object} attributes - ...
* @param {boolean} [attributes.muted] Join the conference muted
* @param {conference.beep} [attributes.beep] Play beep when joining
* @param {boolean} [attributes.startConferenceOnEnter] Start the conference on enter
* @param {boolean} [attributes.endConferenceOnExit] End the conferenceon exit
* @param {url} [attributes.waitUrl] Wait URL
* @param {http_method} [attributes.waitMethod] Wait URL method
* @param {integer} [attributes.maxParticipants] Maximum number of participants
* @param {conference.record} [attributes.record] Record the conference
* @param {conference.region} [attributes.region] Conference region
* @param {sid} [attributes.whisper] Call whisper
* @param {conference.trim} [attributes.trim] Trim the conference recording
* @param {sip.event} [attributes.statusCallbackEvent] Events to call status callback URL
* @param {url} [attributes.statusCallback] Status callback URL
* @param {http_method} [attributes.statusCallbackMethod] Status callback URL method
* @param {url} [attributes.recordingStatusCallback] Recording status callback URL
* @param {http_method} [attributes.recordingStatusCallbackMethod] Recording status callback URL method
* @param {url} [attributes.eventCallbackUrl] Event callback URL
* @param {string} name Conference name
*/
/* jshint ignore:end */
Dial.prototype.conference = function conference(attributes, name) {
this.dial.ele('Conference', attributes, name);
};
/* jshint ignore:start */
/**
* <Number> TwiML Noun
*
* @param {object} attributes - ...
* @param {string} [attributes.sendDigits] DTMF tones to play when the call is answered
* @param {url} [attributes.url] TwiML URL
* @param {http_method} [attributes.method] TwiML URL method
* @param {sip.event} [attributes.statusCallbackEvent] Events to call status callback
* @param {url} [attributes.statusCallback] Status callback URL
* @param {http_method} [attributes.statusCallbackMethod] Status callback URL method
* @param {phone_number} phoneNumber Phone Number to dial
*/
/* jshint ignore:end */
Dial.prototype.number = function number(attributes, phoneNumber) {
this.dial.ele('Number', attributes, phoneNumber);
};
/* jshint ignore:start */
/**
* <Queue> TwiML Noun
*
* @param {object} attributes - ...
* @param {url} [attributes.url] Action URL
* @param {http_method} [attributes.method] Action URL method
* @param {string} [attributes.reservationSid] TaskRouter Reservation SID
* @param {string} [attributes.postWorkActivitySid] TaskRouter Activity SID
* @param {string} name Queue name
*/
/* jshint ignore:end */
Dial.prototype.queue = function queue(attributes, name) {
this.dial.ele('Queue', attributes, name);
};
/* jshint ignore:start */
/**
* <Sim> TwiML Noun
*
* @param {object} attributes - TwiML attributes
* @param {sid} simSid SIM SID
*/
/* jshint ignore:end */
Dial.prototype.sim = function sim(attributes, simSid) {
this.dial.ele('Sim', attributes, simSid);
};
/* jshint ignore:start */
/**
* <Sip> TwiML Noun
*
* @param {object} attributes - ...
* @param {string} [attributes.username] SIP Username
* @param {string} [attributes.password] SIP Password
* @param {url} [attributes.url] Action URL
* @param {http_method} [attributes.method] Action URL method
* @param {sip.event} [attributes.statusCallbackEvent] Status callback events
* @param {url} [attributes.statusCallback] Status callback URL
* @param {http_method} [attributes.statusCallbackMethod] Status callback URL method
* @param {url} sipUrl SIP URL
*/
/* jshint ignore:end */
Dial.prototype.sip = function sip(attributes, sipUrl) {
this.dial.ele('Sip', attributes, sipUrl);
};
module.exports = VoiceResponse;