Skip to content

Commit 7dc7809

Browse files
committed
refactor(personality-insights): v4 changes
1 parent 4a2c731 commit 7dc7809

File tree

3 files changed

+64
-118
lines changed

3 files changed

+64
-118
lines changed

personality-insights/v3-generated.ts

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616

1717
import { AxiosResponse } from 'axios';
1818
import * as extend from 'extend';
19-
import { BaseService, FileObject, getMissingParams } from 'ibm-cloud-sdk-core';
19+
import { BaseService, getMissingParams } from 'ibm-cloud-sdk-core';
2020
import { getSdkHeaders } from '../lib/common';
21+
import { FileObject } from 'ibm-cloud-sdk-core';
2122

2223
/**
2324
* The IBM Watson™ Personality Insights service enables applications to derive insights from social media, enterprise data, or other digital communications. The service uses linguistic analytics to infer individuals' intrinsic personality characteristics, including Big Five, Needs, and Values, from digital communications such as email, text messages, tweets, and forum posts. The service can automatically infer, from potentially noisy social media, portraits of individuals that reflect their personality characteristics. The service can infer consumption preferences based on the results of its analysis and, for JSON content that is timestamped, can report temporal behavior. * For information about the meaning of the models that the service uses to describe personality characteristics, see [Personality models](https://cloud.ibm.com/docs/services/personality-insights/models.html). * For information about the meaning of the consumption preferences, see [Consumption preferences](https://cloud.ibm.com/docs/services/personality-insights/preferences.html). **Note:** Request logging is disabled for the Personality Insights service. Regardless of whether you set the `X-Watson-Learning-Opt-Out` request header, the service does not log or retain data from requests and responses.
@@ -100,10 +101,6 @@ class PersonalityInsightsV3 extends BaseService {
100101
* less text; for more information, see [Providing sufficient
101102
* input](https://cloud.ibm.com/docs/services/personality-insights/input.html#sufficient). For JSON input, provide an
102103
* object of type `Content`.
103-
* @param {string} [params.content_type] - The type of the input. For more information, see **Content types** in the
104-
* method description.
105-
*
106-
* Default: `text/plain`.
107104
* @param {string} [params.content_language] - The language of the input text for the request: Arabic, English,
108105
* Japanese, Korean, or Spanish. Regional variants are treated as their parent language; for example, `en-US` is
109106
* interpreted as `en`.
@@ -124,9 +121,13 @@ class PersonalityInsightsV3 extends BaseService {
124121
* default, no column labels are returned. Applies only when the response type is CSV (`text/csv`).
125122
* @param {boolean} [params.consumption_preferences] - Indicates whether consumption preferences are returned with the
126123
* results. By default, no consumption preferences are returned.
124+
* @param {string} [params.content_type] - The type of the input. For more information, see **Content types** in the
125+
* method description.
126+
*
127+
* Default: `text/plain`.
127128
* @param {Object} [params.headers] - Custom request headers
128129
* @param {Function} [callback] - The callback that handles the response.
129-
* @returns {NodeJS.ReadableStream|void}
130+
* @returns {Promise<any>|void}
130131
*/
131132
public profile(params: PersonalityInsightsV3.ProfileParams, callback?: PersonalityInsightsV3.Callback<PersonalityInsightsV3.Profile>): Promise<any> | void {
132133
const _params = extend({}, params);
@@ -154,21 +155,20 @@ class PersonalityInsightsV3 extends BaseService {
154155
};
155156

156157
const sdkHeaders = getSdkHeaders('personality_insights', 'v3', 'profile');
157-
158+
158159
const parameters = {
159160
options: {
160161
url: '/v3/profile',
161162
method: 'POST',
162-
json: (_params.content_type === 'application/json'),
163163
body,
164164
qs: query,
165165
},
166166
defaultOptions: extend(true, {}, this._options, {
167167
headers: extend(true, sdkHeaders, {
168168
'Accept': 'application/json',
169-
'Content-Type': _params.content_type,
170169
'Content-Language': _params.content_language,
171-
'Accept-Language': _params.accept_language
170+
'Accept-Language': _params.accept_language,
171+
'Content-Type': _params.content_type
172172
}, _params.headers),
173173
}),
174174
};
@@ -216,10 +216,6 @@ class PersonalityInsightsV3 extends BaseService {
216216
* less text; for more information, see [Providing sufficient
217217
* input](https://cloud.ibm.com/docs/services/personality-insights/input.html#sufficient). For JSON input, provide an
218218
* object of type `Content`.
219-
* @param {string} [params.content_type] - The type of the input. For more information, see **Content types** in the
220-
* method description.
221-
*
222-
* Default: `text/plain`.
223219
* @param {string} [params.content_language] - The language of the input text for the request: Arabic, English,
224220
* Japanese, Korean, or Spanish. Regional variants are treated as their parent language; for example, `en-US` is
225221
* interpreted as `en`.
@@ -240,9 +236,13 @@ class PersonalityInsightsV3 extends BaseService {
240236
* default, no column labels are returned. Applies only when the response type is CSV (`text/csv`).
241237
* @param {boolean} [params.consumption_preferences] - Indicates whether consumption preferences are returned with the
242238
* results. By default, no consumption preferences are returned.
239+
* @param {string} [params.content_type] - The type of the input. For more information, see **Content types** in the
240+
* method description.
241+
*
242+
* Default: `text/plain`.
243243
* @param {Object} [params.headers] - Custom request headers
244244
* @param {Function} [callback] - The callback that handles the response.
245-
* @returns {NodeJS.ReadableStream|void}
245+
* @returns {Promise<any>|void}
246246
*/
247247
public profileAsCsv(params: PersonalityInsightsV3.ProfileAsCsvParams, callback?: PersonalityInsightsV3.Callback<NodeJS.ReadableStream|FileObject|Buffer>): Promise<any> | void {
248248
const _params = extend({}, params);
@@ -270,21 +270,20 @@ class PersonalityInsightsV3 extends BaseService {
270270
};
271271

272272
const sdkHeaders = getSdkHeaders('personality_insights', 'v3', 'profileAsCsv');
273-
273+
274274
const parameters = {
275275
options: {
276276
url: '/v3/profile',
277277
method: 'POST',
278-
json: (_params.content_type === 'application/json'),
279278
body,
280279
qs: query,
281280
},
282281
defaultOptions: extend(true, {}, this._options, {
283282
headers: extend(true, sdkHeaders, {
284283
'Accept': 'text/csv',
285-
'Content-Type': _params.content_type,
286284
'Content-Language': _params.content_language,
287-
'Accept-Language': _params.accept_language
285+
'Accept-Language': _params.accept_language,
286+
'Content-Type': _params.content_type
288287
}, _params.headers),
289288
}),
290289
};
@@ -330,8 +329,6 @@ namespace PersonalityInsightsV3 {
330329
export interface ProfileParams {
331330
/** A maximum of 20 MB of content to analyze, though the service requires much less text; for more information, see [Providing sufficient input](https://cloud.ibm.com/docs/services/personality-insights/input.html#sufficient). For JSON input, provide an object of type `Content`. */
332331
content: Content|string;
333-
/** The type of the input. For more information, see **Content types** in the method description. Default: `text/plain`. */
334-
content_type?: ProfileConstants.ContentType | string;
335332
/** The language of the input text for the request: Arabic, English, Japanese, Korean, or Spanish. Regional variants are treated as their parent language; for example, `en-US` is interpreted as `en`. The effect of the **Content-Language** parameter depends on the **Content-Type** parameter. When **Content-Type** is `text/plain` or `text/html`, **Content-Language** is the only way to specify the language. When **Content-Type** is `application/json`, **Content-Language** overrides a language specified with the `language` parameter of a `ContentItem` object, and content items that specify a different language are ignored; omit this parameter to base the language on the specification of the content items. You can specify any combination of languages for **Content-Language** and **Accept-Language**. */
336333
content_language?: ProfileConstants.ContentLanguage | string;
337334
/** The desired language of the response. For two-character arguments, regional variants are treated as their parent language; for example, `en-US` is interpreted as `en`. You can specify any combination of languages for the input and response content. */
@@ -342,18 +339,14 @@ namespace PersonalityInsightsV3 {
342339
csv_headers?: boolean;
343340
/** Indicates whether consumption preferences are returned with the results. By default, no consumption preferences are returned. */
344341
consumption_preferences?: boolean;
342+
/** The type of the input. For more information, see **Content types** in the method description. Default: `text/plain`. */
343+
content_type?: ProfileConstants.ContentType | string;
345344
headers?: Object;
346345
return_response?: boolean;
347346
}
348347

349348
/** Constants for the `profile` operation. */
350349
export namespace ProfileConstants {
351-
/** The type of the input. For more information, see **Content types** in the method description. Default: `text/plain`. */
352-
export enum ContentType {
353-
APPLICATION_JSON = 'application/json',
354-
TEXT_HTML = 'text/html',
355-
TEXT_PLAIN = 'text/plain',
356-
}
357350
/** The language of the input text for the request: Arabic, English, Japanese, Korean, or Spanish. Regional variants are treated as their parent language; for example, `en-US` is interpreted as `en`. The effect of the **Content-Language** parameter depends on the **Content-Type** parameter. When **Content-Type** is `text/plain` or `text/html`, **Content-Language** is the only way to specify the language. When **Content-Type** is `application/json`, **Content-Language** overrides a language specified with the `language` parameter of a `ContentItem` object, and content items that specify a different language are ignored; omit this parameter to base the language on the specification of the content items. You can specify any combination of languages for **Content-Language** and **Accept-Language**. */
358351
export enum ContentLanguage {
359352
AR = 'ar',
@@ -376,14 +369,18 @@ namespace PersonalityInsightsV3 {
376369
ZH_CN = 'zh-cn',
377370
ZH_TW = 'zh-tw',
378371
}
372+
/** The type of the input. For more information, see **Content types** in the method description. Default: `text/plain`. */
373+
export enum ContentType {
374+
APPLICATION_JSON = 'application/json',
375+
TEXT_HTML = 'text/html',
376+
TEXT_PLAIN = 'text/plain',
377+
}
379378
}
380379

381380
/** Parameters for the `profileAsCsv` operation. */
382381
export interface ProfileAsCsvParams {
383382
/** A maximum of 20 MB of content to analyze, though the service requires much less text; for more information, see [Providing sufficient input](https://cloud.ibm.com/docs/services/personality-insights/input.html#sufficient). For JSON input, provide an object of type `Content`. */
384383
content: Content|string;
385-
/** The type of the input. For more information, see **Content types** in the method description. Default: `text/plain`. */
386-
content_type?: ProfileAsCsvConstants.ContentType | string;
387384
/** The language of the input text for the request: Arabic, English, Japanese, Korean, or Spanish. Regional variants are treated as their parent language; for example, `en-US` is interpreted as `en`. The effect of the **Content-Language** parameter depends on the **Content-Type** parameter. When **Content-Type** is `text/plain` or `text/html`, **Content-Language** is the only way to specify the language. When **Content-Type** is `application/json`, **Content-Language** overrides a language specified with the `language` parameter of a `ContentItem` object, and content items that specify a different language are ignored; omit this parameter to base the language on the specification of the content items. You can specify any combination of languages for **Content-Language** and **Accept-Language**. */
388385
content_language?: ProfileAsCsvConstants.ContentLanguage | string;
389386
/** The desired language of the response. For two-character arguments, regional variants are treated as their parent language; for example, `en-US` is interpreted as `en`. You can specify any combination of languages for the input and response content. */
@@ -394,18 +391,14 @@ namespace PersonalityInsightsV3 {
394391
csv_headers?: boolean;
395392
/** Indicates whether consumption preferences are returned with the results. By default, no consumption preferences are returned. */
396393
consumption_preferences?: boolean;
394+
/** The type of the input. For more information, see **Content types** in the method description. Default: `text/plain`. */
395+
content_type?: ProfileAsCsvConstants.ContentType | string;
397396
headers?: Object;
398397
return_response?: boolean;
399398
}
400399

401400
/** Constants for the `profileAsCsv` operation. */
402401
export namespace ProfileAsCsvConstants {
403-
/** The type of the input. For more information, see **Content types** in the method description. Default: `text/plain`. */
404-
export enum ContentType {
405-
APPLICATION_JSON = 'application/json',
406-
TEXT_HTML = 'text/html',
407-
TEXT_PLAIN = 'text/plain',
408-
}
409402
/** The language of the input text for the request: Arabic, English, Japanese, Korean, or Spanish. Regional variants are treated as their parent language; for example, `en-US` is interpreted as `en`. The effect of the **Content-Language** parameter depends on the **Content-Type** parameter. When **Content-Type** is `text/plain` or `text/html`, **Content-Language** is the only way to specify the language. When **Content-Type** is `application/json`, **Content-Language** overrides a language specified with the `language` parameter of a `ContentItem` object, and content items that specify a different language are ignored; omit this parameter to base the language on the specification of the content items. You can specify any combination of languages for **Content-Language** and **Accept-Language**. */
410403
export enum ContentLanguage {
411404
AR = 'ar',
@@ -428,6 +421,12 @@ namespace PersonalityInsightsV3 {
428421
ZH_CN = 'zh-cn',
429422
ZH_TW = 'zh-tw',
430423
}
424+
/** The type of the input. For more information, see **Content types** in the method description. Default: `text/plain`. */
425+
export enum ContentType {
426+
APPLICATION_JSON = 'application/json',
427+
TEXT_HTML = 'text/html',
428+
TEXT_PLAIN = 'text/plain',
429+
}
431430
}
432431

433432
/*************************

test/integration/personality_insights.v3.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('personality_insights_v3_integration', function() {
1212
jest.setTimeout(TWENTY_SECONDS);
1313

1414
const mobydick = fs.readFileSync(path.join(__dirname, '../resources/mobydick.txt'), 'utf8');
15-
auth.personality_insights.version = '2016-10-19';
15+
auth.personality_insights.version = '2019-03-27';
1616
const personality_insights = new PersonalityInsightsV3(auth.personality_insights);
1717

1818
it('profile with text content', function(done) {

0 commit comments

Comments
 (0)