2022-08-17 08:50:24 -07:00
import { INodeProperties } from 'n8n-workflow' ;
2021-01-19 15:16:25 -08:00
2021-12-03 00:44:16 -08:00
export const contactOperations : INodeProperties [ ] = [
2021-01-19 15:16:25 -08:00
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2021-01-19 15:16:25 -08:00
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'contact' ] ,
2021-01-19 15:16:25 -08:00
} ,
} ,
options : [
{
2022-06-03 10:23:49 -07:00
name : 'Create or Update' ,
2021-01-19 15:16:25 -08:00
value : 'upsert' ,
2022-08-17 08:50:24 -07:00
description :
'Create a new contact, or update the current one if it already exists (upsert)' ,
2022-07-10 13:50:51 -07:00
action : 'Create or update a contact' ,
2021-01-19 15:16:25 -08:00
} ,
{
name : 'Delete' ,
value : 'delete' ,
description : 'Delete a contact' ,
2022-07-10 13:50:51 -07:00
action : 'Delete a contact' ,
2021-01-19 15:16:25 -08:00
} ,
{
name : 'Get' ,
value : 'get' ,
description : 'Get a contact by ID' ,
2022-07-10 13:50:51 -07:00
action : 'Get a contact' ,
2021-01-19 15:16:25 -08:00
} ,
{
2022-09-07 07:51:14 -07:00
name : 'Get Many' ,
2021-01-19 15:16:25 -08:00
value : 'getAll' ,
description : 'Get all contacts' ,
2022-09-08 08:10:13 -07:00
action : 'Get many contacts' ,
2021-01-19 15:16:25 -08:00
} ,
] ,
default : 'upsert' ,
} ,
2021-12-03 00:44:16 -08:00
] ;
2021-01-19 15:16:25 -08:00
2021-12-03 00:44:16 -08:00
export const contactFields : INodeProperties [ ] = [
2021-01-19 15:16:25 -08:00
/* -------------------------------------------------------------------------- */
/* contact:getAll */
/* -------------------------------------------------------------------------- */
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'contact' ] ,
operation : [ 'getAll' ] ,
2021-01-19 15:16:25 -08:00
} ,
} ,
default : false ,
2022-05-06 14:01:25 -07:00
description : 'Whether to return all results or only up to a given limit' ,
2021-01-19 15:16:25 -08:00
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'contact' ] ,
operation : [ 'getAll' ] ,
returnAll : [ false ] ,
2021-01-19 15:16:25 -08:00
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 1000 ,
} ,
default : 100 ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2021-01-19 15:16:25 -08:00
} ,
{
displayName : 'Filters' ,
name : 'filters' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'contact' ] ,
operation : [ 'getAll' ] ,
2021-01-19 15:16:25 -08:00
} ,
} ,
options : [
{
displayName : 'Query' ,
name : 'query' ,
type : 'string' ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
'The query field accepts valid <a href="https://sendgrid.com/docs/for-developers/sending-email/segmentation-query-language/">SGQL</a> for searching for a contact' ,
2021-01-19 15:16:25 -08:00
} ,
] ,
} ,
/* -------------------------------------------------------------------------- */
/* contact:create */
/* -------------------------------------------------------------------------- */
{
displayName : 'Email' ,
name : 'email' ,
type : 'string' ,
2022-06-20 07:54:01 -07:00
placeholder : 'name@email.com' ,
2021-01-19 15:16:25 -08:00
required : true ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'upsert' ] ,
resource : [ 'contact' ] ,
2021-01-19 15:16:25 -08:00
} ,
} ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Primary email for the contact' ,
2021-01-19 15:16:25 -08:00
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'contact' ] ,
operation : [ 'upsert' ] ,
2021-01-19 15:16:25 -08:00
} ,
} ,
options : [
{
displayName : 'Address' ,
name : 'addressUi' ,
placeholder : 'Address' ,
type : 'fixedCollection' ,
typeOptions : {
multipleValues : false ,
} ,
default : { } ,
options : [
{
name : 'addressValues' ,
displayName : 'Address' ,
values : [
{
displayName : 'Address Line 1' ,
name : 'address1' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Address Line 2' ,
name : 'address2' ,
type : 'string' ,
default : '' ,
} ,
] ,
} ,
] ,
} ,
{
displayName : 'Alternate Emails' ,
name : 'alternateEmails' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'City' ,
name : 'city' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Country' ,
name : 'country' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'First Name' ,
name : 'firstName' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Last Name' ,
name : 'lastName' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Postal Code' ,
name : 'postalCode' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'State/Province/Region' ,
name : 'stateProvinceRegion' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'List IDs' ,
name : 'listIdsUi' ,
placeholder : 'List IDs' ,
2022-05-06 14:01:25 -07:00
description : 'Adds a custom field to set also values which have not been predefined' ,
2021-01-19 15:16:25 -08:00
type : 'fixedCollection' ,
default : { } ,
options : [
{
name : 'listIdValues' ,
displayName : 'List IDs' ,
values : [
{
2022-06-20 07:54:01 -07:00
displayName : 'List Names or IDs' ,
2021-01-19 15:16:25 -08:00
name : 'listIds' ,
type : 'multiOptions' ,
typeOptions : {
loadOptionsMethod : 'getListIds' ,
} ,
2022-04-22 09:29:51 -07:00
default : [ ] ,
2022-08-17 08:50:24 -07:00
description :
'ID of the field to set. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2021-01-19 15:16:25 -08:00
} ,
] ,
} ,
] ,
} ,
{
displayName : 'Custom Fields' ,
name : 'customFieldsUi' ,
placeholder : 'Add Custom Fields' ,
description : 'Adds custom fields' ,
type : 'fixedCollection' ,
typeOptions : {
multipleValues : true ,
} ,
default : { } ,
options : [
{
name : 'customFieldValues' ,
displayName : 'Field' ,
values : [
{
2022-06-03 10:23:49 -07:00
displayName : 'Field Name or ID' ,
2021-01-19 15:16:25 -08:00
name : 'fieldId' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getCustomFields' ,
} ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
'ID of the field. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2021-01-19 15:16:25 -08:00
} ,
{
displayName : 'Field Value' ,
name : 'fieldValue' ,
type : 'string' ,
default : '' ,
description : 'Value for the field' ,
} ,
] ,
} ,
] ,
} ,
] ,
} ,
/* -------------------------------------------------------------------------- */
/* contact:delete */
/* -------------------------------------------------------------------------- */
{
displayName : 'Contact IDs' ,
name : 'ids' ,
type : 'string' ,
2021-12-03 00:44:16 -08:00
default : '' ,
2021-01-19 15:16:25 -08:00
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'contact' ] ,
operation : [ 'delete' ] ,
deleteAll : [ false ] ,
2021-01-19 15:16:25 -08:00
} ,
} ,
description : 'ID of the contact. Multiple can be added separated by comma.' ,
} ,
{
displayName : 'Delete All' ,
name : 'deleteAll' ,
type : 'boolean' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'contact' ] ,
operation : [ 'delete' ] ,
2021-01-19 15:16:25 -08:00
} ,
} ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether all contacts will be deleted' ,
2021-01-19 15:16:25 -08:00
} ,
/* -------------------------------------------------------------------------- */
/* contact:get */
/* -------------------------------------------------------------------------- */
{
displayName : 'By' ,
name : 'by' ,
type : 'options' ,
options : [
{
name : 'ID' ,
value : 'id' ,
} ,
{
name : 'Email' ,
value : 'email' ,
} ,
] ,
required : true ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'get' ] ,
resource : [ 'contact' ] ,
2021-01-19 15:16:25 -08:00
} ,
} ,
default : 'id' ,
2022-05-06 14:01:25 -07:00
description : 'Search the user by ID or email' ,
2021-01-19 15:16:25 -08:00
} ,
{
displayName : 'Contact ID' ,
name : 'contactId' ,
type : 'string' ,
required : true ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'get' ] ,
resource : [ 'contact' ] ,
by : [ 'id' ] ,
2021-01-19 15:16:25 -08:00
} ,
} ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'ID of the contact' ,
2021-01-19 15:16:25 -08:00
} ,
{
displayName : 'Email' ,
name : 'email' ,
type : 'string' ,
2022-06-20 07:54:01 -07:00
placeholder : 'name@email.com' ,
2021-01-19 15:16:25 -08:00
required : true ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'get' ] ,
resource : [ 'contact' ] ,
by : [ 'email' ] ,
2021-01-19 15:16:25 -08:00
} ,
} ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Email of the contact' ,
2021-01-19 15:16:25 -08:00
} ,
2021-12-03 00:44:16 -08:00
] ;