mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
* 👕 Enable `consistent-type-imports` for nodes-base * 👕 Apply to nodes-base * ⏪ Undo unrelated changes * 🚚 Move to `.eslintrc.js` in nodes-base * ⏪ Revert "Enable `consistent-type-imports` for nodes-base" This reverts commit 529ad72b051478fa1633aaf84b2864f2fdc7613c. * 👕 Fix severity
36 lines
873 B
TypeScript
36 lines
873 B
TypeScript
import type { ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
|
|
import { NodeOperationError } from 'n8n-workflow';
|
|
|
|
import { apiRequestAllItems } from '../transport';
|
|
|
|
// Get all the available channels
|
|
|
|
export async function getCustomers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
|
const endpoint = 'customers';
|
|
const responseData = await apiRequestAllItems.call(this, 'GET', endpoint, {});
|
|
|
|
if (responseData === undefined) {
|
|
throw new NodeOperationError(this.getNode(), 'No data got returned');
|
|
}
|
|
|
|
const returnData: INodePropertyOptions[] = [];
|
|
for (const data of responseData) {
|
|
returnData.push({
|
|
name: data.fullname as string,
|
|
value: data.id as number,
|
|
});
|
|
}
|
|
|
|
returnData.sort((a, b) => {
|
|
if (a.name < b.name) {
|
|
return -1;
|
|
}
|
|
if (a.name > b.name) {
|
|
return 1;
|
|
}
|
|
return 0;
|
|
});
|
|
|
|
return returnData;
|
|
}
|