Minor improvements to Paddle-Node

This commit is contained in:
Jan Oberhauser 2020-08-25 10:51:16 +02:00
parent 72102faed5
commit 5def03855b
7 changed files with 106 additions and 114 deletions

View file

@ -37,9 +37,9 @@ export const couponOperations = [
] as INodeProperties[]; ] as INodeProperties[];
export const couponFields = [ export const couponFields = [
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* coupon:create */ /* coupon:create */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Coupon Type', displayName: 'Coupon Type',
name: 'couponType', name: 'couponType',
@ -199,14 +199,14 @@ export const couponFields = [
name: 'BRL', name: 'BRL',
value: 'BRL' value: 'BRL'
}, },
{
name: 'GBP',
value: 'GBP'
},
{ {
name: 'CAD', name: 'CAD',
value: 'CAD' value: 'CAD'
}, },
{
name: 'CHF',
value: 'CHF'
},
{ {
name: 'CNY', name: 'CNY',
value: 'CNY' value: 'CNY'
@ -223,6 +223,10 @@ export const couponFields = [
name: 'EUR', name: 'EUR',
value: 'EUR' value: 'EUR'
}, },
{
name: 'GBP',
value: 'GBP'
},
{ {
name: 'HKD', name: 'HKD',
value: 'HKD' value: 'HKD'
@ -239,22 +243,22 @@ export const couponFields = [
name: 'JPY', name: 'JPY',
value: 'JPY' value: 'JPY'
}, },
{
name: 'KRW',
value: 'KRW'
},
{ {
name: 'MXN', name: 'MXN',
value: 'MXN' value: 'MXN'
}, },
{ {
name: 'TWD', name: 'NOK',
value: 'TWD' value: 'NOK'
}, },
{ {
name: 'NZD', name: 'NZD',
value: 'NZD' value: 'NZD'
}, },
{
name: 'NOK',
value: 'NOK'
},
{ {
name: 'PLN', name: 'PLN',
value: 'PLN' value: 'PLN'
@ -263,38 +267,30 @@ export const couponFields = [
name: 'RUB', name: 'RUB',
value: 'RUB' value: 'RUB'
}, },
{
name: 'SGD',
value: 'SGD'
},
{
name: 'ZAR',
value: 'ZAR'
},
{
name: 'KRW',
value: 'KRW'
},
{ {
name: 'SEK', name: 'SEK',
value: 'SEK' value: 'SEK'
}, },
{ {
name: 'CHF', name: 'SGD',
value: 'CHF' value: 'SGD'
}, },
{ {
name: 'THB', name: 'THB',
value: 'THB' value: 'THB'
}, },
{ {
name: 'CHF', name: 'TWD',
value: 'CHF' value: 'TWD'
}, },
{ {
name: 'USD', name: 'USD',
value: 'USD' value: 'USD'
}, },
{
name: 'ZAR',
value: 'ZAR'
},
], ],
displayOptions: { displayOptions: {
show: { show: {
@ -394,6 +390,13 @@ export const couponFields = [
default: '', default: '',
description: 'Prefix for generated codes. Not valid if coupon_code is specified.', description: 'Prefix for generated codes. Not valid if coupon_code is specified.',
}, },
{
displayName: 'Description',
name: 'description',
type: 'string',
default: '',
description: 'Description of the coupon. This will be displayed in the Seller Dashboard.',
},
{ {
displayName: 'Expires', displayName: 'Expires',
name: 'expires', name: 'expires',
@ -412,13 +415,6 @@ export const couponFields = [
default: '', default: '',
description: 'The name of the coupon group this coupon should be assigned to.', description: 'The name of the coupon group this coupon should be assigned to.',
}, },
{
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.',
},
{ {
displayName: 'Number of Coupons', displayName: 'Number of Coupons',
name: 'numberOfCoupons', name: 'numberOfCoupons',
@ -427,17 +423,17 @@ export const couponFields = [
description: 'Number of coupons to generate. Not valid if coupon_code is specified.', description: 'Number of coupons to generate. Not valid if coupon_code is specified.',
}, },
{ {
displayName: 'Description', displayName: 'Recurring',
name: 'description', name: 'recurring',
type: 'string', type: 'boolean',
default: '', default: false,
description: 'Description of the coupon. This will be displayed in the Seller Dashboard.', description: 'If the coupon is used on subscription products, this indicates whether the discount should apply to recurring payments after the initial purchase.',
}, },
], ],
}, },
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* coupon:getAll */ /* coupon:getAll */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Product ID', displayName: 'Product ID',
name: 'productId', name: 'productId',
@ -497,9 +493,9 @@ export const couponFields = [
default: 100, default: 100,
description: 'How many results to return.', description: 'How many results to return.',
}, },
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* coupon:update */ /* coupon:update */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Update by', displayName: 'Update by',
name: 'updateBy', name: 'updateBy',
@ -594,7 +590,7 @@ export const couponFields = [
}, },
}, },
{ {
displayName: ' Additional Fields', displayName: 'Additional Fields',
name: 'additionalFieldsJson', name: 'additionalFieldsJson',
type: 'json', type: 'json',
typeOptions: { typeOptions: {
@ -679,14 +675,14 @@ export const couponFields = [
name: 'BRL', name: 'BRL',
value: 'BRL' value: 'BRL'
}, },
{
name: 'GBP',
value: 'GBP'
},
{ {
name: 'CAD', name: 'CAD',
value: 'CAD' value: 'CAD'
}, },
{
name: 'CHF',
value: 'CHF'
},
{ {
name: 'CNY', name: 'CNY',
value: 'CNY' value: 'CNY'
@ -703,6 +699,10 @@ export const couponFields = [
name: 'EUR', name: 'EUR',
value: 'EUR' value: 'EUR'
}, },
{
name: 'GBP',
value: 'GBP'
},
{ {
name: 'HKD', name: 'HKD',
value: 'HKD' value: 'HKD'
@ -719,22 +719,22 @@ export const couponFields = [
name: 'JPY', name: 'JPY',
value: 'JPY' value: 'JPY'
}, },
{
name: 'KRW',
value: 'KRW'
},
{ {
name: 'MXN', name: 'MXN',
value: 'MXN' value: 'MXN'
}, },
{ {
name: 'TWD', name: 'NOK',
value: 'TWD' value: 'NOK'
}, },
{ {
name: 'NZD', name: 'NZD',
value: 'NZD' value: 'NZD'
}, },
{
name: 'NOK',
value: 'NOK'
},
{ {
name: 'PLN', name: 'PLN',
value: 'PLN' value: 'PLN'
@ -743,57 +743,32 @@ export const couponFields = [
name: 'RUB', name: 'RUB',
value: 'RUB' value: 'RUB'
}, },
{
name: 'SGD',
value: 'SGD'
},
{
name: 'ZAR',
value: 'ZAR'
},
{
name: 'KRW',
value: 'KRW'
},
{ {
name: 'SEK', name: 'SEK',
value: 'SEK' value: 'SEK'
}, },
{ {
name: 'CHF', name: 'SGD',
value: 'CHF' value: 'SGD'
}, },
{ {
name: 'THB', name: 'THB',
value: 'THB' value: 'THB'
}, },
{ {
name: 'CHF', name: 'TWD',
value: 'CHF' value: 'TWD'
}, },
{ {
name: 'USD', name: 'USD',
value: 'USD' value: 'USD'
}, },
{
name: 'ZAR',
value: 'ZAR'
},
], ],
}, },
{
displayName: 'Discount Type',
name: 'discountType',
type: 'options',
default: 'flat',
description: 'Either flat or percentage.',
options: [
{
name: 'Flat',
value: 'flat'
},
{
name: 'Percentage',
value: 'percentage'
},
]
},
{ {
displayName: 'Discount Amount Currency', displayName: 'Discount Amount Currency',
name: 'discountAmount', name: 'discountAmount',
@ -829,6 +804,23 @@ export const couponFields = [
maxValue: 100 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'
},
]
},
], ],
}, },
], ],

View file

@ -21,12 +21,12 @@ export async function paddleApiRequest(this: IHookFunctions | IExecuteFunctions
throw new Error('Could not retrieve credentials!'); throw new Error('Could not retrieve credentials!');
} }
const options : OptionsWithUri = { const options: OptionsWithUri = {
method, method,
headers: { headers: {
'content-type': 'application/json' 'content-type': 'application/json'
}, },
uri: `https://vendors.paddle.com/api${endpoint}` , uri: `https://vendors.paddle.com/api${endpoint}`,
body, body,
json: true json: true
}; };

View file

@ -28,9 +28,9 @@ export const orderOperations = [
export const orderFields = [ export const orderFields = [
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* order:get */ /* order:get */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Checkout ID', displayName: 'Checkout ID',
name: 'checkoutId', name: 'checkoutId',

View file

@ -4,11 +4,11 @@ import {
import { import {
IDataObject, IDataObject,
ILoadOptionsFunctions,
INodeExecutionData, INodeExecutionData,
INodePropertyOptions,
INodeType, INodeType,
INodeTypeDescription, INodeTypeDescription,
ILoadOptionsFunctions,
INodePropertyOptions
} from 'n8n-workflow'; } from 'n8n-workflow';
import { import {
@ -163,7 +163,7 @@ export class Paddle implements INodeType {
const products = await paddleApiRequest.call(this, endpoint, 'POST', {}); const products = await paddleApiRequest.call(this, endpoint, 'POST', {});
// Alert user if there's no products present to be loaded into payments property // Alert user if there's no products present to be loaded into payments property
if ( products.length === 0) { if (products.length === 0) {
throw Error('No products on account.'); throw Error('No products on account.');
} }

View file

@ -32,9 +32,9 @@ export const paymentOperations = [
] as INodeProperties[]; ] as INodeProperties[];
export const paymentFields = [ export const paymentFields = [
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* payment:getAll */ /* payment:getAll */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Return All', displayName: 'Return All',
name: 'returnAll', name: 'returnAll',
@ -94,7 +94,7 @@ export const paymentFields = [
}, },
}, },
{ {
displayName: ' Additional Fields', displayName: 'Additional Fields',
name: 'additionalFieldsJson', name: 'additionalFieldsJson',
type: 'json', type: 'json',
typeOptions: { typeOptions: {
@ -204,9 +204,9 @@ export const paymentFields = [
}, },
], ],
}, },
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* payment:reschedule */ /* payment:reschedule */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Payment ID', displayName: 'Payment ID',
name: 'paymentId', name: 'paymentId',

View file

@ -33,9 +33,9 @@ export const planOperations = [
export const planFields = [ export const planFields = [
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* plan:get */ /* plan:get */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Plan ID', displayName: 'Plan ID',
name: 'planId', name: 'planId',

View file

@ -27,9 +27,9 @@ export const userOperations = [
] as INodeProperties[]; ] as INodeProperties[];
export const userFields = [ export const userFields = [
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* user:getAll */ /* user:getAll */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Return All', displayName: 'Return All',
name: 'returnAll', name: 'returnAll',
@ -51,7 +51,7 @@ export const userFields = [
displayName: 'Limit', displayName: 'Limit',
name: 'limit', name: 'limit',
type: 'number', type: 'number',
default: 1, default: 100,
required: true, required: true,
typeOptions: { typeOptions: {
minValue: 1, minValue: 1,
@ -90,7 +90,7 @@ export const userFields = [
}, },
}, },
{ {
displayName: ' Additional Fields', displayName: 'Additional Fields',
name: 'additionalFieldsJson', name: 'additionalFieldsJson',
type: 'json', type: 'json',
typeOptions: { typeOptions: {