mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
⚡ Some changes and fixes on Intercom-Node
This commit is contained in:
parent
efb0ce88f1
commit
9897a156ca
|
@ -1,6 +1,6 @@
|
||||||
import { INodeProperties } from "n8n-workflow";
|
import { INodeProperties } from "n8n-workflow";
|
||||||
|
|
||||||
export const companyOpeations = [
|
export const companyOperations = [
|
||||||
{
|
{
|
||||||
displayName: 'Operation',
|
displayName: 'Operation',
|
||||||
name: 'operation',
|
name: 'operation',
|
||||||
|
@ -18,28 +18,28 @@ export const companyOpeations = [
|
||||||
value: 'create',
|
value: 'create',
|
||||||
description: 'Create a new company',
|
description: 'Create a new company',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Get',
|
||||||
|
value: 'get',
|
||||||
|
description: 'Get data of a company',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Get All',
|
||||||
|
value: 'getAll',
|
||||||
|
description: 'Get data of all companies',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Update',
|
name: 'Update',
|
||||||
value: 'update',
|
value: 'update',
|
||||||
description: 'Update a company',
|
description: 'Update a company',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: 'View',
|
|
||||||
value: 'view',
|
|
||||||
description: 'View a company',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'List',
|
|
||||||
value: 'list',
|
|
||||||
description: 'List companies',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'Users',
|
name: 'Users',
|
||||||
value: 'users',
|
value: 'users',
|
||||||
description: `List company's users`,
|
description: `List company's users`,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: '',
|
default: 'create',
|
||||||
description: 'The operation to perform.',
|
description: 'The operation to perform.',
|
||||||
},
|
},
|
||||||
] as INodeProperties[];
|
] as INodeProperties[];
|
||||||
|
@ -68,18 +68,16 @@ export const companyFields = [
|
||||||
{
|
{
|
||||||
name: 'ID',
|
name: 'ID',
|
||||||
value: 'id',
|
value: 'id',
|
||||||
default: '',
|
|
||||||
description: 'The Intercom defined id representing the company',
|
description: 'The Intercom defined id representing the company',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Company ID',
|
name: 'Company ID',
|
||||||
value: 'companyId',
|
value: 'companyId',
|
||||||
default: '',
|
|
||||||
description: 'The company_id you have given to the company',
|
description: 'The company_id you have given to the company',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: '',
|
default: '',
|
||||||
description: 'List by'
|
description: 'List by',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Value',
|
displayName: 'Value',
|
||||||
|
@ -100,77 +98,91 @@ export const companyFields = [
|
||||||
description: 'View by value',
|
description: 'View by value',
|
||||||
},
|
},
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* company:list */
|
/* company:getAll */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
{
|
{
|
||||||
displayName: 'List by',
|
displayName: 'Return All',
|
||||||
name: 'listBy',
|
name: 'returnAll',
|
||||||
type: 'options',
|
type: 'boolean',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: [
|
resource: [
|
||||||
'company',
|
'company',
|
||||||
],
|
],
|
||||||
operation: [
|
operation: [
|
||||||
'list',
|
'getAll',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: false,
|
||||||
|
description: 'If all results should be returned or only up to a given limit.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Limit',
|
||||||
|
name: 'limit',
|
||||||
|
type: 'number',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'company',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getAll',
|
||||||
|
],
|
||||||
|
returnAll: [
|
||||||
|
false,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
typeOptions: {
|
||||||
|
minValue: 1,
|
||||||
|
maxValue: 60,
|
||||||
|
},
|
||||||
|
default: 50,
|
||||||
|
description: 'How many results to return.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Filters',
|
||||||
|
name: 'filters',
|
||||||
|
type: 'collection',
|
||||||
|
placeholder: 'Add Filter',
|
||||||
|
default: {},
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'company',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getAll',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: 'Segment ID',
|
displayName: 'Segment ID',
|
||||||
value: 'segmentId',
|
name: 'segment_id',
|
||||||
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
description: 'Segment representing the Lead',
|
description: 'Segment representing the Lead',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Tag ID',
|
displayName: 'Tag ID',
|
||||||
value: 'tagId',
|
name: 'tag_id',
|
||||||
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
description: 'Tag representing the Lead',
|
description: 'Tag representing the Lead',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: 'All',
|
|
||||||
value: 'all',
|
|
||||||
default: '',
|
|
||||||
description: 'List all users',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
default: '',
|
|
||||||
description: 'List by'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: 'Value',
|
|
||||||
name: 'value',
|
|
||||||
type: 'string',
|
|
||||||
default: '',
|
|
||||||
required: true,
|
|
||||||
displayOptions: {
|
|
||||||
show: {
|
|
||||||
resource: [
|
|
||||||
'company',
|
|
||||||
],
|
|
||||||
operation: [
|
|
||||||
'list',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
hide: {
|
|
||||||
listBy: [
|
|
||||||
'all'
|
|
||||||
]
|
]
|
||||||
}
|
|
||||||
},
|
|
||||||
description: 'list by value',
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* company:view */
|
/* company:get */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
{
|
{
|
||||||
displayName: 'View By',
|
displayName: 'Select By',
|
||||||
name: 'viewBy',
|
name: 'selectBy',
|
||||||
type: 'options',
|
type: 'options',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
|
@ -178,32 +190,29 @@ export const companyFields = [
|
||||||
'company',
|
'company',
|
||||||
],
|
],
|
||||||
operation: [
|
operation: [
|
||||||
'view',
|
'get',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
{
|
|
||||||
name: 'ID',
|
|
||||||
value: 'id',
|
|
||||||
default: '',
|
|
||||||
description: 'The Intercom defined id representing the company',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'Company ID',
|
name: 'Company ID',
|
||||||
value: 'companyId',
|
value: 'companyId',
|
||||||
default: '',
|
|
||||||
description: 'The company_id you have given to the company',
|
description: 'The company_id you have given to the company',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'ID',
|
||||||
|
value: 'id',
|
||||||
|
description: 'The Intercom defined id representing the company',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Name',
|
name: 'Name',
|
||||||
value: 'name',
|
value: 'name',
|
||||||
default: '',
|
|
||||||
description: 'The name of the company',
|
description: 'The name of the company',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: '',
|
default: '',
|
||||||
description: 'View by'
|
description: 'What property to use to query the company.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Value',
|
displayName: 'Value',
|
||||||
|
@ -217,7 +226,7 @@ export const companyFields = [
|
||||||
'company',
|
'company',
|
||||||
],
|
],
|
||||||
operation: [
|
operation: [
|
||||||
'view',
|
'get',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -240,7 +249,7 @@ export const companyFields = [
|
||||||
],
|
],
|
||||||
operation: [
|
operation: [
|
||||||
'create',
|
'create',
|
||||||
'update'
|
'update',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -259,16 +268,16 @@ export const companyFields = [
|
||||||
'update',
|
'update',
|
||||||
],
|
],
|
||||||
resource: [
|
resource: [
|
||||||
'company'
|
'company',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Options',
|
displayName: 'Additional Fields',
|
||||||
name: 'options',
|
name: 'additionalFields',
|
||||||
type: 'collection',
|
type: 'collection',
|
||||||
placeholder: 'Add Option',
|
placeholder: 'Add Field',
|
||||||
default: {},
|
default: {},
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
|
@ -277,11 +286,18 @@ export const companyFields = [
|
||||||
'update',
|
'update',
|
||||||
],
|
],
|
||||||
resource: [
|
resource: [
|
||||||
'company'
|
'company',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Industry',
|
||||||
|
name: 'industry',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
description: 'The industry that this company operates in',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Monthly Spend',
|
displayName: 'Monthly Spend',
|
||||||
name: 'monthlySpend',
|
name: 'monthlySpend',
|
||||||
|
@ -317,13 +333,7 @@ export const companyFields = [
|
||||||
name: 'website',
|
name: 'website',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
description: `The URL for this company's website. Please note that the value specified here is not validated. Accepts any string.`,
|
description: `The URL for this company's website. Please note that the value<br />specified here is not validated. Accepts any string.`,
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: 'Industry',
|
|
||||||
name: 'industry',
|
|
||||||
type: 'string',
|
|
||||||
description: 'The industry that this company operates in',
|
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -399,4 +409,3 @@ export const companyFields = [
|
||||||
description: 'A hash of key/value pairs to represent custom data you want to attribute to a user.',
|
description: 'A hash of key/value pairs to represent custom data you want to attribute to a user.',
|
||||||
},
|
},
|
||||||
] as INodeProperties[];
|
] as INodeProperties[];
|
||||||
|
|
||||||
|
|
|
@ -7,21 +7,24 @@ import {
|
||||||
IExecuteSingleFunctions
|
IExecuteSingleFunctions
|
||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
|
|
||||||
export async function intercomApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, resource: string, method: string, body: any = {}, headers?: object): Promise<any> { // tslint:disable-line:no-any
|
import {
|
||||||
|
IDataObject,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
export async function intercomApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, endpoint: string, method: string, body: any = {}, query?: IDataObject, uri?: string): Promise<any> { // tslint:disable-line:no-any
|
||||||
const credentials = this.getCredentials('intercomApi');
|
const credentials = this.getCredentials('intercomApi');
|
||||||
if (credentials === undefined) {
|
if (credentials === undefined) {
|
||||||
throw new Error('No credentials got returned!');
|
throw new Error('No credentials got returned!');
|
||||||
}
|
}
|
||||||
|
|
||||||
const headerWithAuthentication = Object.assign({}, headers,
|
const headerWithAuthentication = Object.assign({},
|
||||||
{ Authorization: `Bearer ${credentials.apiKey}`, Accept: 'application/json' });
|
{ Authorization: `Bearer ${credentials.apiKey}`, Accept: 'application/json' });
|
||||||
|
|
||||||
const endpoint = 'api.intercom.io';
|
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: headerWithAuthentication,
|
headers: headerWithAuthentication,
|
||||||
method,
|
method,
|
||||||
uri: `https://${endpoint}${resource}`,
|
qs: query,
|
||||||
|
uri: uri || `https://api.intercom.io${endpoint}`,
|
||||||
body,
|
body,
|
||||||
json: true
|
json: true
|
||||||
};
|
};
|
||||||
|
@ -29,8 +32,6 @@ export async function intercomApiRequest(this: IHookFunctions | IExecuteFunction
|
||||||
try {
|
try {
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.request!(options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
|
||||||
|
|
||||||
const errorMessage = error.response.body.message || error.response.body.Message;
|
const errorMessage = error.response.body.message || error.response.body.Message;
|
||||||
|
|
||||||
if (errorMessage !== undefined) {
|
if (errorMessage !== undefined) {
|
||||||
|
@ -40,6 +41,36 @@ export async function intercomApiRequest(this: IHookFunctions | IExecuteFunction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make an API request to paginated intercom endpoint
|
||||||
|
* and return all results
|
||||||
|
*/
|
||||||
|
export async function intercomApiRequestAllItems(this: IHookFunctions | IExecuteFunctions, propertyName: string, endpoint: string, method: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||||
|
|
||||||
|
const returnData: IDataObject[] = [];
|
||||||
|
|
||||||
|
let responseData;
|
||||||
|
|
||||||
|
query.per_page = 60;
|
||||||
|
|
||||||
|
let uri: string | undefined;
|
||||||
|
|
||||||
|
do {
|
||||||
|
responseData = await intercomApiRequest.call(this, endpoint, method, body, query, uri);
|
||||||
|
uri = responseData.pages.next;
|
||||||
|
returnData.push.apply(returnData, responseData[propertyName]);
|
||||||
|
} while (
|
||||||
|
responseData.pages !== undefined &&
|
||||||
|
responseData.pages.next !== undefined &&
|
||||||
|
responseData.pages.next !== null
|
||||||
|
);
|
||||||
|
|
||||||
|
return returnData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any
|
export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any
|
||||||
let result;
|
let result;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import {
|
||||||
} from './LeadDescription';
|
} from './LeadDescription';
|
||||||
import {
|
import {
|
||||||
intercomApiRequest,
|
intercomApiRequest,
|
||||||
|
intercomApiRequestAllItems,
|
||||||
validateJSON,
|
validateJSON,
|
||||||
} from './GenericFunctions';
|
} from './GenericFunctions';
|
||||||
import {
|
import {
|
||||||
|
@ -24,7 +25,7 @@ import {
|
||||||
} from './LeadInterface';
|
} from './LeadInterface';
|
||||||
import { userOpeations, userFields } from './UserDescription';
|
import { userOpeations, userFields } from './UserDescription';
|
||||||
import { IUser, IUserCompany } from './UserInterface';
|
import { IUser, IUserCompany } from './UserInterface';
|
||||||
import { companyOpeations, companyFields } from './CompanyDescription';
|
import { companyOperations, companyFields } from './CompanyDescription';
|
||||||
import { ICompany } from './CompanyInteface';
|
import { ICompany } from './CompanyInteface';
|
||||||
|
|
||||||
export class Intercom implements INodeType {
|
export class Intercom implements INodeType {
|
||||||
|
@ -55,9 +56,9 @@ export class Intercom implements INodeType {
|
||||||
type: 'options',
|
type: 'options',
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: 'User',
|
name: 'Company',
|
||||||
value: 'user',
|
value: 'company',
|
||||||
description: 'The Users resource is the primary way of interacting with Intercom',
|
description: 'Companies allow you to represent commercial organizations using your product.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Lead',
|
name: 'Lead',
|
||||||
|
@ -65,17 +66,17 @@ export class Intercom implements INodeType {
|
||||||
description: 'Leads are useful for representing logged-out users of your application.',
|
description: 'Leads are useful for representing logged-out users of your application.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Company',
|
name: 'User',
|
||||||
value: 'company',
|
value: 'user',
|
||||||
description: 'Companies allow you to represent commercial organizations using your product.',
|
description: 'The Users resource is the primary way of interacting with Intercom',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: '',
|
default: 'user',
|
||||||
description: 'Resource to consume.',
|
description: 'Resource to consume.',
|
||||||
},
|
},
|
||||||
...leadOpeations,
|
...leadOpeations,
|
||||||
...userOpeations,
|
...userOpeations,
|
||||||
...companyOpeations,
|
...companyOperations,
|
||||||
...userFields,
|
...userFields,
|
||||||
...leadFields,
|
...leadFields,
|
||||||
...companyFields,
|
...companyFields,
|
||||||
|
@ -112,58 +113,62 @@ export class Intercom implements INodeType {
|
||||||
const items = this.getInputData();
|
const items = this.getInputData();
|
||||||
const returnData: IDataObject[] = [];
|
const returnData: IDataObject[] = [];
|
||||||
const length = items.length as unknown as number;
|
const length = items.length as unknown as number;
|
||||||
|
let qs: IDataObject;
|
||||||
let responseData;
|
let responseData;
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
|
qs = {};
|
||||||
const resource = this.getNodeParameter('resource', 0) as string;
|
const resource = this.getNodeParameter('resource', 0) as string;
|
||||||
const operation = this.getNodeParameter('operation', 0) as string;
|
const operation = this.getNodeParameter('operation', 0) as string;
|
||||||
//https://developers.intercom.com/intercom-api-reference/reference#leads
|
//https://developers.intercom.com/intercom-api-reference/reference#leads
|
||||||
if (resource === 'lead') {
|
if (resource === 'lead') {
|
||||||
if (operation === 'create' || operation === 'update') {
|
if (operation === 'create' || operation === 'update') {
|
||||||
const email = this.getNodeParameter('email', i) as string;
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
|
||||||
const jsonActive = this.getNodeParameter('jsonParameters', i) as boolean;
|
const jsonActive = this.getNodeParameter('jsonParameters', i) as boolean;
|
||||||
const body: ILead = {};
|
const body: ILead = {};
|
||||||
if (email) {
|
if (operation === 'create') {
|
||||||
body.email = this.getNodeParameter('email', i) as string;
|
body.email = this.getNodeParameter('email', i) as string;
|
||||||
}
|
}
|
||||||
if (options.phone) {
|
if (additionalFields.email) {
|
||||||
body.phone = options.phone as string;
|
body.email = additionalFields.email as string;
|
||||||
}
|
}
|
||||||
if (options.name) {
|
if (additionalFields.phone) {
|
||||||
body.name = options.name as string;
|
body.phone = additionalFields.phone as string;
|
||||||
}
|
}
|
||||||
if (options.unsubscribedFromEmails) {
|
if (additionalFields.name) {
|
||||||
body.unsubscribed_from_emails = options.unsubscribedFromEmails as boolean;
|
body.name = additionalFields.name as string;
|
||||||
}
|
}
|
||||||
if (options.updateLastRequestAt) {
|
if (additionalFields.unsubscribedFromEmails) {
|
||||||
body.update_last_request_at = options.updateLastRequestAt as boolean;
|
body.unsubscribed_from_emails = additionalFields.unsubscribedFromEmails as boolean;
|
||||||
}
|
}
|
||||||
if (options.utmSource) {
|
if (additionalFields.updateLastRequestAt) {
|
||||||
body.utm_source = options.utmSource as string;
|
body.update_last_request_at = additionalFields.updateLastRequestAt as boolean;
|
||||||
}
|
}
|
||||||
if (options.utmMedium) {
|
if (additionalFields.utmSource) {
|
||||||
body.utm_medium = options.utmMedium as string;
|
body.utm_source = additionalFields.utmSource as string;
|
||||||
}
|
}
|
||||||
if (options.utmCampaign) {
|
if (additionalFields.utmMedium) {
|
||||||
body.utm_campaign = options.utmCampaign as string;
|
body.utm_medium = additionalFields.utmMedium as string;
|
||||||
}
|
}
|
||||||
if (options.utmTerm) {
|
if (additionalFields.utmCampaign) {
|
||||||
body.utm_term = options.utmTerm as string;
|
body.utm_campaign = additionalFields.utmCampaign as string;
|
||||||
}
|
}
|
||||||
if (options.utmContent) {
|
if (additionalFields.utmTerm) {
|
||||||
body.utm_content = options.utmContent as string;
|
body.utm_term = additionalFields.utmTerm as string;
|
||||||
}
|
}
|
||||||
if(options.avatar) {
|
if (additionalFields.utmContent) {
|
||||||
|
body.utm_content = additionalFields.utmContent as string;
|
||||||
|
}
|
||||||
|
if (additionalFields.avatar) {
|
||||||
const avatar: IAvatar = {
|
const avatar: IAvatar = {
|
||||||
type: 'avatar',
|
type: 'avatar',
|
||||||
image_url: options.avatar as string,
|
image_url: additionalFields.avatar as string,
|
||||||
};
|
};
|
||||||
body.avatar = avatar;
|
body.avatar = avatar;
|
||||||
}
|
}
|
||||||
if (options.companies) {
|
if (additionalFields.companies) {
|
||||||
const companies: ILeadCompany[] = [];
|
const companies: ILeadCompany[] = [];
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
options.companies.forEach( o => {
|
additionalFields.companies.forEach( o => {
|
||||||
const company: ILeadCompany = {};
|
const company: ILeadCompany = {};
|
||||||
company.company_id = o;
|
company.company_id = o;
|
||||||
companies.push(company);
|
companies.push(company);
|
||||||
|
@ -186,6 +191,7 @@ export class Intercom implements INodeType {
|
||||||
body.custom_attributes = customAttributesJson;
|
body.custom_attributes = customAttributesJson;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operation === 'update') {
|
if (operation === 'update') {
|
||||||
const updateBy = this.getNodeParameter('updateBy', 0) as string;
|
const updateBy = this.getNodeParameter('updateBy', 0) as string;
|
||||||
const value = this.getNodeParameter('value', i) as string;
|
const value = this.getNodeParameter('value', i) as string;
|
||||||
|
@ -196,43 +202,49 @@ export class Intercom implements INodeType {
|
||||||
body.id = value;
|
body.id = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
responseData = await intercomApiRequest.call(this, '/contacts', 'POST', body);
|
responseData = await intercomApiRequest.call(this, '/contacts', 'POST', body);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (operation === 'view') {
|
if (operation === 'get') {
|
||||||
let query = '';
|
const selectBy = this.getNodeParameter('selectBy', 0) as string;
|
||||||
const viewBy = this.getNodeParameter('viewBy', 0) as string;
|
|
||||||
const value = this.getNodeParameter('value', i) as string;
|
const value = this.getNodeParameter('value', i) as string;
|
||||||
if (viewBy === 'userId') {
|
if (selectBy === 'email') {
|
||||||
query = `user_id=${value}`;
|
qs.email = value;
|
||||||
}
|
}
|
||||||
if (viewBy === 'phone') {
|
if (selectBy === 'userId') {
|
||||||
query = `phone=${value}`;
|
qs.user_id = value;
|
||||||
|
}
|
||||||
|
if (selectBy === 'phone') {
|
||||||
|
qs.phone = value;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (viewBy === 'id') {
|
if (selectBy === 'id') {
|
||||||
responseData = await intercomApiRequest.call(this, `/contacts/${value}`, 'GET');
|
responseData = await intercomApiRequest.call(this, `/contacts/${value}`, 'GET');
|
||||||
} else {
|
} else {
|
||||||
responseData = await intercomApiRequest.call(this, `/contacts?${query}`, 'GET');
|
responseData = await intercomApiRequest.call(this, '/contacts', 'GET', {}, qs);
|
||||||
|
responseData = responseData.contacts;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (operation === 'list') {
|
if (operation === 'getAll') {
|
||||||
let query = '';
|
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||||
const listBy = this.getNodeParameter('listBy', 0) as string;
|
const filters = this.getNodeParameter('filters', i) as IDataObject;
|
||||||
if (listBy === 'email') {
|
Object.assign(qs, filters);
|
||||||
query = `email=${this.getNodeParameter('value', i) as string}`;
|
|
||||||
}
|
|
||||||
if (listBy === 'phone') {
|
|
||||||
query = `phone=${this.getNodeParameter('value', i) as string}`;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
responseData = await intercomApiRequest.call(this, `/contacts?${query}`, 'GET');
|
if (returnAll === true) {
|
||||||
|
responseData = await intercomApiRequestAllItems.call(this, 'contacts', '/contacts', 'GET', {}, qs);
|
||||||
|
} else {
|
||||||
|
qs.per_page = this.getNodeParameter('limit', i) as number;
|
||||||
|
responseData = await intercomApiRequest.call(this, '/contacts', 'GET', {}, qs);
|
||||||
|
responseData = responseData.contacts;
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
||||||
}
|
}
|
||||||
|
@ -244,7 +256,8 @@ export class Intercom implements INodeType {
|
||||||
if (deleteBy === 'id') {
|
if (deleteBy === 'id') {
|
||||||
responseData = await intercomApiRequest.call(this, `/contacts/${value}`, 'DELETE');
|
responseData = await intercomApiRequest.call(this, `/contacts/${value}`, 'DELETE');
|
||||||
} else {
|
} else {
|
||||||
responseData = await intercomApiRequest.call(this, `/contacts?user_id=${value}`, 'DELETE');
|
qs.user_id = value;
|
||||||
|
responseData = await intercomApiRequest.call(this, '/contacts', 'DELETE', {}, qs);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
||||||
|
@ -254,65 +267,74 @@ export class Intercom implements INodeType {
|
||||||
//https://developers.intercom.com/intercom-api-reference/reference#users
|
//https://developers.intercom.com/intercom-api-reference/reference#users
|
||||||
if (resource === 'user') {
|
if (resource === 'user') {
|
||||||
if (operation === 'create' || operation === 'update') {
|
if (operation === 'create' || operation === 'update') {
|
||||||
const id = this.getNodeParameter('id', i) as string;
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
|
||||||
const jsonActive = this.getNodeParameter('jsonParameters', i) as boolean;
|
const jsonActive = this.getNodeParameter('jsonParameters', i) as boolean;
|
||||||
const body: IUser = {};
|
const body: IUser = {};
|
||||||
if (id === 'email') {
|
|
||||||
|
if (operation === 'create') {
|
||||||
|
const identifierType = this.getNodeParameter('identifierType', i) as string;
|
||||||
|
if (identifierType === 'email') {
|
||||||
body.email = this.getNodeParameter('idValue', i) as string;
|
body.email = this.getNodeParameter('idValue', i) as string;
|
||||||
}
|
} else if (identifierType === 'userId') {
|
||||||
if (id === 'userId') {
|
|
||||||
body.user_id = this.getNodeParameter('idValue', i) as string;
|
body.user_id = this.getNodeParameter('idValue', i) as string;
|
||||||
}
|
}
|
||||||
if (options.phone) {
|
|
||||||
body.phone = options.phone as string;
|
|
||||||
}
|
}
|
||||||
if (options.name) {
|
|
||||||
body.name = options.name as string;
|
if (additionalFields.email) {
|
||||||
|
body.email = additionalFields.email as string;
|
||||||
}
|
}
|
||||||
if (options.unsubscribedFromEmails) {
|
if (additionalFields.userId) {
|
||||||
body.unsubscribed_from_emails = options.unsubscribedFromEmails as boolean;
|
body.user_id = additionalFields.userId as string;
|
||||||
}
|
}
|
||||||
if (options.updateLastRequestAt) {
|
if (additionalFields.phone) {
|
||||||
body.update_last_request_at = options.updateLastRequestAt as boolean;
|
body.phone = additionalFields.phone as string;
|
||||||
}
|
}
|
||||||
if (options.sessionCount) {
|
if (additionalFields.name) {
|
||||||
body.session_count = options.sessionCount as number;
|
body.name = additionalFields.name as string;
|
||||||
}
|
}
|
||||||
if(options.avatar) {
|
if (additionalFields.unsubscribedFromEmails) {
|
||||||
|
body.unsubscribed_from_emails = additionalFields.unsubscribedFromEmails as boolean;
|
||||||
|
}
|
||||||
|
if (additionalFields.updateLastRequestAt) {
|
||||||
|
body.update_last_request_at = additionalFields.updateLastRequestAt as boolean;
|
||||||
|
}
|
||||||
|
if (additionalFields.sessionCount) {
|
||||||
|
body.session_count = additionalFields.sessionCount as number;
|
||||||
|
}
|
||||||
|
if (additionalFields.avatar) {
|
||||||
const avatar: IAvatar = {
|
const avatar: IAvatar = {
|
||||||
type: 'avatar',
|
type: 'avatar',
|
||||||
image_url: options.avatar as string,
|
image_url: additionalFields.avatar as string,
|
||||||
};
|
};
|
||||||
body.avatar = avatar;
|
body.avatar = avatar;
|
||||||
}
|
}
|
||||||
if (options.utmSource) {
|
if (additionalFields.utmSource) {
|
||||||
body.utm_source = options.utmSource as string;
|
body.utm_source = additionalFields.utmSource as string;
|
||||||
}
|
}
|
||||||
if (options.utmMedium) {
|
if (additionalFields.utmMedium) {
|
||||||
body.utm_medium = options.utmMedium as string;
|
body.utm_medium = additionalFields.utmMedium as string;
|
||||||
}
|
}
|
||||||
if (options.utmCampaign) {
|
if (additionalFields.utmCampaign) {
|
||||||
body.utm_campaign = options.utmCampaign as string;
|
body.utm_campaign = additionalFields.utmCampaign as string;
|
||||||
}
|
}
|
||||||
if (options.utmTerm) {
|
if (additionalFields.utmTerm) {
|
||||||
body.utm_term = options.utmTerm as string;
|
body.utm_term = additionalFields.utmTerm as string;
|
||||||
}
|
}
|
||||||
if (options.utmContent) {
|
if (additionalFields.utmContent) {
|
||||||
body.utm_content = options.utmContent as string;
|
body.utm_content = additionalFields.utmContent as string;
|
||||||
}
|
}
|
||||||
if (options.companies) {
|
if (additionalFields.companies) {
|
||||||
const companies: IUserCompany[] = [];
|
const companies: IUserCompany[] = [];
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
options.companies.forEach( o => {
|
additionalFields.companies.forEach( o => {
|
||||||
const company: IUserCompany = {};
|
const company: IUserCompany = {};
|
||||||
company.company_id = o;
|
company.company_id = o;
|
||||||
companies.push(company);
|
companies.push(company);
|
||||||
});
|
});
|
||||||
body.companies = companies;
|
body.companies = companies;
|
||||||
}
|
}
|
||||||
if (options.sessionCount) {
|
if (additionalFields.sessionCount) {
|
||||||
body.session_count = options.sessionCount as number;
|
body.session_count = additionalFields.sessionCount as number;
|
||||||
}
|
}
|
||||||
if (!jsonActive) {
|
if (!jsonActive) {
|
||||||
const customAttributesValues = (this.getNodeParameter('customAttributesUi', i) as IDataObject).customAttributesValues as IDataObject[];
|
const customAttributesValues = (this.getNodeParameter('customAttributesUi', i) as IDataObject).customAttributesValues as IDataObject[];
|
||||||
|
@ -330,57 +352,56 @@ export class Intercom implements INodeType {
|
||||||
body.custom_attributes = customAttributesJson;
|
body.custom_attributes = customAttributesJson;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operation === 'update') {
|
if (operation === 'update') {
|
||||||
const id = this.getNodeParameter('id', i) as string;
|
const updateBy = this.getNodeParameter('updateBy', 0) as string;
|
||||||
const email = this.getNodeParameter('email', i) as string;
|
|
||||||
const userId = this.getNodeParameter('userId', i) as string;
|
|
||||||
if (id) {
|
|
||||||
body.id = id;
|
|
||||||
}
|
|
||||||
if (email) {
|
|
||||||
body.email = email;
|
|
||||||
}
|
|
||||||
if (userId) {
|
|
||||||
body.user_id = userId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
responseData = await intercomApiRequest.call(this, '/users', 'POST', body);
|
|
||||||
} catch (err) {
|
|
||||||
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (operation === 'view') {
|
|
||||||
let query = '';
|
|
||||||
const viewBy = this.getNodeParameter('viewBy', 0) as string;
|
|
||||||
const value = this.getNodeParameter('value', i) as string;
|
const value = this.getNodeParameter('value', i) as string;
|
||||||
if (viewBy === 'userId') {
|
if (updateBy === 'userId') {
|
||||||
query = `user_id=${value}`;
|
body.user_id = value;
|
||||||
|
}
|
||||||
|
if (updateBy === 'id') {
|
||||||
|
body.id = value;
|
||||||
|
}
|
||||||
|
if (updateBy === 'email') {
|
||||||
|
body.email = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
responseData = await intercomApiRequest.call(this, '/users', 'POST', body, qs);
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (operation === 'get') {
|
||||||
|
const selectBy = this.getNodeParameter('selectBy', 0) as string;
|
||||||
|
const value = this.getNodeParameter('value', i) as string;
|
||||||
|
if (selectBy === 'userId') {
|
||||||
|
qs.user_id = value;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (viewBy === 'id') {
|
if (selectBy === 'id') {
|
||||||
responseData = await intercomApiRequest.call(this, `/users/${value}`, 'GET');
|
responseData = await intercomApiRequest.call(this, `/users/${value}`, 'GET', {}, qs);
|
||||||
} else {
|
} else {
|
||||||
responseData = await intercomApiRequest.call(this, `/users?${query}`, 'GET');
|
responseData = await intercomApiRequest.call(this, '/users', 'GET', {}, qs);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (operation === 'list') {
|
if (operation === 'getAll') {
|
||||||
let query = '';
|
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||||
const listBy = this.getNodeParameter('listBy', 0) as string;
|
const filters = this.getNodeParameter('filters', i) as IDataObject;
|
||||||
if (listBy === 'email') {
|
Object.assign(qs, filters);
|
||||||
query = `email=${this.getNodeParameter('value', i) as string}`;
|
|
||||||
}
|
|
||||||
if (listBy === 'segmentId') {
|
|
||||||
query = `segment_id=${this.getNodeParameter('value', i) as string}`;
|
|
||||||
}
|
|
||||||
if (listBy === 'tagId') {
|
|
||||||
query = `tag_id=${this.getNodeParameter('value', i) as string}`;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
responseData = await intercomApiRequest.call(this, `/users?${query}`, 'GET');
|
if (returnAll === true) {
|
||||||
|
responseData = await intercomApiRequestAllItems.call(this, 'users', '/users', 'GET', {}, qs);
|
||||||
|
} else {
|
||||||
|
qs.per_page = this.getNodeParameter('limit', i) as number;
|
||||||
|
responseData = await intercomApiRequest.call(this, '/users', 'GET', {}, qs);
|
||||||
|
responseData = responseData.users;
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
||||||
}
|
}
|
||||||
|
@ -398,28 +419,28 @@ export class Intercom implements INodeType {
|
||||||
if (resource === 'company') {
|
if (resource === 'company') {
|
||||||
if (operation === 'create' || operation === 'update') {
|
if (operation === 'create' || operation === 'update') {
|
||||||
const id = this.getNodeParameter('companyId', i) as string;
|
const id = this.getNodeParameter('companyId', i) as string;
|
||||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
const jsonActive = this.getNodeParameter('jsonParameters', i) as boolean;
|
const jsonActive = this.getNodeParameter('jsonParameters', i) as boolean;
|
||||||
const body: ICompany = {
|
const body: ICompany = {
|
||||||
company_id: id,
|
company_id: id,
|
||||||
};
|
};
|
||||||
if (options.monthlySpend) {
|
if (additionalFields.monthlySpend) {
|
||||||
body.monthly_spend = options.monthlySpend as number;
|
body.monthly_spend = additionalFields.monthlySpend as number;
|
||||||
}
|
}
|
||||||
if (options.name) {
|
if (additionalFields.name) {
|
||||||
body.name = options.name as string;
|
body.name = additionalFields.name as string;
|
||||||
}
|
}
|
||||||
if (options.plan) {
|
if (additionalFields.plan) {
|
||||||
body.plan = options.plan as string;
|
body.plan = additionalFields.plan as string;
|
||||||
}
|
}
|
||||||
if (options.size) {
|
if (additionalFields.size) {
|
||||||
body.size = options.size as number;
|
body.size = additionalFields.size as number;
|
||||||
}
|
}
|
||||||
if (options.website) {
|
if (additionalFields.website) {
|
||||||
body.website = options.website as string;
|
body.website = additionalFields.website as string;
|
||||||
}
|
}
|
||||||
if (options.industry) {
|
if (additionalFields.industry) {
|
||||||
body.industry = options.industry as string;
|
body.industry = additionalFields.industry as string;
|
||||||
}
|
}
|
||||||
if (!jsonActive) {
|
if (!jsonActive) {
|
||||||
const customAttributesValues = (this.getNodeParameter('customAttributesUi', i) as IDataObject).customAttributesValues as IDataObject[];
|
const customAttributesValues = (this.getNodeParameter('customAttributesUi', i) as IDataObject).customAttributesValues as IDataObject[];
|
||||||
|
@ -438,58 +459,59 @@ export class Intercom implements INodeType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
responseData = await intercomApiRequest.call(this, '/companies', 'POST', body);
|
responseData = await intercomApiRequest.call(this, '/companies', 'POST', body, qs);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (operation === 'view') {
|
if (operation === 'get') {
|
||||||
let query = '';
|
const selectBy = this.getNodeParameter('selectBy', 0) as string;
|
||||||
const viewBy = this.getNodeParameter('viewBy', 0) as string;
|
|
||||||
const value = this.getNodeParameter('value', i) as string;
|
const value = this.getNodeParameter('value', i) as string;
|
||||||
if (viewBy === 'companyId') {
|
if (selectBy === 'companyId') {
|
||||||
query = `company_id=${value}`;
|
qs.company_id = value;
|
||||||
}
|
}
|
||||||
if (viewBy === 'name') {
|
if (selectBy === 'name') {
|
||||||
query = `name=${value}`;
|
qs.name = value;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (viewBy === 'id') {
|
if (selectBy === 'id') {
|
||||||
responseData = await intercomApiRequest.call(this, `/companies/${value}`, 'GET');
|
responseData = await intercomApiRequest.call(this, `/companies/${value}`, 'GET', {}, qs);
|
||||||
} else {
|
} else {
|
||||||
responseData = await intercomApiRequest.call(this, `/companies?${query}`, 'GET');
|
responseData = await intercomApiRequest.call(this, '/companies', 'GET', {}, qs);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (operation === 'list') {
|
if (operation === 'getAll') {
|
||||||
let query = '';
|
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||||
const listBy = this.getNodeParameter('listBy', 0) as string;
|
const filters = this.getNodeParameter('filters', i) as IDataObject;
|
||||||
if (listBy === 'segmentId') {
|
Object.assign(qs, filters);
|
||||||
query = `segment_id=${this.getNodeParameter('value', i) as string}`;
|
|
||||||
}
|
|
||||||
if (listBy === 'tagId') {
|
|
||||||
query = `tag_id=${this.getNodeParameter('value', i) as string}`;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
responseData = await intercomApiRequest.call(this, `/companies?${query}`, 'GET');
|
if (returnAll === true) {
|
||||||
|
responseData = await intercomApiRequestAllItems.call(this, 'companies', '/companies', 'GET', {}, qs);
|
||||||
|
} else {
|
||||||
|
qs.per_page = this.getNodeParameter('limit', i) as number;
|
||||||
|
responseData = await intercomApiRequest.call(this, '/companies', 'GET', {}, qs);
|
||||||
|
responseData = responseData.companies;
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (operation === 'users') {
|
if (operation === 'users') {
|
||||||
let query = '';
|
const filterBy = this.getNodeParameter('filterBy', 0) as string;
|
||||||
const listBy = this.getNodeParameter('listBy', 0) as string;
|
|
||||||
const value = this.getNodeParameter('value', i) as string;
|
const value = this.getNodeParameter('value', i) as string;
|
||||||
if (listBy === 'companyId') {
|
if (filterBy === 'companyId') {
|
||||||
query = `company_id=${value}`;
|
qs.company_id = value;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (listBy === 'id') {
|
if (filterBy === 'id') {
|
||||||
responseData = await intercomApiRequest.call(this, `/companies/${value}/users`, 'GET');
|
responseData = await intercomApiRequest.call(this, `/companies/${value}/users`, 'GET', {}, qs);
|
||||||
} else {
|
} else {
|
||||||
responseData = await intercomApiRequest.call(this, `/companies?${query}&type=users`, 'GET');
|
qs.type = 'users';
|
||||||
|
responseData = await intercomApiRequest.call(this, '/companies', 'GET', {}, qs);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
throw new Error(`Intercom Error: ${JSON.stringify(err)}`);
|
||||||
|
|
|
@ -18,28 +18,28 @@ export const leadOpeations = [
|
||||||
value: 'create',
|
value: 'create',
|
||||||
description: 'Create a new lead',
|
description: 'Create a new lead',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Get',
|
||||||
|
value: 'get',
|
||||||
|
description: 'Get data of a lead',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Get All',
|
||||||
|
value: 'getAll',
|
||||||
|
description: 'Get data of all leads',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Update',
|
name: 'Update',
|
||||||
value: 'update',
|
value: 'update',
|
||||||
description: 'Update new lead',
|
description: 'Update new lead',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: 'View',
|
|
||||||
value: 'view',
|
|
||||||
description: 'View a lead',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'List',
|
|
||||||
value: 'list',
|
|
||||||
description: 'List leads',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'Delete',
|
name: 'Delete',
|
||||||
value: 'delete',
|
value: 'delete',
|
||||||
description: 'Delete a lead',
|
description: 'Delete a lead',
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
default: '',
|
default: 'create',
|
||||||
description: 'The operation to perform.',
|
description: 'The operation to perform.',
|
||||||
},
|
},
|
||||||
] as INodeProperties[];
|
] as INodeProperties[];
|
||||||
|
@ -68,18 +68,16 @@ export const leadFields = [
|
||||||
{
|
{
|
||||||
name: 'ID',
|
name: 'ID',
|
||||||
value: 'id',
|
value: 'id',
|
||||||
default: '',
|
|
||||||
description: 'The Intercom defined id representing the Lead',
|
description: 'The Intercom defined id representing the Lead',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'User ID',
|
name: 'User ID',
|
||||||
value: 'userId',
|
value: 'userId',
|
||||||
default: '',
|
|
||||||
description: 'Automatically generated identifier for the Lead',
|
description: 'Automatically generated identifier for the Lead',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: '',
|
default: '',
|
||||||
description: 'Delete by'
|
description: 'Delete by',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Value',
|
displayName: 'Value',
|
||||||
|
@ -100,12 +98,12 @@ export const leadFields = [
|
||||||
},
|
},
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* lead:view */
|
/* lead:get */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
{
|
{
|
||||||
displayName: 'View By',
|
displayName: 'Select By',
|
||||||
name: 'viewBy',
|
name: 'selectBy',
|
||||||
type: 'options',
|
type: 'options',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
|
@ -113,67 +111,7 @@ export const leadFields = [
|
||||||
'lead',
|
'lead',
|
||||||
],
|
],
|
||||||
operation: [
|
operation: [
|
||||||
'view',
|
'get',
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: 'ID',
|
|
||||||
value: 'id',
|
|
||||||
default: '',
|
|
||||||
description: 'The Intercom defined id representing the Lead',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'User ID',
|
|
||||||
value: 'userId',
|
|
||||||
default: '',
|
|
||||||
description: 'Automatically generated identifier for the Lead',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Phone',
|
|
||||||
value: 'phone',
|
|
||||||
default: '',
|
|
||||||
description: 'Phone representing the Lead',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
default: '',
|
|
||||||
description: 'View by'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: 'Value',
|
|
||||||
name: 'value',
|
|
||||||
type: 'string',
|
|
||||||
default: '',
|
|
||||||
required: true,
|
|
||||||
displayOptions: {
|
|
||||||
show: {
|
|
||||||
resource: [
|
|
||||||
'lead',
|
|
||||||
],
|
|
||||||
operation: [
|
|
||||||
'view',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
description: 'View by value',
|
|
||||||
},
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
/* lead:list */
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
{
|
|
||||||
displayName: 'List by',
|
|
||||||
name: 'listBy',
|
|
||||||
type: 'options',
|
|
||||||
displayOptions: {
|
|
||||||
show: {
|
|
||||||
resource: [
|
|
||||||
'lead',
|
|
||||||
],
|
|
||||||
operation: [
|
|
||||||
'list',
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -181,24 +119,26 @@ export const leadFields = [
|
||||||
{
|
{
|
||||||
name: 'Email',
|
name: 'Email',
|
||||||
value: 'email',
|
value: 'email',
|
||||||
default: '',
|
|
||||||
description: 'Email representing the Lead',
|
description: 'Email representing the Lead',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'ID',
|
||||||
|
value: 'id',
|
||||||
|
description: 'The Intercom defined id representing the Lead',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'User ID',
|
||||||
|
value: 'userId',
|
||||||
|
description: 'Automatically generated identifier for the Lead',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Phone',
|
name: 'Phone',
|
||||||
value: 'phone',
|
value: 'phone',
|
||||||
default: '',
|
|
||||||
description: 'Phone representing the Lead',
|
description: 'Phone representing the Lead',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: 'All',
|
|
||||||
value: 'all',
|
|
||||||
default: '',
|
|
||||||
description: 'List all leads',
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
default: '',
|
default: '',
|
||||||
description: 'List by'
|
description: 'The property to select the lead by.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Value',
|
displayName: 'Value',
|
||||||
|
@ -212,16 +152,90 @@ export const leadFields = [
|
||||||
'lead',
|
'lead',
|
||||||
],
|
],
|
||||||
operation: [
|
operation: [
|
||||||
'list',
|
'get',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
hide: {
|
|
||||||
listBy: [
|
|
||||||
'all'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
description: 'list by value',
|
description: 'View by value',
|
||||||
|
},
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* lead:getAll */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
{
|
||||||
|
displayName: 'Return All',
|
||||||
|
name: 'returnAll',
|
||||||
|
type: 'boolean',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'lead',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getAll',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: false,
|
||||||
|
description: 'If all results should be returned or only up to a given limit.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Limit',
|
||||||
|
name: 'limit',
|
||||||
|
type: 'number',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'lead',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getAll',
|
||||||
|
],
|
||||||
|
returnAll: [
|
||||||
|
false,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
typeOptions: {
|
||||||
|
minValue: 1,
|
||||||
|
maxValue: 60,
|
||||||
|
},
|
||||||
|
default: 50,
|
||||||
|
description: 'How many results to return.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Filters',
|
||||||
|
name: 'filters',
|
||||||
|
type: 'collection',
|
||||||
|
placeholder: 'Add Filter',
|
||||||
|
default: {},
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'lead',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getAll',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Email',
|
||||||
|
name: 'email',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
description: 'The email address of the lead',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Phone',
|
||||||
|
name: 'phone',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
description: 'The phone number of the lead',
|
||||||
|
},
|
||||||
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
@ -246,18 +260,16 @@ export const leadFields = [
|
||||||
{
|
{
|
||||||
name: 'User ID',
|
name: 'User ID',
|
||||||
value: 'userId',
|
value: 'userId',
|
||||||
default: '',
|
|
||||||
description: 'Automatically generated identifier for the Lead',
|
description: 'Automatically generated identifier for the Lead',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'ID',
|
name: 'ID',
|
||||||
value: 'id',
|
value: 'id',
|
||||||
default: '',
|
|
||||||
description: 'The Intercom defined id representing the Lead',
|
description: 'The Intercom defined id representing the Lead',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: '',
|
default: 'id',
|
||||||
description: 'Update by',
|
description: 'The property via which to query the lead.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Value',
|
displayName: 'Value',
|
||||||
|
@ -275,7 +287,7 @@ export const leadFields = [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
description: 'Update by value',
|
description: 'Value of the property to identify the lead to update',
|
||||||
},
|
},
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
@ -300,24 +312,6 @@ export const leadFields = [
|
||||||
},
|
},
|
||||||
description: 'The email of the user.',
|
description: 'The email of the user.',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
displayName: 'Email',
|
|
||||||
name: 'email',
|
|
||||||
type: 'string',
|
|
||||||
default: '',
|
|
||||||
required: false,
|
|
||||||
displayOptions: {
|
|
||||||
show: {
|
|
||||||
resource: [
|
|
||||||
'lead',
|
|
||||||
],
|
|
||||||
operation: [
|
|
||||||
'update',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
description: 'The email of the user.',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
displayName: 'JSON Parameters',
|
displayName: 'JSON Parameters',
|
||||||
name: 'jsonParameters',
|
name: 'jsonParameters',
|
||||||
|
@ -331,16 +325,16 @@ export const leadFields = [
|
||||||
'update',
|
'update',
|
||||||
],
|
],
|
||||||
resource: [
|
resource: [
|
||||||
'lead'
|
'lead',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Options',
|
displayName: 'Additional Fields',
|
||||||
name: 'options',
|
name: 'additionalFields',
|
||||||
type: 'collection',
|
type: 'collection',
|
||||||
placeholder: 'Add Option',
|
placeholder: 'Add Field',
|
||||||
default: {},
|
default: {},
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
|
@ -349,11 +343,25 @@ export const leadFields = [
|
||||||
'update',
|
'update',
|
||||||
],
|
],
|
||||||
resource: [
|
resource: [
|
||||||
'lead'
|
'lead',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Avatar',
|
||||||
|
name: 'avatar',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
description: 'An avatar image URL. note: the image url needs to be https.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Name',
|
||||||
|
name: 'name',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
description: 'Name of the user',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Phone',
|
displayName: 'Phone',
|
||||||
name: 'phone',
|
name: 'phone',
|
||||||
|
@ -361,20 +369,11 @@ export const leadFields = [
|
||||||
default: '',
|
default: '',
|
||||||
description: 'The phone number of the user',
|
description: 'The phone number of the user',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
displayName: 'Name',
|
|
||||||
name: 'name',
|
|
||||||
type: 'string',
|
|
||||||
default: '',
|
|
||||||
placeholder: '',
|
|
||||||
description: 'Name of the user',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
displayName: 'Unsubscribed From Emails',
|
displayName: 'Unsubscribed From Emails',
|
||||||
name: 'unsubscribedFromEmails',
|
name: 'unsubscribedFromEmails',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: '',
|
default: false,
|
||||||
placeholder: '',
|
|
||||||
description: 'Whether the Lead is unsubscribed from emails',
|
description: 'Whether the Lead is unsubscribed from emails',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -382,8 +381,7 @@ export const leadFields = [
|
||||||
name: 'updateLastRequestAt',
|
name: 'updateLastRequestAt',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
default: false,
|
||||||
options: [],
|
description: 'A boolean value, which if true, instructs Intercom to update the<br />users last_request_at value to the current API service time in<br />UTC. default value if not sent is false.',
|
||||||
description: `A boolean value, which if true, instructs Intercom to update the users' last_request_at value to the current API service time in UTC. default value if not sent is false.`,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Companies',
|
displayName: 'Companies',
|
||||||
|
@ -396,11 +394,21 @@ export const leadFields = [
|
||||||
description: 'Identifies the companies this user belongs to.',
|
description: 'Identifies the companies this user belongs to.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Avatar',
|
displayName: 'Email',
|
||||||
name: 'avatar',
|
name: 'email',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
description: 'An avatar image URL. note: the image url needs to be https.',
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
'/resource': [
|
||||||
|
'lead',
|
||||||
|
],
|
||||||
|
'/operation': [
|
||||||
|
'update',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The email of the user.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'UTM Source',
|
displayName: 'UTM Source',
|
||||||
|
@ -511,4 +519,3 @@ export const leadFields = [
|
||||||
description: 'A hash of key/value pairs to represent custom data you want to attribute to a user.',
|
description: 'A hash of key/value pairs to represent custom data you want to attribute to a user.',
|
||||||
},
|
},
|
||||||
] as INodeProperties[];
|
] as INodeProperties[];
|
||||||
|
|
||||||
|
|
|
@ -18,28 +18,28 @@ export const userOpeations = [
|
||||||
value: 'create',
|
value: 'create',
|
||||||
description: 'Create a new user',
|
description: 'Create a new user',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Get',
|
||||||
|
value: 'get',
|
||||||
|
description: 'Get data of a user',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Get All',
|
||||||
|
value: 'getAll',
|
||||||
|
description: 'Get data of all users',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Update',
|
name: 'Update',
|
||||||
value: 'update',
|
value: 'update',
|
||||||
description: 'Update a user',
|
description: 'Update a user',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: 'View',
|
|
||||||
value: 'view',
|
|
||||||
description: 'View a user',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'List',
|
|
||||||
value: 'list',
|
|
||||||
description: 'List users',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'Delete',
|
name: 'Delete',
|
||||||
value: 'delete',
|
value: 'delete',
|
||||||
description: 'Delete a user',
|
description: 'Delete a user',
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
default: '',
|
default: 'create',
|
||||||
description: 'The operation to perform.',
|
description: 'The operation to perform.',
|
||||||
},
|
},
|
||||||
] as INodeProperties[];
|
] as INodeProperties[];
|
||||||
|
@ -70,89 +70,106 @@ export const userFields = [
|
||||||
},
|
},
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* user:list */
|
/* user:getAll */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
{
|
{
|
||||||
displayName: 'List by',
|
displayName: 'Return All',
|
||||||
name: 'listBy',
|
name: 'returnAll',
|
||||||
type: 'options',
|
type: 'boolean',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: [
|
resource: [
|
||||||
'user',
|
'user',
|
||||||
],
|
],
|
||||||
operation: [
|
operation: [
|
||||||
'list',
|
'getAll',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: false,
|
||||||
|
description: 'If all results should be returned or only up to a given limit.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Limit',
|
||||||
|
name: 'limit',
|
||||||
|
type: 'number',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'user',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getAll',
|
||||||
|
],
|
||||||
|
returnAll: [
|
||||||
|
false,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
typeOptions: {
|
||||||
|
minValue: 1,
|
||||||
|
maxValue: 60,
|
||||||
|
},
|
||||||
|
default: 50,
|
||||||
|
description: 'How many results to return.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Filters',
|
||||||
|
name: 'filters',
|
||||||
|
type: 'collection',
|
||||||
|
placeholder: 'Add Filter',
|
||||||
|
default: {},
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'user',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getAll',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: 'Email',
|
displayName: 'Company ID',
|
||||||
value: 'email',
|
name: 'company_id',
|
||||||
default: '',
|
|
||||||
description: 'Email representing the Lead',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Segment ID',
|
|
||||||
value: 'segmentId',
|
|
||||||
default: '',
|
|
||||||
description: 'Segment representing the Lead',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Tag ID',
|
|
||||||
value: 'tagId',
|
|
||||||
default: '',
|
|
||||||
description: 'Tag representing the Lead',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Company ID',
|
|
||||||
value: 'companyId',
|
|
||||||
default: '',
|
|
||||||
description: 'Company representing the Lead',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'All',
|
|
||||||
value: 'all',
|
|
||||||
default: '',
|
|
||||||
description: 'List all users',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
default: '',
|
|
||||||
description: 'List by'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: 'Value',
|
|
||||||
name: 'value',
|
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
required: true,
|
description: 'Company ID representing the user',
|
||||||
displayOptions: {
|
|
||||||
show: {
|
|
||||||
resource: [
|
|
||||||
'user',
|
|
||||||
],
|
|
||||||
operation: [
|
|
||||||
'list',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
hide: {
|
{
|
||||||
listBy: [
|
displayName: 'Email',
|
||||||
'all'
|
name: 'email',
|
||||||
]
|
type: 'string',
|
||||||
}
|
default: '',
|
||||||
|
description: 'The email address of the user',
|
||||||
},
|
},
|
||||||
description: 'list by value',
|
{
|
||||||
|
displayName: 'Tag ID',
|
||||||
|
name: 'tag_id',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
description: 'Tag representing the user',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Segment ID',
|
||||||
|
name: 'segment_id',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
description: 'Segment representing the user',
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* view:user */
|
/* user:get */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
{
|
{
|
||||||
displayName: 'View By',
|
displayName: 'Select By',
|
||||||
name: 'viewBy',
|
name: 'selectBy',
|
||||||
type: 'options',
|
type: 'options',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
|
@ -160,7 +177,7 @@ export const userFields = [
|
||||||
'user',
|
'user',
|
||||||
],
|
],
|
||||||
operation: [
|
operation: [
|
||||||
'view',
|
'get',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -179,7 +196,7 @@ export const userFields = [
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: '',
|
default: '',
|
||||||
description: 'View by'
|
description: 'The property to select the user by.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Value',
|
displayName: 'Value',
|
||||||
|
@ -193,7 +210,7 @@ export const userFields = [
|
||||||
'user',
|
'user',
|
||||||
],
|
],
|
||||||
operation: [
|
operation: [
|
||||||
'view',
|
'get',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -205,10 +222,9 @@ export const userFields = [
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
{
|
{
|
||||||
displayName: 'Id',
|
displayName: 'Update By',
|
||||||
name: 'id',
|
name: 'updateBy',
|
||||||
type: 'string',
|
type: 'options',
|
||||||
default: '',
|
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: [
|
resource: [
|
||||||
|
@ -219,30 +235,33 @@ export const userFields = [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
description: 'id is matched - the user_id and email will be updated if they are sent.',
|
options: [
|
||||||
|
{
|
||||||
|
name: 'ID',
|
||||||
|
value: 'id',
|
||||||
|
description: 'The Intercom defined id representing the user',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'User Id',
|
name: 'Email',
|
||||||
name: 'userId',
|
value: 'email',
|
||||||
type: 'string',
|
description: 'The email address of user',
|
||||||
default: '',
|
|
||||||
displayOptions: {
|
|
||||||
show: {
|
|
||||||
resource: [
|
|
||||||
'user',
|
|
||||||
],
|
|
||||||
operation: [
|
|
||||||
'update',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
description: 'user_id match - the email will be updated, the id is not updated.',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Email',
|
name: 'User ID',
|
||||||
name: 'email',
|
value: 'userId',
|
||||||
|
description: 'Automatically generated identifier for the user',
|
||||||
|
},
|
||||||
|
|
||||||
|
],
|
||||||
|
default: 'id',
|
||||||
|
description: 'The property via which to query the user.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Value',
|
||||||
|
name: 'value',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
|
required: true,
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: [
|
resource: [
|
||||||
|
@ -253,8 +272,7 @@ export const userFields = [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
description: `email match where no user_id set on the matching user - the user_id will be set to the value sent in the request, the id is not updated.
|
description: 'Value of the property to identify the user to update',
|
||||||
email match where there is a user_id set on the matching user - a new unique record with new id will be created if a new value for user_id is sent in the request.`,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
@ -262,8 +280,8 @@ export const userFields = [
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
{
|
{
|
||||||
displayName: 'Id',
|
displayName: 'Identifier Type',
|
||||||
name: 'id',
|
name: 'identifierType',
|
||||||
type: 'options',
|
type: 'options',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
|
@ -277,15 +295,13 @@ export const userFields = [
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: 'User Id',
|
name: 'User ID',
|
||||||
value: 'userId',
|
value: 'userId',
|
||||||
default: '',
|
|
||||||
description: 'A unique string identifier for the user. It is required on creation if an email is not supplied.',
|
description: 'A unique string identifier for the user. It is required on creation if an email is not supplied.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Email',
|
name: 'Email',
|
||||||
value: 'email',
|
value: 'email',
|
||||||
default: '',
|
|
||||||
description: `The user's email address. It is required on creation if a user_id is not supplied.`,
|
description: `The user's email address. It is required on creation if a user_id is not supplied.`,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -329,10 +345,10 @@ export const userFields = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Options',
|
displayName: 'Additional Fields',
|
||||||
name: 'options',
|
name: 'additionalFields',
|
||||||
type: 'collection',
|
type: 'collection',
|
||||||
placeholder: 'Add Option',
|
placeholder: 'Add Field',
|
||||||
default: {},
|
default: {},
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
|
@ -346,6 +362,51 @@ export const userFields = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Email',
|
||||||
|
name: 'email',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
'/operation': [
|
||||||
|
'update',
|
||||||
|
],
|
||||||
|
'/resource': [
|
||||||
|
'user'
|
||||||
|
],
|
||||||
|
},
|
||||||
|
hide: {
|
||||||
|
'/updateBy': [
|
||||||
|
'email',
|
||||||
|
]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
description: 'Email of the user',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'User ID',
|
||||||
|
name: 'userId',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
'/operation': [
|
||||||
|
'update',
|
||||||
|
],
|
||||||
|
'/resource': [
|
||||||
|
'user'
|
||||||
|
],
|
||||||
|
},
|
||||||
|
hide: {
|
||||||
|
'/updateBy': [
|
||||||
|
'email',
|
||||||
|
'userId',
|
||||||
|
]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
description: 'Email of the user',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Phone',
|
displayName: 'Phone',
|
||||||
name: 'phone',
|
name: 'phone',
|
||||||
|
@ -375,7 +436,7 @@ export const userFields = [
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
default: false,
|
||||||
options: [],
|
options: [],
|
||||||
description: `A boolean value, which if true, instructs Intercom to update the users' last_request_at value to the current API service time in UTC. default value if not sent is false.`,
|
description: 'A boolean value, which if true, instructs Intercom to update the users<br />last_request_at value to the current API service time in UTC.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Session Count',
|
displayName: 'Session Count',
|
||||||
|
@ -511,4 +572,3 @@ export const userFields = [
|
||||||
description: 'A hash of key/value pairs to represent custom data you want to attribute to a user.',
|
description: 'A hash of key/value pairs to represent custom data you want to attribute to a user.',
|
||||||
},
|
},
|
||||||
] as INodeProperties[];
|
] as INodeProperties[];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue