| 1 | import type * as socialmessaging from "@distilled.cloud/aws/socialmessaging"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { LinkedWhatsAppBusinessAccount } from "./LinkedWhatsAppBusinessAccount.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Request for {@link CreateWhatsAppFlow}. The linked WABA `id` is injected by |
| 8 | * the binding from the bound {@link LinkedWhatsAppBusinessAccount}. |
| 9 | */ |
| 10 | export interface CreateWhatsAppFlowRequest extends Omit< |
| 11 | socialmessaging.CreateWhatsAppFlowInput, |
| 12 | "id" |
| 13 | > {} |
| 14 | |
| 15 | /** |
| 16 | * Runtime binding for `social-messaging:CreateWhatsAppFlow`. |
| 17 | * |
| 18 | * Creates a WhatsApp Flow (a rich interactive form users complete inside |
| 19 | * WhatsApp) on the bound account, in DRAFT status unless `publish` is set |
| 20 | * with a valid `flowJson`. |
| 21 | * |
| 22 | * The deploy-time half grants `social-messaging:CreateWhatsAppFlow` on the |
| 23 | * bound WABA's ARN and the runtime half injects the linked account id |
| 24 | * into every request. |
| 25 | * Provide the implementation with |
| 26 | * `Effect.provide(AWS.SocialMessaging.CreateWhatsAppFlowHttp)`. |
| 27 | * ### Managing WhatsApp Flows |
| 28 | * **Example:** Create a Flow |
| 29 | * ```typescript |
| 30 | * // init — bind the operation to the linked WABA |
| 31 | * const createFlow = yield* AWS.SocialMessaging.CreateWhatsAppFlow(account); |
| 32 | * |
| 33 | * // runtime |
| 34 | * const { flowId, validationErrors } = yield* createFlow({ |
| 35 | * flowName: "appointment-booking", |
| 36 | * categories: ["APPOINTMENT_BOOKING"], |
| 37 | * }); |
| 38 | * ``` |
| 39 | * |
| 40 | * @binding |
| 41 | */ |
| 42 | export interface CreateWhatsAppFlow extends Binding.Service< |
| 43 | CreateWhatsAppFlow, |
| 44 | "AWS.SocialMessaging.CreateWhatsAppFlow", |
| 45 | ( |
| 46 | account: LinkedWhatsAppBusinessAccount, |
| 47 | ) => Effect.Effect< |
| 48 | ( |
| 49 | request: CreateWhatsAppFlowRequest, |
| 50 | ) => Effect.Effect< |
| 51 | socialmessaging.CreateWhatsAppFlowOutput, |
| 52 | socialmessaging.CreateWhatsAppFlowError |
| 53 | > |
| 54 | > |
| 55 | > {} |
| 56 | export const CreateWhatsAppFlow = Binding.Service<CreateWhatsAppFlow>( |
| 57 | "AWS.SocialMessaging.CreateWhatsAppFlow", |
| 58 | ); |