@eleva-io/erp-sdk
Version:
SDK oficial para el ERP de Eleva
62 lines • 1.96 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReceiptsDetailsAPI = exports.ReceiptsAPI = void 0;
const crud_1 = require("../../../../utils/crud");
const guards_1 = require("../../../../utils/guards");
class ReceiptsAPI {
_httpClient;
_baseUrl;
_receiptId;
_crud;
constructor(_httpClient, _baseUrl, _receiptId) {
this._httpClient = _httpClient;
this._baseUrl = _baseUrl;
this._receiptId = _receiptId;
this._crud = new crud_1.CRUD(_httpClient, {
basePath: _baseUrl,
id: _receiptId,
});
}
get(id) {
return this._crud.get(id);
}
create(propertyId, data) {
return this._httpClient.post(`${this._baseUrl}/properties/${propertyId}`, data);
}
update(id, data) {
return this._crud.update(id, data);
}
delete(id) {
return this._crud.delete(id);
}
find(query) {
return this._crud.find(query);
}
totalDebt(query) {
return this._httpClient.get(`${this._baseUrl}/total-debt`, query);
}
summary(query) {
return this._httpClient.get(`${this._baseUrl}/summary`, query);
}
details(id) {
const receiptId = this._getIdParam(id);
return new ReceiptsDetailsAPI(this._httpClient, `${this._baseUrl}/${receiptId}/details`);
}
async download(id) {
const receiptId = this._getIdParam(id);
return this._httpClient.getBinary(`${this._baseUrl}/${receiptId}/download`);
}
_getIdParam(id) {
const receiptId = id || this._receiptId;
(0, guards_1.requireField)('receiptId', receiptId);
return receiptId;
}
}
exports.ReceiptsAPI = ReceiptsAPI;
class ReceiptsDetailsAPI extends crud_1.CRUD {
constructor(httpClient, baseUrl) {
super(httpClient, { basePath: baseUrl });
}
}
exports.ReceiptsDetailsAPI = ReceiptsDetailsAPI;
//# sourceMappingURL=receipts.js.map