UNPKG

@railzai/railz-visualizations

Version:
40 lines 1.29 kB
/*! * Accounting Data as a Service™ is the solution that makes sense of your business customers' financial data. * Built with Stencil * Copyright (c) FIS. */ import { RAILZ_API_HOST } from '../types/constants/endpoints'; import { ConfigurationInstance } from './configuration'; /** * RequestService to make API Calls to Accounting Data as a Service™ **/ class RequestService { constructor() { this.getUrl = () => { var _a; return ((_a = ConfigurationInstance.configuration) === null || _a === void 0 ? void 0 : _a.endpoint) || RAILZ_API_HOST; }; } async getReportData({ path, filter, }) { const url = `${path}?${new URLSearchParams(filter)}`; return await this.getRequest({ url, }); } async getRequest({ url, }) { var _a; const token = (_a = ConfigurationInstance.configuration) === null || _a === void 0 ? void 0 : _a.token; const baseUrl = this.getUrl(); return await fetch(`${baseUrl}${url}`, { headers: { authorization: `Bearer ${token}`, }, }).then((response) => { if (response.status === 204 || response.status === 202) return response; return response.json(); }); } } export const RequestServiceInstance = new RequestService(); //# sourceMappingURL=request.js.map