Skip to content

Commit 4cfdcd7

Browse files
closes #70
1 parent e31bdbf commit 4cfdcd7

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

services/speech_to_text/v1.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,15 +317,21 @@ SpeechToText.prototype.createSession = function(params, callback) {
317317
* @param {String} [params.session_id] Session id.
318318
*/
319319
SpeechToText.prototype.deleteSession = function(params, callback) {
320-
var path = params || {};
320+
var missingParams = helper.getMissingParams(params, ['session_id', 'cookie_session']);
321+
if (missingParams) {
322+
callback(new Error('Missing required parameters: ' + missingParams.join(', ')));
323+
return;
324+
}
325+
321326
var parameters = {
322327
options: {
323328
method: 'DELETE',
324-
url: '/v1/sessions/' + path.session_id,
325-
path: path,
326-
json: true
329+
url: '/v1/sessions/' + params.session_id,
330+
json: true,
331+
headers: {
332+
'Cookie': 'SESSIONID=' + params.cookie_session
333+
}
327334
},
328-
requiredParams: ['session_id'],
329335
defaultOptions: this._options
330336
};
331337
return requestFactory(parameters, callback);

test/test.speech_to_text.v1.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,14 @@ describe('speech_to_text', function() {
7373
it('should check no parameters provided', function() {
7474
speech_to_text.deleteSession({}, missingParameter);
7575
speech_to_text.deleteSession(null, missingParameter);
76+
speech_to_text.deleteSession({session_id: 'foo'}, missingParameter);
7677
});
7778

7879
it('should generate a valid payload', function() {
79-
var req = speech_to_text.deleteSession({session_id: 'foo'}, noop);
80+
var req = speech_to_text.deleteSession({session_id: 'foo', cookie_session:'cooki3'}, noop);
8081
assert.equal(req.uri.href, service.url + path);
8182
assert.equal(req.method, 'DELETE');
83+
assert.equal(req.headers['Cookie'], 'SESSIONID=cooki3');
8284
});
8385
});
8486

0 commit comments

Comments
 (0)