| 1 | import type * as smsvoice from "@distilled.cloud/aws/pinpoint-sms-voice-v2"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { PhoneNumber } from "./PhoneNumber.ts"; |
| 5 | |
| 6 | /** |
| 7 | * The `OriginationIdentity` is injected by the binding from the bound |
| 8 | * phone number; the caller supplies the destination and message body. |
| 9 | */ |
| 10 | export interface SendTextMessageRequest extends Omit< |
| 11 | smsvoice.SendTextMessageRequest, |
| 12 | "OriginationIdentity" |
| 13 | > {} |
| 14 | |
| 15 | /** |
| 16 | * Runtime binding for `sms-voice:SendTextMessage`. |
| 17 | * |
| 18 | * Sends an SMS message from the bound origination phone number to one |
| 19 | * recipient — the effectful call made from a deployed Lambda or Task. The |
| 20 | * deploy-time half grants `sms-voice:SendTextMessage` on the number and |
| 21 | * the runtime half injects its ARN as the request's `OriginationIdentity`. |
| 22 | * Provide the implementation with |
| 23 | * `Effect.provide(AWS.PinpointSMSVoiceV2.SendTextMessageHttp)`. |
| 24 | * ### Sending Text Messages |
| 25 | * **Example:** Send an SMS from a Lambda |
| 26 | * ```typescript |
| 27 | * // init — lease a number and bind the send operation |
| 28 | * const number = yield* AWS.PinpointSMSVoiceV2.PhoneNumber("Sender", { |
| 29 | * isoCountryCode: "US", |
| 30 | * messageType: "TRANSACTIONAL", |
| 31 | * numberCapabilities: ["SMS"], |
| 32 | * numberType: "TOLL_FREE", |
| 33 | * }); |
| 34 | * const sendText = yield* AWS.PinpointSMSVoiceV2.SendTextMessage(number); |
| 35 | * |
| 36 | * // runtime |
| 37 | * const { MessageId } = yield* sendText({ |
| 38 | * DestinationPhoneNumber: "+12065550100", |
| 39 | * MessageBody: "Your code is 123456", |
| 40 | * MessageType: "TRANSACTIONAL", |
| 41 | * }); |
| 42 | * ``` |
| 43 | * |
| 44 | * @binding |
| 45 | */ |
| 46 | export interface SendTextMessage extends Binding.Service< |
| 47 | SendTextMessage, |
| 48 | "AWS.PinpointSMSVoiceV2.SendTextMessage", |
| 49 | ( |
| 50 | phoneNumber: PhoneNumber, |
| 51 | ) => Effect.Effect< |
| 52 | ( |
| 53 | request: SendTextMessageRequest, |
| 54 | ) => Effect.Effect< |
| 55 | smsvoice.SendTextMessageResult, |
| 56 | smsvoice.SendTextMessageError |
| 57 | > |
| 58 | > |
| 59 | > {} |
| 60 | export const SendTextMessage = Binding.Service<SendTextMessage>( |
| 61 | "AWS.PinpointSMSVoiceV2.SendTextMessage", |
| 62 | ); |