Created
December 3, 2019 20:31
-
-
Save aaronbassett/533a58019cd39efdbae518809daad513 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
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