Skip to content

Instantly share code, notes, and snippets.

@aaronbassett
Created December 3, 2019 20:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronbassett/533a58019cd39efdbae518809daad513 to your computer and use it in GitHub Desktop.
Save aaronbassett/533a58019cd39efdbae518809daad513 to your computer and use it in GitHub Desktop.
exports = function(changeEvent) {
const http = context.services.get("salesHTTP");
const fullDocument = changeEvent.fullDocument;
return http.post({
url: "https://api.pushover.net/1/messages.json",
body: {
token: context.values.get("PUSHOVER_API_TOKEN"),
user: context.values.get("PUSHOVER_USER"),
title: 'New Sale',
message:`${fullDocument.productName} - ${fullDocument.price}`,
sound: 'cashregister'
},
encodeBodyAsJSON: true
})
.then(response => {
// The response body is encoded as raw BSON.Binary. Parse it to JSON.
const ejson_body = EJSON.parse(response.body.text());
return ejson_body;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment