Merge pull request #124 from kunal-plivo/master

adds support for getInput
This commit is contained in:
Kunal Sanghvi 2019-10-18 17:00:19 +05:30 committed by GitHub
commit 73a2d41f4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 2 deletions

View file

@ -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

View file

@ -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('<Response><PreAnswer/><Record/><Hangup/><Speak>text</Speak><Wait/><DTMF>123</DTMF><Conference>test</Conference><Redirect>url</Redirect><GetDigits/><Play>url</Play><Dial><Number>123</Number><User>sip:test@sip.plivo.com</User></Dial><Message src="123" dst="456">∫test</Message></Response>', response.toXML());
assert.equal('<Response><PreAnswer/><Record/><Hangup/><Speak>text</Speak><Wait/><DTMF>123</DTMF><Conference>test</Conference><Redirect>url</Redirect><GetDigits/><GetInput/><Play>url</Play><Dial><Number>123</Number><User>sip:test@sip.plivo.com</User></Dial><Message src="123" dst="456">∫test</Message></Response>', response.toXML());
});
});