2020-06-30 04:34:09 -07:00
import {
INodeProperties ,
} from 'n8n-workflow' ;
export const couponOperations = [
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
displayOptions : {
show : {
resource : [
'coupon' ,
] ,
} ,
} ,
options : [
{
name : 'Create' ,
value : 'create' ,
description : 'Create a coupon.' ,
} ,
{
name : 'Get All' ,
value : 'getAll' ,
description : 'Get all coupons.' ,
} ,
{
name : 'Update' ,
value : 'update' ,
description : 'Update a coupon.' ,
} ,
] ,
default : 'create' ,
description : 'The operation to perform.' ,
} ,
] as INodeProperties [ ] ;
export const couponFields = [
2020-09-01 08:00:52 -07:00
/* -------------------------------------------------------------------------- */
/* coupon:create */
/* -------------------------------------------------------------------------- */
2020-06-30 04:34:09 -07:00
{
displayName : 'Coupon Type' ,
name : 'couponType' ,
type : 'options' ,
displayOptions : {
show : {
resource : [
'coupon' ,
] ,
operation : [
` create `
2020-07-02 02:12:27 -07:00
] ,
jsonParameters : [
false
2020-06-30 04:34:09 -07:00
]
} ,
} ,
2020-06-30 08:38:55 -07:00
default : 'checkout' ,
2020-06-30 04:34:09 -07:00
description : 'Either product (valid for specified products or subscription plans) or checkout (valid for any checkout).' ,
options : [
{
name : 'Checkout' ,
value : 'checkout'
} ,
{
name : 'Product' ,
value : 'product'
} ,
]
} ,
{
2020-09-01 08:00:52 -07:00
displayName : 'Product IDs' ,
2020-06-30 04:34:09 -07:00
name : 'productIds' ,
2020-09-01 08:00:52 -07:00
type : 'multiOptions' ,
typeOptions : {
loadOptionsMethod : 'getProducts' ,
} ,
2020-06-30 04:34:09 -07:00
displayOptions : {
show : {
resource : [
'coupon' ,
] ,
operation : [
` create `
] ,
couponType : [
'product' ,
] ,
2020-07-02 02:12:27 -07:00
jsonParameters : [
false
]
2020-06-30 04:34:09 -07:00
} ,
} ,
default : '' ,
description : 'Comma-separated list of product IDs. Required if coupon_type is product.' ,
required : true ,
} ,
{
displayName : 'Discount Type' ,
name : 'discountType' ,
type : 'options' ,
displayOptions : {
show : {
resource : [
'coupon' ,
] ,
operation : [
` create `
] ,
2020-07-02 02:12:27 -07:00
jsonParameters : [
false
]
2020-06-30 04:34:09 -07:00
} ,
} ,
default : 'flat' ,
description : 'Either flat or percentage.' ,
options : [
{
name : 'Flat' ,
value : 'flat'
} ,
{
name : 'Percentage' ,
value : 'percentage'
} ,
]
} ,
{
displayName : 'Discount Amount Currency' ,
name : 'discountAmount' ,
type : 'number' ,
default : '' ,
description : 'Discount amount in currency.' ,
typeOptions : {
2020-07-02 02:12:27 -07:00
minValue : 1
2020-06-30 04:34:09 -07:00
} ,
displayOptions : {
show : {
resource : [
'coupon' ,
] ,
operation : [
` create `
] ,
discountType : [
'flat' ,
2020-07-02 02:12:27 -07:00
] ,
jsonParameters : [
false
2020-06-30 04:34:09 -07:00
]
} ,
} ,
} ,
{
displayName : 'Discount Amount %' ,
name : 'discountAmount' ,
type : 'number' ,
default : '' ,
description : 'Discount amount in percentage.' ,
typeOptions : {
2020-07-02 02:12:27 -07:00
minValue : 1 ,
2020-06-30 04:34:09 -07:00
maxValue : 100
} ,
displayOptions : {
show : {
resource : [
'coupon' ,
] ,
operation : [
` create `
] ,
discountType : [
'percentage' ,
2020-07-02 02:12:27 -07:00
] ,
jsonParameters : [
false
2020-06-30 04:34:09 -07:00
]
} ,
} ,
} ,
{
displayName : 'Currency' ,
name : 'currency' ,
type : 'options' ,
2020-07-02 02:12:27 -07:00
default : 'EUR' ,
2020-06-30 04:34:09 -07:00
description : 'The currency must match the balance currency specified in your account.' ,
options : [
2020-09-01 08:00:52 -07:00
{
name : 'ARS' ,
value : 'ARS'
} ,
{
name : 'AUD' ,
value : 'AUD'
} ,
{
name : 'BRL' ,
value : 'BRL'
} ,
{
name : 'CAD' ,
value : 'CAD'
} ,
{
name : 'CHF' ,
value : 'CHF'
} ,
{
name : 'CNY' ,
value : 'CNY'
} ,
{
name : 'CZK' ,
value : 'CZK'
} ,
{
name : 'DKK' ,
value : 'DKK'
} ,
2020-06-30 04:34:09 -07:00
{
name : 'EUR' ,
2020-07-02 02:12:27 -07:00
value : 'EUR'
2020-06-30 04:34:09 -07:00
} ,
{
name : 'GBP' ,
2020-07-02 02:12:27 -07:00
value : 'GBP'
2020-06-30 04:34:09 -07:00
} ,
2020-09-01 08:00:52 -07:00
{
name : 'HKD' ,
value : 'HKD'
} ,
{
name : 'HUF' ,
value : 'HUF'
} ,
{
name : 'INR' ,
value : 'INR'
} ,
{
name : 'JPY' ,
value : 'JPY'
} ,
{
name : 'KRW' ,
value : 'KRW'
} ,
{
name : 'MXN' ,
value : 'MXN'
} ,
{
name : 'NOK' ,
value : 'NOK'
} ,
{
name : 'NZD' ,
value : 'NZD'
} ,
{
name : 'PLN' ,
value : 'PLN'
} ,
{
name : 'RUB' ,
value : 'RUB'
} ,
{
name : 'SEK' ,
value : 'SEK'
} ,
{
name : 'SGD' ,
value : 'SGD'
} ,
{
name : 'THB' ,
value : 'THB'
} ,
{
name : 'TWD' ,
value : 'TWD'
} ,
2020-06-30 04:34:09 -07:00
{
name : 'USD' ,
2020-07-02 02:12:27 -07:00
value : 'USD'
2020-06-30 04:34:09 -07:00
} ,
2020-09-01 08:00:52 -07:00
{
name : 'ZAR' ,
value : 'ZAR'
} ,
2020-06-30 04:34:09 -07:00
] ,
displayOptions : {
show : {
resource : [
'coupon' ,
] ,
operation : [
` create `
] ,
discountType : [
'flat' ,
2020-07-02 02:12:27 -07:00
] ,
jsonParameters : [
false
2020-06-30 04:34:09 -07:00
]
} ,
} ,
} ,
2020-07-02 02:12:27 -07:00
{
displayName : 'JSON Parameters' ,
name : 'jsonParameters' ,
type : 'boolean' ,
default : false ,
description : '' ,
displayOptions : {
show : {
resource : [
'coupon' ,
] ,
operation : [
'create' ,
] ,
} ,
} ,
} ,
{
displayName : ' Additional Fields' ,
name : 'additionalFieldsJson' ,
type : 'json' ,
typeOptions : {
alwaysOpenEditWindow : true ,
} ,
default : '' ,
displayOptions : {
show : {
resource : [
'coupon' ,
] ,
operation : [
'create' ,
] ,
jsonParameters : [
true ,
] ,
} ,
} ,
description : ` Attributes in JSON form. ` ,
} ,
2020-06-30 04:34:09 -07:00
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
displayOptions : {
show : {
resource : [
'coupon' ,
] ,
operation : [
'create' ,
] ,
2020-07-02 02:12:27 -07:00
jsonParameters : [
false
]
2020-06-30 04:34:09 -07:00
} ,
} ,
default : { } ,
options : [
{
displayName : 'Allowed Uses' ,
name : 'allowedUses' ,
type : 'number' ,
default : 1 ,
description : 'Number of times a coupon can be used in a checkout. This will be set to 999,999 by default, if not specified.' ,
} ,
{
displayName : 'Coupon Code' ,
name : 'couponCode' ,
type : 'string' ,
default : '' ,
description : 'Will be randomly generated if not specified.' ,
} ,
{
displayName : 'Coupon Prefix' ,
name : 'couponPrefix' ,
type : 'string' ,
default : '' ,
description : 'Prefix for generated codes. Not valid if coupon_code is specified.' ,
} ,
2020-09-01 08:00:52 -07:00
{
displayName : 'Description' ,
name : 'description' ,
type : 'string' ,
default : '' ,
description : 'Description of the coupon. This will be displayed in the Seller Dashboard.' ,
} ,
2020-06-30 04:34:09 -07:00
{
displayName : 'Expires' ,
name : 'expires' ,
2020-07-02 02:12:27 -07:00
type : 'dateTime' ,
2020-06-30 04:34:09 -07:00
default : '' ,
description : 'The coupon will expire on the date at 00:00:00 UTC.' ,
} ,
{
displayName : 'Group' ,
name : 'group' ,
type : 'string' ,
typeOptions : {
minValue : 1 ,
maxValue : 50
} ,
default : '' ,
description : 'The name of the coupon group this coupon should be assigned to.' ,
} ,
{
displayName : 'Number of Coupons' ,
name : 'numberOfCoupons' ,
type : 'number' ,
default : 1 ,
description : 'Number of coupons to generate. Not valid if coupon_code is specified.' ,
} ,
{
2020-09-01 08:00:52 -07:00
displayName : 'Recurring' ,
name : 'recurring' ,
type : 'boolean' ,
default : false ,
description : 'If the coupon is used on subscription products, this indicates whether the discount should apply to recurring payments after the initial purchase.' ,
2020-06-30 04:34:09 -07:00
} ,
] ,
} ,
2020-09-01 08:00:52 -07:00
/* -------------------------------------------------------------------------- */
/* coupon:getAll */
/* -------------------------------------------------------------------------- */
2020-06-30 08:38:55 -07:00
{
displayName : 'Product ID' ,
name : 'productId' ,
2020-09-01 08:00:52 -07:00
type : 'string' ,
2020-06-30 08:38:55 -07:00
displayOptions : {
show : {
resource : [
'coupon' ,
] ,
operation : [
` getAll `
]
} ,
} ,
default : '' ,
2020-09-01 08:00:52 -07:00
required : true ,
2020-06-30 08:38:55 -07:00
description : 'The specific product/subscription ID.' ,
} ,
2020-09-01 08:00:52 -07:00
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
operation : [
'getAll' ,
] ,
resource : [
'coupon' ,
] ,
} ,
} ,
default : false ,
description : 'If all results should be returned or only up to a given limit.' ,
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
operation : [
'getAll' ,
] ,
resource : [
'coupon' ,
] ,
returnAll : [
false ,
] ,
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 500 ,
} ,
default : 100 ,
description : 'How many results to return.' ,
} ,
/* -------------------------------------------------------------------------- */
/* coupon:update */
/* -------------------------------------------------------------------------- */
2020-06-30 04:34:09 -07:00
{
displayName : 'Update by' ,
name : 'updateBy' ,
type : 'options' ,
displayOptions : {
show : {
resource : [
'coupon' ,
] ,
operation : [
` update `
] ,
2020-07-02 02:12:27 -07:00
jsonParameters : [
false ,
] ,
2020-06-30 04:34:09 -07:00
} ,
} ,
default : 'couponCode' ,
description : 'Either flat or percentage.' ,
options : [
{
name : 'Coupon Code' ,
value : 'couponCode'
} ,
{
name : 'Group' ,
value : 'group'
} ,
]
} ,
{
displayName : 'Coupon Code' ,
name : 'couponCode' ,
type : 'string' ,
displayOptions : {
show : {
resource : [
'coupon' ,
] ,
operation : [
'update'
] ,
updateBy : [
'couponCode'
2020-07-02 02:12:27 -07:00
] ,
jsonParameters : [
false ,
] ,
2020-06-30 04:34:09 -07:00
} ,
} ,
default : '' ,
description : 'Identify the coupon to update' ,
} ,
{
displayName : 'Group' ,
name : 'group' ,
type : 'string' ,
displayOptions : {
show : {
resource : [
'coupon' ,
] ,
operation : [
'update'
] ,
updateBy : [
'group'
2020-07-02 02:12:27 -07:00
] ,
jsonParameters : [
false ,
] ,
2020-06-30 04:34:09 -07:00
} ,
} ,
default : '' ,
description : 'The name of the group of coupons you want to update.' ,
} ,
2020-07-02 02:12:27 -07:00
{
displayName : 'JSON Parameters' ,
name : 'jsonParameters' ,
type : 'boolean' ,
default : false ,
description : '' ,
displayOptions : {
show : {
resource : [
'coupon' ,
] ,
operation : [
'update' ,
] ,
} ,
} ,
} ,
{
2020-09-01 08:00:52 -07:00
displayName : 'Additional Fields' ,
2020-07-02 02:12:27 -07:00
name : 'additionalFieldsJson' ,
type : 'json' ,
typeOptions : {
alwaysOpenEditWindow : true ,
} ,
default : '' ,
displayOptions : {
show : {
resource : [
'coupon' ,
] ,
operation : [
'update' ,
] ,
jsonParameters : [
true ,
] ,
} ,
} ,
description : ` Attributes in JSON form. ` ,
} ,
2020-06-30 04:34:09 -07:00
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
displayOptions : {
show : {
resource : [
'coupon' ,
] ,
operation : [
'update' ,
] ,
2020-07-02 02:12:27 -07:00
jsonParameters : [
false
]
2020-06-30 04:34:09 -07:00
} ,
} ,
default : { } ,
options : [
{
displayName : 'Allowed Uses' ,
name : 'allowedUses' ,
type : 'number' ,
default : 1 ,
description : 'Number of times a coupon can be used in a checkout. This will be set to 999,999 by default, if not specified.' ,
} ,
{
2020-09-01 08:00:52 -07:00
displayName : 'Discount' ,
name : 'discount' ,
type : 'fixedCollection' ,
default : 'discountProperties' ,
2020-06-30 04:34:09 -07:00
options : [
{
2020-09-01 08:00:52 -07:00
displayName : 'Discount Properties' ,
name : 'discountProperties' ,
values : [
{
displayName : 'Currency' ,
name : 'currency' ,
type : 'options' ,
default : 'EUR' ,
description : 'The currency must match the balance currency specified in your account.' ,
displayOptions : {
show : {
discountType : [
'flat' ,
] ,
} ,
} ,
options : [
{
name : 'ARS' ,
value : 'ARS'
} ,
{
name : 'AUD' ,
value : 'AUD'
} ,
{
name : 'BRL' ,
value : 'BRL'
} ,
{
name : 'CAD' ,
value : 'CAD'
} ,
{
name : 'CHF' ,
value : 'CHF'
} ,
{
name : 'CNY' ,
value : 'CNY'
} ,
{
name : 'CZK' ,
value : 'CZK'
} ,
{
name : 'DKK' ,
value : 'DKK'
} ,
{
name : 'EUR' ,
value : 'EUR'
} ,
{
name : 'GBP' ,
value : 'GBP'
} ,
{
name : 'HKD' ,
value : 'HKD'
} ,
{
name : 'HUF' ,
value : 'HUF'
} ,
{
name : 'INR' ,
value : 'INR'
} ,
{
name : 'JPY' ,
value : 'JPY'
} ,
{
name : 'KRW' ,
value : 'KRW'
} ,
{
name : 'MXN' ,
value : 'MXN'
} ,
{
name : 'NOK' ,
value : 'NOK'
} ,
{
name : 'NZD' ,
value : 'NZD'
} ,
{
name : 'PLN' ,
value : 'PLN'
} ,
{
name : 'RUB' ,
value : 'RUB'
} ,
{
name : 'SEK' ,
value : 'SEK'
} ,
{
name : 'SGD' ,
value : 'SGD'
} ,
{
name : 'THB' ,
value : 'THB'
} ,
{
name : 'TWD' ,
value : 'TWD'
} ,
{
name : 'USD' ,
value : 'USD'
} ,
{
name : 'ZAR' ,
value : 'ZAR'
} ,
] ,
} ,
{
displayName : 'Discount Amount Currency' ,
name : 'discountAmount' ,
type : 'number' ,
default : '' ,
description : 'Discount amount.' ,
displayOptions : {
show : {
discountType : [
'flat' ,
] ,
} ,
} ,
typeOptions : {
minValue : 0
} ,
} ,
{
displayName : 'Discount Amount Percentage' ,
name : 'discountAmount' ,
type : 'number' ,
default : '' ,
description : 'Discount amount.' ,
displayOptions : {
show : {
discountType : [
'percentage' ,
] ,
} ,
} ,
typeOptions : {
minValue : 0 ,
maxValue : 100
} ,
} ,
{
displayName : 'Discount Type' ,
name : 'discountType' ,
type : 'options' ,
default : 'flat' ,
description : 'Either flat or percentage.' ,
options : [
{
name : 'Flat' ,
value : 'flat'
} ,
{
name : 'Percentage' ,
value : 'percentage'
} ,
]
} ,
] ,
2020-06-30 04:34:09 -07:00
} ,
] ,
} ,
{
displayName : 'Expires' ,
name : 'expires' ,
2020-07-02 02:12:27 -07:00
type : 'dateTime' ,
2020-06-30 04:34:09 -07:00
default : '' ,
description : 'The coupon will expire on the date at 00:00:00 UTC.' ,
} ,
{
displayName : 'New Coupon Code' ,
name : 'newCouponCode' ,
type : 'string' ,
default : '' ,
description : 'New code to rename the coupon to.' ,
} ,
{
displayName : 'New Group Name' ,
name : 'newGroup' ,
type : 'string' ,
typeOptions : {
minValue : 1 ,
maxValue : 50
} ,
default : '' ,
description : 'New group name to move coupon to.' ,
} ,
{
2020-09-01 08:00:52 -07:00
displayName : 'Product IDs' ,
2020-06-30 04:34:09 -07:00
name : 'productIds' ,
type : 'string' ,
default : '' ,
2020-07-02 02:12:27 -07:00
description : 'Comma-separated list of products e.g. 499531,1234,123546. If blank then remove associated products.' ,
2020-06-30 04:34:09 -07:00
} ,
{
displayName : 'Recurring' ,
name : 'recurring' ,
type : 'boolean' ,
default : false ,
description : 'If the coupon is used on subscription products, this indicates whether the discount should apply to recurring payments after the initial purchase.' ,
} ,
] ,
} ,
] as INodeProperties [ ] ;