2023-01-27 03:22:44 -08:00
import type { INodeProperties } from 'n8n-workflow' ;
2021-10-28 17:00:25 -07:00
2022-08-17 08:50:24 -07:00
import { getAccountFields } from '../GenericFunctions' ;
2021-10-28 17:00:25 -07:00
2021-12-03 00:44:16 -08:00
export const accountOperations : INodeProperties [ ] = [
2021-10-28 17:00:25 -07:00
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2021-10-28 17:00:25 -07:00
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'account' ] ,
2021-10-28 17:00:25 -07:00
} ,
} ,
options : [
{
name : 'Create' ,
value : 'create' ,
2022-07-10 13:50:51 -07:00
action : 'Create an account' ,
2021-10-28 17:00:25 -07:00
} ,
{
name : 'Delete' ,
value : 'delete' ,
2022-07-10 13:50:51 -07:00
action : 'Delete an account' ,
2021-10-28 17:00:25 -07:00
} ,
{
name : 'Get' ,
value : 'get' ,
2022-07-10 13:50:51 -07:00
action : 'Get an account' ,
2021-10-28 17:00:25 -07:00
} ,
{
2022-09-07 07:51:14 -07:00
name : 'Get Many' ,
2021-10-28 17:00:25 -07:00
value : 'getAll' ,
2022-09-08 08:10:13 -07:00
action : 'Get many accounts' ,
2021-10-28 17:00:25 -07:00
} ,
{
name : 'Update' ,
value : 'update' ,
2022-07-10 13:50:51 -07:00
action : 'Update an account' ,
2021-10-28 17:00:25 -07:00
} ,
] ,
default : 'create' ,
} ,
2021-12-03 00:44:16 -08:00
] ;
2021-10-28 17:00:25 -07:00
2021-12-03 00:44:16 -08:00
export const accountFields : INodeProperties [ ] = [
2021-10-28 17:00:25 -07:00
// ----------------------------------------
// account:create
// ----------------------------------------
{
displayName : 'Name' ,
name : 'name' ,
description : 'Company or business name' ,
type : 'string' ,
required : true ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'account' ] ,
operation : [ 'create' ] ,
2021-10-28 17:00:25 -07:00
} ,
} ,
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'account' ] ,
operation : [ 'create' ] ,
2021-10-28 17:00:25 -07:00
} ,
} ,
2022-08-17 08:50:24 -07:00
options : [ . . . getAccountFields ( ) ] ,
2021-10-28 17:00:25 -07:00
} ,
// ----------------------------------------
// account:get
// ----------------------------------------
{
displayName : 'Account ID' ,
name : 'accountId' ,
type : 'string' ,
required : true ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'account' ] ,
operation : [ 'delete' , 'get' , 'update' ] ,
2021-10-28 17:00:25 -07:00
} ,
} ,
} ,
// ----------------------------------------
// account:getAll
// ----------------------------------------
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'account' ] ,
operation : [ 'getAll' ] ,
2021-10-28 17:00:25 -07:00
} ,
} ,
default : false ,
2022-05-06 14:01:25 -07:00
description : 'Whether to return all results or only up to a given limit' ,
2021-10-28 17:00:25 -07:00
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'account' ] ,
operation : [ 'getAll' ] ,
returnAll : [ false ] ,
2021-10-28 17:00:25 -07:00
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 10 ,
} ,
default : 5 ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2021-10-28 17:00:25 -07:00
} ,
{
displayName : 'Options' ,
name : 'options' ,
type : 'collection' ,
2024-07-29 05:27:23 -07:00
placeholder : 'Add option' ,
2021-10-28 17:00:25 -07:00
default : { } ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'account' ] ,
operation : [ 'get' , 'getAll' ] ,
2021-10-28 17:00:25 -07:00
} ,
} ,
options : [
{
2022-06-20 07:54:01 -07:00
displayName : 'Return Field Names or IDs' ,
2021-10-28 17:00:25 -07:00
name : 'returnFields' ,
type : 'multiOptions' ,
2022-08-17 08:50:24 -07:00
description :
2024-09-12 07:53:36 -07:00
'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>' ,
2021-10-28 17:00:25 -07:00
typeOptions : {
loadOptionsMethod : 'getAccountFields' ,
} ,
2022-04-22 09:29:51 -07:00
default : [ ] ,
2021-10-28 17:00:25 -07:00
} ,
{
2022-06-20 07:54:01 -07:00
displayName : 'Expand Field Names or IDs' ,
2021-10-28 17:00:25 -07:00
name : 'expandFields' ,
type : 'multiOptions' ,
2022-08-17 08:50:24 -07:00
description :
2024-09-12 07:53:36 -07:00
'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>' ,
2021-10-28 17:00:25 -07:00
typeOptions : {
loadOptionsMethod : 'getExpandableAccountFields' ,
} ,
2022-04-22 09:29:51 -07:00
default : [ ] ,
2021-10-28 17:00:25 -07:00
} ,
] ,
} ,
{
displayName : 'Filters' ,
name : 'filters' ,
type : 'collection' ,
placeholder : 'Add Filter' ,
default : { } ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'account' ] ,
operation : [ 'getAll' ] ,
2021-10-28 17:00:25 -07:00
} ,
} ,
options : [
{
displayName : 'Query' ,
name : 'query' ,
type : 'string' ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
'Query to filter the results. Check <a href="https://docs.microsoft.com/en-us/powerapps/developer/data-platform/webapi/query-data-web-api#filter-results" target="_blank">filters</a>.' ,
2021-10-28 17:00:25 -07:00
} ,
] ,
} ,
// ----------------------------------------
// account:update
// ----------------------------------------
{
displayName : 'Update Fields' ,
name : 'updateFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'account' ] ,
operation : [ 'update' ] ,
2021-10-28 17:00:25 -07:00
} ,
} ,
2022-08-17 08:50:24 -07:00
options : [ . . . getAccountFields ( ) ] ,
2021-10-28 17:00:25 -07:00
} ,
{
displayName : 'Options' ,
name : 'options' ,
type : 'collection' ,
2024-07-29 05:27:23 -07:00
placeholder : 'Add option' ,
2021-10-28 17:00:25 -07:00
default : { } ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'account' ] ,
operation : [ 'create' , 'update' ] ,
2021-10-28 17:00:25 -07:00
} ,
} ,
options : [
{
2022-06-20 07:54:01 -07:00
displayName : 'Return Field Names or IDs' ,
2021-10-28 17:00:25 -07:00
name : 'returnFields' ,
type : 'multiOptions' ,
typeOptions : {
loadOptionsMethod : 'getAccountFields' ,
} ,
2022-04-22 09:29:51 -07:00
default : [ ] ,
2022-08-17 08:50:24 -07:00
description :
2024-09-12 07:53:36 -07:00
'Fields the response will include. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.' ,
2021-10-28 17:00:25 -07:00
} ,
] ,
} ,
2021-12-03 00:44:16 -08:00
] ;