Created
December 7, 2021 00:34
-
-
Save ShariqT/1e78b43458cb50fe91f60682adf42426 to your computer and use it in GitHub Desktop.
callback.js
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
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