Skip to content

Instantly share code, notes, and snippets.

@mickaelramanitrera
Created November 7, 2018 10:20
Show Gist options
  • Save mickaelramanitrera/64ff8bc2ddf47b341eb4a6cd03b44d6f to your computer and use it in GitHub Desktop.
Save mickaelramanitrera/64ff8bc2ddf47b341eb4a6cd03b44d6f to your computer and use it in GitHub Desktop.
Podio JS push notifications
const podio = new PodioJs.api({
authType: "password",
clientId: process.env.PODIO_CLIENT_ID,
clientSecret: process.env.PODIO_CLIENT_SECRET,
}, {
enablePushService: true,
});
podio.authenticateWithCredentials(process.env.PODIO_USER_EMAIL, process.env.PODIO_USER_PWD, (err) => {
if (err) { console.log("Error", err); }
//this is for a space sub
//must get the space to get the push configurations of this space
podio.request("get", `/space/${process.env.SPACE_ID}`)
.then((space: any) => {
console.log("Space infos", space);
// add push exts
podio.push(space.push).subscribe((event: any) => {
console.log("------EVENT RECEIVED---------", event);
}).then(() => {
console.log("Subscription added!");
});
})
.catch((erro: any) => {
console.log("ERR", erro);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment