// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import * as Shared from '../shared'; import * as ActivitiesAPI from './activities'; import { Activities, ActivityCreateParams } from './activities'; import * as HighlightsAPI from './highlights'; import { HighlightCreateParams, HighlightDeleteParams, HighlightUpdateParams, Highlights, } from './highlights'; import { APIPromise } from '../../core/api-promise'; import { PagePromise, PylonCursorPage, type PylonCursorPageParams, PylonSearchPage, type PylonSearchPageParams, } from '../../core/pagination'; import { buildHeaders } from '../../internal/headers'; import { RequestOptions } from '../../internal/request-options'; import { path } from '../../internal/utils/path'; export class Accounts extends APIResource { activities: ActivitiesAPI.Activities = new ActivitiesAPI.Activities(this._client); highlights: HighlightsAPI.Highlights = new HighlightsAPI.Highlights(this._client); /** * Create an account */ create(body: AccountCreateParams, options?: RequestOptions): APIPromise { return this._client.post('/accounts', { body, ...options }); } /** * Get an account by its ID or external ID */ retrieve(id: string, options?: RequestOptions): APIPromise { return this._client.get(path`/accounts/${id}`, options); } /** * Update an account */ update(id: string, body: AccountUpdateParams, options?: RequestOptions): APIPromise { return this._client.patch(path`/accounts/${id}`, { body, ...options }); } /** * List accounts */ list( query: AccountListParams | null | undefined = {}, options?: RequestOptions, ): PagePromise { return this._client.getAPIList('/accounts', PylonCursorPage, { query, ...options }); } /** * Delete an account */ delete(id: string, options?: RequestOptions): APIPromise { return this._client.delete(path`/accounts/${id}`, { ...options, headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), }); } /** * Search accounts */ search(body: AccountSearchParams, options?: RequestOptions): PagePromise { return this._client.getAPIList('/accounts/search', PylonSearchPage, { body, method: 'post', ...options, }); } } export type AccountsPylonCursorPage = PylonCursorPage; export type AccountsPylonSearchPage = PylonSearchPage; export interface Account { id?: string; channels?: Array; created_at?: string; crm_settings?: Account.CRMSettings; custom_fields?: { [key: string]: Shared.CustomFieldValue }; /** * @deprecated */ domain?: string; domains?: Array; external_ids?: Array; latest_customer_activity_time?: string; name?: string; owner?: UserReference; primary_domain?: string; tags?: Array; type?: string; } export namespace Account { export interface CRMSettings { details?: Array; } export namespace CRMSettings { export interface Detail { id?: string; source?: string; } } } export interface AccountListResponse { data?: Array; pagination?: Pagination; request_id?: string; } export interface AccountResponse { data?: Account; request_id?: string; } export interface Channel { channel_id?: string; is_primary?: boolean; source?: string; } export interface CustomField { slug?: string; value?: string; values?: Array; } export interface ExternalID { external_id?: string; label?: string; } export interface Pagination { cursor?: string; has_next_page?: boolean; } export interface SearchRequest { /** * The cursor to use for pagination */ cursor?: string; filter?: Shared.Filter; /** * The number of items to fetch */ limit?: number; } export interface UserReference { id?: string; email?: string; } export interface AccountCreateParams { /** * The name of the account */ name: string; /** * An array of channels to be linked to this account */ channels?: Array; /** * An array of custom fields to be used on this account */ custom_fields?: Array; /** * @deprecated Deprecated. Use domains instead */ domain?: string; /** * Domains of the account. Must specify one domain as primary */ domains?: Array; /** * An array of external IDs to be used on this account */ external_ids?: Array; /** * The logo URL of the account */ logo_url?: string; /** * The primary domain of the account */ primary_domain?: string; /** * An array of tags to apply to this account */ tags?: Array; } export interface AccountUpdateParams { /** * An array of channels to be linked to this account */ channels?: Array; /** * An array of custom fields to be used on this account */ custom_fields?: Array; /** * Domains of the account. Must specify one domain as primary */ domains?: Array; /** * An array of external IDs to be used on this account */ external_ids?: Array; /** * The name of the account */ name?: string; /** * The ID of the owner of the account */ owner_id?: string; /** * The primary domain of the account */ primary_domain?: string; /** * An array of tags to apply to this account */ tags?: Array; } export interface AccountListParams extends PylonCursorPageParams {} export interface AccountSearchParams extends PylonSearchPageParams {} Accounts.Activities = Activities; Accounts.Highlights = Highlights; export declare namespace Accounts { export { type Account as Account, type AccountListResponse as AccountListResponse, type AccountResponse as AccountResponse, type Channel as Channel, type CustomField as CustomField, type ExternalID as ExternalID, type Pagination as Pagination, type SearchRequest as SearchRequest, type UserReference as UserReference, type AccountsPylonCursorPage as AccountsPylonCursorPage, type AccountsPylonSearchPage as AccountsPylonSearchPage, type AccountCreateParams as AccountCreateParams, type AccountUpdateParams as AccountUpdateParams, type AccountListParams as AccountListParams, type AccountSearchParams as AccountSearchParams, }; export { Activities as Activities, type ActivityCreateParams as ActivityCreateParams }; export { Highlights as Highlights, type HighlightCreateParams as HighlightCreateParams, type HighlightUpdateParams as HighlightUpdateParams, type HighlightDeleteParams as HighlightDeleteParams, }; }