diff --git a/personality-insights/v3.js b/personality-insights/v3.js index 2da576fe21..6b44205702 100644 --- a/personality-insights/v3.js +++ b/personality-insights/v3.js @@ -47,10 +47,10 @@ PersonalityInsightsV3.URL = 'https://gateway.watsonplatform.net/personality-insi /** * @param {Object} params The parameters to call the service * @param {Object} [params.headers] - The header parameters. - * @param {string} [params.headers.Accept-Language=en] - The desired language of the response: ar (Arabic), en (English), es (Spanish), or ja (Japanese). - * @param {string} [params.headers.Content-Type=text/plain] - The content type of the request: text/plain (the default), text/html, or application/json. - * @param {string} [params.headers.Content-Language=en] - The language of the input text for the request: ar (Arabic), en (English), es (Spanish), or ja (Japanese) - * @param {string} [params.headers.Accept=application/json] - The desired content type of the response: application/json (the default) or text/csv + * @param {string} [params.headers.accept-language=en] - The desired language of the response: ar (Arabic), en (English), es (Spanish), or ja (Japanese). + * @param {string} [params.headers.content-type=text/plain] - The content type of the request: text/plain (the default), text/html, or application/json. + * @param {string} [params.headers.content-language=en] - The language of the input text for the request: ar (Arabic), en (English), es (Spanish), or ja (Japanese) + * @param {string} [params.headers.accept=application/json] - The desired content type of the response: application/json (the default) or text/csv * @param {string} [params.text] - The text to analyze. * @param {Object} [params.content_items] - A JSON input (if 'text' not provided). * @param {boolean} [params.raw_scores=false] - include raw results. @@ -84,7 +84,7 @@ PersonalityInsightsV3.prototype.profile = function(_params, callback) { // eslin body: params.text || pick(params, ['contentItems']), json: true, qs: pick(params, ['csv_headers', 'raw_scores', 'consumption_preferences']), - headers: extend({ 'Content-type': content_type, 'Accept-language': 'en' }, params.headers) + headers: extend({ 'content-type': content_type, 'accept-language': 'en' }, params.headers) }, defaultOptions: this._options }; diff --git a/test/integration/test.personality_insights.v3.js b/test/integration/test.personality_insights.v3.js index f4e907bffa..1a2da2db58 100644 --- a/test/integration/test.personality_insights.v3.js +++ b/test/integration/test.personality_insights.v3.js @@ -52,7 +52,7 @@ describe('personality_insights_v3_integration', function() { consumption_preferences: true, csv_headers: true, headers: { - 'Accept': 'text/csv' + 'accept': 'text/csv' } }; personality_insights.profile(params, done); diff --git a/test/unit/test.personality_insights.v3.js b/test/unit/test.personality_insights.v3.js index 494426c0aa..b60fd3bb90 100644 --- a/test/unit/test.personality_insights.v3.js +++ b/test/unit/test.personality_insights.v3.js @@ -71,7 +71,7 @@ describe('personality_insights_v3', function() { assert.equal(req.uri.href, service.url + service_path + '?version=2016-10-19'); assert.equal(body, '"' + service_request.text + '"'); assert.equal(req.method, 'POST'); - assert.equal(req.headers['Content-type'], 'text/plain'); + assert.equal(req.headers['content-type'], 'text/plain'); }); it('should generate a valid payload with contentItems', function() { @@ -80,8 +80,8 @@ describe('personality_insights_v3', function() { assert.equal(req.uri.href, service.url + service_path + '?version=2016-10-19'); assert.equal(body, JSON.stringify(payload)); assert.equal(req.method, 'POST'); - assert.equal(req.headers['Content-language'], undefined); // service bug: content-language header overrides the language specified in JSON for each content item, so it must not be set - assert.equal(req.headers['Content-type'], 'application/json'); + assert.equal(req.headers['content-language'], undefined); // service bug: content-language header overrides the language specified in JSON for each content item, so it must not be set + assert.equal(req.headers['content-type'], 'application/json'); }); it('should generate a valid payload with content_items', function() { @@ -91,8 +91,8 @@ describe('personality_insights_v3', function() { assert.equal(req.uri.href, service.url + service_path + '?version=2016-10-19'); assert.equal(body, JSON.stringify(payload)); assert.equal(req.method, 'POST'); - assert.equal(req.headers['Content-language'], undefined); // service bug: content-language header overrides the language specified in JSON for each content item, so it must not be set - assert.equal(req.headers['Content-type'], 'application/json'); + assert.equal(req.headers['content-language'], undefined); // service bug: content-language header overrides the language specified in JSON for each content item, so it must not be set + assert.equal(req.headers['content-type'], 'application/json'); }); it('should generate a valid payload with html', function() { @@ -102,14 +102,14 @@ describe('personality_insights_v3', function() { assert.equal(req.uri.href, service.url + service_path + '?version=2016-10-19'); assert.equal(body, JSON.stringify(html_req.text)); assert.equal(req.method, 'POST'); - assert.equal(req.headers['Content-type'], 'text/html'); + assert.equal(req.headers['content-type'], 'text/html'); }); - it('should generate a valid payload with raw_scores, Accept-Language and Contnet-Language', function() { + it('should generate a valid payload with raw_scores, accept-Language and content-language', function() { var params = extend({ raw_scores: true, headers: { - 'Content-language': 'es', - 'Accept-language': 'es' + 'content-language': 'es', + 'accept-language': 'es' } }, payload); @@ -118,27 +118,27 @@ describe('personality_insights_v3', function() { assert.equal(req.uri.href, service.url + service_path + '?version=2016-10-19&raw_scores=true'); assert.equal(body, JSON.stringify(payload)); assert.equal(req.method, 'POST'); - assert.equal(req.headers['Content-type'], 'application/json'); - assert.equal(req.headers['Content-language'], 'es'); - assert.equal(req.headers['Accept-language'], 'es'); + assert.equal(req.headers['content-type'], 'application/json'); + assert.equal(req.headers['content-language'], 'es'); + assert.equal(req.headers['accept-language'], 'es'); }); it('should generate a valid request with { headers: {Accept: "text/csv"}}', function() { - var params = extend({ headers: { Accept: 'text/csv'} }, payload); + var params = extend({ headers: { accept: 'text/csv'} }, payload); var req = personality_insights.profile(params, noop); var body = new Buffer(req.body).toString('ascii'); assert.equal(req.uri.href, service.url + service_path + '?version=2016-10-19'); assert.equal(body, JSON.stringify(payload)); - assert.equal(req.headers['Accept'], 'text/csv'); + assert.equal(req.headers['accept'], 'text/csv'); }); - it('should generate a valid request with {headers: {Accept: "text/csv"}, csv_headers: true}', function() { - var params = extend({ headers: {Accept: "text/csv"}, csv_headers: true}, payload); + it('should generate a valid request with {headers: {accept: "text/csv"}, csv_headers: true}', function() { + var params = extend({ headers: {accept: "text/csv"}, csv_headers: true}, payload); var req = personality_insights.profile(params, noop); var body = new Buffer(req.body).toString('ascii'); assert.equal(req.uri.href, service.url + service_path + '?version=2016-10-19&csv_headers=true'); assert.equal(body, JSON.stringify(payload)); - assert.equal(req.headers['Accept'], 'text/csv'); + assert.equal(req.headers['accept'], 'text/csv'); }); it('should format the response', function(done) {