Minor improvements to Google Contacts-Node

This commit is contained in:
Jan Oberhauser 2020-08-15 23:26:01 +02:00
parent eb9644f7de
commit b965dc0155
3 changed files with 39 additions and 40 deletions

View file

@ -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`,

View file

@ -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<any> { // tslint:disable-line:no-any
export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // 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) {

View file

@ -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];
}
}