From b965dc0155fbddadd29c8af26c83e99d061c3fc8 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Sat, 15 Aug 2020 23:26:01 +0200 Subject: [PATCH] :zap: Minor improvements to Google Contacts-Node --- .../Google/Contacts/ContactDescription.ts | 61 +++++++++---------- .../nodes/Google/Contacts/GenericFunctions.ts | 14 ++--- .../Google/Contacts/GoogleContacts.node.ts | 4 +- 3 files changed, 39 insertions(+), 40 deletions(-) diff --git a/packages/nodes-base/nodes/Google/Contacts/ContactDescription.ts b/packages/nodes-base/nodes/Google/Contacts/ContactDescription.ts index b1e3a45bc..74fff8d06 100644 --- a/packages/nodes-base/nodes/Google/Contacts/ContactDescription.ts +++ b/packages/nodes-base/nodes/Google/Contacts/ContactDescription.ts @@ -1,7 +1,6 @@ import { INodeProperties, } from 'n8n-workflow'; -import { LoadNodeParameterOptions } from 'n8n-core'; export const contactOperations = [ { @@ -471,57 +470,57 @@ export const contactFields = [ type: 'options', options: [ { - name: 'Spouse', - value: 'spouse', - }, - { - name: 'Child', - value: 'child', - }, - { - name: 'Mother', - value: 'mother', - }, - { - name: 'Father', - value: 'father', - }, - { - name: 'Parent', - value: 'parent', + name: 'Assistant', + value: 'assistant', }, { name: 'Brother', value: 'brother', }, { - name: 'Sister', - value: 'sister', - }, - { - name: 'Friend', - value: 'friend', - }, - { - name: 'Relative', - value: 'relative', + name: 'Child', + value: 'child', }, { name: 'Domestic Partner', value: 'domesticPartner', }, + { + name: 'Father', + value: 'father', + }, + { + name: 'Friend', + value: 'friend', + }, { name: 'Manager', value: 'manager', }, { - name: 'Assistant', - value: 'assistant', + name: 'Mother', + value: 'mother', + }, + { + name: 'Parent', + value: 'parent', }, { name: 'Referred By', value: 'referredBy', }, + { + name: 'Relative', + value: 'relative', + }, + { + name: 'Sister', + value: 'sister', + }, + { + name: 'Spouse', + value: 'spouse', + }, ], default: '', description: `The person's relation to the other person. The type can be custom or one of these predefined values`, diff --git a/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts index 950c26126..2996cfe15 100644 --- a/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts @@ -1,6 +1,6 @@ import { OptionsWithUri, - } from 'request'; +} from 'request'; import { IExecuteFunctions, @@ -57,7 +57,7 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF } } -export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any const returnData: IDataObject[] = []; @@ -76,7 +76,7 @@ export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOp return returnData; } -export const allFields = [ +export const allFields = [ 'addresses', 'biographies', 'birthdays', @@ -103,14 +103,14 @@ export const allFields = [ 'userDefined', ]; -export function cleanData(responseData: any) { +export function cleanData(responseData: any) { // tslint:disable-line:no-any const fields = ['emailAddresses', 'phoneNumbers', 'relations', 'events', 'addresses']; const newResponseData = []; if (!Array.isArray(responseData)) { responseData = [responseData]; } - for (let y = 0; y < responseData.length; y++ ) { - const object: { [key: string]: any } = {}; + for (let y = 0; y < responseData.length; y++) { + const object: { [key: string]: any } = {}; // tslint:disable-line:no-any for (const key of Object.keys(responseData[y])) { if (key === 'metadata') { continue; @@ -140,7 +140,7 @@ export function cleanData(responseData: any) { } } if (fields.includes(key)) { - const value: { [key: string]: any } = {}; + const value: { [key: string]: any } = {}; // tslint:disable-line:no-any for (const data of responseData[y][key]) { let result; if (value[data.type] === undefined) { diff --git a/packages/nodes-base/nodes/Google/Contacts/GoogleContacts.node.ts b/packages/nodes-base/nodes/Google/Contacts/GoogleContacts.node.ts index 313c68da0..10eee8be6 100644 --- a/packages/nodes-base/nodes/Google/Contacts/GoogleContacts.node.ts +++ b/packages/nodes-base/nodes/Google/Contacts/GoogleContacts.node.ts @@ -78,7 +78,7 @@ export class GoogleContacts implements INodeType { 'contactGroups', 'GET', `/contactGroups`, - ); + ); for (const group of groups) { const groupName = group.name; const groupId = group.resourceName; @@ -294,7 +294,7 @@ export class GoogleContacts implements INodeType { responseData = cleanData(responseData); } - for (let i = 0; i < responseData.length; i++ ) { + for (let i = 0; i < responseData.length; i++) { responseData[i].contactId = responseData[i].resourceName.split('/')[1]; } }