UNPKG

@eleva-io/erp-sdk

Version:

SDK oficial para el ERP de Eleva

46 lines 1.4 kB
import { requireField } from '../../../../utils/guards'; import { CRUD } from '../../../../utils'; export class TicketingTaskResourcesAPI { _httpClient; _baseUrl; _taskId; _cud; _r; constructor(_httpClient, _baseUrl, _taskId) { this._httpClient = _httpClient; this._baseUrl = _baseUrl; this._taskId = _taskId; this._cud = new CRUD(this._httpClient, { basePath: `${this._baseUrl}/${this._taskId}/resources`, }); this._r = new CRUD(this._httpClient, { basePath: `${this._baseUrl}/resources`, }); } async find(query) { if (this._taskId) { const taskId = query?.taskId || []; taskId.push(this._taskId); if (query) { query.taskId = taskId; } else { query = { taskId }; } } return this._r.find(query); } async create(data) { requireField('taskId', this._taskId); return this._cud.create(data); } async update(refId, data) { requireField('taskId', this._taskId); return this._httpClient.patch(`${this._baseUrl}/${this._taskId}/resources/${refId}`, data); } async delete(refId) { requireField('taskId', this._taskId); return this._cud.delete(refId); } } //# sourceMappingURL=resources.js.map