Created
February 11, 2021 03:48
-
-
Save dannyrandall/196c16469175323bef2af335cbed046e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruleset twilio { | |
meta { | |
name "Twilio" | |
author "Daniel Randall" | |
configure using | |
accountSID = "" | |
authToken = "" | |
provides sendSMS, messages | |
} | |
global { | |
baseURL = <<https://api.twilio.com/2010-04-01/Accounts/#{accountSID}>> | |
sendSMS = defaction(from, to, message) { | |
http:post((baseURL+"/Messages.json").klog("url"), auth = { | |
"username": accountSID, | |
"password": authToken | |
}.klog("auth"), form = { | |
"From": from, | |
"To": to, | |
"Body": message | |
}.klog("form")) setting(resp) | |
return resp{"content"}.decode() | |
} | |
messages = function(from, to, pageSize) { | |
qs = { | |
"From": from, | |
"To": to, | |
"PageSize": pageSize | |
} | |
resp = http:get((baseURL+"/Messages.json").klog("url"), auth = { | |
"username": accountSID, | |
"password": authToken | |
}.klog("auth"), qs = qs.filter(function(v, k) {v}).klog("query")) | |
resp{"content"}.decode() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment