Google Apps Script project that uses Sierra API to send patrons notification e-mails. Created by Brendan Lawlor for test purposes only. Use at your own risk. Not supported by CLAMS.
https://nodejs.org/en/download/
npm install @google/clasp -g
https://script.google.com/home/usersettings
git clone https://github.com/b-lawlor/Renewal-Notifications
cd Renewal-Notifications
clasp login
clasp create --title "Renewal Notifications"
choose standalone
clasp push
clasp open
In auth.gs:
getToken_()
var key = "YOUR SIERRA API KEY";
var secret = "YOUR SUPER SECRET API SECRET";
var getTokenUrl = "https://LIBRARY.DOMAIN/iii/sierra-api/v5/token";
In main.gs:
main()
// set limit field to a low number for testing
var url = "https://LIBRARY.DOMAIN/iii/sierra-api/v5/patrons/query?offset=0&limit=3";
sendNotifications()
var supportEmail = "support@LIBRAY.DOMAIN"
var testEmail = "you@LIBRARY.DOMAIN"
// uncomment to send emails to patrons
//GmailApp.sendEmail(patron.emails[0], subject, body, options);
getLocations()
var loc = apiGet(token, "https://LIBRARY.DOMAIN/iii/sierra-api/v5/branches/pickupLocations");
In emailBody.gs:
getPlainBody()
var body = "notification plain text"
getHtmlBody()
var body = "notification with html markup"
- Run-> Run function -> main
- Click Allow
- Edit-> Current project's triggers
- "+" Add Trigger
- Choose which function to run: main
- Choose which deployment to run: Head
- Select event source: Time-driven
- Select type of time based trigger: Day timer
- Select time of day: 9am to 10am