/** * Contact Methods Resource * * Manages communication channels (email, phone, etc.) for clients. */ import type { AtomicBatchResult, ContactMethodFilter, ContactMethodSort, ContactMethodType, CreateContactMethodInput, ListOptions, PaginatedResponse, PartialBatchResult, SyncItem, SyncResult, UpdateContactMethodInput, UpsertContactMethodByExternalIdInput, UpsertContactMethodInput, UpsertResult } from "@artu-ai/shared"; import { ContactMethod, type ContactMethodData } from "../models/ContactMethod"; import { BaseResource } from "./base"; /** * Resource for managing client contact methods. * * @example * ```typescript * // Create an email contact for a client * const email = await sdk.contactMethods.create({ * clientId: "client_123", * type: "email", * value: "juan@example.com", * label: "Personal", * isPrimary: true, * }); * * // Get the primary email for a client * const primary = await sdk.contactMethods.getPrimary("client_123", "email"); * ``` */ export declare class ContactMethodsResource extends BaseResource { /** * Creates a contact method for a client * * @param data - Contact method data including clientId * @returns The created ContactMethod */ create(data: CreateContactMethodInput): Promise; /** * Retrieves a contact method by ID * * @param id - The contact method ID * @returns The ContactMethod */ retrieve(id: string): Promise; /** * Retrieves a contact method by metadata key/value. */ retrieveByMetadata(key: string, value: string): Promise; /** * Retrieves a contact method by externalId. */ retrieveByExternalId(externalId: string): Promise; /** * Updates a contact method * * @param id - The contact method ID * @param data - Fields to update * @returns The updated ContactMethod */ update(id: string, data: UpdateContactMethodInput): Promise; /** * Deletes a contact method * * @param id - The contact method ID */ delete(id: string): Promise; /** * Lists contact methods with optional filtering * * @param options - Filtering and pagination options * @returns Paginated list of ContactMethods */ list(options?: ListOptions): Promise>; /** * Lists all contact methods for a specific client * * @param clientId - The client ID * @param options - Optional pagination options * @returns Paginated list of ContactMethods */ listByClient(clientId: string, options?: { cursor?: string; limit?: number; }): Promise>; /** * Counts contact methods matching the given filter. * * @param filter - Optional filter criteria * @returns The count of matching contact methods */ count(filter?: ContactMethodFilter): Promise; /** * Returns an async iterator over all contact methods matching the filter. */ iterate(options?: { filter?: ContactMethodFilter; sort?: ContactMethodSort; pageSize?: number; }): AsyncGenerator; /** * Creates multiple contact methods in a single request. * * @param contacts - Array of contact method data (each includes clientId) * @param options - Batch options (atomic: true by default) * @returns Atomic result with data array, or partial result with succeeded/failed */ createMany(contacts: CreateContactMethodInput[], options?: { atomic?: true; }): Promise>; createMany(contacts: CreateContactMethodInput[], options: { atomic: false; }): Promise>; /** * Updates multiple contact methods in a single request. * * @param updates - Array of { id, data } updates * @param options - Batch options (atomic: true by default) * @returns Atomic result with data array, or partial result with succeeded/failed */ updateMany(updates: { id: string; data: UpdateContactMethodInput; }[], options?: { atomic?: true; }): Promise>; updateMany(updates: { id: string; data: UpdateContactMethodInput; }[], options: { atomic: false; }): Promise>; /** * Creates or updates a contact method by externalId. * * If a contact method with the given externalId exists, it will be updated. * Otherwise, a new contact method will be created. * * @param data - Contact method upsert data (must include externalId and clientId) * @returns The created or updated contact method with action indicator */ upsertByExternalId(data: UpsertContactMethodByExternalIdInput): Promise>; /** * Creates or updates multiple contact methods by externalId in a single request. * * @param contacts - Array of contact method upsert data (each must include externalId and clientId) * @param options - Batch options (atomic: true by default) * @returns Atomic result with data array, or partial result with succeeded/failed */ upsertManyByExternalId(contacts: UpsertContactMethodInput[], options?: { atomic?: true; }): Promise>>; upsertManyByExternalId(contacts: UpsertContactMethodInput[], options: { atomic: false; }): Promise>>; /** * Syncs contact methods for a client - handles create, update, and delete in bulk. * * This is the most efficient way to reconcile a set of contact methods for a client. * Primary contact methods are handled per-type (e.g., one primary email, one primary phone). * * @param clientId - The client ID * @param items - Array of sync items: * - Without `id`: create new contact method * - With `id` and `_delete: true`: delete existing contact method * - With `id` (no `_delete`): update existing contact method * @param options - Sync options * @param options.replaceMode - When true, items not in the array are deleted (default: false) * @returns Sync result with created, updated, and deleted arrays * * @example * ```typescript * // Patch mode (default) - only mentioned items are affected * const result = await sdk.contactMethods.sync("client_123", [ * // Create new email (no id) * { type: "email", value: "new@example.com", isPrimary: true }, * // Update existing phone (has id) * { id: "cm_456", value: "+52 555 123 4567" }, * // Delete contact method (has id and _delete: true) * { id: "cm_789", _delete: true }, * ]); * * // Replace mode - provided array becomes the complete set (requires full create input for new items) * const result = await sdk.contactMethods.sync("client_123", methods, { replaceMode: true }); * * console.log(result.created); // newly created contact methods * console.log(result.updated); // updated contact methods * console.log(result.deleted); // array of deleted IDs * ``` */ sync(clientId: string, items: SyncItem[], options: { replaceMode: true; }): Promise>; sync(clientId: string, items: SyncItem[], options?: { replaceMode?: boolean; }): Promise>; /** * Gets the primary contact method of a specific type for a client * * @param clientId - The client ID * @param type - The contact method type * @returns The primary ContactMethod or null */ getPrimary(clientId: string, type: ContactMethodType): Promise; /** * Marks a contact method as verified * * @param id - The contact method ID * @returns The updated ContactMethod */ markVerified(id: string): Promise; protected instantiate(data: ContactMethodData): ContactMethod; }