| 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:GetWhatsAppMessageMedia`. |
| 8 | * |
| 9 | * Retrieves a media file received in a WhatsApp message — either just its |
| 10 | * metadata (`metadataOnly: true`) or a full download into an S3 object or |
| 11 | * presigned URL. |
| 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:GetWhatsAppMessageMedia` on `*`. |
| 16 | * Provide the implementation with |
| 17 | * `Effect.provide(AWS.SocialMessaging.GetWhatsAppMessageMediaHttp)`. |
| 18 | * ### Managing Message Media |
| 19 | * **Example:** Download Received Media to S3 |
| 20 | * ```typescript |
| 21 | * // init — bind the operation to the linked WABA |
| 22 | * const getMedia = yield* AWS.SocialMessaging.GetWhatsAppMessageMedia(account); |
| 23 | * |
| 24 | * // runtime |
| 25 | * const { mimeType, fileSize } = yield* getMedia({ |
| 26 | * mediaId: "media-id-from-inbound-event", |
| 27 | * originationPhoneNumberId: "phone-number-id-0123456789abcdef", |
| 28 | * destinationS3File: { bucketName: "my-inbox", key: "media/inbound" }, |
| 29 | * }); |
| 30 | * ``` |
| 31 | * |
| 32 | * @binding |
| 33 | */ |
| 34 | export interface GetWhatsAppMessageMedia extends Binding.Service< |
| 35 | GetWhatsAppMessageMedia, |
| 36 | "AWS.SocialMessaging.GetWhatsAppMessageMedia", |
| 37 | ( |
| 38 | account: LinkedWhatsAppBusinessAccount, |
| 39 | ) => Effect.Effect< |
| 40 | ( |
| 41 | request: socialmessaging.GetWhatsAppMessageMediaInput, |
| 42 | ) => Effect.Effect< |
| 43 | socialmessaging.GetWhatsAppMessageMediaOutput, |
| 44 | socialmessaging.GetWhatsAppMessageMediaError |
| 45 | > |
| 46 | > |
| 47 | > {} |
| 48 | export const GetWhatsAppMessageMedia = Binding.Service<GetWhatsAppMessageMedia>( |
| 49 | "AWS.SocialMessaging.GetWhatsAppMessageMedia", |
| 50 | ); |