Skip to content

Commit

Permalink
feat(call): Use either Twiml or URL when calling
Browse files Browse the repository at this point in the history
  • Loading branch information
elpete committed Nov 17, 2023
1 parent e27d6cd commit 37e3897
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions models/TwilioClient.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,28 @@ component singleton accessors="true" {
* @from The phone number the call is from.
* This must be a valid Twilio number.
* @twiml The twiml XML instructions for the call.
* @URL A URL to call to get Twiml instructions for the call.
* @additionalParams Any additional param to send with the request
*
* @returns A configured HyperRequest instance.
*/
function call(
required string to,
required string from,
required string twiml,
string twiml,
string URL,
struct additionalParams = {}
) {
var body = { "From": arguments.from, "To": arguments.to, "Twiml": arguments.twiml };
if ( isNull( arguments.twiml ) && isNull( arguments.URL ) ) {
throw( "Either a Twiml string or a URL is required." );
}

var body = { "From": arguments.from, "To": arguments.to };
if ( isNull( arguments.URL ) ) {
body[ "URL" ] = arguments.URL;
} else {
body[ "Twiml" ] = arguments.twiml;
}
structAppend( body, additionalParams );

return newRequest()
Expand Down

0 comments on commit 37e3897

Please sign in to comment.