From 83f8d0992134466bb4b216d1c82163625fc2d59a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sede=C3=B1o?= Date: Mon, 4 Nov 2024 22:09:25 +0100 Subject: [PATCH] feat: Add function getSMS to get the info of a sent SMS --- models/TwilioClient.cfc | 13 +++++++++++++ readme.md | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/models/TwilioClient.cfc b/models/TwilioClient.cfc index 38b4ccc..27c1671 100644 --- a/models/TwilioClient.cfc +++ b/models/TwilioClient.cfc @@ -71,6 +71,19 @@ component singleton accessors="true" { .setBody( { "From": arguments.from, "To": arguments.to, "Body": escapeNewlineCharacters( arguments.body ) } ); } + /** + * Get the info of a SMS from Twilio + * + * @sid Id of the SMS + * + * @returns A configured HyperRequest instance. The return data is in field: data + */ + function getSMS( required string sid ) { + return newRequest() + .setMethod( "GET" ) + .setUrl( "/Accounts/#variables.accountSID#/Messages/#arguments.sid#.json") + } + /** * Initiate a phone call * diff --git a/readme.md b/readme.md index ebf4fc8..3102c79 100644 --- a/readme.md +++ b/readme.md @@ -53,6 +53,22 @@ Send an sms message. Returns a configured `HyperRequest` instance. | from | String | `true` | | The phone number the sms is from. This must be a valid Twilio number. | | body | String | `true` | | The body of the sms message. | +#### getSMS + +Get information of a SMS sent with Twilio + +| Name | Type | Required? | Default | Description | +| ---- | ------ | --------- | ------- | --------------------------------------------------------------------- | +| sid | String | `true` | | Sid of the Message | + +The information of the sms is in the field `data` as json of the returned object. +To get that information you need to deserialize it: + +``` +responseObj = getSMS(sid); +smsData = deserializejson( responseObj.data ); +``` + ### Hyper Integration The Twilio SDK uses the Hyper HTTP Client under the hood. This entire power is