@ikarha/emecef
Version:
Node.js client library for interacting with the Benin e-MCF API for normalized invoicing
56 lines (55 loc) • 1.91 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.InfoService = void 0;
const axios_1 = __importDefault(require("axios"));
const config_1 = require("./config");
const api_error_1 = require("../errors/api-error");
class InfoService {
constructor() {
const apiConfig = (0, config_1.getConfig)();
this.axiosInstance = axios_1.default.create({
baseURL: `${apiConfig.baseUrl}/info`,
headers: apiConfig.headers
});
}
async getEmeCefInfo() {
try {
const response = await this.axiosInstance.get('/status');
return api_error_1.EmecfApiError.checkSuccessResponse(response);
}
catch (error) {
throw api_error_1.EmecfApiError.fromResponse(error);
}
}
async getTaxGroups() {
try {
const response = await this.axiosInstance.get('/taxGroups');
return api_error_1.EmecfApiError.checkSuccessResponse(response);
}
catch (error) {
throw api_error_1.EmecfApiError.fromResponse(error);
}
}
async getInvoiceTypes() {
try {
const response = await this.axiosInstance.get('/invoiceTypes');
return api_error_1.EmecfApiError.checkSuccessResponse(response);
}
catch (error) {
throw api_error_1.EmecfApiError.fromResponse(error);
}
}
async getPaymentTypes() {
try {
const response = await this.axiosInstance.get('/paymentTypes');
return api_error_1.EmecfApiError.checkSuccessResponse(response);
}
catch (error) {
throw api_error_1.EmecfApiError.fromResponse(error);
}
}
}
exports.InfoService = InfoService;