twilio
Version:
A Twilio helper library
103 lines (90 loc) • 2.36 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 Messages
*/
/* jshint ignore:end */
function MessagingResponse() {
this.response = builder.create('Response').dec('1.0', 'UTF-8');
}
/* jshint ignore:start */
/**
* <Message> TwiML Verb
*
* @param {object} attributes - ...
* @param {string} [attributes.to] Phone Number to send Message to
* @param {string} [attributes.from] Phone Number to send Message from
* @param {url} [attributes.action] Action URL
* @param {http_method} [attributes.method] Action URL Method
* @param {string} [body] Message Body
*
* @returns Message
*/
/* jshint ignore:end */
MessagingResponse.prototype.message = function message(attributes, body) {
return new Message(this.response.ele('Message', attributes, body));
};
/* 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 */
MessagingResponse.prototype.redirect = function redirect(attributes, url) {
this.response.ele('Redirect', attributes, url);
};
/* jshint ignore:start */
/**
* Convert to TwiML
*
* @returns TwiML XML
*/
/* jshint ignore:end */
MessagingResponse.prototype.toString = function toString() {
return this.response.end();
};
/* jshint ignore:start */
/**
* <Message> TwiML Verb
*
* @param {object} message message <Message> TwiML Verb
*/
/* jshint ignore:end */
function Message(message) {
this.message = message;
}
/* jshint ignore:start */
/**
* <Body> TwiML Noun
*
* @param {object} attributes - TwiML attributes
* @param {string} message Message Body
*/
/* jshint ignore:end */
Message.prototype.body = function body(attributes, message) {
this.message.ele('Body', attributes, message);
};
/* jshint ignore:start */
/**
* <Media> TwiML Noun
*
* @param {object} attributes - TwiML attributes
* @param {url} url Media URL
*/
/* jshint ignore:end */
Message.prototype.media = function media(attributes, url) {
this.message.ele('Media', attributes, url);
};
module.exports = MessagingResponse;