Skip to content

Instantly share code, notes, and snippets.

@ShariqT
Created December 7, 2021 00:34
Show Gist options
  • Save ShariqT/1e78b43458cb50fe91f60682adf42426 to your computer and use it in GitHub Desktop.
Save ShariqT/1e78b43458cb50fe91f60682adf42426 to your computer and use it in GitHub Desktop.
callback.js
export default function callback(req, res) {
const eventType = req.body.event_type.id;
const from = req.body.body.to.name;
const to = req.body.body.from.name;
switch (eventType) {
case "postcard.created":
case "postcard.deleted":
// update the billing software
break;
case "postcard.mailed":
console.log(
`Send an email to the admin that the postcard sent from ${from} to ${to} is in the mail.`
);
break;
case "postcard.re-routed":
case "postcard.returned_to_sender":
// A possible problem? Update CRM to reach out about possible change of address.
break;
default:
// Update the CRM dashboard in some way.
}
res.send({ message: "ok" });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment