n8n-nodes-cigotracker
Version:
n8n node for CigoTracker API integration - manage deliveries, routes, and field service operations
83 lines (82 loc) • 2.9 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CigoTrackerMinimal = void 0;
const CigoTracker_helpers_1 = require("./CigoTracker.helpers");
class CigoTrackerMinimal {
constructor() {
this.description = {
displayName: 'CigoTracker Minimal',
name: 'cigoTrackerMinimal',
icon: 'file:Cigo-Logo.png',
group: ['transform'],
version: 1,
description: 'Minimal CigoTracker test node',
defaults: {
name: 'CigoTracker Minimal',
},
inputs: ['main'],
outputs: ['main'],
credentials: [
{
name: 'cigoTrackerApi',
required: true,
},
],
properties: [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
options: [
{
name: 'Test Message',
value: 'test',
description: 'Return a test message',
},
{
name: 'Ping API',
value: 'ping',
description: 'Test API connection',
},
],
default: 'test',
description: 'Choose operation',
},
],
};
}
async execute() {
const items = this.getInputData();
const operation = this.getNodeParameter('operation', 0);
try {
if (operation === 'test') {
return [[{
json: {
message: 'Test successful',
itemCount: items.length,
timestamp: new Date().toISOString(),
}
}]];
}
else if (operation === 'ping') {
const response = await CigoTracker_helpers_1.cigoTrackerApiRequest.call(this, 'GET', '/ping');
return [[{
json: response || { message: 'Ping successful' }
}]];
}
}
catch (error) {
if (this.continueOnFail()) {
return [[{
json: {
error: error instanceof Error ? error.message : 'Unknown error',
operation,
}
}]];
}
throw error;
}
return [[{ json: { message: 'No operation performed' } }]];
}
}
exports.CigoTrackerMinimal = CigoTrackerMinimal;