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[];
export const couponFields = [
/* -------------------------------------------------------------------------- */
/* coupon:create */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* coupon:create */
/* -------------------------------------------------------------------------- */
{
displayName: 'Coupon Type',
name: 'couponType',
@ -199,14 +199,14 @@ export const couponFields = [
name: 'BRL',
value: 'BRL'
},
{
name: 'GBP',
value: 'GBP'
},
{
name: 'CAD',
value: 'CAD'
},
{
name: 'CHF',
value: 'CHF'
},
{
name: 'CNY',
value: 'CNY'
@ -223,6 +223,10 @@ export const couponFields = [
name: 'EUR',
value: 'EUR'
},
{
name: 'GBP',
value: 'GBP'
},
{
name: 'HKD',
value: 'HKD'
@ -239,22 +243,22 @@ export const couponFields = [
name: 'JPY',
value: 'JPY'
},
{
name: 'KRW',
value: 'KRW'
},
{
name: 'MXN',
value: 'MXN'
},
{
name: 'TWD',
value: 'TWD'
name: 'NOK',
value: 'NOK'
},
{
name: 'NZD',
value: 'NZD'
},
{
name: 'NOK',
value: 'NOK'
},
{
name: 'PLN',
value: 'PLN'
@ -263,38 +267,30 @@ export const couponFields = [
name: 'RUB',
value: 'RUB'
},
{
name: 'SGD',
value: 'SGD'
},
{
name: 'ZAR',
value: 'ZAR'
},
{
name: 'KRW',
value: 'KRW'
},
{
name: 'SEK',
value: 'SEK'
},
{
name: 'CHF',
value: 'CHF'
name: 'SGD',
value: 'SGD'
},
{
name: 'THB',
value: 'THB'
},
{
name: 'CHF',
value: 'CHF'
name: 'TWD',
value: 'TWD'
},
{
name: 'USD',
value: 'USD'
},
{
name: 'ZAR',
value: 'ZAR'
},
],
displayOptions: {
show: {
@ -394,6 +390,13 @@ export const couponFields = [
default: '',
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',
name: 'expires',
@ -412,13 +415,6 @@ export const couponFields = [
default: '',
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',
name: 'numberOfCoupons',
@ -427,17 +423,17 @@ export const couponFields = [
description: 'Number of coupons to generate. 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: '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.',
},
],
},
/* -------------------------------------------------------------------------- */
/* coupon:getAll */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* coupon:getAll */
/* -------------------------------------------------------------------------- */
{
displayName: 'Product ID',
name: 'productId',
@ -497,9 +493,9 @@ export const couponFields = [
default: 100,
description: 'How many results to return.',
},
/* -------------------------------------------------------------------------- */
/* coupon:update */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* coupon:update */
/* -------------------------------------------------------------------------- */
{
displayName: 'Update by',
name: 'updateBy',
@ -594,7 +590,7 @@ export const couponFields = [
},
},
{
displayName: ' Additional Fields',
displayName: 'Additional Fields',
name: 'additionalFieldsJson',
type: 'json',
typeOptions: {
@ -679,14 +675,14 @@ export const couponFields = [
name: 'BRL',
value: 'BRL'
},
{
name: 'GBP',
value: 'GBP'
},
{
name: 'CAD',
value: 'CAD'
},
{
name: 'CHF',
value: 'CHF'
},
{
name: 'CNY',
value: 'CNY'
@ -703,6 +699,10 @@ export const couponFields = [
name: 'EUR',
value: 'EUR'
},
{
name: 'GBP',
value: 'GBP'
},
{
name: 'HKD',
value: 'HKD'
@ -719,22 +719,22 @@ export const couponFields = [
name: 'JPY',
value: 'JPY'
},
{
name: 'KRW',
value: 'KRW'
},
{
name: 'MXN',
value: 'MXN'
},
{
name: 'TWD',
value: 'TWD'
name: 'NOK',
value: 'NOK'
},
{
name: 'NZD',
value: 'NZD'
},
{
name: 'NOK',
value: 'NOK'
},
{
name: 'PLN',
value: 'PLN'
@ -743,57 +743,32 @@ export const couponFields = [
name: 'RUB',
value: 'RUB'
},
{
name: 'SGD',
value: 'SGD'
},
{
name: 'ZAR',
value: 'ZAR'
},
{
name: 'KRW',
value: 'KRW'
},
{
name: 'SEK',
value: 'SEK'
},
{
name: 'CHF',
value: 'CHF'
name: 'SGD',
value: 'SGD'
},
{
name: 'THB',
value: 'THB'
},
{
name: 'CHF',
value: 'CHF'
name: 'TWD',
value: 'TWD'
},
{
name: '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',
name: 'discountAmount',
@ -829,6 +804,23 @@ export const couponFields = [
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!');
}
const options : OptionsWithUri = {
const options: OptionsWithUri = {
method,
headers: {
'content-type': 'application/json'
},
uri: `https://vendors.paddle.com/api${endpoint}` ,
uri: `https://vendors.paddle.com/api${endpoint}`,
body,
json: true
};

View file

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

View file

@ -4,11 +4,11 @@ import {
import {
IDataObject,
ILoadOptionsFunctions,
INodeExecutionData,
INodePropertyOptions,
INodeType,
INodeTypeDescription,
ILoadOptionsFunctions,
INodePropertyOptions
} from 'n8n-workflow';
import {
@ -163,7 +163,7 @@ export class Paddle implements INodeType {
const products = await paddleApiRequest.call(this, endpoint, 'POST', {});
// 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.');
}

View file

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

View file

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

View file

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