How to use the ibm-cloud-sdk-core.qs function in ibm-cloud-sdk-core

To help you get started, we’ve selected a few ibm-cloud-sdk-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github umple / umple / umpleonline / watson / node_modules / watson-developer-cloud / lib / synthesize-stream.js View on Github external
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');
        };
github umple / umple / umpleonline / watson / node_modules / watson-developer-cloud / lib / recognize-stream.js View on Github external
}
        if (options.content_type && !options['content-type']) {
            options['content-type'] = options.content_type;
        }
        if (options['X-WDC-PL-OPT-OUT'] && !options['X-Watson-Learning-Opt-Out']) {
            options['X-Watson-Learning-Opt-Out'] = options['X-WDC-PL-OPT-OUT'];
        }
        // compatibility code for the deprecated param, customization_id
        if (options.customization_id && !options.language_customization_id) {
            options.language_customization_id = options.customization_id;
            delete options.customization_id;
        }
        var queryParams = extend('language_customization_id' in options
            ? pick(options, QUERY_PARAMS_ALLOWED)
            : { model: 'en-US_BroadbandModel' }, pick(options, QUERY_PARAMS_ALLOWED));
        var queryString = ibm_cloud_sdk_core_1.qs.stringify(queryParams);
        var url = (options.url || 'wss://stream.watsonplatform.net/speech-to-text/api').replace(/^http/, 'ws') +
            '/v1/recognize?' +
            queryString;
        var openingMessage = pick(options, OPENING_MESSAGE_PARAMS_ALLOWED);
        openingMessage.action = 'start';
        var self = this;
        // node params: requestUrl, protocols, origin, headers, extraRequestOptions, clientConfig options
        // browser params: requestUrl, protocols (all others ignored)
        // for the last argument, `tlsOptions` gets passed to Node's `http` library,
        // which allows us to pass a rejectUnauthorized option
        // for disabling SSL verification (for ICP)
        var socket = (this.socket = new w3cWebSocket(url, null, null, options.headers, null, { tlsOptions: { rejectUnauthorized: options.rejectUnauthorized } }));
        // when the input stops, let the service know that we're done
        self.on('finish', self.finish.bind(self));
        /**
         * This can happen if the credentials are invalid - in that case, the response from DataPower doesn't include the