services/personality_insights/v3.js
function prepareParams(msg, config) {
    var params = {},
      inputlang = config.inputlang ? config.inputlang : 'en',
      outputlang = config.outputlang ? config.outputlang : 'en';

    if (msg.piparams) {
      if (msg.piparams.inputlanguage &&
            -1 < VALID_INPUT_LANGUAGES.indexOf(msg.piparams.inputlanguage)) {
        inputlang = msg.piparams.inputlanguage;
      }
      if (msg.piparams.responselanguage &&
            -1 < VALID_RESPONSE_LANGUAGES.indexOf(msg.piparams.responselanguage)) {
        outputlang = msg.piparams.responselanguage;
      }
    }

    params = {
      content: msg.payload,
      consumption_preferences: config.consumption ? config.consumption : false,
      raw_scores: config.rawscores ? config.rawscores : false,
      headers: {
        'content-language': inputlang,
        'accept-language': outputlang,
        'accept': 'application/json'
      }
    };

    if ('string' === typeof msg.payload) {
      params.content_type = 'text/plain';
    } else {
      params.content_type = 'application/json';
    }

    return Promise.resolve(params);
  }
function prepareParams(msg, config) {
    var params = {},
      inputlang = config.inputlang ? config.inputlang : 'en',
      outputlang = config.outputlang ? config.outputlang : 'en';

    if (msg.piparams) {
      if (msg.piparams.inputlanguage &&
            -1 < VALID_INPUT_LANGUAGES.indexOf(msg.piparams.inputlanguage)) {
        inputlang = msg.piparams.inputlanguage;
      }
      if (msg.piparams.responselanguage &&
            -1 < VALID_RESPONSE_LANGUAGES.indexOf(msg.piparams.responselanguage)) {
        outputlang = msg.piparams.responselanguage;
      }
    }

    params = {
      content: msg.payload,
      consumption_preferences: config.consumption ? config.consumption : false,
      raw_scores: config.rawscores ? config.rawscores : false,
      headers: {
        'content-language': inputlang,
        'accept-language': outputlang,
        'accept': 'application/json'
      }
    };

    if ('string' === typeof msg.payload) {
      params.content_type = 'text/plain';
    } else {
      params.content_type = 'application/json';
    }

    return Promise.resolve(params);
  }
function prepareParams ( msg , config ) { var params = { } , inputlang = config . inputlang ? config . inputlang : 'en' , outputlang = config . outputlang ? config . outputlang : 'en' ; if ( msg . piparams ) { if ( msg . piparams . inputlanguage && - 1 < VALID_INPUT_LANGUAGES . indexOf ( msg . piparams . inputlanguage ) ) { inputlang = msg . piparams . inputlanguage ; } if ( msg . piparams . responselanguage && - 1 < VALID_RESPONSE_LANGUAGES . indexOf ( msg . piparams . responselanguage ) ) { outputlang = msg . piparams . responselanguage ; } } params = { content : msg . payload , consumption_preferences : config . consumption ? config . consumption : false , raw_scores : config . rawscores ? config . rawscores : false , headers : { 'content-language' : inputlang , 'accept-language' : outputlang , 'accept' : 'application/json' } } ; if ( 'string' === typeof msg . payload ) { params . content_type = 'text/plain' ; } else { params . content_type = 'application/json' ; } return Promise . resolve ( params ) ; }
This function prepares the params object for the call to Personality Insights
This function prepares the params object for the call to Personality Insights