// 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 AccountsAPI from './accounts/accounts'; import { APIPromise } from '../core/api-promise'; import { PagePromise, PylonSearchPage, type PylonSearchPageParams } from '../core/pagination'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; export class Contacts extends APIResource { /** * Create a contact */ create(body: ContactCreateParams, options?: RequestOptions): APIPromise { return this._client.post('/contacts', { body, ...options }); } /** * Get a contact by its ID */ retrieve(id: string, query: ContactRetrieveParams, options?: RequestOptions): APIPromise { return this._client.get(path`/contacts/${id}`, { query, ...options }); } /** * Update a contact */ update(id: string, body: ContactUpdateParams, options?: RequestOptions): APIPromise { return this._client.patch(path`/contacts/${id}`, { body, ...options }); } /** * Search contacts */ search(body: ContactSearchParams, options?: RequestOptions): PagePromise { return this._client.getAPIList('/contacts/search', PylonSearchPage, { body, method: 'post', ...options, }); } } export type ContactsPylonSearchPage = PylonSearchPage; export interface Contact { id?: string; account?: Contact.Account; avatar_url?: string; custom_fields?: { [key: string]: Shared.CustomFieldValue }; email?: string; emails?: Array; name?: string; portal_role?: 'no_access' | 'viewer' | 'editor'; } export namespace Contact { export interface Account { id?: string; } } export interface ContactResponse { data?: Contact; request_id?: string; } export interface ContactCreateParams { /** * The email of the contact */ email: string; /** * The account that this contact belongs to */ account_id?: string; /** * The avatar URL of the contact. Must be a square .png, .jpg or .jpeg */ avatar_url?: string; /** * An array of custom fields to be applied to this contact */ custom_fields?: Array; /** * The name of the contact */ name?: string; /** * The portal role to assign to the contact */ portal_role?: 'no_access' | 'viewer' | 'editor'; } export interface ContactRetrieveParams { /** * The number of contacts to fetch */ limit: number; /** * The cursor to use for pagination */ cursor?: string; } export interface ContactUpdateParams { /** * The account to move the contact to */ account_id?: string; /** * The avatar URL of the contact. Must be a square .png, .jpg or .jpeg */ avatar_url?: string; /** * An array of custom fields to be applied to this contact */ custom_fields?: Array; /** * The email of the contact */ email?: string; /** * The name of the contact */ name?: string; /** * The portal role to assign to the contact */ portal_role?: 'no_access' | 'viewer' | 'editor'; } export interface ContactSearchParams extends PylonSearchPageParams {} export declare namespace Contacts { export { type Contact as Contact, type ContactResponse as ContactResponse, type ContactsPylonSearchPage as ContactsPylonSearchPage, type ContactCreateParams as ContactCreateParams, type ContactRetrieveParams as ContactRetrieveParams, type ContactUpdateParams as ContactUpdateParams, type ContactSearchParams as ContactSearchParams, }; }