Created
March 15, 2023 18:04
-
-
Save ctesene/29245b64acc909872f6bd4042b5dbb1c to your computer and use it in GitHub Desktop.
Velosimo API
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
var Velosimo = { | |
_appName: '', | |
_key: '', | |
_token: '', | |
init: function (name, key, token) { | |
this._appName = name; | |
this._key = key; | |
this._token = token; | |
}, | |
getCases: async function (recordId) { | |
var url = `https://dev.velosimo.io/app/${this._appName}/log/docs?X-Tenant-Access-Key=${this._key}&X-Tenant-Access-Token=${this._token}&recordId=${recordId}`; | |
return new Promise((resolve, reject) => { | |
$.ajax({ | |
url, | |
type: 'get', | |
success: function (data, textStatus, xhr) { | |
if (!data.status || !data.status == 'success') { | |
return reject(`invalid status (${data.status})`); | |
} | |
if (!Array.isArray(data.documents)) { | |
return reject('No documents'); | |
} | |
resolve(data.documents); | |
}, | |
error: function (xhr, status, error) { | |
reject({ status, xhr, error }); | |
} | |
}) | |
}); | |
}, | |
getCaseDetail: async function (recordId, caseId) { | |
var url = `https://dev.velosimo.io/app/${this._appName}/log/case-detail?X-Tenant-Access-Key=${this._key}&X-Tenant-Access-Token=${this._token}&recordId=${recordId}&caseId=${caseId}`; | |
return new Promise((resolve, reject) => { | |
$.ajax({ | |
url, | |
type: 'get', | |
success: function (data, textStatus, xhr) { | |
if (!data.status || !data.status == 'success') { | |
return reject(`invalid status (${data.status})`); | |
} | |
resolve(data.case); | |
}, | |
error: function (xhr, status, error) { | |
reject({ status, xhr, error }); | |
} | |
}) | |
}); | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment