feat: add get person by email to Copper

Copper 'Person' is more conveniently fetched by email (a unique key)
in most workflows. Add a getPersonByEmail via

https://developer.copper.com/people/fetch-a-person-by-email.html
This commit is contained in:
Don Bowman 2024-11-11 19:41:50 -05:00
parent c08d23c00f
commit fd7417d8b0
No known key found for this signature in database
GPG key ID: D21D0E75160D9894
2 changed files with 40 additions and 0 deletions

View file

@ -422,6 +422,23 @@ export class Copper implements INodeType {
const personId = this.getNodeParameter('personId', i);
responseData = await copperApiRequest.call(this, 'GET', `/people/${personId}`);
} else if (operation === 'getByEmail') {
// ----------------------------------------
// person: getByEmail
// ----------------------------------------
// https://developer.copper.com/people/fetch-a-person-by-email.html
const body: IDataObject = {
email: this.getNodeParameter('personEmail', i),
};
responseData = await copperApiRequest.call(
this,
'POST',
'/people/fetch_by_email',
body,
);
} else if (operation === 'getAll') {
// ----------------------------------------
// person: getAll

View file

@ -33,6 +33,11 @@ export const personOperations: INodeProperties[] = [
value: 'get',
action: 'Get a person',
},
{
name: 'GetByEmail',
value: 'getByEmail',
action: 'Get a person by email',
},
{
name: 'Get Many',
value: 'getAll',
@ -134,6 +139,24 @@ export const personFields: INodeProperties[] = [
},
},
// ----------------------------------------
// person: getByEmail
// ----------------------------------------
{
displayName: 'Person Email',
name: 'personEmail',
description: 'Email of the person to retrieve',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: ['person'],
operation: ['getByEmail'],
},
},
},
// ----------------------------------------
// person: getAll
// ----------------------------------------