Skip to content

Instantly share code, notes, and snippets.

@molsches
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save molsches/3d1c9d7747e8c3ebc69e to your computer and use it in GitHub Desktop.
Save molsches/3d1c9d7747e8c3ebc69e to your computer and use it in GitHub Desktop.
//First post the schema to Catalyze.
//You mentioned that it needed to have an ID (auto-generated, unless you want a custom one), timestamp (let's use a UNIX timestamp), and a JSON object
//You'll need to auth and grab a session token first. See the API docs here: https://docs.catalyze.io/api/latest/
var Request = new XMLHttpRequest();
Request.open('POST', 'https://api.catalyze.io/v2/classes');
Request.setRequestHeader('X-Api-Key', '<your API key>');
Request.setRequestHeader('Authorization', 'Bearer <Your Session Token>');
Request.setRequestHeader('Accept', 'application/json');
Request.setRequestHeader('Content-Type', 'application/json');
Request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
var body = {
'name': 'EligibilityQuery',
'schema': {
'createdOn': 'integer',
'queryResponse': 'object'
}
};
Request.send(JSON.stringify(body));
//Then you can post your date to the endpoint created for this custom class
var Request = new XMLHttpRequest();
Request.open('POST', 'https://api.catalyze.io/v2/classes/EligibilityQuery/entry');
Request.setRequestHeader('X-Api-Key', '<your API key>');
Request.setRequestHeader('Authorization', 'Bearer <Your Session Token>');
Request.setRequestHeader('Accept', 'application/json');
Request.setRequestHeader('Content-Type', 'application/json');
Request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
//The Eligible X12 JSON response is proprietary. So, you'll need to insert it into 'queryResponse" yourself.
var body = {
'createdOn' : 1407269776201,
'queryResponse' : {"object" : {"sub-object": "value"}}
};
Request.send(JSON.stringify(body));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment