diff --git a/lib/utils/plivoxml.js b/lib/utils/plivoxml.js index 94f5266..ec0b72f 100644 --- a/lib/utils/plivoxml.js +++ b/lib/utils/plivoxml.js @@ -11,7 +11,7 @@ export class PlivoXMLError extends Error { } */ export function Response() { this.element = 'Response'; - this.nestables = ['Speak', 'Play', 'GetDigits', 'Record', 'Dial', 'Message', + this.nestables = ['Speak', 'Play', 'GetDigits', 'GetInput', 'Record', 'Dial', 'Message', 'Redirect', 'Wait', 'Hangup', 'PreAnswer', 'Conference', 'DTMF']; this.valid_attributes = []; this.elem = xmlBuilder.begin().ele(this.element); @@ -162,6 +162,31 @@ Response.prototype = { return this.add(new GetDigits(Response), '', attributes); }, + /** + * Add a GetInput element + * @method + * @param {object} attributes + * @param {string} [attributes.action] + * @param {string} [attributes.method] + * @param {string} [attributes.inputType] + * @param {number} [attributes.executionTimeout] + * @param {number} [attributes.digitEndTimeout] + * @param {number} [attributes.speechEndTimeout] + * @param {string} [attributes.finishOnKey] + * @param {number} [attributes.numDigits] + * @param {string} [attributes.speechModel] + * @param {string} [attributes.hints] + * @param {string} [attributes.language] + * @param {string} [attributes.interimSpeechResultsCallback] + * @param {string} [attributes.interimSpeechResultsCallbackMethod] + * @param {boolean} [attributes.log] + * @param {boolean} [attributes.redirect] + * @param {string} [attributes.profanityFilter] + */ + addGetInput: function (attributes) { + return this.add(new GetInput(Response), '', attributes); + }, + /** * Add a Hangup element * @method @@ -366,6 +391,20 @@ function GetDigits(Response) { } util.inherits(GetDigits, Response); +/** + * GetInput element + * @constructor + */ +function GetInput(Response) { + this.element = 'GetInput'; + this.valid_attributes = ['action', 'method', 'inputType', 'executionTimeout', + 'digitEndTimeout', 'speechEndTimeout', 'finishOnKey', 'numDigits', + 'speechModel', 'hints','language', 'interimSpeechResultsCallback', + 'interimSpeechResultsCallbackMethod', 'log', 'redirect', 'profanityFilter']; + this.nestables = ['Speak', 'Play', 'Wait']; +} +util.inherits(GetInput, Response); + /** * Hangup element * @constructor diff --git a/test/xml.js b/test/xml.js index 9b935fd..ca6068a 100644 --- a/test/xml.js +++ b/test/xml.js @@ -14,6 +14,7 @@ describe('PlivoXML', function () { response.addConference('test'); response.addRedirect('url'); response.addGetDigits(); + response.addGetInput(); response.addPlay('url'); const dial = response.addDial(); dial.addNumber('123'); @@ -22,6 +23,6 @@ describe('PlivoXML', function () { src: '123', dst: '456', }); - assert.equal('text123testurlurl123sip:test@sip.plivo.com∫test', response.toXML()); + assert.equal('text123testurlurl123sip:test@sip.plivo.com∫test', response.toXML()); }); });