n8n-3867-progressively-apply-prettier-to-all (#3873)

* 🔨 formatting nodes with prettier
This commit is contained in:
Michael Kret
2022-08-17 18:50:24 +03:00
committed by GitHub
parent f2d326c7f0
commit 91d7e16c81
1072 changed files with 42357 additions and 59109 deletions

View File

@@ -1,6 +1,4 @@
import {
IExecuteFunctions,
} from 'n8n-core';
import { IExecuteFunctions } from 'n8n-core';
import {
ICredentialDataDecryptedObject,
@@ -28,57 +26,27 @@ import {
hubspotApiRequestAllItems,
} from './GenericFunctions';
import {
contactFields,
contactOperations,
} from './ContactDescription';
import { contactFields, contactOperations } from './ContactDescription';
import {
contactListFields,
contactListOperations,
} from './ContactListDescription';
import { contactListFields, contactListOperations } from './ContactListDescription';
import {
companyFields,
companyOperations,
} from './CompanyDescription';
import { companyFields, companyOperations } from './CompanyDescription';
import {
dealFields,
dealOperations,
} from './DealDescription';
import { dealFields, dealOperations } from './DealDescription';
import {
engagementFields,
engagementOperations,
} from './EngagementDescription';
import { engagementFields, engagementOperations } from './EngagementDescription';
import {
formFields,
formOperations,
} from './FormDescription';
import { formFields, formOperations } from './FormDescription';
import {
ticketFields,
ticketOperations,
} from './TicketDescription';
import { ticketFields, ticketOperations } from './TicketDescription';
import {
IForm,
} from './FormInterface';
import { IForm } from './FormInterface';
import {
IAssociation,
IDeal,
} from './DealInterface';
import { IAssociation, IDeal } from './DealInterface';
import {
snakeCase,
} from 'change-case';
import { snakeCase } from 'change-case';
import {
validateCredentials
} from './GenericFunctions';
import { validateCredentials } from './GenericFunctions';
export class Hubspot implements INodeType {
description: INodeTypeDescription = {
displayName: 'HubSpot',
@@ -100,9 +68,7 @@ export class Hubspot implements INodeType {
testedBy: 'hubspotApiTest',
displayOptions: {
show: {
authentication: [
'apiKey',
],
authentication: ['apiKey'],
},
},
},
@@ -112,9 +78,7 @@ export class Hubspot implements INodeType {
testedBy: 'hubspotApiTest',
displayOptions: {
show: {
authentication: [
'appToken',
],
authentication: ['appToken'],
},
},
},
@@ -123,9 +87,7 @@ export class Hubspot implements INodeType {
required: true,
displayOptions: {
show: {
authentication: [
'oAuth2',
],
authentication: ['oAuth2'],
},
},
},
@@ -214,7 +176,10 @@ export class Hubspot implements INodeType {
methods = {
credentialTest: {
async hubspotApiTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise<INodeCredentialTestResult> {
async hubspotApiTest(
this: ICredentialTestFunctions,
credential: ICredentialsDecrypted,
): Promise<INodeCredentialTestResult> {
try {
await validateCredentials.call(this, credential.data as ICredentialDataDecryptedObject);
} catch (error) {
@@ -282,7 +247,9 @@ export class Hubspot implements INodeType {
// Get all the contact lifecycle stages to display them to user so that he can
// select them easily
async getContactLifeCycleStages(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
async getContactLifeCycleStages(
this: ILoadOptionsFunctions,
): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const endpoint = '/properties/v2/contacts/properties';
const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {});
@@ -303,7 +270,9 @@ export class Hubspot implements INodeType {
// Get all the contact lifecycle stages to display them to user so that he can
// select them easily
async getContactOriginalSources(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
async getContactOriginalSources(
this: ILoadOptionsFunctions,
): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const endpoint = '/properties/v2/contacts/properties';
const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {});
@@ -324,7 +293,9 @@ export class Hubspot implements INodeType {
// Get all the contact preffered languages to display them to user so that he can
// select them easily
async getContactPrefferedLanguages(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
async getContactPrefferedLanguages(
this: ILoadOptionsFunctions,
): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const endpoint = '/properties/v2/contacts/properties';
const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {});
@@ -383,7 +354,9 @@ export class Hubspot implements INodeType {
// Get all the contact properties to display them to user so that he can
// select them easily
async getContactCustomProperties(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
async getContactCustomProperties(
this: ILoadOptionsFunctions,
): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const endpoint = '/properties/v2/contacts/properties';
const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {});
@@ -402,7 +375,9 @@ export class Hubspot implements INodeType {
// Get all the contact number of employees options to display them to user so that he can
// select them easily
async getContactNumberOfEmployees(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
async getContactNumberOfEmployees(
this: ILoadOptionsFunctions,
): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const endpoint = '/properties/v2/contacts/properties';
const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {});
@@ -469,7 +444,9 @@ export class Hubspot implements INodeType {
// Get all the company lifecycle stages to display them to user so that he can
// select them easily
async getCompanylifecycleStages(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
async getCompanylifecycleStages(
this: ILoadOptionsFunctions,
): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const endpoint = '/properties/v2/companies/properties';
const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {});
@@ -553,7 +530,9 @@ export class Hubspot implements INodeType {
// Get all the company web technologies stages to display them to user so that he can
// select them easily
async getCompanyWebTechnologies(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
async getCompanyWebTechnologies(
this: ILoadOptionsFunctions,
): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const endpoint = '/properties/v2/companies/properties';
const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {});
@@ -591,7 +570,9 @@ export class Hubspot implements INodeType {
// Get all the company custom properties to display them to user so that he can
// select them easily
async getCompanyCustomProperties(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
async getCompanyCustomProperties(
this: ILoadOptionsFunctions,
): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const endpoint = '/properties/v2/companies/properties';
const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {});
@@ -708,7 +689,13 @@ export class Hubspot implements INodeType {
async getSubscriptionTypes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const endpoint = '/email/public/v1/subscriptions';
const subscriptions = await hubspotApiRequestAllItems.call(this, 'subscriptionDefinitions', 'GET', endpoint, {});
const subscriptions = await hubspotApiRequestAllItems.call(
this,
'subscriptionDefinitions',
'GET',
endpoint,
{},
);
for (const subscription of subscriptions) {
const subscriptionName = subscription.name;
const subscriptionId = subscription.id;
@@ -742,7 +729,7 @@ export class Hubspot implements INodeType {
}
}
}
return returnData.sort((a, b) => a.name < b.name ? 0 : 1);
return returnData.sort((a, b) => (a.name < b.name ? 0 : 1));
},
// Get all the ticket pipelines to display them to user so that he can
@@ -818,7 +805,7 @@ export class Hubspot implements INodeType {
}
}
}
return returnData.sort((a, b) => a.name < b.name ? 0 : 1);
return returnData.sort((a, b) => (a.name < b.name ? 0 : 1));
},
// Get all the ticket sources to display them to user so that he can
@@ -839,7 +826,7 @@ export class Hubspot implements INodeType {
}
}
}
return returnData.sort((a, b) => a.name < b.name ? 0 : 1);
return returnData.sort((a, b) => (a.name < b.name ? 0 : 1));
},
// Get all the ticket stages to display them to user so that he can
@@ -896,16 +883,25 @@ export class Hubspot implements INodeType {
properties: ['name'],
};
const endpoint = '/companies/v2/companies/paged';
const companies = await hubspotApiRequestAllItems.call(this, 'companies', 'GET', endpoint, {}, qs);
const companies = await hubspotApiRequestAllItems.call(
this,
'companies',
'GET',
endpoint,
{},
qs,
);
for (const company of companies) {
const companyName = (company.properties.name) ? company.properties.name.value : company.companyId;
const companyName = company.properties.name
? company.properties.name.value
: company.companyId;
const companyId = company.companyId;
returnData.push({
name: companyName,
value: companyId,
});
}
return returnData.sort((a, b) => a.name < b.name ? 0 : 1);
return returnData.sort((a, b) => (a.name < b.name ? 0 : 1));
},
// Get all the companies to display them to user so that he can
@@ -926,9 +922,8 @@ export class Hubspot implements INodeType {
description: `Contact VID: ${contactId}`,
});
}
return returnData.sort((a, b) => a.name < b.name ? 0 : 1);
return returnData.sort((a, b) => (a.name < b.name ? 0 : 1));
},
},
};
@@ -958,7 +953,12 @@ export class Hubspot implements INodeType {
body.emails.push(email as never);
}
}
responseData = await hubspotApiRequest.call(this, 'POST', `/contacts/v1/lists/${listId}/add`, body);
responseData = await hubspotApiRequest.call(
this,
'POST',
`/contacts/v1/lists/${listId}/add`,
body,
);
returnData.push(responseData);
}
//https://legacydocs.hubspot.com/docs/methods/lists/remove_contact_from_list
@@ -969,7 +969,12 @@ export class Hubspot implements INodeType {
const id = this.getNodeParameter('id', i) as string;
body.vids.push(parseInt(id, 10) as never);
}
responseData = await hubspotApiRequest.call(this, 'POST', `/contacts/v1/lists/${listId}/remove`, body);
responseData = await hubspotApiRequest.call(
this,
'POST',
`/contacts/v1/lists/${listId}/remove`,
body,
);
returnData.push(responseData);
}
} catch (error) {
@@ -1262,7 +1267,8 @@ export class Hubspot implements INodeType {
}
if (additionalFields.customPropertiesUi) {
const customProperties = (additionalFields.customPropertiesUi as IDataObject).customPropertiesValues as IDataObject[];
const customProperties = (additionalFields.customPropertiesUi as IDataObject)
.customPropertiesValues as IDataObject[];
if (customProperties) {
for (const customProperty of customProperties) {
@@ -1275,7 +1281,9 @@ export class Hubspot implements INodeType {
}
const endpoint = `/contacts/v1/contact/createOrUpdate/email/${email}`;
responseData = await hubspotApiRequest.call(this, 'POST', endpoint, { properties: body });
responseData = await hubspotApiRequest.call(this, 'POST', endpoint, {
properties: body,
});
if (additionalFields.associatedCompanyId) {
const companyAssociations: IDataObject[] = [];
@@ -1285,7 +1293,12 @@ export class Hubspot implements INodeType {
category: 'HUBSPOT_DEFINED',
definitionId: 1,
});
await hubspotApiRequest.call(this, 'PUT', '/crm-associations/v1/associations/create-batch', companyAssociations);
await hubspotApiRequest.call(
this,
'PUT',
'/crm-associations/v1/associations/create-batch',
companyAssociations,
);
}
if (resolveData) {
@@ -1294,7 +1307,13 @@ export class Hubspot implements INodeType {
if (additionalFields.properties) {
qs.property = additionalFields.properties as string[];
}
responseData = await hubspotApiRequest.call(this, 'GET', `/contacts/v1/contact/vid/${responseData.vid}/profile`, {}, qs);
responseData = await hubspotApiRequest.call(
this,
'GET',
`/contacts/v1/contact/vid/${responseData.vid}/profile`,
{},
qs,
);
responseData.isNew = isNew;
}
}
@@ -1335,7 +1354,14 @@ export class Hubspot implements INodeType {
}
const endpoint = '/contacts/v1/lists/all/contacts/all';
if (returnAll) {
responseData = await hubspotApiRequestAllItems.call(this, 'contacts', 'GET', endpoint, {}, qs);
responseData = await hubspotApiRequestAllItems.call(
this,
'contacts',
'GET',
endpoint,
{},
qs,
);
} else {
qs.count = this.getNodeParameter('limit', 0) as number;
responseData = await hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
@@ -1363,7 +1389,14 @@ export class Hubspot implements INodeType {
endpoint = '/contacts/v1/lists/recently_updated/contacts/recent';
if (returnAll) {
responseData = await hubspotApiRequestAllItems.call(this, 'contacts', 'GET', endpoint, {}, qs);
responseData = await hubspotApiRequestAllItems.call(
this,
'contacts',
'GET',
endpoint,
{},
qs,
);
} else {
qs.count = this.getNodeParameter('limit', 0) as number;
responseData = await hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
@@ -1394,12 +1427,14 @@ export class Hubspot implements INodeType {
};
if (filtersGroupsUi) {
const filterGroupValues = (filtersGroupsUi as IDataObject).filterGroupsValues as IDataObject[];
const filterGroupValues = (filtersGroupsUi as IDataObject)
.filterGroupsValues as IDataObject[];
if (filterGroupValues) {
body.filterGroups = [];
for (const filterGroupValue of filterGroupValues) {
if (filterGroupValue.filtersUi) {
const filterValues = (filterGroupValue.filtersUi as IDataObject).filterValues as IDataObject[];
const filterValues = (filterGroupValue.filtersUi as IDataObject)
.filterValues as IDataObject[];
if (filterValues) {
//@ts-ignore
body.filterGroups.push({ filters: filterValues });
@@ -1414,7 +1449,14 @@ export class Hubspot implements INodeType {
const endpoint = '/crm/v3/objects/contacts/search';
if (returnAll) {
responseData = await hubspotApiRequestAllItems.call(this, 'results', 'POST', endpoint, body, qs);
responseData = await hubspotApiRequestAllItems.call(
this,
'results',
'POST',
endpoint,
body,
qs,
);
} else {
body.limit = this.getNodeParameter('limit', 0) as number;
responseData = await hubspotApiRequest.call(this, 'POST', endpoint, body, qs);
@@ -1632,7 +1674,8 @@ export class Hubspot implements INodeType {
});
}
if (additionalFields.customPropertiesUi) {
const customProperties = (additionalFields.customPropertiesUi as IDataObject).customPropertiesValues as IDataObject[];
const customProperties = (additionalFields.customPropertiesUi as IDataObject)
.customPropertiesValues as IDataObject[];
if (customProperties) {
for (const customProperty of customProperties) {
@@ -1644,7 +1687,9 @@ export class Hubspot implements INodeType {
}
}
const endpoint = '/companies/v2/companies';
responseData = await hubspotApiRequest.call(this, 'POST', endpoint, { properties: body });
responseData = await hubspotApiRequest.call(this, 'POST', endpoint, {
properties: body,
});
}
//https://developers.hubspot.com/docs/methods/companies/update_company
if (operation === 'update') {
@@ -1856,7 +1901,8 @@ export class Hubspot implements INodeType {
});
}
if (updateFields.customPropertiesUi) {
const customProperties = (updateFields.customPropertiesUi as IDataObject).customPropertiesValues as IDataObject[];
const customProperties = (updateFields.customPropertiesUi as IDataObject)
.customPropertiesValues as IDataObject[];
if (customProperties) {
for (const customProperty of customProperties) {
@@ -1868,7 +1914,9 @@ export class Hubspot implements INodeType {
}
}
const endpoint = `/companies/v2/companies/${companyId}`;
responseData = await hubspotApiRequest.call(this, 'PUT', endpoint, { properties: body });
responseData = await hubspotApiRequest.call(this, 'PUT', endpoint, {
properties: body,
});
}
//https://developers.hubspot.com/docs/methods/companies/get_company
if (operation === 'get') {
@@ -1895,7 +1943,14 @@ export class Hubspot implements INodeType {
}
const endpoint = `/companies/v2/companies/paged`;
if (returnAll) {
responseData = await hubspotApiRequestAllItems.call(this, 'companies', 'GET', endpoint, {}, qs);
responseData = await hubspotApiRequestAllItems.call(
this,
'companies',
'GET',
endpoint,
{},
qs,
);
} else {
qs.limit = this.getNodeParameter('limit', 0) as number;
responseData = await hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
@@ -1916,7 +1971,14 @@ export class Hubspot implements INodeType {
endpoint = `/companies/v2/companies/recent/modified`;
}
if (returnAll) {
responseData = await hubspotApiRequestAllItems.call(this, 'results', 'GET', endpoint, {}, qs);
responseData = await hubspotApiRequestAllItems.call(
this,
'results',
'GET',
endpoint,
{},
qs,
);
} else {
qs.count = this.getNodeParameter('limit', 0) as number;
responseData = await hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
@@ -1936,7 +1998,13 @@ export class Hubspot implements INodeType {
}
const endpoint = `/companies/v2/domains/${domain}/companies`;
if (returnAll) {
responseData = await hubspotApiRequestAllItems.call(this, 'results', 'POST', endpoint, body);
responseData = await hubspotApiRequestAllItems.call(
this,
'results',
'POST',
endpoint,
body,
);
} else {
body.limit = this.getNodeParameter('limit', 0) as number;
responseData = await hubspotApiRequest.call(this, 'POST', endpoint, body);
@@ -2007,7 +2075,8 @@ export class Hubspot implements INodeType {
});
}
if (additionalFields.customPropertiesUi) {
const customProperties = (additionalFields.customPropertiesUi as IDataObject).customPropertiesValues as IDataObject[];
const customProperties = (additionalFields.customPropertiesUi as IDataObject)
.customPropertiesValues as IDataObject[];
if (customProperties) {
for (const customProperty of customProperties) {
body.properties.push({
@@ -2069,7 +2138,8 @@ export class Hubspot implements INodeType {
});
}
if (updateFields.customPropertiesUi) {
const customProperties = (updateFields.customPropertiesUi as IDataObject).customPropertiesValues as IDataObject[];
const customProperties = (updateFields.customPropertiesUi as IDataObject)
.customPropertiesValues as IDataObject[];
if (customProperties) {
for (const customProperty of customProperties) {
body.properties.push({
@@ -2099,15 +2169,26 @@ export class Hubspot implements INodeType {
}
if (filters.properties) {
const properties = filters.properties as string | string[];
qs.properties = (!Array.isArray(filters.properties)) ? (properties as string).split(',') : properties;
qs.properties = !Array.isArray(filters.properties)
? (properties as string).split(',')
: properties;
}
if (filters.propertiesWithHistory) {
const propertiesWithHistory = filters.propertiesWithHistory as string | string[];
qs.propertiesWithHistory = (!Array.isArray(filters.propertiesWithHistory)) ? (propertiesWithHistory as string).split(',') : propertiesWithHistory;
qs.propertiesWithHistory = !Array.isArray(filters.propertiesWithHistory)
? (propertiesWithHistory as string).split(',')
: propertiesWithHistory;
}
const endpoint = `/deals/v1/deal/paged`;
if (returnAll) {
responseData = await hubspotApiRequestAllItems.call(this, 'deals', 'GET', endpoint, {}, qs);
responseData = await hubspotApiRequestAllItems.call(
this,
'deals',
'GET',
endpoint,
{},
qs,
);
} else {
qs.limit = this.getNodeParameter('limit', 0) as number;
responseData = await hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
@@ -2130,7 +2211,14 @@ export class Hubspot implements INodeType {
endpoint = `/deals/v1/deal/recent/modified`;
}
if (returnAll) {
responseData = await hubspotApiRequestAllItems.call(this, 'results', 'GET', endpoint, {}, qs);
responseData = await hubspotApiRequestAllItems.call(
this,
'results',
'GET',
endpoint,
{},
qs,
);
} else {
qs.count = this.getNodeParameter('limit', 0) as number;
responseData = await hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
@@ -2160,12 +2248,14 @@ export class Hubspot implements INodeType {
};
if (filtersGroupsUi) {
const filterGroupValues = (filtersGroupsUi as IDataObject).filterGroupsValues as IDataObject[];
const filterGroupValues = (filtersGroupsUi as IDataObject)
.filterGroupsValues as IDataObject[];
if (filterGroupValues) {
body.filterGroups = [];
for (const filterGroupValue of filterGroupValues) {
if (filterGroupValue.filtersUi) {
const filterValues = (filterGroupValue.filtersUi as IDataObject).filterValues as IDataObject[];
const filterValues = (filterGroupValue.filtersUi as IDataObject)
.filterValues as IDataObject[];
if (filterValues) {
//@ts-ignore
body.filterGroups.push({ filters: filterValues });
@@ -2180,9 +2270,14 @@ export class Hubspot implements INodeType {
const endpoint = '/crm/v3/objects/deals/search';
if (returnAll) {
responseData = await hubspotApiRequestAllItems.call(this, 'results', 'POST', endpoint, body, qs);
responseData = await hubspotApiRequestAllItems.call(
this,
'results',
'POST',
endpoint,
body,
qs,
);
} else {
body.limit = this.getNodeParameter('limit', 0) as number;
responseData = await hubspotApiRequest.call(this, 'POST', endpoint, body, qs);
@@ -2195,19 +2290,24 @@ export class Hubspot implements INodeType {
if (operation === 'create') {
const type = this.getNodeParameter('type', i) as string;
const metadata = this.getNodeParameter('metadata', i) as IDataObject;
const associations = this.getNodeParameter('additionalFields.associations', i, {}) as IDataObject;
const associations = this.getNodeParameter(
'additionalFields.associations',
i,
{},
) as IDataObject;
if (!Object.keys(metadata).length) {
throw new NodeOperationError(
this.getNode(),
`At least one metadata field needs to set`, { itemIndex: i },
`At least one metadata field needs to set`,
{ itemIndex: i },
);
}
const body: {
engagement: { type: string },
metadata: IDataObject,
associations: IDataObject
engagement: { type: string };
metadata: IDataObject;
associations: IDataObject;
} = {
engagement: {
type: type.toUpperCase(),
@@ -2256,7 +2356,14 @@ export class Hubspot implements INodeType {
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
const endpoint = `/engagements/v1/engagements/paged`;
if (returnAll) {
responseData = await hubspotApiRequestAllItems.call(this, 'results', 'GET', endpoint, {}, qs);
responseData = await hubspotApiRequestAllItems.call(
this,
'results',
'GET',
endpoint,
{},
qs,
);
} else {
qs.limit = this.getNodeParameter('limit', 0) as number;
responseData = await hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
@@ -2269,16 +2376,27 @@ export class Hubspot implements INodeType {
//https://developers.hubspot.com/docs/methods/forms/v2/get_fields
if (operation === 'getFields') {
const formId = this.getNodeParameter('formId', i) as string;
responseData = await hubspotApiRequest.call(this, 'GET', `/forms/v2/fields/${formId}`);
responseData = await hubspotApiRequest.call(
this,
'GET',
`/forms/v2/fields/${formId}`,
);
}
//https://developers.hubspot.com/docs/methods/forms/submit_form_v3
if (operation === 'submit') {
const formId = this.getNodeParameter('formId', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const context = (this.getNodeParameter('contextUi', i) as IDataObject).contextValue as IDataObject;
const legalConsent = (this.getNodeParameter('lengalConsentUi', i) as IDataObject).lengalConsentValues as IDataObject;
const legitimateInteres = (this.getNodeParameter('lengalConsentUi', i) as IDataObject).legitimateInterestValues as IDataObject;
const { portalId } = await hubspotApiRequest.call(this, 'GET', `/forms/v2/forms/${formId}`);
const context = (this.getNodeParameter('contextUi', i) as IDataObject)
.contextValue as IDataObject;
const legalConsent = (this.getNodeParameter('lengalConsentUi', i) as IDataObject)
.lengalConsentValues as IDataObject;
const legitimateInteres = (this.getNodeParameter('lengalConsentUi', i) as IDataObject)
.legitimateInterestValues as IDataObject;
const { portalId } = await hubspotApiRequest.call(
this,
'GET',
`/forms/v2/forms/${formId}`,
);
const body: IForm = {
formId,
portalId,
@@ -2300,7 +2418,8 @@ export class Hubspot implements INodeType {
consent!.text = legalConsent.text as string;
}
if (legalConsent.communicationsUi) {
consent.communications = (legalConsent.communicationsUi as IDataObject).communicationValues as IDataObject;
consent.communications = (legalConsent.communicationsUi as IDataObject)
.communicationValues as IDataObject;
}
}
body.legalConsentOptions!.consent = consent;
@@ -2309,7 +2428,9 @@ export class Hubspot implements INodeType {
body.fields?.push({ name: key, value: fields[key] });
}
if (body.legalConsentOptions!.legitimateInterest) {
Object.assign(body, { legalConsentOptions: { legitimateInterest: legitimateInteres } });
Object.assign(body, {
legalConsentOptions: { legitimateInterest: legitimateInteres },
});
}
if (context) {
clean(context);
@@ -2405,7 +2526,12 @@ export class Hubspot implements INodeType {
definitionId: 26,
});
}
await hubspotApiRequest.call(this, 'PUT', '/crm-associations/v1/associations/create-batch', companyAssociations);
await hubspotApiRequest.call(
this,
'PUT',
'/crm-associations/v1/associations/create-batch',
companyAssociations,
);
}
if (additionalFields.associatedContactIds) {
@@ -2418,7 +2544,12 @@ export class Hubspot implements INodeType {
definitionId: 16,
});
}
await hubspotApiRequest.call(this, 'PUT', '/crm-associations/v1/associations/create-batch', contactAssociations);
await hubspotApiRequest.call(
this,
'PUT',
'/crm-associations/v1/associations/create-batch',
contactAssociations,
);
}
}
//https://developers.hubspot.com/docs/methods/tickets/get_ticket_by_id
@@ -2429,7 +2560,9 @@ export class Hubspot implements INodeType {
qs.properties = additionalFields.properties as string[];
}
if (additionalFields.propertiesWithHistory) {
qs.propertiesWithHistory = (additionalFields.propertiesWithHistory as string).split(',');
qs.propertiesWithHistory = (additionalFields.propertiesWithHistory as string).split(
',',
);
}
if (additionalFields.includeDeleted) {
qs.includeDeleted = additionalFields.includeDeleted as boolean;
@@ -2445,14 +2578,30 @@ export class Hubspot implements INodeType {
qs.properties = additionalFields.properties as string[];
}
if (additionalFields.propertiesWithHistory) {
qs.propertiesWithHistory = (additionalFields.propertiesWithHistory as string).split(',');
qs.propertiesWithHistory = (additionalFields.propertiesWithHistory as string).split(
',',
);
}
const endpoint = `/crm-objects/v1/objects/tickets/paged`;
if (returnAll) {
responseData = await hubspotApiRequestAllItems.call(this, 'objects', 'GET', endpoint, {}, qs);
responseData = await hubspotApiRequestAllItems.call(
this,
'objects',
'GET',
endpoint,
{},
qs,
);
} else {
qs.limit = this.getNodeParameter('limit', 0) as number;
responseData = await hubspotApiRequestAllItems.call(this, 'objects', 'GET', endpoint, {}, qs);
responseData = await hubspotApiRequestAllItems.call(
this,
'objects',
'GET',
endpoint,
{},
qs,
);
responseData = responseData.splice(0, qs.limit);
}
}
@@ -2547,7 +2696,12 @@ export class Hubspot implements INodeType {
definitionId: 26,
});
}
await hubspotApiRequest.call(this, 'PUT', '/crm-associations/v1/associations/create-batch', companyAssociations);
await hubspotApiRequest.call(
this,
'PUT',
'/crm-associations/v1/associations/create-batch',
companyAssociations,
);
}
if (updateFields.associatedContactIds) {
@@ -2560,7 +2714,12 @@ export class Hubspot implements INodeType {
definitionId: 16,
});
}
await hubspotApiRequest.call(this, 'PUT', '/crm-associations/v1/associations/create-batch', contactAssociations);
await hubspotApiRequest.call(
this,
'PUT',
'/crm-associations/v1/associations/create-batch',
contactAssociations,
);
}
}
}