"use strict"; const axios = require('axios'); const { getConfig } = require('./config.js'); function _getUrl(path) { const cfg = getConfig(); return `${cfg.apiUrl}${path}`; } function _headers(token) { return { 'Authorization': `Bearer ${token || getConfig().apiKey}`, }; } async function getDomains({ fedidUrl, auth: authPayload }) { const cfg = getConfig(); return (await axios.post(_getUrl('/api/v1/data/entity/domains/get'), { fedidUrl: fedidUrl || cfg.fedidUrl, auth: authPayload, }, { headers: _headers() })).data; } async function createEntity({ fedidUrl, shortName }) { const cfg = getConfig(); return (await axios.post(_getUrl('/api/v1/data/entity/create'), { fedidUrl: fedidUrl || cfg.fedidUrl, shortName, }, { headers: _headers() })).data; } async function getEntity({ shortName }) { return (await axios.post(_getUrl('/api/v1/data/entity/get'), { shortName }, { headers: _headers() })); } module.exports = { getDomains, getEntity, createEntity };