UNPKG

@planet-a/affinity-node

Version:
351 lines (350 loc) 23.5 kB
// TODO: better import syntax? import { BaseAPIRequestFactory, RequiredError } from './baseapi.js'; import { HttpMethod, HttpInfo } from '../http/http.js'; import { ObjectSerializer } from '../models/ObjectSerializer.js'; import { ApiException } from './exception.js'; import { isCodeInRange } from '../util.js'; /** * no description */ export class PersonMergesApiRequestFactory extends BaseAPIRequestFactory { /** * Retrieve paginated person merges for the organization. Returns all person merges initiated by users in your organization, including their current status, the persons involved, and merge details. You can filter person merges using the `filter` query parameter. The filter parameter is a string that you can specify conditions based on the following properties: | Property | Type | Operators | Values | Examples | |----------|------|-----------|--------|----------| | `status` | `enum` | `=` | `in-progress`, `success`, `failed` | `status=failed` | | `taskId` | `string` | `=` | | `taskId=789e0123-e45b-67c8-d901-234567890123` | Person merges are returned in reverse chronological order (most recent first). Requires the \"Manage duplicates\" [permission](#section/Getting-Started/Permissions) and organization admin role. * Get All Person Merges * @param cursor Cursor for the next or previous page * @param limit Number of items to include in the page * @param filter Filter person merges using Affinity Filtering Language */ async v2PersonMergesGET(cursor, limit, filter, _options) { let _config = _options || this.configuration; // Path Params const localVarPath = '/v2/person-merges'; // Make Request Context const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); // Query Params if (cursor !== undefined) { requestContext.setQueryParam("cursor", ObjectSerializer.serialize(cursor, "string", "")); } // Query Params if (limit !== undefined) { requestContext.setQueryParam("limit", ObjectSerializer.serialize(limit, "number", "int32")); } // Query Params if (filter !== undefined) { requestContext.setQueryParam("filter", ObjectSerializer.serialize(filter, "string", "")); } let authMethod; // Apply auth methods authMethod = _config.authMethods["bearerAuth"]; if (authMethod?.applySecurityAuthentication) { await authMethod?.applySecurityAuthentication(requestContext); } const defaultAuth = _config?.authMethods?.default; if (defaultAuth?.applySecurityAuthentication) { await defaultAuth?.applySecurityAuthentication(requestContext); } return requestContext; } /** * Retrieve the status and details of a specific person merge. Returns information about the person merge including its current status, the persons involved, timestamps, and any error information if the merge failed. The `mergeId` can be obtained from the response of the [Get All Person Merges](#tag/personMerges/operation/v2_person-merges__GET) endpoint, or by filtering person merges by task ID using `/v2/person-merges?filter=taskId={taskId}` after initiating a merge. Requires the \"Manage duplicates\" [permission](#section/Getting-Started/Permissions) and organization admin role. * Get Person Merge * @param mergeId Person merge ID */ async v2PersonMergesMergeIdGET(mergeId, _options) { let _config = _options || this.configuration; // verify required parameter 'mergeId' is not null or undefined if (mergeId === null || mergeId === undefined) { throw new RequiredError("PersonMergesApi", "v2PersonMergesMergeIdGET", "mergeId"); } // Path Params const localVarPath = '/v2/person-merges/{mergeId}' .replace('{' + 'mergeId' + '}', encodeURIComponent(String(mergeId))); // Make Request Context const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); let authMethod; // Apply auth methods authMethod = _config.authMethods["bearerAuth"]; if (authMethod?.applySecurityAuthentication) { await authMethod?.applySecurityAuthentication(requestContext); } const defaultAuth = _config?.authMethods?.default; if (defaultAuth?.applySecurityAuthentication) { await defaultAuth?.applySecurityAuthentication(requestContext); } return requestContext; } /** * Initiate a person merge to combine a duplicate person profile into a primary person profile. This is an asynchronous process that will merge all data from the duplicate person into the primary person. Once the merge is initiated, you can track its progress using the returned [task URL](#tag/personMerges/operation/v2_tasks_person-merges_taskId__GET). Requires the \"Manage duplicates\" [permission](#section/Getting-Started/Permissions) and organization admin role. * Initiate Person Merge * @param personMergeRequest */ async v2PersonMergesPOST(personMergeRequest, _options) { let _config = _options || this.configuration; // verify required parameter 'personMergeRequest' is not null or undefined if (personMergeRequest === null || personMergeRequest === undefined) { throw new RequiredError("PersonMergesApi", "v2PersonMergesPOST", "personMergeRequest"); } // Path Params const localVarPath = '/v2/person-merges'; // Make Request Context const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); // Body Params const contentType = ObjectSerializer.getPreferredMediaType([ "application/json" ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer.stringify(ObjectSerializer.serialize(personMergeRequest, "PersonMergeRequest", ""), contentType); requestContext.setBody(serializedBody); let authMethod; // Apply auth methods authMethod = _config.authMethods["bearerAuth"]; if (authMethod?.applySecurityAuthentication) { await authMethod?.applySecurityAuthentication(requestContext); } const defaultAuth = _config?.authMethods?.default; if (defaultAuth?.applySecurityAuthentication) { await defaultAuth?.applySecurityAuthentication(requestContext); } return requestContext; } /** * Retrieve paginated person merge tasks for the organization. Returns all merge tasks initiated by users in your organization, including their current status, the persons involved, and task details. You can filter tasks using the `filter` query parameter. The filter parameter is a string that you can specify conditions based on the following properties: | Property | Type | Operators | Values | Examples | |----------|------|-----------|--------|----------| | `status` | `enum` | `=` | `in-progress`, `success`, `failed` | `status=failed` | Tasks are returned in reverse chronological order (most recent first). Requires the \"Manage duplicates\" [permission](#section/Getting-Started/Permissions) and organization admin role. * Get All Person Merge Tasks * @param cursor Cursor for the next or previous page * @param limit Number of items to include in the page * @param filter Filter tasks using Affinity Filtering Language */ async v2TasksPersonMergesGET(cursor, limit, filter, _options) { let _config = _options || this.configuration; // Path Params const localVarPath = '/v2/tasks/person-merges'; // Make Request Context const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); // Query Params if (cursor !== undefined) { requestContext.setQueryParam("cursor", ObjectSerializer.serialize(cursor, "string", "")); } // Query Params if (limit !== undefined) { requestContext.setQueryParam("limit", ObjectSerializer.serialize(limit, "number", "int32")); } // Query Params if (filter !== undefined) { requestContext.setQueryParam("filter", ObjectSerializer.serialize(filter, "string", "")); } let authMethod; // Apply auth methods authMethod = _config.authMethods["bearerAuth"]; if (authMethod?.applySecurityAuthentication) { await authMethod?.applySecurityAuthentication(requestContext); } const defaultAuth = _config?.authMethods?.default; if (defaultAuth?.applySecurityAuthentication) { await defaultAuth?.applySecurityAuthentication(requestContext); } return requestContext; } /** * Retrieve the status and details of a specific task for person merges. Returns information about the person merges for a specific task including its overall status, number of merges in-progress, completed, and failed. Detailed information about individual merges for this task can be found by querying: `/v2/person-merges?filter=taskId={taskId}` See [Person Merges](#tag/personMerges/operation/v2_person-merges__GET) for more details. Task statuses: - `in-progress`: The merge task is currently being processed. - `success`: The merge task completed successfully. - `failed`: The merge task failed. Requires the \"Manage duplicates\" [permission](#section/Getting-Started/Permissions) and organization admin role. * Get Person Merge Task * @param taskId Person merge task ID */ async v2TasksPersonMergesTaskIdGET(taskId, _options) { let _config = _options || this.configuration; // verify required parameter 'taskId' is not null or undefined if (taskId === null || taskId === undefined) { throw new RequiredError("PersonMergesApi", "v2TasksPersonMergesTaskIdGET", "taskId"); } // Path Params const localVarPath = '/v2/tasks/person-merges/{taskId}' .replace('{' + 'taskId' + '}', encodeURIComponent(String(taskId))); // Make Request Context const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); let authMethod; // Apply auth methods authMethod = _config.authMethods["bearerAuth"]; if (authMethod?.applySecurityAuthentication) { await authMethod?.applySecurityAuthentication(requestContext); } const defaultAuth = _config?.authMethods?.default; if (defaultAuth?.applySecurityAuthentication) { await defaultAuth?.applySecurityAuthentication(requestContext); } return requestContext; } } export class PersonMergesApiResponseProcessor { /** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects * * @params response Response returned by the server for a request to v2PersonMergesGET * @throws ApiException if the response code was not in [200, 299] */ async v2PersonMergesGETWithHttpInfo(response) { const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "PersonMergeStatePaged", ""); return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); } if (isCodeInRange("400", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "Responses400", ""); throw new ApiException(response.httpStatusCode, "Bad Request", body, response.headers); } if (isCodeInRange("403", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "AuthorizationErrors", ""); throw new ApiException(response.httpStatusCode, "Forbidden", body, response.headers); } if (isCodeInRange("0", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "Errors", ""); throw new ApiException(response.httpStatusCode, "Errors", body, response.headers); } // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "PersonMergeStatePaged", ""); return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); } throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); } /** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects * * @params response Response returned by the server for a request to v2PersonMergesMergeIdGET * @throws ApiException if the response code was not in [200, 299] */ async v2PersonMergesMergeIdGETWithHttpInfo(response) { const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "PersonMergeState", ""); return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); } if (isCodeInRange("400", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "Responses400", ""); throw new ApiException(response.httpStatusCode, "Bad Request", body, response.headers); } if (isCodeInRange("403", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "AuthorizationErrors", ""); throw new ApiException(response.httpStatusCode, "Forbidden", body, response.headers); } if (isCodeInRange("404", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "NotFoundErrors", ""); throw new ApiException(response.httpStatusCode, "Not Found", body, response.headers); } if (isCodeInRange("0", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "Errors", ""); throw new ApiException(response.httpStatusCode, "Errors", body, response.headers); } // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "PersonMergeState", ""); return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); } throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); } /** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects * * @params response Response returned by the server for a request to v2PersonMergesPOST * @throws ApiException if the response code was not in [200, 299] */ async v2PersonMergesPOSTWithHttpInfo(response) { const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("202", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "PersonMergeResponse", ""); return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); } if (isCodeInRange("400", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "Responses400", ""); throw new ApiException(response.httpStatusCode, "Bad Request", body, response.headers); } if (isCodeInRange("403", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "AuthorizationErrors", ""); throw new ApiException(response.httpStatusCode, "Forbidden", body, response.headers); } if (isCodeInRange("0", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "Errors", ""); throw new ApiException(response.httpStatusCode, "Errors", body, response.headers); } // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "PersonMergeResponse", ""); return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); } throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); } /** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects * * @params response Response returned by the server for a request to v2TasksPersonMergesGET * @throws ApiException if the response code was not in [200, 299] */ async v2TasksPersonMergesGETWithHttpInfo(response) { const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "PersonMergeTaskPaged", ""); return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); } if (isCodeInRange("400", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "Responses400", ""); throw new ApiException(response.httpStatusCode, "Bad Request", body, response.headers); } if (isCodeInRange("403", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "AuthorizationErrors", ""); throw new ApiException(response.httpStatusCode, "Forbidden", body, response.headers); } if (isCodeInRange("0", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "Errors", ""); throw new ApiException(response.httpStatusCode, "Errors", body, response.headers); } // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "PersonMergeTaskPaged", ""); return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); } throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); } /** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects * * @params response Response returned by the server for a request to v2TasksPersonMergesTaskIdGET * @throws ApiException if the response code was not in [200, 299] */ async v2TasksPersonMergesTaskIdGETWithHttpInfo(response) { const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "PersonMergeTask", ""); return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); } if (isCodeInRange("400", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "Responses400", ""); throw new ApiException(response.httpStatusCode, "Bad Request", body, response.headers); } if (isCodeInRange("403", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "AuthorizationErrors", ""); throw new ApiException(response.httpStatusCode, "Forbidden", body, response.headers); } if (isCodeInRange("404", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "NotFoundErrors", ""); throw new ApiException(response.httpStatusCode, "Not Found", body, response.headers); } if (isCodeInRange("0", response.httpStatusCode)) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "Errors", ""); throw new ApiException(response.httpStatusCode, "Errors", body, response.headers); } // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const body = ObjectSerializer.deserialize(ObjectSerializer.parse(await response.body.text(), contentType), "PersonMergeTask", ""); return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); } throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); } }