mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(HighLevel Node): Add support for calendar items (#10820)
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import type {
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
INodeListSearchItems,
|
||||
INodeListSearchResult,
|
||||
INodeProperties,
|
||||
INodeType,
|
||||
INodeTypeBaseDescription,
|
||||
@@ -6,6 +10,7 @@ import type {
|
||||
} from 'n8n-workflow';
|
||||
import { NodeConnectionType } from 'n8n-workflow';
|
||||
|
||||
import { calendarFields, calendarOperations } from './description/CalendarDescription';
|
||||
import { contactFields, contactNotes, contactOperations } from './description/ContactDescription';
|
||||
import { opportunityFields, opportunityOperations } from './description/OpportunityDescription';
|
||||
import { taskFields, taskOperations } from './description/TaskDescription';
|
||||
@@ -13,7 +18,6 @@ import {
|
||||
getContacts,
|
||||
getPipelines,
|
||||
getPipelineStages,
|
||||
getTimezones,
|
||||
getUsers,
|
||||
highLevelApiPagination,
|
||||
} from './GenericFunctions';
|
||||
@@ -37,6 +41,10 @@ const resources: INodeProperties[] = [
|
||||
name: 'Task',
|
||||
value: 'task',
|
||||
},
|
||||
{
|
||||
name: 'Calendar',
|
||||
value: 'calendar',
|
||||
},
|
||||
],
|
||||
default: 'contact',
|
||||
required: true,
|
||||
@@ -82,6 +90,8 @@ const versionDescription: INodeTypeDescription = {
|
||||
...opportunityFields,
|
||||
...taskOperations,
|
||||
...taskFields,
|
||||
...calendarOperations,
|
||||
...calendarFields,
|
||||
],
|
||||
};
|
||||
|
||||
@@ -101,7 +111,82 @@ export class HighLevelV2 implements INodeType {
|
||||
getContacts,
|
||||
getPipelineStages,
|
||||
getUsers,
|
||||
getTimezones,
|
||||
},
|
||||
listSearch: {
|
||||
async searchCustomFields(
|
||||
this: ILoadOptionsFunctions,
|
||||
filter?: string,
|
||||
): Promise<INodeListSearchResult> {
|
||||
const { locationId } =
|
||||
((await this.getCredentials('highLevelOAuth2Api'))?.oauthTokenData as IDataObject) ?? {};
|
||||
|
||||
const responseData: IDataObject = (await this.helpers.httpRequestWithAuthentication.call(
|
||||
this,
|
||||
'highLevelOAuth2Api',
|
||||
{
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||
url: `https://services.leadconnectorhq.com/locations/${locationId}/customFields?model=contact`,
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
Version: '2021-07-28',
|
||||
},
|
||||
},
|
||||
)) as IDataObject;
|
||||
|
||||
const customFields = responseData.customFields as Array<{ name: string; id: string }>;
|
||||
|
||||
const results: INodeListSearchItems[] = customFields
|
||||
.map((a) => ({
|
||||
name: a.name,
|
||||
value: a.id,
|
||||
}))
|
||||
.filter((a) => !filter || a.name.toLowerCase().includes(filter.toLowerCase()))
|
||||
.sort((a, b) => {
|
||||
if (a.name.toLowerCase() < b.name.toLowerCase()) return -1;
|
||||
if (a.name.toLowerCase() > b.name.toLowerCase()) return 1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
return { results };
|
||||
},
|
||||
async searchTimezones(
|
||||
this: ILoadOptionsFunctions,
|
||||
filter?: string,
|
||||
): Promise<INodeListSearchResult> {
|
||||
const { locationId } =
|
||||
((await this.getCredentials('highLevelOAuth2Api'))?.oauthTokenData as IDataObject) ?? {};
|
||||
|
||||
const responseData: IDataObject = (await this.helpers.httpRequestWithAuthentication.call(
|
||||
this,
|
||||
'highLevelOAuth2Api',
|
||||
{
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||
url: `https://services.leadconnectorhq.com/locations/${locationId}/timezones`,
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
Version: '2021-07-28',
|
||||
},
|
||||
},
|
||||
)) as IDataObject;
|
||||
|
||||
const timezones = responseData.timeZones as string[];
|
||||
|
||||
const results: INodeListSearchItems[] = timezones
|
||||
.map((zone) => ({
|
||||
name: zone.trim(),
|
||||
value: zone.trim(),
|
||||
}))
|
||||
.filter((zone) => !filter || zone.name.toLowerCase().includes(filter.toLowerCase()))
|
||||
.sort((a, b) => {
|
||||
if (a.name.toLowerCase() < b.name.toLowerCase()) return -1;
|
||||
if (a.name.toLowerCase() > b.name.toLowerCase()) return 1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
return { results };
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user