upgrade to 1.1.0
This commit is contained in:
1 parent
02c95d89bb
commit
f5893a107d
46 files changed
+3764
-2891
No files matched your search
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
const axios = require('axios');
|
||||
const { getConfig, getDefault } = require('./config.js');
|
||||
function _getUrl(path) {
|
||||
const cfg = getConfig();
|
||||
return `${cfg.apiUrl}${path}`;
|
||||
}
|
||||
function _headers(token) {
|
||||
return {
|
||||
'Authorization': `Bearer ${token || getConfig().apiKey}`,
|
||||
};
|
||||
}
|
||||
async function produceEvent({ type, senderShortName, recipientShortName, agreementId, meta, data, archive }) {
|
||||
const cfg = getConfig();
|
||||
const defaultArchive = { url: cfg.archiveUrl, key: cfg.archiveKey };
|
||||
return (await axios.post(_getUrl('/api/v1/data/event/produce'), {
|
||||
type,
|
||||
senderShortName,
|
||||
recipientShortName,
|
||||
agreementId: agreementId || getDefault('agreementId'),
|
||||
meta,
|
||||
data,
|
||||
archive: archive || defaultArchive,
|
||||
}, { headers: _headers() })).data;
|
||||
}
|
||||
async function getEvent({ eventId, meta }) {
|
||||
return (await axios.post(_getUrl('/api/v1/data/event/get'), { eventId, meta }, { headers: _headers() })).data;
|
||||
}
|
||||
async function processEvent({ eventId, shortName, archive }) {
|
||||
const cfg = getConfig();
|
||||
const defaultArchive = { url: cfg.archiveUrl, key: cfg.archiveKey };
|
||||
return (await axios.post(_getUrl('/api/v1/data/event/process'), {
|
||||
eventId,
|
||||
shortName,
|
||||
archive: archive || defaultArchive,
|
||||
}, { headers: _headers() })).data;
|
||||
}
|
||||
module.exports = { produceEvent, getEvent, processEvent };
|
||||
Reference in new issue
Block a user