| 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 | * Runtime binding for `social-messaging:PostWhatsAppMessageMedia`. |
| 8 | * |
| 9 | * Uploads a media file to WhatsApp (from an S3 object or presigned URL) so |
| 10 | * it can be referenced by `mediaId` in outbound messages sent from the |
| 11 | * given phone number. |
| 12 | * |
| 13 | * The caller addresses one of the bound account's phone numbers per |
| 14 | * request; phone-number ARNs are provisioned by Meta under the WABA, so |
| 15 | * the deploy-time half grants `social-messaging:PostWhatsAppMessageMedia` on `*`. |
| 16 | * Provide the implementation with |
| 17 | * `Effect.provide(AWS.SocialMessaging.PostWhatsAppMessageMediaHttp)`. |
| 18 | * ### Managing Message Media |
| 19 | * **Example:** Upload Media from S3 |
| 20 | * ```typescript |
| 21 | * // init — bind the operation to the linked WABA |
| 22 | * const postMedia = yield* AWS.SocialMessaging.PostWhatsAppMessageMedia(account); |
| 23 | * |
| 24 | * // runtime |
| 25 | * const { mediaId } = yield* postMedia({ |
| 26 | * originationPhoneNumberId: "phone-number-id-0123456789abcdef", |
| 27 | * sourceS3File: { bucketName: "my-assets", key: "welcome.png" }, |
| 28 | * }); |
| 29 | * ``` |
| 30 | * |
| 31 | * @binding |
| 32 | */ |
| 33 | export interface PostWhatsAppMessageMedia extends Binding.Service< |
| 34 | PostWhatsAppMessageMedia, |
| 35 | "AWS.SocialMessaging.PostWhatsAppMessageMedia", |
| 36 | ( |
| 37 | account: LinkedWhatsAppBusinessAccount, |
| 38 | ) => Effect.Effect< |
| 39 | ( |
| 40 | request: socialmessaging.PostWhatsAppMessageMediaInput, |
| 41 | ) => Effect.Effect< |
| 42 | socialmessaging.PostWhatsAppMessageMediaOutput, |
| 43 | socialmessaging.PostWhatsAppMessageMediaError |
| 44 | > |
| 45 | > |
| 46 | > {} |
| 47 | export const PostWhatsAppMessageMedia = |
| 48 | Binding.Service<PostWhatsAppMessageMedia>( |
| 49 | "AWS.SocialMessaging.PostWhatsAppMessageMedia", |
| 50 | ); |