import type { Channel, ChannelActionResult, ChannelGetProp, ChannelPropResponse, ChannelResponse, ChannelSetProp, ListChannelsQuery, Paginated, UpdateChannelDetailsInput } from '../../types'; import type { HttpClient } from '../../http'; /** Options for a property write; `raw` switches the body to file bytes. */ export interface SetPropOptions { /** JSON body. Ignored when `raw` is given. */ body?: Record; /** Query string parameters for the property. */ query?: Record; /** File bytes, for `profile_pic`, `resumable_upload` and `upload_media`. */ raw?: BodyInit; /** Media type of `raw`, e.g. `image/jpeg`. Required whenever `raw` is set. */ contentType?: string; } /** * Channels: the connections an account sends and receives on -- a WhatsApp * number, an RCS agent, a webchat widget. * * A channel is provisioned by onboarding, not by this API: there is no create * and no delete. `disable` retires one for good, keeping the row its billing, * wallet and activity history hang off. * * Anything that lives with the provider rather than on the channel document -- * the business profile, the QR code, media uploads, number registration -- * moves through `getProp` and `setProp`. */ export declare class Channels { private readonly http; constructor(http: HttpClient); /** * `GET /v1/channels` -- offset paginated, newest first. `search` matches the * channel name and its identity (number, handle, address). `type`, `active` * and `status` are quick filters. * * Credentials and the private auth block are stripped from every row. * * Scope: `channels:read`. */ list(query?: Partial): Promise>; /** * `GET /v1/channels/:id` -- wrapped as `{ data }`, and **`{ data: {} }` * rather than a 404** when nothing matches. Check for `id` on the payload * before using it. * * Scope: `channels:read`. */ get(id: string): Promise; /** * `PUT /v1/channels/:id` -- renames or recolours a channel, and moves its * billing currency. Returns `{ data }` with the updated channel. * * At least one of `name`, `color` or `currency` is required. Currency is the * one field with consequences: it only moves on a WhatsApp channel whose * wallet is empty, because a balance carried across a switch would be worth a * different amount on the other side. Otherwise 409 `wallet_not_empty`. * Asking for the currency the channel already bills in changes nothing. * * Scope: `channels:write`. */ updateDetails(id: string, input: UpdateChannelDetailsInput): Promise; /** * `POST /v1/channels/:id/disable` -- retires a channel for good. It stops * delivering, drops out of every listing, and cannot be brought back. * * A negative wallet balance blocks it with 409 `negative_wallet_balance`: * that is money owed that nothing would collect afterwards. A webchat * channel has its widget subscription removed first. * * Scope: `channels:write`. */ disable(id: string): Promise; /** * `DELETE /v1/channels/:id/token` -- issues a new inbound API token and * discards the old one, which stops working immediately. * * The new value is not in the response; read it back with * `getProp(id, 'token')`. * * Scope: `channels:write`. */ rotateToken(id: string): Promise; /** * `GET /v1/channels/:id/:prop` -- reads one provider-side property. Answers * `{ data, prop, channel }`, where `data` follows the property and is * therefore untyped; pass a type argument when you know the shape. * * WhatsApp supports every property. RCS reads only `fetch_channel_queue`, * `recharge_url` and `token`; anything else is 400 * `unsupported_channel_prop`, with the supported list in `details`. * * Scope: `channels:read`. */ getProp(id: string, prop: ChannelGetProp, query?: Record): Promise>; /** * `POST /v1/channels/:id/:prop` -- writes one provider-side property, or runs * the action it names. Answers the same `{ data, prop, channel }` envelope. * * `profile_pic`, `resumable_upload` and `upload_media` take the file bytes as * the request body: pass them as `raw` with a `contentType`. Every other * property takes JSON in `body`. * * ```ts * await crm.channels.setProp(id, 'business_profile', { * body: { about: 'We reply in minutes' }, * }); * * await crm.channels.setProp(id, 'profile_pic', { * raw: fileBytes, * contentType: 'image/jpeg', * }); * ``` * * Scope: `channels:write`. */ setProp(id: string, prop: ChannelSetProp, options?: SetPropOptions): Promise>; }