2022-08-01 13:47:55 -07:00
|
|
|
import { INodeProperties } from 'n8n-workflow';
|
2021-04-02 10:12:19 -07:00
|
|
|
|
2022-08-01 13:47:55 -07:00
|
|
|
import { isoCountryCodes } from '../utils/isoCountryCodes';
|
2021-04-02 10:12:19 -07:00
|
|
|
|
2022-08-01 13:47:55 -07:00
|
|
|
import { addressFixedCollection, phoneNumbersFixedCollection } from '../utils/sharedFields';
|
2021-04-02 10:12:19 -07:00
|
|
|
|
2021-12-03 00:44:16 -08:00
|
|
|
export const companyOperations: INodeProperties[] = [
|
2021-04-02 10:12:19 -07:00
|
|
|
{
|
|
|
|
displayName: 'Operation',
|
|
|
|
name: 'operation',
|
|
|
|
type: 'options',
|
2022-05-20 14:47:24 -07:00
|
|
|
noDataExpression: true,
|
2021-04-02 10:12:19 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-01 13:47:55 -07:00
|
|
|
resource: ['company'],
|
2021-04-02 10:12:19 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'Create',
|
|
|
|
value: 'create',
|
2022-07-10 13:50:51 -07:00
|
|
|
action: 'Create a company',
|
2021-04-02 10:12:19 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Delete',
|
|
|
|
value: 'delete',
|
2022-07-10 13:50:51 -07:00
|
|
|
action: 'Delete a company',
|
2021-04-02 10:12:19 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Get',
|
|
|
|
value: 'get',
|
2022-07-10 13:50:51 -07:00
|
|
|
action: 'Get a company',
|
2021-04-02 10:12:19 -07:00
|
|
|
},
|
|
|
|
{
|
2022-09-07 07:51:14 -07:00
|
|
|
name: 'Get Many',
|
2021-04-02 10:12:19 -07:00
|
|
|
value: 'getAll',
|
2022-09-08 08:10:13 -07:00
|
|
|
action: 'Get many companies',
|
2021-04-02 10:12:19 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Update',
|
|
|
|
value: 'update',
|
2022-07-10 13:50:51 -07:00
|
|
|
action: 'Update a company',
|
2021-04-02 10:12:19 -07:00
|
|
|
},
|
|
|
|
],
|
|
|
|
default: 'create',
|
|
|
|
},
|
2021-12-03 00:44:16 -08:00
|
|
|
];
|
2021-04-02 10:12:19 -07:00
|
|
|
|
2021-12-03 00:44:16 -08:00
|
|
|
export const companyFields: INodeProperties[] = [
|
2021-04-02 10:12:19 -07:00
|
|
|
// ----------------------------------------
|
|
|
|
// company: create
|
|
|
|
// ----------------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Name',
|
|
|
|
name: 'name',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'Name of the company to create',
|
2021-04-02 10:12:19 -07:00
|
|
|
type: 'string',
|
|
|
|
required: true,
|
|
|
|
default: '',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-01 13:47:55 -07:00
|
|
|
resource: ['company'],
|
|
|
|
operation: ['create'],
|
2021-04-02 10:12:19 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Additional Fields',
|
|
|
|
name: 'additionalFields',
|
|
|
|
type: 'collection',
|
|
|
|
placeholder: 'Add Field',
|
|
|
|
default: {},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-01 13:47:55 -07:00
|
|
|
resource: ['company'],
|
|
|
|
operation: ['create'],
|
2021-04-02 10:12:19 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
addressFixedCollection,
|
|
|
|
{
|
|
|
|
displayName: 'Details',
|
|
|
|
name: 'details',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'Description of the company to create',
|
2021-04-02 10:12:19 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Email Domain',
|
|
|
|
name: 'email_domain',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
phoneNumbersFixedCollection,
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------------
|
|
|
|
// company: delete
|
|
|
|
// ----------------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Company ID',
|
|
|
|
name: 'companyId',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'ID of the company to delete',
|
2021-04-02 10:12:19 -07:00
|
|
|
type: 'string',
|
|
|
|
required: true,
|
|
|
|
default: '',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-01 13:47:55 -07:00
|
|
|
resource: ['company'],
|
|
|
|
operation: ['delete'],
|
2021-04-02 10:12:19 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------------
|
|
|
|
// company: get
|
|
|
|
// ----------------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Company ID',
|
|
|
|
name: 'companyId',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'ID of the company to retrieve',
|
2021-04-02 10:12:19 -07:00
|
|
|
type: 'string',
|
|
|
|
required: true,
|
|
|
|
default: '',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-01 13:47:55 -07:00
|
|
|
resource: ['company'],
|
|
|
|
operation: ['get'],
|
2021-04-02 10:12:19 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------------
|
|
|
|
// company: getAll
|
|
|
|
// ----------------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Return All',
|
|
|
|
name: 'returnAll',
|
|
|
|
type: 'boolean',
|
|
|
|
default: false,
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'Whether to return all results or only up to a given limit',
|
2021-04-02 10:12:19 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-01 13:47:55 -07:00
|
|
|
resource: ['company'],
|
|
|
|
operation: ['getAll'],
|
2021-04-02 10:12:19 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Limit',
|
|
|
|
name: 'limit',
|
|
|
|
type: 'number',
|
|
|
|
default: 5,
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'Max number of results to return',
|
2021-04-02 10:12:19 -07:00
|
|
|
typeOptions: {
|
|
|
|
minValue: 1,
|
|
|
|
maxValue: 1000,
|
|
|
|
},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-01 13:47:55 -07:00
|
|
|
resource: ['company'],
|
|
|
|
operation: ['getAll'],
|
|
|
|
returnAll: [false],
|
2021-04-02 10:12:19 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Filters',
|
|
|
|
name: 'filterFields',
|
|
|
|
type: 'collection',
|
|
|
|
placeholder: 'Add Filter',
|
|
|
|
default: {},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-01 13:47:55 -07:00
|
|
|
resource: ['company'],
|
|
|
|
operation: ['getAll'],
|
2021-04-02 10:12:19 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
displayName: 'Country',
|
|
|
|
name: 'country',
|
|
|
|
type: 'options',
|
|
|
|
options: isoCountryCodes.map(({ name, alpha2 }) => ({ name, value: alpha2 })),
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'Country of the company to filter by',
|
2021-04-02 10:12:19 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Name',
|
|
|
|
name: 'name',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'Name of the company to filter by',
|
2021-04-02 10:12:19 -07:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------------
|
|
|
|
// company: update
|
|
|
|
// ----------------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Company ID',
|
|
|
|
name: 'companyId',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'ID of the company to update',
|
2021-04-02 10:12:19 -07:00
|
|
|
type: 'string',
|
|
|
|
required: true,
|
|
|
|
default: '',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-01 13:47:55 -07:00
|
|
|
resource: ['company'],
|
|
|
|
operation: ['update'],
|
2021-04-02 10:12:19 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Update Fields',
|
|
|
|
name: 'updateFields',
|
|
|
|
type: 'collection',
|
|
|
|
placeholder: 'Add Field',
|
|
|
|
default: {},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-01 13:47:55 -07:00
|
|
|
resource: ['company'],
|
|
|
|
operation: ['update'],
|
2021-04-02 10:12:19 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
addressFixedCollection,
|
|
|
|
{
|
|
|
|
displayName: 'Details',
|
|
|
|
name: 'details',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'Description to set for the company',
|
2021-04-02 10:12:19 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Name',
|
|
|
|
name: 'name',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'Name to set for the company',
|
2021-04-02 10:12:19 -07:00
|
|
|
},
|
|
|
|
phoneNumbersFixedCollection,
|
|
|
|
],
|
|
|
|
},
|
2021-12-03 00:44:16 -08:00
|
|
|
];
|