From 99f7e380a88a34e3c75d713a89ce3bd3af37f3f7 Mon Sep 17 00:00:00 2001 From: florianbepunkt Date: Wed, 1 Mar 2017 13:17:59 +0100 Subject: [PATCH 1/3] fix FBA outbound shipping --- lib/request.js | 27 +++++++++++++++++---------- lib/sections/fulfillment.js | 3 ++- 2 files changed, 19 insertions(+), 11 deletions(-) mode change 100644 => 100755 lib/request.js mode change 100644 => 100755 lib/sections/fulfillment.js diff --git a/lib/request.js b/lib/request.js old mode 100644 new mode 100755 index 306506c..1aed47f --- a/lib/request.js +++ b/lib/request.js @@ -32,7 +32,7 @@ function getValueForParam(param, val) { return String(!!val); case Type.COMPLEX: - // return param.construct(members); // TODO: fix + return val; default: return val; @@ -149,13 +149,15 @@ class AmazonMwsRequest { return (_.isString(value) || _.isNumber(value)) ? [value] : value; } - // Lists need to be sequentially numbered and we take care of that here - if (param.list) { - const values = _.map(toCollection(value), getValue); - - _.forEach(values, (value, i) => { - this.values[`${param.name}.${i + 1}`] = value; - }); + // only used for FBA outbound shipping + // converts the LineItems array of UpdateFulfillmentOrder() to proper MWS params + if (param.type == Type.COMPLEX) { + let members = value; + for (var i = 0; i < members.length; i++) { + for (var j in members[i]) { + this.values['Items.members.' + (i + 1) + '.' + j] = members[i][j]; + } + } } else { this.values[param.name] = getValue(value); @@ -181,14 +183,19 @@ class AmazonMwsRequest { query() { return Promise.try(() => { const missing = _.filter(this.params, (param) => { - const isList = param.list; + // const isList = (param.type == Type.COMPLEX); const isRequired = param.required; if (!isRequired) { return false; } - const value = isList ? this.values[`${param.name}.1`] : this.values[param.name]; + if(param.type == Type.COMPLEX) { + return false; + } + + // const value = isList ? this.values[`${param.name}.1`] : this.values[param.name]; + const value = this.values[param.name]; // intentional `==` return value == null; diff --git a/lib/sections/fulfillment.js b/lib/sections/fulfillment.js old mode 100644 new mode 100755 index 3481910..103de0d --- a/lib/sections/fulfillment.js +++ b/lib/sections/fulfillment.js @@ -226,6 +226,7 @@ const requests = { DisplayableOrderComment: {}, FulfillmentPolicy: { type: 'fba.FulfillmentPolicy' }, FulfillmentMethod: {}, + FulfillmentAction: {}, NotificationEmails: { name: 'NotificationEmailList.member', list }, DestName: { name: 'DestinationAddress.Name' }, DestAddressLine1: { name: 'DestinationAddress.Line1' }, @@ -297,7 +298,7 @@ const requests = { DestCountryCode: { name: 'DestinationAddress.CountryCode' }, DestDistrictOrCounty: { name: 'DestinationAddress.DistrictOrCounty' }, DestPhoneNumber: { name: 'DestinationAddress.PhoneNumber' }, - LineItems: { type: Type.COMPLEX, construct: complex.CreateLineItems } + LineItems: { name: 'LineItems', type: Type.COMPLEX } } } } From 5e2d9175258c6c84375cb770921f9553013933ca Mon Sep 17 00:00:00 2001 From: florianbepunkt Date: Wed, 1 Mar 2017 16:07:46 +0100 Subject: [PATCH 2/3] corrected PR fix FBA outbound shipping --- README.md | 0 feeds.js | 0 index.js | 0 lib/api.js | 0 lib/client.js | 0 lib/complexList.js | 0 lib/enum.js | 0 lib/feeds/fulfillment.js | 0 lib/feeds/index.js | 0 lib/feeds/orders.js | 0 lib/feeds/products.js | 0 lib/request.js | 17 +++++++++++------ lib/sections/feeds.js | 0 lib/sections/finances.js | 0 lib/sections/fulfillment.js | 4 ++-- lib/sections/orders.js | 0 lib/sections/products.js | 0 lib/sections/reports.js | 0 lib/sections/sellers.js | 0 lib/types.js | 0 lib/xml.js | 0 package.json | 0 test/xml.js | 0 23 files changed, 13 insertions(+), 8 deletions(-) mode change 100644 => 100755 README.md mode change 100644 => 100755 feeds.js mode change 100644 => 100755 index.js mode change 100644 => 100755 lib/api.js mode change 100644 => 100755 lib/client.js mode change 100644 => 100755 lib/complexList.js mode change 100644 => 100755 lib/enum.js mode change 100644 => 100755 lib/feeds/fulfillment.js mode change 100644 => 100755 lib/feeds/index.js mode change 100644 => 100755 lib/feeds/orders.js mode change 100644 => 100755 lib/feeds/products.js mode change 100644 => 100755 lib/sections/feeds.js mode change 100644 => 100755 lib/sections/finances.js mode change 100644 => 100755 lib/sections/orders.js mode change 100644 => 100755 lib/sections/products.js mode change 100644 => 100755 lib/sections/reports.js mode change 100644 => 100755 lib/sections/sellers.js mode change 100644 => 100755 lib/types.js mode change 100644 => 100755 lib/xml.js mode change 100644 => 100755 package.json mode change 100644 => 100755 test/xml.js diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/feeds.js b/feeds.js old mode 100644 new mode 100755 diff --git a/index.js b/index.js old mode 100644 new mode 100755 diff --git a/lib/api.js b/lib/api.js old mode 100644 new mode 100755 diff --git a/lib/client.js b/lib/client.js old mode 100644 new mode 100755 diff --git a/lib/complexList.js b/lib/complexList.js old mode 100644 new mode 100755 diff --git a/lib/enum.js b/lib/enum.js old mode 100644 new mode 100755 diff --git a/lib/feeds/fulfillment.js b/lib/feeds/fulfillment.js old mode 100644 new mode 100755 diff --git a/lib/feeds/index.js b/lib/feeds/index.js old mode 100644 new mode 100755 diff --git a/lib/feeds/orders.js b/lib/feeds/orders.js old mode 100644 new mode 100755 diff --git a/lib/feeds/products.js b/lib/feeds/products.js old mode 100644 new mode 100755 diff --git a/lib/request.js b/lib/request.js index 1aed47f..a5b5167 100755 --- a/lib/request.js +++ b/lib/request.js @@ -33,6 +33,7 @@ function getValueForParam(param, val) { case Type.COMPLEX: return val; + // return param.construct(members); // TODO: fix default: return val; @@ -149,9 +150,14 @@ class AmazonMwsRequest { return (_.isString(value) || _.isNumber(value)) ? [value] : value; } - // only used for FBA outbound shipping - // converts the LineItems array of UpdateFulfillmentOrder() to proper MWS params - if (param.type == Type.COMPLEX) { + // Lists need to be sequentially numbered and we take care of that here + if (param.list) { + const values = _.map(toCollection(value), getValue); + + _.forEach(values, (value, i) => { + this.values[`${param.name}.${i + 1}`] = value; + }); + } else if (param.type == Type.COMPLEX) { let members = value; for (var i = 0; i < members.length; i++) { for (var j in members[i]) { @@ -183,7 +189,7 @@ class AmazonMwsRequest { query() { return Promise.try(() => { const missing = _.filter(this.params, (param) => { - // const isList = (param.type == Type.COMPLEX); + const isList = param.list; const isRequired = param.required; if (!isRequired) { @@ -194,8 +200,7 @@ class AmazonMwsRequest { return false; } - // const value = isList ? this.values[`${param.name}.1`] : this.values[param.name]; - const value = this.values[param.name]; + const value = isList ? this.values[`${param.name}.1`] : this.values[param.name]; // intentional `==` return value == null; diff --git a/lib/sections/feeds.js b/lib/sections/feeds.js old mode 100644 new mode 100755 diff --git a/lib/sections/finances.js b/lib/sections/finances.js old mode 100644 new mode 100755 diff --git a/lib/sections/fulfillment.js b/lib/sections/fulfillment.js index 103de0d..10d0f1e 100755 --- a/lib/sections/fulfillment.js +++ b/lib/sections/fulfillment.js @@ -225,8 +225,8 @@ const requests = { DisplayableOrderDateTime: { type: Type.TIMESTAMP }, DisplayableOrderComment: {}, FulfillmentPolicy: { type: 'fba.FulfillmentPolicy' }, - FulfillmentMethod: {}, FulfillmentAction: {}, + FulfillmentMethod: {}, NotificationEmails: { name: 'NotificationEmailList.member', list }, DestName: { name: 'DestinationAddress.Name' }, DestAddressLine1: { name: 'DestinationAddress.Line1' }, @@ -298,7 +298,7 @@ const requests = { DestCountryCode: { name: 'DestinationAddress.CountryCode' }, DestDistrictOrCounty: { name: 'DestinationAddress.DistrictOrCounty' }, DestPhoneNumber: { name: 'DestinationAddress.PhoneNumber' }, - LineItems: { name: 'LineItems', type: Type.COMPLEX } + LineItems: { type: Type.COMPLEX, construct: complex.CreateLineItems } } } } diff --git a/lib/sections/orders.js b/lib/sections/orders.js old mode 100644 new mode 100755 diff --git a/lib/sections/products.js b/lib/sections/products.js old mode 100644 new mode 100755 diff --git a/lib/sections/reports.js b/lib/sections/reports.js old mode 100644 new mode 100755 diff --git a/lib/sections/sellers.js b/lib/sections/sellers.js old mode 100644 new mode 100755 diff --git a/lib/types.js b/lib/types.js old mode 100644 new mode 100755 diff --git a/lib/xml.js b/lib/xml.js old mode 100644 new mode 100755 diff --git a/package.json b/package.json old mode 100644 new mode 100755 diff --git a/test/xml.js b/test/xml.js old mode 100644 new mode 100755 From b4c632a3b5c2fba636d6c3636bbbd0e0e618a674 Mon Sep 17 00:00:00 2001 From: Florian Bischoff Date: Mon, 20 Nov 2017 00:03:08 +0100 Subject: [PATCH 3/3] added MarketplaceId param to CreateFulfillmentOrder --- lib/sections/fulfillment.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/sections/fulfillment.js b/lib/sections/fulfillment.js index 10d0f1e..ed52869 100755 --- a/lib/sections/fulfillment.js +++ b/lib/sections/fulfillment.js @@ -219,6 +219,7 @@ const requests = { CreateFulfillmentOrder: { params: { + MarketplaceId: {}, SellerFulfillmentOrderId: { required }, ShippingSpeedCategory: { required, type: 'fba.ShippingSpeedCategory' }, DisplayableOrderId: { required },