UNPKG

@planet-a/affinity-node

Version:
475 lines (474 loc) 29.8 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 NotesApiRequestFactory extends BaseAPIRequestFactory { /** * | ⚠️ This endpoint is currently in BETA | |--| Returns all notes, with the exception of replies. 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** | |-----------------------------|-----------------------------------------------------------------|------------|--------------------------------------|---------------------------------| | `id` | Filter notes by id | `int32` | `=` | `id=1` | | `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 all Notes * @param totalCount Include total count of the collection in the pagination response * @param cursor Cursor for the next or previous page * @param limit Number of items to include in the page * @param filter Filter options * @param includes Additional properties to include in the response */ async v2NotesGET(totalCount, cursor, limit, filter, includes, _options) { let _config = _options || this.configuration; // Path Params const localVarPath = '/v2/notes'; // Make Request Context const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); // Query Params if (totalCount !== undefined) { requestContext.setQueryParam("totalCount", ObjectSerializer.serialize(totalCount, "boolean", "")); } // 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", "")); } // Query Params if (includes !== undefined) { const serializedParams = ObjectSerializer.serialize(includes, "Set<'companiesPreview' | 'personsPreview' | 'opportunitiesPreview' | 'repliesCount'>", ""); for (const serializedParam of serializedParams) { requestContext.appendQueryParam("includes", 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; } /** * | ⚠️ This endpoint is currently in BETA | |--| Returns directly attached companies for a given Note. * Get Companies attached to a Note * @param noteId The id of the Note to get attached Companies * @param totalCount Include total count of the collection in the pagination response * @param cursor Cursor for the next or previous page * @param limit Number of items to include in the page */ async v2NotesNoteIdAttachedCompaniesGET(noteId, totalCount, cursor, limit, _options) { let _config = _options || this.configuration; // verify required parameter 'noteId' is not null or undefined if (noteId === null || noteId === undefined) { throw new RequiredError("NotesApi", "v2NotesNoteIdAttachedCompaniesGET", "noteId"); } // Path Params const localVarPath = '/v2/notes/{noteId}/attached-companies' .replace('{' + 'noteId' + '}', encodeURIComponent(String(noteId))); // Make Request Context const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); // Query Params if (totalCount !== undefined) { requestContext.setQueryParam("totalCount", ObjectSerializer.serialize(totalCount, "boolean", "")); } // 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 directly attached opportunities for a given Note. * Get Opportunities attached to a Note * @param noteId The id of the Note to get attached Opportunities * @param totalCount Include total count of the collection in the pagination response * @param cursor Cursor for the next or previous page * @param limit Number of items to include in the page */ async v2NotesNoteIdAttachedOpportunitiesGET(noteId, totalCount, cursor, limit, _options) { let _config = _options || this.configuration; // verify required parameter 'noteId' is not null or undefined if (noteId === null || noteId === undefined) { throw new RequiredError("NotesApi", "v2NotesNoteIdAttachedOpportunitiesGET", "noteId"); } // Path Params const localVarPath = '/v2/notes/{noteId}/attached-opportunities' .replace('{' + 'noteId' + '}', encodeURIComponent(String(noteId))); // Make Request Context const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); // Query Params if (totalCount !== undefined) { requestContext.setQueryParam("totalCount", ObjectSerializer.serialize(totalCount, "boolean", "")); } // 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 directly attached persons for a given Note. * Get Persons attached to a Note * @param noteId The id of the Note to get attached Persons * @param totalCount Include total count of the collection in the pagination response * @param cursor Cursor for the next or previous page * @param limit Number of items to include in the page */ async v2NotesNoteIdAttachedPersonsGET(noteId, totalCount, cursor, limit, _options) { let _config = _options || this.configuration; // verify required parameter 'noteId' is not null or undefined if (noteId === null || noteId === undefined) { throw new RequiredError("NotesApi", "v2NotesNoteIdAttachedPersonsGET", "noteId"); } // Path Params const localVarPath = '/v2/notes/{noteId}/attached-persons' .replace('{' + 'noteId' + '}', encodeURIComponent(String(noteId))); // Make Request Context const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); // Query Params if (totalCount !== undefined) { requestContext.setQueryParam("totalCount", ObjectSerializer.serialize(totalCount, "boolean", "")); } // 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 | |--| Get a Note with a given id * Get a single Note * @param noteId The id of the Note * @param includes Additional properties to include in the response */ async v2NotesNoteIdGET(noteId, includes, _options) { let _config = _options || this.configuration; // verify required parameter 'noteId' is not null or undefined if (noteId === null || noteId === undefined) { throw new RequiredError("NotesApi", "v2NotesNoteIdGET", "noteId"); } // Path Params const localVarPath = '/v2/notes/{noteId}' .replace('{' + 'noteId' + '}', encodeURIComponent(String(noteId))); // Make Request Context const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); // Query Params if (includes !== undefined) { const serializedParams = ObjectSerializer.serialize(includes, "Set<'companiesPreview' | 'personsPreview' | 'opportunitiesPreview' | 'repliesCount'>", ""); for (const serializedParam of serializedParams) { requestContext.appendQueryParam("includes", 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; } /** * | ⚠️ This endpoint is currently in BETA | |--| This endpoint returns reply notes for a given note id. You can filter replies 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 replies for a Note * @param noteId Note 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 v2NotesNoteIdRepliesGET(noteId, filter, cursor, limit, totalCount, _options) { let _config = _options || this.configuration; // verify required parameter 'noteId' is not null or undefined if (noteId === null || noteId === undefined) { throw new RequiredError("NotesApi", "v2NotesNoteIdRepliesGET", "noteId"); } // Path Params const localVarPath = '/v2/notes/{noteId}/replies' .replace('{' + 'noteId' + '}', encodeURIComponent(String(noteId))); // 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; } } export class NotesApiResponseProcessor { /** * 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 v2NotesGET * @throws ApiException if the response code was not in [200, 299] */ async v2NotesGETWithHttpInfo(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 v2NotesNoteIdAttachedCompaniesGET * @throws ApiException if the response code was not in [200, 299] */ async v2NotesNoteIdAttachedCompaniesGETWithHttpInfo(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), "CompanyDataPaged", ""); 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), "CompanyDataPaged", ""); 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 v2NotesNoteIdAttachedOpportunitiesGET * @throws ApiException if the response code was not in [200, 299] */ async v2NotesNoteIdAttachedOpportunitiesGETWithHttpInfo(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), "OpportunityPaged", ""); 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), "OpportunityPaged", ""); 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 v2NotesNoteIdAttachedPersonsGET * @throws ApiException if the response code was not in [200, 299] */ async v2NotesNoteIdAttachedPersonsGETWithHttpInfo(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), "PersonDataPaged", ""); 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), "PersonDataPaged", ""); 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 v2NotesNoteIdGET * @throws ApiException if the response code was not in [200, 299] */ async v2NotesNoteIdGETWithHttpInfo(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), "NotesNote", ""); 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), "NotesNote", ""); 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 v2NotesNoteIdRepliesGET * @throws ApiException if the response code was not in [200, 299] */ async v2NotesNoteIdRepliesGETWithHttpInfo(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), "NotesRepliesPaged", ""); 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), "NotesRepliesPaged", ""); return new HttpInfo(response.httpStatusCode, response.headers, response.body, body); } throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); } }