How to use the ibm-cloud-sdk-core.isHTML 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 / personality-insights / v2.js View on Github external
PersonalityInsightsV2.prototype.profile = function (params, callback) {
        var _params = params || {};
        // support for the new snake_case
        if (_params['content_items']) {
            _params['contentItems'] = _params['content_items'];
        }
        if (!_params.text && !_params.contentItems) {
            callback(new Error('Missing required parameters: text or content_items'));
            return;
        }
        // Content-Type
        var contentType = null;
        if (_params.text) {
            contentType = ibm_cloud_sdk_core_2.isHTML(_params.text) ? 'text/html' : 'text/plain';
        }
        else {
            contentType = 'application/json';
        }
        var headers = {
            'Content-type': contentType,
            'Accept-language': _params.accept_language || _params.acceptLanguage || 'en',
            Accept: undefined
        };
        // service bug: language in header overrides language in each JSON content item, so we can't set it on those requests
        // (also, content-language doesn't really make sense on JSON)
        if (_params.language || _params.text) {
            headers['Content-language'] = _params.language || 'en';
        }
        var parameters = {
            options: {
github watson-developer-cloud / node-sdk / personality-insights / v2.ts View on Github external
params: PersonalityInsightsV2.ProfileParams,
    callback: PersonalityInsightsV2.Callback
  ) {
    const _params = params || {};
    // support for the new snake_case
    if (_params['content_items']) {
      _params['contentItems'] = _params['content_items'];
    }
    if (!_params.text && !_params.contentItems) {
      callback(new Error('Missing required parameters: text or content_items'));
      return;
    }
    // Content-Type
    let contentType = null;
    if (_params.text) {
      contentType = isHTML(_params.text) ? 'text/html' : 'text/plain';
    } else {
      contentType = 'application/json';
    }
    const headers = {
      'Content-type': contentType,
      'Accept-language':
        _params.accept_language || _params.acceptLanguage || 'en',
      Accept: undefined
    };
    // service bug: language in header overrides language in each JSON content item, so we can't set it on those requests
    // (also, content-language doesn't really make sense on JSON)
    if (_params.language || _params.text) {
      headers['Content-language'] = _params.language || 'en';
    }
    const parameters = {
      options: {
github umple / umple / umpleonline / watson / node_modules / watson-developer-cloud / personality-insights / v3.js View on Github external
PersonalityInsightsV3.prototype.profile = function (params, callback) {
        if (params && (params.content || params.content_type)) {
            return _super.prototype.profile.call(this, params, callback);
        }
        if (params && params.content_items) {
            params.contentItems = params.content_items;
        }
        if (!params || (!params.text && !params.contentItems)) {
            callback(new Error('Missing required parameters: text or content_items'));
            return;
        }
        var contentType = null;
        if (params.text) {
            contentType = ibm_cloud_sdk_core_1.isHTML(params.text) ? 'text/html' : 'text/plain';
        }
        else {
            contentType = 'application/json';
        }
        var newParams = {
            content: params.text || pick(params, ['contentItems']),
            content_type: contentType,
            raw_scores: params.raw_scores,
            csv_headers: params.csv_headers,
            consumption_preferences: params.consumption_preferences
        };
        var headers = ibm_cloud_sdk_core_1.toLowerKeys(params.headers);
        if (headers['accept-language']) {
            newParams.accept_language = headers['accept-language'];
        }
        if (headers['content-type']) {