Contact Delete

This commit is contained in:
Rupenieks 2020-05-04 15:14:22 +02:00
parent dce70ad5c7
commit e17df72dc6
3 changed files with 41 additions and 4 deletions

View file

@ -80,6 +80,14 @@ export class AgileCrm implements INodeType {
}
if(operation === 'delete'){
const contactId = this.getNodeParameter('contactId', i) as string;
const endpoint = `api/contacts/${contactId}`;
responseData = await agileCrmApiRequest.call(this, 'DELETE', endpoint, {});
}
if(operation === 'getAll'){
const returnAll = this.getNodeParameter('returnAll', i) as boolean;

View file

@ -30,6 +30,16 @@ export const contactOperations = [
value: 'create',
description: 'Create a new contact',
},
{
name: 'Update',
value: 'update',
description: 'Update contact properties',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a contact',
},
],
default: 'get',
description: 'The operation to perform.',
@ -555,9 +565,28 @@ export const contactFields = [
]
},
],
},
/* -------------------------------------------------------------------------- */
/* contact:delete */
/* -------------------------------------------------------------------------- */
{
displayName: 'Contact ID',
name: 'contactId',
type: 'string',
required: true,
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'delete',
],
},
},
default: '',
description: 'Unique identifier for a particular contact',
},
] as INodeProperties[];

View file

@ -30,8 +30,8 @@ export async function agileCrmApiRequest(this: IHookFunctions | IExecuteFunction
json: true
};
// Only add Body property if method not GET to avoid 400 response
if(method !== "GET"){
// Only add Body property if method not GET or DELETE to avoid 400 response
if(method !== "GET" && method !== "DELETE"){
options.body = body;
}