import type { ChannelOnboardingOption, ChannelResponse, CompleteOnboardingInput, OnboardingChannelType, OnboardingExchangeInput, OnboardingExchangeResult, OnboardingPendingResult, OnboardingUrlInput, OnboardingUrlResult } from '../../types'; import type { HttpClient } from '../../http'; import { type OpenSignupOptions } from '../../internal/embedded-signup'; /** Options for the one-call driver. */ export interface ConnectOptions extends OpenSignupOptions { /** Which family to connect. Only `whatsapp` today, and the default. */ type?: OnboardingChannelType; /** The inclusion to spend, when the plan carries more than one. */ slug?: string; /** The BSP to connect through, by provider code. Omit for the active one. */ provider?: string; /** * Where the popup is handed back to. **Required**, and it has to be a page on * this page's own origin -- that is what makes the outcome readable from here. */ redirectUri: string; } /** * Connecting a channel. The browser only runs Meta's dialog: Meta returns to * the service's callback, which redeems the code and sends the browser back to * `redirectUri` with a `status` and a `token` -- no credential reaches this * page. `connect()` drives all of it; or call `url()`, open the dialog * yourself, and read the return off your own landing page. * * ```ts * // In the click handler for "Connect WhatsApp" -- not after an await. * const candidate = await crm.channelOnboarding.connect({ * redirectUri: 'https://console.example.com/channels/connected', * }); * // One number, or several to choose between: candidate.numbers * const { data: channel } = await crm.channelOnboarding.complete({ * token: candidate.id, * phoneNumberId: chosen.id, * name: form.name, * }); * ``` */ export declare class ChannelOnboarding { private readonly http; constructor(http: HttpClient); /** * `GET /v1/channels/onboarding/types` -- the families this caller can connect * right now. Anything the plan, the provider record or their role rules out is * left out, so an empty list means "nothing to offer". Scope: `channels:read`. */ types(): Promise<{ data: ChannelOnboardingOption[]; }>; /** * `POST /v1/channels/onboarding/url` -- the page to open. **Meta refuses to * be framed**: use a popup, or navigate. 402 if the plan has no room. * * `url` is a launcher on the app's own domain that forwards to the dialog * (`dialogUrl`); `redirectUri` is where *we* return the browser, not what * Meta is given -- that is `callbackUri`. */ url(input: OnboardingUrlInput): Promise<{ data: OnboardingUrlResult; }>; /** * `GET /v1/channels/onboarding/pending/:token` -- what the return URL's * `token` refers to: the numbers it covers, and the form's prefill. */ pending(token: string): Promise<{ data: OnboardingPendingResult; }>; /** * `POST /v1/channels/onboarding/exchange` -- redeems a code you hold yourself, * for a BSP app whose registered redirect is a page of yours rather than the * service's callback. **Creates nothing**: show `phoneNumber` and confirm. */ exchange(input: OnboardingExchangeInput): Promise<{ data: OnboardingExchangeResult; }>; /** * `POST /v1/channels/onboarding/complete` -- creates the channel, **inactive**: * `setProp(id, 'wa_pin_update')` brings it up, or `wa_biz_update` for a WA Biz number. */ complete(input: CompleteOnboardingInput): Promise; /** * The URL, the dialog, and the record the callback leaves behind, in one call. * **Call it straight from the click handler**, or the popup is blocked. * Rejects with `EmbeddedSignupError`; `reason` carries the service's own code. * * What comes back is a *candidate* -- nothing exists until `complete()`, and * if it holds several numbers the person picks one. */ connect(options: ConnectOptions): Promise; }