From 698a69207c031ab96cef9886519db03d69ea5a51 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Tue, 25 Feb 2020 11:01:13 +0100 Subject: [PATCH] :zap: Small improvements on WooCommerce-Node --- .../nodes/WooCommerce/GenericFunctions.ts | 6 ++-- .../nodes/WooCommerce/OrderDescription.ts | 34 +++++++----------- .../nodes/WooCommerce/WooCommerce.node.ts | 30 ++++++++-------- .../WooCommerce/WooCommerceTrigger.node.ts | 2 +- .../nodes/WooCommerce/wooCommerce.png | Bin 0 -> 999 bytes .../nodes/WooCommerce/woocommerce.png | Bin 1942 -> 0 bytes 6 files changed, 30 insertions(+), 42 deletions(-) create mode 100644 packages/nodes-base/nodes/WooCommerce/wooCommerce.png delete mode 100644 packages/nodes-base/nodes/WooCommerce/woocommerce.png diff --git a/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts b/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts index ee254ec1e..804392fea 100644 --- a/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts +++ b/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts @@ -101,8 +101,7 @@ export function setMetadata(data: //@ts-ignore data[i].meta_data = data[i].metadataUi.metadataValues; //@ts-ignore - delete data[i].metadataUi - console.log(data[i]); + delete data[i].metadataUi; } else { //@ts-ignore delete data[i].metadataUi; @@ -128,7 +127,7 @@ export function toSnakeCase(data: remove = true; } //@ts-ignore - data[i][snakeCase(key)] = data[i][key] + data[i][snakeCase(key)] = data[i][key]; if (remove) { //@ts-ignore delete data[i][key]; @@ -137,4 +136,3 @@ export function toSnakeCase(data: } } } - diff --git a/packages/nodes-base/nodes/WooCommerce/OrderDescription.ts b/packages/nodes-base/nodes/WooCommerce/OrderDescription.ts index 0dc8e51a6..eda9c1339 100644 --- a/packages/nodes-base/nodes/WooCommerce/OrderDescription.ts +++ b/packages/nodes-base/nodes/WooCommerce/OrderDescription.ts @@ -111,13 +111,6 @@ export const orderFields = [ default: '', description: 'Payment method title.', }, - { - displayName: 'Payment Method Title', - name: 'paymentMethodTitle', - type: 'string', - default: '', - description: 'Payment method title.', - }, { displayName: 'Set Paid', name: 'setPaid', @@ -130,14 +123,14 @@ export const orderFields = [ name: 'status', type: 'options', options: [ - { - name: 'completed', - value: 'completed', - }, { name: 'cancelled', value: 'cancelled', }, + { + name: 'completed', + value: 'completed', + }, { name: 'failed', value: 'failed', @@ -831,26 +824,19 @@ export const orderFields = [ default: '', description: 'Payment method title.', }, - { - displayName: 'Payment Method Title', - name: 'paymentMethodTitle', - type: 'string', - default: '', - description: 'Payment method title.', - }, { displayName: 'Status', name: 'status', type: 'options', options: [ - { - name: 'completed', - value: 'completed', - }, { name: 'cancelled', value: 'cancelled', }, + { + name: 'completed', + value: 'completed', + }, { name: 'failed', value: 'failed', @@ -1568,6 +1554,10 @@ export const orderFields = [ displayName: 'Decimal Points', name: 'decimalPoints', type: 'number', + typeOptions: { + minValue: 0, + maxValue: 10, + }, default: 2, description: 'Number of decimal points to use in each resource.', }, diff --git a/packages/nodes-base/nodes/WooCommerce/WooCommerce.node.ts b/packages/nodes-base/nodes/WooCommerce/WooCommerce.node.ts index 27056f0c4..bbb3d8668 100644 --- a/packages/nodes-base/nodes/WooCommerce/WooCommerce.node.ts +++ b/packages/nodes-base/nodes/WooCommerce/WooCommerce.node.ts @@ -10,10 +10,10 @@ import { INodePropertyOptions, } from 'n8n-workflow'; import { + setMetadata, + toSnakeCase, woocommerceApiRequest, woocommerceApiRequestAllItems, - toSnakeCase, - setMetadata, } from './GenericFunctions'; import { productFields, @@ -22,18 +22,18 @@ import { import { orderFields, orderOperations, -} from './Orderdescription'; +} from './OrderDescription'; import { - IProduct, - IImage, IDimension, + IImage, + IProduct, } from './ProductInterface'; import { - IOrder, IAddress, ICouponLine, IFeeLine, ILineItem, + IOrder, IShoppingLine, } from './OrderInterface'; @@ -41,7 +41,7 @@ export class WooCommerce implements INodeType { description: INodeTypeDescription = { displayName: 'WooCommerce', name: 'wooCommerce', - icon: 'file:woocommerce.png', + icon: 'file:wooCommerce.png', group: ['output'], version: 1, subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', @@ -64,14 +64,14 @@ export class WooCommerce implements INodeType { name: 'resource', type: 'options', options: [ - { - name: 'Product', - value: 'product', - }, { name: 'Order', value: 'order', }, + { + name: 'Product', + value: 'product', + }, ], default: 'product', description: 'Resource to consume.', @@ -455,10 +455,10 @@ export class WooCommerce implements INodeType { body.parent_id = parseInt(additionalFields.parentId as string, 10); } if (additionalFields.paymentMethodId) { - body.payment_method = additionalFields.paymentMethodId as string + body.payment_method = additionalFields.paymentMethodId as string; } if (additionalFields.paymentMethodTitle) { - body.payment_method_title = additionalFields.paymentMethodTitle as string + body.payment_method_title = additionalFields.paymentMethodTitle as string; } if (additionalFields.setPaid) { body.set_paid = additionalFields.setPaid as boolean; @@ -528,10 +528,10 @@ export class WooCommerce implements INodeType { body.parent_id = parseInt(updateFields.parentId as string, 10); } if (updateFields.paymentMethodId) { - body.payment_method = updateFields.paymentMethodId as string + body.payment_method = updateFields.paymentMethodId as string; } if (updateFields.paymentMethodTitle) { - body.payment_method_title = updateFields.paymentMethodTitle as string + body.payment_method_title = updateFields.paymentMethodTitle as string; } if (updateFields.status) { diff --git a/packages/nodes-base/nodes/WooCommerce/WooCommerceTrigger.node.ts b/packages/nodes-base/nodes/WooCommerce/WooCommerceTrigger.node.ts index 73123ec3e..6a09e525d 100644 --- a/packages/nodes-base/nodes/WooCommerce/WooCommerceTrigger.node.ts +++ b/packages/nodes-base/nodes/WooCommerce/WooCommerceTrigger.node.ts @@ -21,7 +21,7 @@ export class WooCommerceTrigger implements INodeType { description: INodeTypeDescription = { displayName: 'WooCommerce Trigger', name: 'wooCommerceTrigger', - icon: 'file:woocommerce.png', + icon: 'file:wooCommerce.png', group: ['trigger'], version: 1, description: 'Handle WooCommerce events via webhooks', diff --git a/packages/nodes-base/nodes/WooCommerce/wooCommerce.png b/packages/nodes-base/nodes/WooCommerce/wooCommerce.png new file mode 100644 index 0000000000000000000000000000000000000000..187de2a2f0e786a8eb62ee4abccb28c49a121c35 GIT binary patch literal 999 zcmV1N*<-nM@qGy+&WR;LggZugW`uO_w@AS#1!nTL4w1lhk>+<8$;NQ#J-N@P5 z!PV8e(95dD$D_cRU5)YR@a*8~#h|{!oV&i1wz!M1vVp0ueWtB?q@G}s{rmj)^Y-uL z?BdVgr*NI5YMGo~koooa+{M?{ywcLP&AXAax{tD^ZJX)a=gh3exs9>St;ex{r_1@aU)v&rEgg|W`%~2Z(H7cv#T@3jm4C(Fj>un>XjTVvwml%K zVr-<;vlz;j(p9)wipZ;WnP~4tb~R?`D#nh|ey?<2umv!x-0J>z5b1qHUS_#6R_u=M zCdxeQ6P-x6i3=ScYCOI=B2XLeQis`@V6;9Rje8ipgqn zOmv9+WR2*;mUW_9IP#EA?Ubmlp3*S-8lmD}_B|VWK)1g*Bvn6*iH?_zL+q zBtO2DahXHcAzvW4=jSnZ$UptSMM2&}4{^p$(8BU2LC$e|Wto_qPjo%*6P+vN6e>ji z4bf8|^gT~XNP9?hme*NgZl2-k78fg={2874k0@48S2#*ondi_53wsTZDh+fkeBv^N z9-!v@Inlrt!EJKQ!l0F{BSfB5kTblng@INf_Ct{X+M;U&?zQaF zl;Y4<0!1-drIKXf?D0#Z@P%@izE0Y!n`{z_)s-Z@_Kft zN~N*`Hzt4M*O#YU5m0V@x-+rkjPyY!B5!`+!`ROuX~q$~9`2H9uUQekvu$fJLrMLr z`+3)jvaz=HF3O5vGJic=U4QfcaR%~=wII7|OG4~ei?X>awyee3+1|8LQd0hZ{s5C( Vfam4nliL6Q002ovPDHLkV1f$a5l;XB literal 0 HcmV?d00001 diff --git a/packages/nodes-base/nodes/WooCommerce/woocommerce.png b/packages/nodes-base/nodes/WooCommerce/woocommerce.png deleted file mode 100644 index b652d7fa60daf510b369bd59ae1d3b7345fd44f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1942 zcmV;H2Wj|;P)ZRgVAv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