2022-08-17 08:50:24 -07:00
import { INodeProperties } from 'n8n-workflow' ;
2021-07-10 04:15:14 -07:00
2021-12-03 00:44:16 -08:00
export const couponOperations : INodeProperties [ ] = [
2021-07-10 04:15:14 -07:00
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2021-07-10 04:15:14 -07:00
default : 'create' ,
options : [
{
name : 'Create' ,
value : 'create' ,
description : 'Create a coupon' ,
2022-07-10 13:50:51 -07:00
action : 'Create a coupon' ,
2021-07-10 04:15:14 -07:00
} ,
{
name : 'Get All' ,
value : 'getAll' ,
description : 'Get all coupons' ,
2022-07-10 13:50:51 -07:00
action : 'Get all coupons' ,
2021-07-10 04:15:14 -07:00
} ,
] ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'coupon' ] ,
2021-07-10 04:15:14 -07:00
} ,
} ,
} ,
2021-12-03 00:44:16 -08:00
] ;
2021-07-10 04:15:14 -07:00
2021-12-03 00:44:16 -08:00
export const couponFields : INodeProperties [ ] = [
2021-07-10 04:15:14 -07:00
// ----------------------------------
// coupon: create
// ----------------------------------
{
displayName : 'Apply' ,
name : 'duration' ,
type : 'options' ,
required : true ,
default : 'once' ,
description : 'How long the discount will be in effect' ,
options : [
{
name : 'Forever' ,
value : 'forever' ,
} ,
{
name : 'Once' ,
value : 'once' ,
} ,
] ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'coupon' ] ,
operation : [ 'create' ] ,
2021-07-10 04:15:14 -07:00
} ,
} ,
} ,
{
displayName : 'Discount Type' ,
name : 'type' ,
type : 'options' ,
required : true ,
default : 'percent' ,
description : 'Whether the coupon discount is a percentage or a fixed amount' ,
options : [
{
name : 'Fixed Amount (in Cents)' ,
value : 'fixedAmount' ,
} ,
{
name : 'Percent' ,
value : 'percent' ,
} ,
] ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'coupon' ] ,
operation : [ 'create' ] ,
2021-07-10 04:15:14 -07:00
} ,
} ,
} ,
{
displayName : 'Amount Off' ,
name : 'amountOff' ,
type : 'number' ,
required : true ,
default : 0 ,
2022-08-17 08:50:24 -07:00
description :
'Amount in cents to subtract from an invoice total, e.g. enter <code>100</code> for $1.00' ,
2021-07-10 04:15:14 -07:00
typeOptions : {
minValue : 0 ,
maxValue : 99999999 ,
} ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'coupon' ] ,
operation : [ 'create' ] ,
type : [ 'fixedAmount' ] ,
2021-07-10 04:15:14 -07:00
} ,
} ,
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'Currency Name or ID' ,
2021-07-10 04:15:14 -07:00
name : 'currency' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getCurrencies' ,
} ,
required : true ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
'Three-letter ISO currency code, e.g. <code>USD</code> or <code>EUR</code>. It must be a <a href="https://stripe.com/docs/currencies">Stripe-supported currency</a>. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2021-07-10 04:15:14 -07:00
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'coupon' ] ,
operation : [ 'create' ] ,
type : [ 'fixedAmount' ] ,
2021-07-10 04:15:14 -07:00
} ,
} ,
} ,
{
displayName : 'Percent Off' ,
name : 'percentOff' ,
type : 'number' ,
required : true ,
default : 1 ,
description : 'Percentage to apply with the coupon' ,
typeOptions : {
minValue : 1 ,
maxValue : 100 ,
} ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'coupon' ] ,
operation : [ 'create' ] ,
type : [ 'percent' ] ,
2021-07-10 04:15:14 -07:00
} ,
} ,
} ,
// ----------------------------------
// coupon: getAll
// ----------------------------------
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
default : false ,
description : 'Whether to return all results or only up to a given limit' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'coupon' ] ,
operation : [ 'getAll' ] ,
2021-07-10 04:15:14 -07:00
} ,
} ,
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
default : 50 ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2021-07-10 04:15:14 -07:00
typeOptions : {
minValue : 1 ,
maxValue : 1000 ,
} ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'coupon' ] ,
operation : [ 'getAll' ] ,
returnAll : [ false ] ,
2021-07-10 04:15:14 -07:00
} ,
} ,
} ,
2021-12-03 00:44:16 -08:00
] ;