// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import * as Shared from '../shared'; import { UsersCursorSearch } from '../shared'; import { APIPromise } from '../../core/api-promise'; import { CursorSearch, type CursorSearchParams, PagePromise } from '../../core/pagination'; import { RequestOptions } from '../../internal/request-options'; import { path } from '../../internal/utils/path'; /** * Manage contacts on a specific account */ export class BaseContacts extends APIResource { static override readonly _key: readonly ['accounts', 'contacts'] = Object.freeze([ 'accounts', 'contacts', ] as const); /** * List merged contacts for a specific account with cursor-based pagination. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const user of client.accounts.contacts.list( * 'accountID', * )) { * // ... * } * ``` */ list( accountID: string, query: ContactListParams | null | undefined = {}, options?: RequestOptions, ): PagePromise { return this._client.getAPIList(path`/v1/accounts/${accountID}/contacts/list`, CursorSearch, { query, ...options, }); } /** * Search contacts on a specific account using merged account contacts, network * search, and exact identifier lookup. The exact lookup only runs when the query * is a phone number, email address, or username; pass one of those to resolve a * specific person. * * @example * ```ts * const response = await client.accounts.contacts.search( * 'accountID', * { query: 'x' }, * ); * ``` */ search( accountID: string, query: ContactSearchParams, options?: RequestOptions, ): APIPromise { return this._client.get(path`/v1/accounts/${accountID}/contacts`, { query, ...options }); } } /** * Manage contacts on a specific account */ export class Contacts extends BaseContacts {} export interface ContactSearchResponse { items: Array; } export interface ContactListParams extends CursorSearchParams { /** * Optional search query for contact lookup. */ query?: string; } export interface ContactSearchParams { /** * Text to search contacts by. A phone number, email address, or username written * with a leading @ is additionally looked up as an exact identifier on the * network; any other text, such as a bare handle or a person or business name, * searches existing contacts only. Matching behavior depends on the network. */ query: string; } export declare namespace Contacts { export { type ContactSearchResponse as ContactSearchResponse, type ContactListParams as ContactListParams, type ContactSearchParams as ContactSearchParams, }; } export { type UsersCursorSearch };