Last active
August 29, 2015 14:04
-
-
Save molsches/3d1c9d7747e8c3ebc69e 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
//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