UNPKG

n8n-nodes-everest-tms

Version:

Everest TMS n8n integration

65 lines 3.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.executeGeneralOperations = executeGeneralOperations; const GenericFunctions_1 = require("../GenericFunctions"); async function executeGeneralOperations(itemIndex) { const operation = this.getNodeParameter('operation', itemIndex); if (operation === 'getPlatformInfo') { return await GenericFunctions_1.everestApiRequest.call(this, 'POST', '/infos'); } if (operation === 'getCurrentUser') { return await GenericFunctions_1.everestApiRequest.call(this, 'POST', '/me'); } if (operation === 'getServices') { const options = this.getNodeParameter('options', itemIndex, {}); const body = (0, GenericFunctions_1.cleanObject)(options); return await GenericFunctions_1.everestApiRequest.call(this, 'POST', '/services', body); } if (operation === 'getSkills') { const options = this.getNodeParameter('options', itemIndex, {}); const body = (0, GenericFunctions_1.cleanObject)(options); return await GenericFunctions_1.everestApiRequest.call(this, 'POST', '/skills', body); } if (operation === 'getStatuses') { return await GenericFunctions_1.everestApiRequest.call(this, 'POST', '/statuses'); } if (operation === 'getVehicleTypes') { return await GenericFunctions_1.everestApiRequest.call(this, 'POST', '/vehicle-types'); } if (operation === 'getAreasOfService') { const options = this.getNodeParameter('options', itemIndex, {}); const body = (0, GenericFunctions_1.cleanObject)(options); return await GenericFunctions_1.everestApiRequest.call(this, 'POST', '/areas-of-service', body); } if (operation === 'getAvailableSlots') { const serviceId = this.getNodeParameter('service_id', itemIndex); const additionalFields = this.getNodeParameter('additionalFields', itemIndex, {}); const body = { service_id: serviceId, ...(0, GenericFunctions_1.cleanObject)(additionalFields), }; if (body.from_time) { body.from_time = Math.floor(new Date(body.from_time).getTime() / 1000); } return await GenericFunctions_1.everestApiRequest.call(this, 'POST', '/slots', body); } if (operation === 'getAvailabilities') { const options = this.getNodeParameter('options', itemIndex, {}); const body = (0, GenericFunctions_1.cleanObject)(options); return await GenericFunctions_1.everestApiRequest.call(this, 'POST', '/availabilities', body); } if (operation === 'checkAddress') { const address = this.getNodeParameter('address', itemIndex); const additionalFields = this.getNodeParameter('additionalFields', itemIndex, {}); const body = { address, ...(0, GenericFunctions_1.cleanObject)(additionalFields), }; if (body.start_date) { body.start_date = Math.floor(new Date(body.start_date).getTime() / 1000); } return await GenericFunctions_1.everestApiRequest.call(this, 'POST', '/is-handled-address', body); } throw new Error(`The operation "${operation}" is not known!`); } //# sourceMappingURL=GeneralOperations.js.map