Skip to content

Instantly share code, notes, and snippets.

@CharlesWinter
Created March 5, 2018 10:01
Show Gist options
  • Select an option

  • Save CharlesWinter/64cd6a15b4f90b3ffd010bcd9f822484 to your computer and use it in GitHub Desktop.

Select an option

Save CharlesWinter/64cd6a15b4f90b3ffd010bcd9f822484 to your computer and use it in GitHub Desktop.
Golang API
const qxrecs = require('qxrecs');
/*
Configure the module with your company name, unique token
and communication protocol (currently either https or wss)
*/
qxrecs.Configure("my_company", "my_token", "https");
//Insert some products using callbacks. Can be used with multiple items
qxrecs.PostProducts([{itemid: "A" }], (err, body) => {
console.log(err);
console.log(body);
});
//Insert some products using Promises
qxrecs.PostProducts([{itemid: "B" }])
.then(console.log, console.error);
//Send a single consumption event with callbacks. Can be used with multiple events
qxrecs.SendEvents([{userid: "1", itemid: "1"}], (err, body) => {
console.log(err);
console.log(body);
});
//Send a single consumption event with Promises. Can be used with multiple events
qxrecs.SendEvents([{userid: "2", itemid: "2"}])
.then(console.log, console.error);
//Get recommendations for a user using callbacks
qxrecs.GetRecs("1", (err, body) => {
console.log(err);
console.log(body);
});
//Get recommendations for a user using Promises
qxrecs.GetRecs("2")
.then(console.log, console.error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment