Skip to content

Commit

Permalink
feat: Add function getSMS to get the info of a sent SMS
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsf authored Nov 4, 2024
1 parent 3c6625f commit 83f8d09
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
13 changes: 13 additions & 0 deletions models/TwilioClient.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
16 changes: 16 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 83f8d09

Please sign in to comment.