From 53395f11274265b4173f08cbf63d1ad41f0a6ef1 Mon Sep 17 00:00:00 2001 From: qyunal Date: Tue, 15 Oct 2019 18:12:55 +0530 Subject: [PATCH 1/3] adds support for getInput --- lib/utils/plivoxml.js | 40 +++++++++++++++++++++++++++++++++++++++- test/xml.js | 1 + 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/lib/utils/plivoxml.js b/lib/utils/plivoxml.js index 94f5266..af4c522 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,30 @@ 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] + */ + addGetInput: function (attributes) { + return this.add(new GetInput(Response), '', attributes); + }, + /** * Add a Hangup element * @method @@ -366,6 +390,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']; + this.nestables = ['Speak', 'Play', 'Wait']; +} +util.inherits(GetInput, Response); + /** * Hangup element * @constructor diff --git a/test/xml.js b/test/xml.js index 9b935fd..6a1e451 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'); From 690998ca43be6093313816a92aedf48f1fd9f418 Mon Sep 17 00:00:00 2001 From: qyunal Date: Wed, 16 Oct 2019 02:23:26 +0530 Subject: [PATCH 2/3] fix tests --- test/xml.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/xml.js b/test/xml.js index 6a1e451..ca6068a 100644 --- a/test/xml.js +++ b/test/xml.js @@ -23,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()); }); }); From 49bfb987c18af9861ede88ec5565f6dc6163ff98 Mon Sep 17 00:00:00 2001 From: qyunal Date: Wed, 16 Oct 2019 17:06:08 +0530 Subject: [PATCH 3/3] adds profanityFilter --- lib/utils/plivoxml.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/utils/plivoxml.js b/lib/utils/plivoxml.js index af4c522..ec0b72f 100644 --- a/lib/utils/plivoxml.js +++ b/lib/utils/plivoxml.js @@ -181,6 +181,7 @@ Response.prototype = { * @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); @@ -399,7 +400,7 @@ function GetInput(Response) { this.valid_attributes = ['action', 'method', 'inputType', 'executionTimeout', 'digitEndTimeout', 'speechEndTimeout', 'finishOnKey', 'numDigits', 'speechModel', 'hints','language', 'interimSpeechResultsCallback', - 'interimSpeechResultsCallbackMethod', 'log', 'redirect']; + 'interimSpeechResultsCallbackMethod', 'log', 'redirect', 'profanityFilter']; this.nestables = ['Speak', 'Play', 'Wait']; } util.inherits(GetInput, Response);