n8n/packages/nodes-base/nodes/Brevo/ContactDescription.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

625 lines
13 KiB
TypeScript
Raw Normal View History

import type {
feat(SendInBlue Node): Add SendInBlue Regular + Trigger Node (#3746) * add sendinblue svg icon * Add code and required files for new sendinblue node * Add node to package.json * Update credentials to display API Key instead of Access Token * Use new svg found in brandfetch * :zap: Improvements * :recycle: Moved descriptions for email to it's own file * :zap: Added support for contact get * :zap: moved email descriptions to it's own file * :zap: Add logic to conditionally remove/format sms,email * :zap: Improvements * :zap: Refactor Sender descriptions to it's own file * :zap: Fix urls * :zap: Improvements attempt * :zap: Refactor remove inline descriptions * :zap: Minor improvement * :art: Learn a nice way to send options as key-value * :zap: Improvements * :recycle: Fix Create Operation structure * :recycle: Refactor create functionality for attribute :recycle: Introduce override for createAttribute selectedCategory :recycle: Add delete functionality * :fire: Remove preSend from delete * :zap: Implement override for body types * :zap: Cleanup node file * :zap: Update response for contact update :zap: Update request url for contact delete * :zap: Add presend check for optional properties that are empty :zap: Add Model file and TransactionalEmail interface * :zap: formatting * :recycle: Remove requestOperations from Node Description level * :recycle: Cleanup routing for Get All :recycle: Make Identifier required * :zap: Formatting * :recycle: Add Options Collection * :recycle: Add Filters area * :recycle: Formatting * :recycle: Handle empty return * :recycle: Remove unused code * :recycle: Fix pagination :recycle: Fix empty return for delete * :zap: Add pagination * :zap: Fix Modified Since * :recycle: Reorder send operation ui * :zap: Remove no longer needed presend :zap: Add send html template operation * :recycle: Make Contact Attribute name and type required * :recycle: Rename Attribute to Contact Attribute * :recycle: Rename Identifier to Contact Identifier * :recycle: Remove SMS from root level because it can exist in Contact Attributes * :recycle: Fix Array type using 'Array<T>' :recycle: Fix double quotes should be single quotes * :tshirt: Lint Fix * :zap: Add email attachment functionality :zap: Add attachment data validation * :zap: Add dynamic loading of Email Template IDs * :recycle: Cleanup validation method * :zap: Introduce workaround and use binary data for attachments * feat: Migrated to npm release of riot-tmpl fork. * :tshirt: Lint fix rules * :shirt: Lint fix rules * fix: Updated imports to use @n8n_io/riot-tmpl * fix: Fixed Logger.ts types. * :zap: Fix mixmatch of filename and package.json credentials list * :zap: fix mixmatch in nodes list * feat(core): Give access to getBinaryDataBuffer in preSend method * :zap: clean up mixmatches in node naming * :recycle: Refactor code to use newly exposed getBinaryDataBuffer method * :zap: Improvements * :fire: Remove unnecessary lines * :shirt: Fix linting issues * :zap: Fix issues with up to date APIs and improve readability * :zap: update naming of files * :recycle: Move sendHtml boolean above subject :recycle: Update naming from Parameters to Fields * :recycle: Move sendHtml boolean above subject :recycle: Update naming from Parameters to Fields * :recycle: Add attribute name url encoding :recycle: Change limit's default to 50 * :zap: Fix default for templateId * :zap: Fix display name for attribute list * :recycle: Add clarity to attribute value display name * :recycle: Add tags and attachments for emails * :recycle: Add use of item's binary data fileName * :shirt: Fix action lint rule * :shirt: Remove deprecated lint rule * :arrow_up: Update eslint-plugin-n8n-nodes-base * :shirt: Fix lint rule for file name * :zap: Fix update attribute * :recycle: Add upsert capabilites * :fire: Remove create or update operation * :recycle: Add sendInBlueWebhookApi namespace * :recycle: Add Webhook API functionality * :zap: Add SendInBlue Trigger * :zap: Return correct webhookId data * :zap: Add placeholder for receiving data * :shirt: Fixing existing linting issues * :rotating_light: Enable namespacing in tslint file * :shirt: Fix linting issues * :zap: Rename exported WebhookApi * :fire: Remove unused Model.ts file * :recycle: Update node to use SendInBlue namespace * :zap: Revert back to allowing upsert functionality * :recycle: Fix options to better describe events * Remove update flag for create operation * :recycle: Fix discrepancies for contact resource * remove no-namespace lint rule * :shirt: Fix linting issues * :recycle: Add sendInBlueWebhookApi namespace * :recycle: Add Webhook API functionality * :zap: Add SendInBlue Trigger * :zap: Return correct webhookId data * :zap: Add placeholder for receiving data * :shirt: Fix linting issues * :zap: Rename exported WebhookApi * :recycle: Fix options to better describe events * Add optionswithuri import that was lost * :zap: Fix details from janober's review * :zap: Fix order of displayName and name properties * :zap: Fix default value and improve loadOptions * :zap: Introduce support for comma separated attribute values * :zap: Introduce support for comma separated attribute values * :shirt: Fix linting issues * Update defaults and required props * :zap: Fix copy paste issue Upsert was not using correct endpoint * :zap: Fix upsert email field display name * :zap: Last update, upsert email description * :zap: Add PostReceived type limit Co-authored-by: ricardo <ricardoespinoza105@gmail.com> Co-authored-by: Alex Grozav <alex@grozav.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2022-08-03 09:08:51 -07:00
GenericValue,
IExecuteSingleFunctions,
IHttpRequestOptions,
INodeProperties,
JsonObject,
} from 'n8n-workflow';
export const contactOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['contact'],
},
},
options: [
{
name: 'Create',
value: 'create',
action: 'Create a contact',
routing: {
request: {
method: 'POST',
url: '/v3/contacts',
},
},
},
{
name: 'Create or Update',
value: 'upsert',
action: 'Upsert a contact',
routing: {
request: {
method: 'POST',
url: '=/v3/contacts',
},
},
},
{
name: 'Delete',
value: 'delete',
action: 'Delete a contact',
},
{
name: 'Get',
value: 'get',
action: 'Get a contact',
},
{
name: 'Get Many',
feat(SendInBlue Node): Add SendInBlue Regular + Trigger Node (#3746) * add sendinblue svg icon * Add code and required files for new sendinblue node * Add node to package.json * Update credentials to display API Key instead of Access Token * Use new svg found in brandfetch * :zap: Improvements * :recycle: Moved descriptions for email to it's own file * :zap: Added support for contact get * :zap: moved email descriptions to it's own file * :zap: Add logic to conditionally remove/format sms,email * :zap: Improvements * :zap: Refactor Sender descriptions to it's own file * :zap: Fix urls * :zap: Improvements attempt * :zap: Refactor remove inline descriptions * :zap: Minor improvement * :art: Learn a nice way to send options as key-value * :zap: Improvements * :recycle: Fix Create Operation structure * :recycle: Refactor create functionality for attribute :recycle: Introduce override for createAttribute selectedCategory :recycle: Add delete functionality * :fire: Remove preSend from delete * :zap: Implement override for body types * :zap: Cleanup node file * :zap: Update response for contact update :zap: Update request url for contact delete * :zap: Add presend check for optional properties that are empty :zap: Add Model file and TransactionalEmail interface * :zap: formatting * :recycle: Remove requestOperations from Node Description level * :recycle: Cleanup routing for Get All :recycle: Make Identifier required * :zap: Formatting * :recycle: Add Options Collection * :recycle: Add Filters area * :recycle: Formatting * :recycle: Handle empty return * :recycle: Remove unused code * :recycle: Fix pagination :recycle: Fix empty return for delete * :zap: Add pagination * :zap: Fix Modified Since * :recycle: Reorder send operation ui * :zap: Remove no longer needed presend :zap: Add send html template operation * :recycle: Make Contact Attribute name and type required * :recycle: Rename Attribute to Contact Attribute * :recycle: Rename Identifier to Contact Identifier * :recycle: Remove SMS from root level because it can exist in Contact Attributes * :recycle: Fix Array type using 'Array<T>' :recycle: Fix double quotes should be single quotes * :tshirt: Lint Fix * :zap: Add email attachment functionality :zap: Add attachment data validation * :zap: Add dynamic loading of Email Template IDs * :recycle: Cleanup validation method * :zap: Introduce workaround and use binary data for attachments * feat: Migrated to npm release of riot-tmpl fork. * :tshirt: Lint fix rules * :shirt: Lint fix rules * fix: Updated imports to use @n8n_io/riot-tmpl * fix: Fixed Logger.ts types. * :zap: Fix mixmatch of filename and package.json credentials list * :zap: fix mixmatch in nodes list * feat(core): Give access to getBinaryDataBuffer in preSend method * :zap: clean up mixmatches in node naming * :recycle: Refactor code to use newly exposed getBinaryDataBuffer method * :zap: Improvements * :fire: Remove unnecessary lines * :shirt: Fix linting issues * :zap: Fix issues with up to date APIs and improve readability * :zap: update naming of files * :recycle: Move sendHtml boolean above subject :recycle: Update naming from Parameters to Fields * :recycle: Move sendHtml boolean above subject :recycle: Update naming from Parameters to Fields * :recycle: Add attribute name url encoding :recycle: Change limit's default to 50 * :zap: Fix default for templateId * :zap: Fix display name for attribute list * :recycle: Add clarity to attribute value display name * :recycle: Add tags and attachments for emails * :recycle: Add use of item's binary data fileName * :shirt: Fix action lint rule * :shirt: Remove deprecated lint rule * :arrow_up: Update eslint-plugin-n8n-nodes-base * :shirt: Fix lint rule for file name * :zap: Fix update attribute * :recycle: Add upsert capabilites * :fire: Remove create or update operation * :recycle: Add sendInBlueWebhookApi namespace * :recycle: Add Webhook API functionality * :zap: Add SendInBlue Trigger * :zap: Return correct webhookId data * :zap: Add placeholder for receiving data * :shirt: Fixing existing linting issues * :rotating_light: Enable namespacing in tslint file * :shirt: Fix linting issues * :zap: Rename exported WebhookApi * :fire: Remove unused Model.ts file * :recycle: Update node to use SendInBlue namespace * :zap: Revert back to allowing upsert functionality * :recycle: Fix options to better describe events * Remove update flag for create operation * :recycle: Fix discrepancies for contact resource * remove no-namespace lint rule * :shirt: Fix linting issues * :recycle: Add sendInBlueWebhookApi namespace * :recycle: Add Webhook API functionality * :zap: Add SendInBlue Trigger * :zap: Return correct webhookId data * :zap: Add placeholder for receiving data * :shirt: Fix linting issues * :zap: Rename exported WebhookApi * :recycle: Fix options to better describe events * Add optionswithuri import that was lost * :zap: Fix details from janober's review * :zap: Fix order of displayName and name properties * :zap: Fix default value and improve loadOptions * :zap: Introduce support for comma separated attribute values * :zap: Introduce support for comma separated attribute values * :shirt: Fix linting issues * Update defaults and required props * :zap: Fix copy paste issue Upsert was not using correct endpoint * :zap: Fix upsert email field display name * :zap: Last update, upsert email description * :zap: Add PostReceived type limit Co-authored-by: ricardo <ricardoespinoza105@gmail.com> Co-authored-by: Alex Grozav <alex@grozav.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2022-08-03 09:08:51 -07:00
value: 'getAll',
routing: {
request: {
method: 'GET',
url: '/v3/contacts',
},
output: {
postReceive: [
{
type: 'rootProperty',
properties: {
property: 'contacts',
},
},
],
},
operations: {
pagination: {
type: 'offset',
properties: {
limitParameter: 'limit',
offsetParameter: 'offset',
pageSize: 1000,
type: 'query',
},
},
},
},
action: 'Get many contacts',
feat(SendInBlue Node): Add SendInBlue Regular + Trigger Node (#3746) * add sendinblue svg icon * Add code and required files for new sendinblue node * Add node to package.json * Update credentials to display API Key instead of Access Token * Use new svg found in brandfetch * :zap: Improvements * :recycle: Moved descriptions for email to it's own file * :zap: Added support for contact get * :zap: moved email descriptions to it's own file * :zap: Add logic to conditionally remove/format sms,email * :zap: Improvements * :zap: Refactor Sender descriptions to it's own file * :zap: Fix urls * :zap: Improvements attempt * :zap: Refactor remove inline descriptions * :zap: Minor improvement * :art: Learn a nice way to send options as key-value * :zap: Improvements * :recycle: Fix Create Operation structure * :recycle: Refactor create functionality for attribute :recycle: Introduce override for createAttribute selectedCategory :recycle: Add delete functionality * :fire: Remove preSend from delete * :zap: Implement override for body types * :zap: Cleanup node file * :zap: Update response for contact update :zap: Update request url for contact delete * :zap: Add presend check for optional properties that are empty :zap: Add Model file and TransactionalEmail interface * :zap: formatting * :recycle: Remove requestOperations from Node Description level * :recycle: Cleanup routing for Get All :recycle: Make Identifier required * :zap: Formatting * :recycle: Add Options Collection * :recycle: Add Filters area * :recycle: Formatting * :recycle: Handle empty return * :recycle: Remove unused code * :recycle: Fix pagination :recycle: Fix empty return for delete * :zap: Add pagination * :zap: Fix Modified Since * :recycle: Reorder send operation ui * :zap: Remove no longer needed presend :zap: Add send html template operation * :recycle: Make Contact Attribute name and type required * :recycle: Rename Attribute to Contact Attribute * :recycle: Rename Identifier to Contact Identifier * :recycle: Remove SMS from root level because it can exist in Contact Attributes * :recycle: Fix Array type using 'Array<T>' :recycle: Fix double quotes should be single quotes * :tshirt: Lint Fix * :zap: Add email attachment functionality :zap: Add attachment data validation * :zap: Add dynamic loading of Email Template IDs * :recycle: Cleanup validation method * :zap: Introduce workaround and use binary data for attachments * feat: Migrated to npm release of riot-tmpl fork. * :tshirt: Lint fix rules * :shirt: Lint fix rules * fix: Updated imports to use @n8n_io/riot-tmpl * fix: Fixed Logger.ts types. * :zap: Fix mixmatch of filename and package.json credentials list * :zap: fix mixmatch in nodes list * feat(core): Give access to getBinaryDataBuffer in preSend method * :zap: clean up mixmatches in node naming * :recycle: Refactor code to use newly exposed getBinaryDataBuffer method * :zap: Improvements * :fire: Remove unnecessary lines * :shirt: Fix linting issues * :zap: Fix issues with up to date APIs and improve readability * :zap: update naming of files * :recycle: Move sendHtml boolean above subject :recycle: Update naming from Parameters to Fields * :recycle: Move sendHtml boolean above subject :recycle: Update naming from Parameters to Fields * :recycle: Add attribute name url encoding :recycle: Change limit's default to 50 * :zap: Fix default for templateId * :zap: Fix display name for attribute list * :recycle: Add clarity to attribute value display name * :recycle: Add tags and attachments for emails * :recycle: Add use of item's binary data fileName * :shirt: Fix action lint rule * :shirt: Remove deprecated lint rule * :arrow_up: Update eslint-plugin-n8n-nodes-base * :shirt: Fix lint rule for file name * :zap: Fix update attribute * :recycle: Add upsert capabilites * :fire: Remove create or update operation * :recycle: Add sendInBlueWebhookApi namespace * :recycle: Add Webhook API functionality * :zap: Add SendInBlue Trigger * :zap: Return correct webhookId data * :zap: Add placeholder for receiving data * :shirt: Fixing existing linting issues * :rotating_light: Enable namespacing in tslint file * :shirt: Fix linting issues * :zap: Rename exported WebhookApi * :fire: Remove unused Model.ts file * :recycle: Update node to use SendInBlue namespace * :zap: Revert back to allowing upsert functionality * :recycle: Fix options to better describe events * Remove update flag for create operation * :recycle: Fix discrepancies for contact resource * remove no-namespace lint rule * :shirt: Fix linting issues * :recycle: Add sendInBlueWebhookApi namespace * :recycle: Add Webhook API functionality * :zap: Add SendInBlue Trigger * :zap: Return correct webhookId data * :zap: Add placeholder for receiving data * :shirt: Fix linting issues * :zap: Rename exported WebhookApi * :recycle: Fix options to better describe events * Add optionswithuri import that was lost * :zap: Fix details from janober's review * :zap: Fix order of displayName and name properties * :zap: Fix default value and improve loadOptions * :zap: Introduce support for comma separated attribute values * :zap: Introduce support for comma separated attribute values * :shirt: Fix linting issues * Update defaults and required props * :zap: Fix copy paste issue Upsert was not using correct endpoint * :zap: Fix upsert email field display name * :zap: Last update, upsert email description * :zap: Add PostReceived type limit Co-authored-by: ricardo <ricardoespinoza105@gmail.com> Co-authored-by: Alex Grozav <alex@grozav.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2022-08-03 09:08:51 -07:00
},
{
name: 'Update',
value: 'update',
routing: {
output: {
postReceive: [
{
type: 'set',
properties: {
value: '={{ { "success": true } }}', // Also possible to use the original response data
},
},
],
},
},
action: 'Update a contact',
},
],
default: 'create',
},
];
const createOperations: INodeProperties[] = [
{
displayName: 'Email',
name: 'email',
type: 'string',
placeholder: 'name@email.com',
displayOptions: {
show: {
resource: ['contact'],
operation: ['create'],
},
},
default: '',
routing: {
send: {
type: 'body',
property: 'email',
},
},
},
{
displayName: 'Contact Attributes',
name: 'createContactAttributes',
default: {},
description: 'Array of attributes to be added',
displayOptions: {
show: {
resource: ['contact'],
operation: ['create'],
},
},
options: [
{
name: 'attributesValues',
displayName: 'Attribute',
values: [
{
displayName: 'Field Name',
name: 'fieldName',
type: 'options',
typeOptions: {
loadOptions: {
routing: {
request: {
method: 'GET',
url: '/v3/contacts/attributes',
},
output: {
postReceive: [
{
type: 'rootProperty',
properties: {
property: 'attributes',
},
},
{
type: 'setKeyValue',
properties: {
name: '={{$responseItem.name}} - ({{$responseItem.category}})',
value: '={{$responseItem.name}}',
},
},
{
type: 'sort',
properties: {
key: 'name',
},
},
],
},
},
},
},
default: '',
},
{
displayName: 'Field Value',
name: 'fieldValue',
type: 'string',
default: '',
routing: {
send: {
value: '={{$value}}',
property: '=attributes.{{$parent.fieldName}}',
type: 'body',
},
},
},
],
},
],
placeholder: 'Add Attribute',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
},
];
const getAllOperations: INodeProperties[] = [
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
routing: {
send: {
paginate: '={{$value}}',
},
},
displayOptions: {
show: {
resource: ['contact'],
operation: ['getAll'],
},
},
default: false,
description: 'Whether to return all results or only up to a given limit',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
displayOptions: {
show: {
resource: ['contact'],
operation: ['getAll'],
returnAll: [false],
},
},
routing: {
send: {
type: 'query',
property: 'limit',
},
},
typeOptions: {
minValue: 1,
maxValue: 1000,
},
default: 50,
description: 'Max number of results to return',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add option',
feat(SendInBlue Node): Add SendInBlue Regular + Trigger Node (#3746) * add sendinblue svg icon * Add code and required files for new sendinblue node * Add node to package.json * Update credentials to display API Key instead of Access Token * Use new svg found in brandfetch * :zap: Improvements * :recycle: Moved descriptions for email to it's own file * :zap: Added support for contact get * :zap: moved email descriptions to it's own file * :zap: Add logic to conditionally remove/format sms,email * :zap: Improvements * :zap: Refactor Sender descriptions to it's own file * :zap: Fix urls * :zap: Improvements attempt * :zap: Refactor remove inline descriptions * :zap: Minor improvement * :art: Learn a nice way to send options as key-value * :zap: Improvements * :recycle: Fix Create Operation structure * :recycle: Refactor create functionality for attribute :recycle: Introduce override for createAttribute selectedCategory :recycle: Add delete functionality * :fire: Remove preSend from delete * :zap: Implement override for body types * :zap: Cleanup node file * :zap: Update response for contact update :zap: Update request url for contact delete * :zap: Add presend check for optional properties that are empty :zap: Add Model file and TransactionalEmail interface * :zap: formatting * :recycle: Remove requestOperations from Node Description level * :recycle: Cleanup routing for Get All :recycle: Make Identifier required * :zap: Formatting * :recycle: Add Options Collection * :recycle: Add Filters area * :recycle: Formatting * :recycle: Handle empty return * :recycle: Remove unused code * :recycle: Fix pagination :recycle: Fix empty return for delete * :zap: Add pagination * :zap: Fix Modified Since * :recycle: Reorder send operation ui * :zap: Remove no longer needed presend :zap: Add send html template operation * :recycle: Make Contact Attribute name and type required * :recycle: Rename Attribute to Contact Attribute * :recycle: Rename Identifier to Contact Identifier * :recycle: Remove SMS from root level because it can exist in Contact Attributes * :recycle: Fix Array type using 'Array<T>' :recycle: Fix double quotes should be single quotes * :tshirt: Lint Fix * :zap: Add email attachment functionality :zap: Add attachment data validation * :zap: Add dynamic loading of Email Template IDs * :recycle: Cleanup validation method * :zap: Introduce workaround and use binary data for attachments * feat: Migrated to npm release of riot-tmpl fork. * :tshirt: Lint fix rules * :shirt: Lint fix rules * fix: Updated imports to use @n8n_io/riot-tmpl * fix: Fixed Logger.ts types. * :zap: Fix mixmatch of filename and package.json credentials list * :zap: fix mixmatch in nodes list * feat(core): Give access to getBinaryDataBuffer in preSend method * :zap: clean up mixmatches in node naming * :recycle: Refactor code to use newly exposed getBinaryDataBuffer method * :zap: Improvements * :fire: Remove unnecessary lines * :shirt: Fix linting issues * :zap: Fix issues with up to date APIs and improve readability * :zap: update naming of files * :recycle: Move sendHtml boolean above subject :recycle: Update naming from Parameters to Fields * :recycle: Move sendHtml boolean above subject :recycle: Update naming from Parameters to Fields * :recycle: Add attribute name url encoding :recycle: Change limit's default to 50 * :zap: Fix default for templateId * :zap: Fix display name for attribute list * :recycle: Add clarity to attribute value display name * :recycle: Add tags and attachments for emails * :recycle: Add use of item's binary data fileName * :shirt: Fix action lint rule * :shirt: Remove deprecated lint rule * :arrow_up: Update eslint-plugin-n8n-nodes-base * :shirt: Fix lint rule for file name * :zap: Fix update attribute * :recycle: Add upsert capabilites * :fire: Remove create or update operation * :recycle: Add sendInBlueWebhookApi namespace * :recycle: Add Webhook API functionality * :zap: Add SendInBlue Trigger * :zap: Return correct webhookId data * :zap: Add placeholder for receiving data * :shirt: Fixing existing linting issues * :rotating_light: Enable namespacing in tslint file * :shirt: Fix linting issues * :zap: Rename exported WebhookApi * :fire: Remove unused Model.ts file * :recycle: Update node to use SendInBlue namespace * :zap: Revert back to allowing upsert functionality * :recycle: Fix options to better describe events * Remove update flag for create operation * :recycle: Fix discrepancies for contact resource * remove no-namespace lint rule * :shirt: Fix linting issues * :recycle: Add sendInBlueWebhookApi namespace * :recycle: Add Webhook API functionality * :zap: Add SendInBlue Trigger * :zap: Return correct webhookId data * :zap: Add placeholder for receiving data * :shirt: Fix linting issues * :zap: Rename exported WebhookApi * :recycle: Fix options to better describe events * Add optionswithuri import that was lost * :zap: Fix details from janober's review * :zap: Fix order of displayName and name properties * :zap: Fix default value and improve loadOptions * :zap: Introduce support for comma separated attribute values * :zap: Introduce support for comma separated attribute values * :shirt: Fix linting issues * Update defaults and required props * :zap: Fix copy paste issue Upsert was not using correct endpoint * :zap: Fix upsert email field display name * :zap: Last update, upsert email description * :zap: Add PostReceived type limit Co-authored-by: ricardo <ricardoespinoza105@gmail.com> Co-authored-by: Alex Grozav <alex@grozav.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2022-08-03 09:08:51 -07:00
displayOptions: {
show: {
resource: ['contact'],
operation: ['getAll'],
},
},
default: {},
options: [
{
displayName: 'Sort',
name: 'sort',
type: 'options',
options: [
{ name: 'DESC', value: 'desc' },
{ name: 'ASC', value: 'asc' },
],
routing: {
send: {
type: 'query',
property: 'sort',
value: '={{$value}}',
},
},
default: 'desc',
description: 'Sort the results in the ascending/descending order of record creation',
},
],
},
{
displayName: 'Filters',
name: 'filters',
type: 'collection',
placeholder: 'Add Filter',
displayOptions: {
show: {
resource: ['contact'],
operation: ['getAll'],
},
},
default: {},
options: [
{
displayName: 'Modified Since',
name: 'modifiedSince',
type: 'dateTime',
routing: {
send: {
type: 'query',
property: 'modifiedSince',
},
},
default: '',
description:
'Filter (urlencoded) the contacts modified after a given UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ)',
},
],
},
];
const getOperations: INodeProperties[] = [
{
displayName: 'Contact Identifier',
name: 'identifier',
type: 'string',
displayOptions: {
show: {
resource: ['contact'],
operation: ['get'],
},
},
routing: {
request: {
method: 'GET',
url: '=/v3/contacts/{{encodeURIComponent($value)}}',
},
},
required: true,
default: '',
description: 'Email (urlencoded) OR ID of the contact OR its SMS attribute value',
},
];
const deleteOperations: INodeProperties[] = [
{
displayName: 'Contact Identifier',
name: 'identifier',
type: 'string',
displayOptions: {
show: {
resource: ['contact'],
operation: ['delete'],
},
},
routing: {
request: {
method: 'DELETE',
url: '=/v3/contacts/{{encodeURIComponent($parameter.identifier)}}',
},
output: {
postReceive: [
{
type: 'set',
properties: {
value: '={{ { "success": true } }}', // Also possible to use the original response data
},
},
],
},
},
default: '',
description: 'Email (urlencoded) OR ID of the contact OR its SMS attribute value',
},
];
const updateOperations: INodeProperties[] = [
{
displayName: 'Contact Identifier',
name: 'identifier',
default: '',
description: 'Email (urlencoded) OR ID of the contact OR its SMS attribute value',
displayOptions: {
show: {
resource: ['contact'],
operation: ['update'],
},
},
type: 'string',
required: true,
},
{
displayName: 'Attributes',
name: 'updateAttributes',
default: {},
description: 'Array of attributes to be updated',
displayOptions: {
show: {
resource: ['contact'],
operation: ['update'],
},
},
options: [
{
displayName: 'Attribute',
name: 'updateAttributesValues',
values: [
{
displayName: 'Field Name',
name: 'fieldName',
type: 'options',
typeOptions: {
loadOptions: {
routing: {
request: {
method: 'GET',
url: '/v3/contacts/attributes',
},
output: {
postReceive: [
{
type: 'rootProperty',
properties: {
property: 'attributes',
},
},
{
type: 'setKeyValue',
properties: {
name: '={{$responseItem.name}} - ({{$responseItem.category}})',
value: '={{$responseItem.name}}',
},
},
{
type: 'sort',
properties: {
key: 'name',
},
},
],
},
},
},
},
default: '',
},
{
displayName: 'Field Value',
name: 'fieldValue',
type: 'string',
default: '',
routing: {
send: {
value: '={{$value}}',
property: '=attributes.{{$parent.fieldName}}',
type: 'body',
},
},
},
],
},
],
placeholder: 'Add Attribute',
routing: {
request: {
method: 'PUT',
url: '=/v3/contacts/{{encodeURIComponent($parameter.identifier)}}',
},
},
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
},
];
const upsertOperations: INodeProperties[] = [
{
displayName: 'Email',
name: 'email',
default: '',
description: 'Email of the contact',
displayOptions: {
show: {
resource: ['contact'],
operation: ['upsert'],
},
},
type: 'string',
placeholder: 'name@email.com',
required: true,
routing: {
send: {
value: '={{$value}}',
property: 'email',
type: 'body',
},
},
},
{
displayName: 'Contact Attributes',
name: 'upsertAttributes',
default: {},
description: 'Array of attributes to be updated',
displayOptions: {
show: {
resource: ['contact'],
operation: ['upsert'],
},
},
options: [
{
name: 'upsertAttributesValues',
displayName: 'Attribute',
values: [
{
displayName: 'Field Name',
name: 'fieldName',
type: 'options',
typeOptions: {
loadOptions: {
routing: {
request: {
method: 'GET',
url: '/v3/contacts/attributes',
},
output: {
postReceive: [
{
type: 'rootProperty',
properties: {
property: 'attributes',
},
},
{
type: 'setKeyValue',
properties: {
name: '={{$responseItem.name}} - ({{$responseItem.category}})',
value: '={{$responseItem.name}}',
},
},
{
type: 'sort',
properties: {
key: 'name',
},
},
],
},
},
},
},
default: '',
},
{
displayName: 'Field Value',
name: 'fieldValue',
type: 'string',
default: '',
routing: {
send: {
value: '={{$value}}',
property: '=attributes.{{$parent.fieldName}}',
type: 'body',
},
},
},
],
},
],
placeholder: 'Add Attribute',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
routing: {
send: {
preSend: [
async function (
this: IExecuteSingleFunctions,
requestOptions: IHttpRequestOptions,
): Promise<IHttpRequestOptions> {
const { body } = requestOptions as GenericValue as JsonObject;
Object.assign(body!, { updateEnabled: true });
return requestOptions;
},
],
},
output: {
postReceive: [
{
type: 'set',
properties: {
value: '={{ { "success": true } }}', // Also possible to use the original response data
},
},
],
},
},
},
];
export const contactFields: INodeProperties[] = [
/* -------------------------------------------------------------------------- */
/* contact:create */
/* -------------------------------------------------------------------------- */
...createOperations,
/* -------------------------------------------------------------------------- */
/* contact:getAll */
/* -------------------------------------------------------------------------- */
...getAllOperations,
/* -------------------------------------------------------------------------- */
/* contact:get */
/* -------------------------------------------------------------------------- */
...getOperations,
/* -------------------------------------------------------------------------- */
/* contact:delete */
/* -------------------------------------------------------------------------- */
...deleteOperations,
/* -------------------------------------------------------------------------- */
/* contact:update */
/* -------------------------------------------------------------------------- */
...updateOperations,
/* -------------------------------------------------------------------------- */
/* contact:update */
/* -------------------------------------------------------------------------- */
...upsertOperations,
];