UNPKG

@planet-a/affinity-node

Version:
472 lines (471 loc) 30 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 CompaniesApiRequestFactory extends BaseAPIRequestFactory { /** * Returns basic information and non-list-specific field data on the requested Company. To retrieve field data, you must use either the `fieldIds` or the `fieldTypes` parameter to specify the Fields for which you want data returned. These Field IDs and Types can be found using the GET `/v2/companies/fields` endpoint. When no `fieldIds` or `fieldTypes` are provided, Companies will be returned without any field data attached. To supply multiple `fieldIds` or `fieldTypes` parameters, generate a query string that looks like this: `?fieldIds=field-1234&fieldIds=affinity-data-location` or `?fieldTypes=enriched&fieldTypes=global`. Requires the \"Export All Organizations directory\" [permission](#section/Getting-Started/Permissions). * Get a single Company * @param companyId Company ID * @param fieldIds Field IDs for which to return field data * @param fieldTypes Field Types for which to return field data */ async v2CompaniesCompanyIdGET(companyId, fieldIds, fieldTypes, _options) { let _config = _options || this.configuration; // verify required parameter 'companyId' is not null or undefined if (companyId === null || companyId === undefined) { throw new RequiredError("CompaniesApi", "v2CompaniesCompanyIdGET", "companyId"); } // Path Params const localVarPath = '/v2/companies/{companyId}' .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); // Make Request Context const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); // Query Params if (fieldIds !== undefined) { const serializedParams = ObjectSerializer.serialize(fieldIds, "Array<string>", ""); for (const serializedParam of serializedParams) { requestContext.appendQueryParam("fieldIds", serializedParam); } } // Query Params if (fieldTypes !== undefined) { const serializedParams = ObjectSerializer.serialize(fieldTypes, "Array<'enriched' | 'global' | 'relationship-intelligence'>", ""); for (const serializedParam of serializedParams) { requestContext.appendQueryParam("fieldTypes", serializedParam); } } 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; } /** * Paginate through the List Entries (AKA rows) for the given Company across all Lists. Each List Entry includes field data for the Company, including list-specific field data. Each List Entry also includes metadata about its creation, i.e., when it was added to the List and by whom. Requires the \"Export data from Lists\" [permission](#section/Getting-Started/Permissions). * Get a Company\'s List Entries * @param companyId Company ID * @param cursor Cursor for the next or previous page * @param limit Number of items to include in the page */ async v2CompaniesCompanyIdListEntriesGET(companyId, cursor, limit, _options) { let _config = _options || this.configuration; // verify required parameter 'companyId' is not null or undefined if (companyId === null || companyId === undefined) { throw new RequiredError("CompaniesApi", "v2CompaniesCompanyIdListEntriesGET", "companyId"); } // Path Params const localVarPath = '/v2/companies/{companyId}/list-entries' .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); // 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")); } 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; } /** * Paginate through all Lists where the given Company appears as an entry and that you have access to view. Returns basic List information for each List that contains this Company. * Get a Company\'s Lists * @param companyId Company ID * @param cursor Cursor for the next or previous page * @param limit Number of items to include in the page */ async v2CompaniesCompanyIdListsGET(companyId, cursor, limit, _options) { let _config = _options || this.configuration; // verify required parameter 'companyId' is not null or undefined if (companyId === null || companyId === undefined) { throw new RequiredError("CompaniesApi", "v2CompaniesCompanyIdListsGET", "companyId"); } // Path Params const localVarPath = '/v2/companies/{companyId}/lists' .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); // 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")); } 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; } /** * | ⚠️ This endpoint is currently in BETA | |--| Returns relevant notes for a given company which includes directly attached notes and notes attached to persons on this company. You can filter notes using the `filter` query parameter. The filter parameter is a string that you can specify conditions based on the following properties. | **Property Name** | **Description** | **Type** | **Allowed Operators** | **Examples** | |-----------------------------|-----------------------------------------------------------------|------------|--------------------------------------|---------------------------------| | `creator.id` | Filter notes by the creator of the note | `int32` | `=` | `creator.id=1` | | `createdAt` | Filter notes by when it was created | `datetime` | `>`, `<`, `>=`, `<=` | `createdAt<2025-02-04T10:48:24Z` | | `updatedAt` | Filter notes by when it was updated | `datetime` | `>`, `<`, `>=`, `<=` | `updatedAt>=2025-02-03T10:48:24Z`| * Get Notes for a Company * @param companyId Company\&#39;s ID * @param filter Filter options * @param cursor Cursor for the next or previous page * @param limit Number of items to include in the page * @param totalCount Include total count of the collection in the pagination response */ async v2CompaniesCompanyIdNotesGET(companyId, filter, cursor, limit, totalCount, _options) { let _config = _options || this.configuration; // verify required parameter 'companyId' is not null or undefined if (companyId === null || companyId === undefined) { throw new RequiredError("CompaniesApi", "v2CompaniesCompanyIdNotesGET", "companyId"); } // Path Params const localVarPath = '/v2/companies/{companyId}/notes' .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); // Make Request Context const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); // Query Params if (filter !== undefined) { requestContext.setQueryParam("filter", ObjectSerializer.serialize(filter, "string", "")); } // 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 (totalCount !== undefined) { requestContext.setQueryParam("totalCount", ObjectSerializer.serialize(totalCount, "boolean", "")); } 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; } /** * Returns metadata on non-list-specific Company Fields. Use the returned Field IDs to request field data from the GET `/v2/companies` and GET `/v2/companies/{id}` endpoints. * Get metadata on Company Fields * @param cursor Cursor for the next or previous page * @param limit Number of items to include in the page */ async v2CompaniesFieldsGET(cursor, limit, _options) { let _config = _options || this.configuration; // Path Params const localVarPath = '/v2/companies/fields'; // 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")); } 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; } /** * Paginate through Companies in Affinity. Returns basic information and non-list-specific field data on each Company. To retrieve field data, you must use either the `fieldIds` or the `fieldTypes` parameter to specify the Fields for which you want data returned. These Field IDs and Types can be found using the GET `/v2/companies/fields` endpoint. When no `fieldIds` or `fieldTypes` are provided, Companies will be returned without any field data attached. To supply multiple `fieldIds` or `fieldTypes` parameters, generate a query string that looks like this: `?fieldIds=field-1234&fieldIds=affinity-data-location` or `?fieldTypes=enriched&fieldTypes=global`. Requires the \"Export All Organizations directory\" [permission](#section/Getting-Started/Permissions). * Get all Companies * @param cursor Cursor for the next or previous page * @param limit Number of items to include in the page * @param ids Company IDs * @param fieldIds Field IDs for which to return field data * @param fieldTypes Field Types for which to return field data */ async v2CompaniesGET(cursor, limit, ids, fieldIds, fieldTypes, _options) { let _config = _options || this.configuration; // Path Params const localVarPath = '/v2/companies'; // 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 (ids !== undefined) { const serializedParams = ObjectSerializer.serialize(ids, "Array<number>", "int64"); for (const serializedParam of serializedParams) { requestContext.appendQueryParam("ids", serializedParam); } } // Query Params if (fieldIds !== undefined) { const serializedParams = ObjectSerializer.serialize(fieldIds, "Array<string>", ""); for (const serializedParam of serializedParams) { requestContext.appendQueryParam("fieldIds", serializedParam); } } // Query Params if (fieldTypes !== undefined) { const serializedParams = ObjectSerializer.serialize(fieldTypes, "Array<'enriched' | 'global' | 'relationship-intelligence'>", ""); for (const serializedParam of serializedParams) { requestContext.appendQueryParam("fieldTypes", serializedParam); } } 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 CompaniesApiResponseProcessor { /** * 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 v2CompaniesCompanyIdGET * @throws ApiException if the response code was not in [200, 299] */ async v2CompaniesCompanyIdGETWithHttpInfo(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), "Company", ""); 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), "Company", ""); 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 v2CompaniesCompanyIdListEntriesGET * @throws ApiException if the response code was not in [200, 299] */ async v2CompaniesCompanyIdListEntriesGETWithHttpInfo(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), "ListEntryPaged", ""); 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), "ListEntryPaged", ""); 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 v2CompaniesCompanyIdListsGET * @throws ApiException if the response code was not in [200, 299] */ async v2CompaniesCompanyIdListsGETWithHttpInfo(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), "ListPaged", ""); 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("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), "ListPaged", ""); 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 v2CompaniesCompanyIdNotesGET * @throws ApiException if the response code was not in [200, 299] */ async v2CompaniesCompanyIdNotesGETWithHttpInfo(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), "NotesNotesPaged", ""); 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("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), "NotesNotesPaged", ""); 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 v2CompaniesFieldsGET * @throws ApiException if the response code was not in [200, 299] */ async v2CompaniesFieldsGETWithHttpInfo(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), "FieldMetadataPaged", ""); 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("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), "FieldMetadataPaged", ""); 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 v2CompaniesGET * @throws ApiException if the response code was not in [200, 299] */ async v2CompaniesGETWithHttpInfo(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), "CompanyPaged", ""); 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), "CompanyPaged", ""); return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); } throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); } }