// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import { APIPromise } from '../../core/api-promise'; import { PageCursorURL, PagePromise } from '../../core/pagination'; import { buildHeaders } from '../../internal/headers'; import { RequestOptions } from '../../internal/request-options'; import { path } from '../../internal/utils/path'; /** * Custom object datarows defined by the company */ export class Records extends APIResource { /** * A list of custom object records. * * - Requires: `API Tier 1` */ list( customObjectAPIName: string, options?: RequestOptions, ): PagePromise { return this._client.getAPIList( path`/custom-objects/${customObjectAPIName}/records/`, PageCursorURL, options, ); } /** * Create a new custom object record. */ create( customObjectAPIName: string, body: RecordCreateParams | null | undefined = undefined, options?: RequestOptions, ): APIPromise { return this._client.post(path`/custom-objects/${customObjectAPIName}/records/`, { body, ...options }); } /** * A list of custom object records filtered by query. */ query( customObjectAPIName: string, body: RecordQueryParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.post(path`/custom-objects/${customObjectAPIName}/records/query/`, { body, ...options, }); } /** * Retrieve a specific custom object record. */ retrieve( customObjectAPIName: string, codrID: string, options?: RequestOptions, ): APIPromise { return this._client.get(path`/custom-objects/${customObjectAPIName}/records/${codrID}/`, options); } /** * Update a specific custom object record. */ update( customObjectAPIName: string, codrID: string, body: RecordUpdateParams | null | undefined = undefined, options?: RequestOptions, ): APIPromise { return this._client.patch(path`/custom-objects/${customObjectAPIName}/records/${codrID}/`, { body, ...options, }); } /** * Delete a custom object record. */ delete(customObjectAPIName: string, codrID: string, options?: RequestOptions): APIPromise { return this._client.delete(path`/custom-objects/${customObjectAPIName}/records/${codrID}/`, { ...options, headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), }); } /** * Retrieve a specific custom object record by its external_id. */ retrieveByExternalID( customObjectAPIName: string, externalID: string, options?: RequestOptions, ): APIPromise { return this._client.get( path`/custom-objects/${customObjectAPIName}/records/external_id/${externalID}/`, options, ); } /** * Bulk create new custom object records. */ bulkCreate( customObjectAPIName: string, body: RecordBulkCreateParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.post(path`/custom-objects/${customObjectAPIName}/records/bulk/`, { body, ...options, }); } /** * Bulk update custom object records. */ bulkUpdate( customObjectAPIName: string, body: RecordBulkUpdateParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.patch(path`/custom-objects/${customObjectAPIName}/records/bulk/`, { body, ...options, }); } /** * Bulk delete custom object records. */ bulkDelete( customObjectAPIName: string, body: RecordBulkDeleteParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.post(path`/custom-objects/${customObjectAPIName}/records/bulk-delete/`, { body, ...options, headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), }); } } export type CustomObjectDataRowsPageCursorURL = PageCursorURL; export interface CustomObjectDataRow { /** * Identifier field */ id: string; /** * Record creation date */ created_at: string; /** * The name of the custom object datarow */ name: string; /** * Record update date */ updated_at: string; created_by?: CustomObjectDataRow.CreatedBy; /** * The external id of the custom object datarow */ external_id?: string; last_modified_by?: CustomObjectDataRow.LastModifiedBy; owner_role?: CustomObjectDataRow.OwnerRole; /** * The timestamp when the record was last updated by the system. */ system_updated_at?: string; [k: string]: unknown; } export namespace CustomObjectDataRow { export interface CreatedBy { /** * The unique identifier of the role. */ id?: string; /** * The display name of the role. */ display_value?: string; /** * The URL of the role's profile image. */ image?: string; } export interface LastModifiedBy { /** * The unique identifier of the role. */ id?: string; /** * The display name of the role. */ display_value?: string; /** * The URL of the role's profile image. */ image?: string; } export interface OwnerRole { /** * The unique identifier of the role. */ id?: string; /** * The display name of the role. */ display_value?: string; /** * The URL of the role's profile image. */ image?: string; } } export interface RecordCreateResponse { data?: CustomObjectDataRow; } export interface RecordQueryResponse { cursor?: string; results?: Array; } export interface RecordUpdateResponse { data?: CustomObjectDataRow; } export interface RecordBulkCreateResponse { data?: Array; } export interface RecordBulkUpdateResponse { data?: Array; } export type RecordCreateParams = { [key: string]: unknown }; export interface RecordQueryParams { /** * A cursor for pagination to fetch the next page of results. */ cursor?: string; /** * The maximum number of results to return. */ limit?: number; /** * The query string to filter results. */ query?: string; } export type RecordUpdateParams = { [key: string]: unknown }; export interface RecordBulkCreateParams { /** * If true, the entire operation fails if any record fails. If false, partial * success is allowed. */ all_or_nothing?: boolean; /** * The list of records to create. */ rows_to_write?: Array<{ [key: string]: unknown }>; } export interface RecordBulkUpdateParams { /** * If true, the entire operation fails if any record fails. If false, partial * success is allowed. */ all_or_nothing?: boolean; /** * The list of records to update. */ rows_to_update?: Array<{ [key: string]: unknown }>; } export interface RecordBulkDeleteParams { /** * If true, the entire operation fails if any record fails. If false, partial * success is allowed. */ all_or_nothing?: boolean; /** * A list of record IDs to delete, e.g. [id_1, id_2]. */ rows_to_delete?: Array; } export declare namespace Records { export { type CustomObjectDataRow as CustomObjectDataRow, type RecordCreateResponse as RecordCreateResponse, type RecordQueryResponse as RecordQueryResponse, type RecordUpdateResponse as RecordUpdateResponse, type RecordBulkCreateResponse as RecordBulkCreateResponse, type RecordBulkUpdateResponse as RecordBulkUpdateResponse, type CustomObjectDataRowsPageCursorURL as CustomObjectDataRowsPageCursorURL, type RecordCreateParams as RecordCreateParams, type RecordQueryParams as RecordQueryParams, type RecordUpdateParams as RecordUpdateParams, type RecordBulkCreateParams as RecordBulkCreateParams, type RecordBulkUpdateParams as RecordBulkUpdateParams, type RecordBulkDeleteParams as RecordBulkDeleteParams, }; }