2022-08-17 08:50:24 -07:00
|
|
|
import { INodeProperties } from 'n8n-workflow';
|
2021-07-02 14:34:12 -07:00
|
|
|
|
|
|
|
import {
|
|
|
|
address,
|
|
|
|
currencies,
|
|
|
|
makeCustomFieldsFixedCollection,
|
|
|
|
makeGetAllFields,
|
|
|
|
} from './SharedFields';
|
|
|
|
|
2021-12-03 00:44:16 -08:00
|
|
|
export const vendorOperations: INodeProperties[] = [
|
2021-07-02 14:34:12 -07:00
|
|
|
{
|
|
|
|
displayName: 'Operation',
|
|
|
|
name: 'operation',
|
|
|
|
type: 'options',
|
2022-05-20 14:47:24 -07:00
|
|
|
noDataExpression: true,
|
2021-07-02 14:34:12 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
resource: ['vendor'],
|
2021-07-02 14:34:12 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'Create',
|
|
|
|
value: 'create',
|
|
|
|
description: 'Create a vendor',
|
2022-07-10 13:50:51 -07:00
|
|
|
action: 'Create a vendor',
|
2021-07-02 14:34:12 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Create or Update',
|
|
|
|
value: 'upsert',
|
|
|
|
description: 'Create a new record, or update the current one if it already exists (upsert)',
|
2022-07-10 13:50:51 -07:00
|
|
|
action: 'Create or update a vendor',
|
2021-07-02 14:34:12 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Delete',
|
|
|
|
value: 'delete',
|
|
|
|
description: 'Delete a vendor',
|
2022-07-10 13:50:51 -07:00
|
|
|
action: 'Delete a vendor',
|
2021-07-02 14:34:12 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Get',
|
|
|
|
value: 'get',
|
|
|
|
description: 'Get a vendor',
|
2022-07-10 13:50:51 -07:00
|
|
|
action: 'Get a vendor',
|
2021-07-02 14:34:12 -07:00
|
|
|
},
|
|
|
|
{
|
2022-09-07 07:51:14 -07:00
|
|
|
name: 'Get Many',
|
2021-07-02 14:34:12 -07:00
|
|
|
value: 'getAll',
|
|
|
|
description: 'Get all vendors',
|
2022-09-08 08:10:13 -07:00
|
|
|
action: 'Get many vendors',
|
2021-07-02 14:34:12 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Update',
|
|
|
|
value: 'update',
|
|
|
|
description: 'Update a vendor',
|
2022-07-10 13:50:51 -07:00
|
|
|
action: 'Update a vendor',
|
2021-07-02 14:34:12 -07:00
|
|
|
},
|
|
|
|
],
|
|
|
|
default: 'create',
|
|
|
|
},
|
2021-12-03 00:44:16 -08:00
|
|
|
];
|
2021-07-02 14:34:12 -07:00
|
|
|
|
2021-12-03 00:44:16 -08:00
|
|
|
export const vendorFields: INodeProperties[] = [
|
2021-07-02 14:34:12 -07:00
|
|
|
// ----------------------------------------
|
|
|
|
// vendor: create
|
|
|
|
// ----------------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Vendor Name',
|
|
|
|
name: 'vendorName',
|
|
|
|
type: 'string',
|
|
|
|
required: true,
|
|
|
|
default: '',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
resource: ['vendor'],
|
|
|
|
operation: ['create'],
|
2021-07-02 14:34:12 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------------
|
|
|
|
// vendor: upsert
|
|
|
|
// ----------------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Vendor Name',
|
|
|
|
name: 'vendorName',
|
2022-08-17 08:50:24 -07:00
|
|
|
description:
|
|
|
|
'Name of the vendor. If a record with this vendor name exists it will be updated, otherwise a new one will be created.',
|
2021-07-02 14:34:12 -07:00
|
|
|
type: 'string',
|
|
|
|
required: true,
|
|
|
|
default: '',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
resource: ['vendor'],
|
|
|
|
operation: ['upsert'],
|
2021-07-02 14:34:12 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------------
|
|
|
|
// vendor: create + upsert
|
|
|
|
// ----------------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Additional Fields',
|
|
|
|
name: 'additionalFields',
|
|
|
|
type: 'collection',
|
|
|
|
placeholder: 'Add Field',
|
|
|
|
default: {},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
resource: ['vendor'],
|
|
|
|
operation: ['create', 'upsert'],
|
2021-07-02 14:34:12 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
address,
|
|
|
|
{
|
|
|
|
displayName: 'Category',
|
|
|
|
name: 'Category',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Currency',
|
|
|
|
name: 'Currency',
|
|
|
|
type: 'options',
|
|
|
|
default: 'USD',
|
|
|
|
options: currencies,
|
|
|
|
},
|
|
|
|
makeCustomFieldsFixedCollection('vendor'),
|
|
|
|
{
|
|
|
|
displayName: 'Description',
|
|
|
|
name: 'Description',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Email',
|
|
|
|
name: 'Email',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Phone',
|
|
|
|
name: 'Phone',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Website',
|
|
|
|
name: 'Website',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------------
|
|
|
|
// vendor: delete
|
|
|
|
// ----------------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Vendor ID',
|
|
|
|
name: 'vendorId',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'ID of the vendor to delete',
|
2021-07-02 14:34:12 -07:00
|
|
|
type: 'string',
|
|
|
|
required: true,
|
|
|
|
default: '',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
resource: ['vendor'],
|
|
|
|
operation: ['delete'],
|
2021-07-02 14:34:12 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------------
|
|
|
|
// vendor: get
|
|
|
|
// ----------------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Vendor ID',
|
|
|
|
name: 'vendorId',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'ID of the vendor to retrieve',
|
2021-07-02 14:34:12 -07:00
|
|
|
type: 'string',
|
|
|
|
required: true,
|
|
|
|
default: '',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
resource: ['vendor'],
|
|
|
|
operation: ['get'],
|
2021-07-02 14:34:12 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------------
|
|
|
|
// vendor: getAll
|
|
|
|
// ----------------------------------------
|
|
|
|
...makeGetAllFields('vendor'),
|
|
|
|
|
|
|
|
// ----------------------------------------
|
|
|
|
// vendor: update
|
|
|
|
// ----------------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Vendor ID',
|
|
|
|
name: 'vendorId',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'ID of the vendor to update',
|
2021-07-02 14:34:12 -07:00
|
|
|
type: 'string',
|
|
|
|
required: true,
|
|
|
|
default: '',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
resource: ['vendor'],
|
|
|
|
operation: ['update'],
|
2021-07-02 14:34:12 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Update Fields',
|
|
|
|
name: 'updateFields',
|
|
|
|
type: 'collection',
|
|
|
|
placeholder: 'Add Field',
|
|
|
|
default: {},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
resource: ['vendor'],
|
|
|
|
operation: ['update'],
|
2021-07-02 14:34:12 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
address,
|
|
|
|
{
|
|
|
|
displayName: 'Category',
|
|
|
|
name: 'Category',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Currency',
|
|
|
|
name: 'Currency',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
makeCustomFieldsFixedCollection('vendor'),
|
|
|
|
{
|
|
|
|
displayName: 'Description',
|
|
|
|
name: 'Description',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Email',
|
|
|
|
name: 'Email',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Phone',
|
|
|
|
name: 'Phone',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Vendor Name',
|
|
|
|
name: 'Vendor_Name',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Website',
|
|
|
|
name: 'Website',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2021-12-03 00:44:16 -08:00
|
|
|
];
|