Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
SynthesizeStream.prototype.initialize = function () {
var options = this.options;
var queryParams = pick(options, QUERY_PARAMS_ALLOWED);
var queryString = ibm_cloud_sdk_core_1.qs.stringify(queryParams);
var url = (options.url || 'wss://stream.watsonplatform.net/text-to-speech/api')
.replace(/^http/, 'ws') +
'/v1/synthesize?' +
queryString;
var socket = (this.socket = new w3cWebSocket(url, null, null, options.headers, null, { tlsOptions: { rejectUnauthorized: options.rejectUnauthorized } }));
// use class context within arrow functions
var self = this;
socket.onopen = function () {
var payload = pick(options, PAYLOAD_PARAMS_ALLOWED);
socket.send(JSON.stringify(payload));
/**
* emitted once the WebSocket connection has been established
* @event SynthesizeStream#open
*/
self.emit('open');
};
public analyze(params: NaturalLanguageUnderstandingV1.AnalyzeParams, callback?: NaturalLanguageUnderstandingV1.Callback): NodeJS.ReadableStream | void {
const _params = extend({}, params);
const _callback = (callback) ? callback : () => { /* noop */ };
const requiredParams = ['features'];
const missingParams = getMissingParams(_params, requiredParams);
if (missingParams) {
return _callback(missingParams);
}
const body = {
'features': _params.features,
'text': _params.text,
'html': _params.html,
'url': _params.url,
'clean': _params.clean,
'xpath': _params.xpath,
'fallback_to_raw': _params.fallback_to_raw,
'return_analyzed_text': _params.return_analyzed_text,
'language': _params.language,
'limit_text_characters': _params.limit_text_characters
};
public deleteClassifier(params: NaturalLanguageClassifierV1.DeleteClassifierParams, callback?: NaturalLanguageClassifierV1.Callback): NodeJS.ReadableStream | void {
const _params = extend({}, params);
const _callback = (callback) ? callback : () => { /* noop */ };
const requiredParams = ['classifier_id'];
const missingParams = getMissingParams(_params, requiredParams);
if (missingParams) {
return _callback(missingParams);
}
const path = {
'classifier_id': _params.classifier_id
};
const sdkHeaders = getSdkHeaders('natural_language_classifier', 'v1', 'deleteClassifier');
const parameters = {
options: {
url: '/v1/classifiers/{classifier_id}',
method: 'DELETE',
path,
},
constructor(options: UserOptions) {
// If the caller didn't supply an authenticator, construct one from external configuration.
if (!options.authenticator) {
options.authenticator = getAuthenticatorFromEnvironment('tone_analyzer');
}
super(options);
// check if 'version' was provided
if (typeof this.baseOptions.version === 'undefined') {
throw new Error('Argument error: version was not specified');
}
this.baseOptions.qs.version = options.version;
}
constructor(options: UserOptions) {
// If the caller didn't supply an authenticator, construct one from external configuration.
if (!options.authenticator) {
options.authenticator = getAuthenticatorFromEnvironment('watson_vision_combined');
}
super(options);
// check if 'version' was provided
if (typeof this.baseOptions.version === 'undefined') {
throw new Error('Argument error: version was not specified');
}
this.baseOptions.qs.version = options.version;
}
constructor(options: UserOptions) {
// If the caller didn't supply an authenticator, construct one from external configuration.
if (!options.authenticator) {
options.authenticator = getAuthenticatorFromEnvironment('discovery');
}
super(options);
// check if 'version' was provided
if (typeof this.baseOptions.version === 'undefined') {
throw new Error('Argument error: version was not specified');
}
this.baseOptions.qs.version = options.version;
}
constructor(options: UserOptions) {
// If the caller didn't supply an authenticator, construct one from external configuration.
if (!options.authenticator) {
options.authenticator = getAuthenticatorFromEnvironment('compare-comply');
}
super(options);
// check if 'version' was provided
if (typeof this.baseOptions.version === 'undefined') {
throw new Error('Argument error: version was not specified');
}
this.baseOptions.qs.version = options.version;
}
constructor(options: UserOptions) {
// If the caller didn't supply an authenticator, construct one from external configuration.
if (!options.authenticator) {
options.authenticator = getAuthenticatorFromEnvironment('personality_insights');
}
super(options);
// check if 'version' was provided
if (typeof this.baseOptions.version === 'undefined') {
throw new Error('Argument error: version was not specified');
}
this.baseOptions.qs.version = options.version;
}
constructor(options: UserOptions) {
// If the caller didn't supply an authenticator, construct one from external configuration.
if (!options.authenticator) {
options.authenticator = getAuthenticatorFromEnvironment('conversation');
}
super(options);
// check if 'version' was provided
if (typeof this.baseOptions.version === 'undefined') {
throw new Error('Argument error: version was not specified');
}
this.baseOptions.qs.version = options.version;
}
constructor(options: UserOptions) {
// If the caller didn't supply an authenticator, construct one from external configuration.
if (!options.authenticator) {
options.authenticator = getAuthenticatorFromEnvironment('text_to_speech');
}
super(options);
}