Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
feat(orders): add AutomatedShippingSettings to Order model (#392)
Browse files Browse the repository at this point in the history
  • Loading branch information
tusbar committed Sep 15, 2021
1 parent 4143d1c commit e009651
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 4 deletions.
7 changes: 7 additions & 0 deletions __tests__/lib/client/models/__snapshots__/orders.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exports[`lib.client.models.orders should call GetOrder 1`] = `
Array [
Object {
"amazonOrderId": "902-3159896-1390916",
"automatedShippingSettings": null,
"buyerCounty": null,
"buyerEmail": null,
"buyerName": null,
Expand Down Expand Up @@ -57,6 +58,7 @@ Object {
"orders": Array [
Object {
"amazonOrderId": "902-3159896-1390916",
"automatedShippingSettings": null,
"buyerCounty": null,
"buyerEmail": "5vlhEXAMPLEh9h5@marketplace.amazon.com",
"buyerName": "Buyer name",
Expand Down Expand Up @@ -125,6 +127,7 @@ Object {
},
Object {
"amazonOrderId": "483-3488972-0896720",
"automatedShippingSettings": null,
"buyerCounty": "Vila Olimpia",
"buyerEmail": "5vlhEXAMPLEh9h5@marketplace.amazon.com.br",
"buyerName": "John Jones",
Expand Down Expand Up @@ -193,6 +196,7 @@ Object {
},
Object {
"amazonOrderId": "058-1233752-8214740",
"automatedShippingSettings": null,
"buyerCounty": null,
"buyerEmail": "5vlhEXAMPLEh9h5@marketplace.amazon.co.jp",
"buyerName": "Jane Smith",
Expand Down Expand Up @@ -284,6 +288,7 @@ Object {
"orders": Array [
Object {
"amazonOrderId": "902-3159896-1390916",
"automatedShippingSettings": null,
"buyerCounty": null,
"buyerEmail": "5vlhEXAMPLEh9h5@marketplace.amazon.com",
"buyerName": "Buyer name",
Expand Down Expand Up @@ -365,6 +370,7 @@ Object {
},
Object {
"amazonOrderId": "483-3488972-0896720",
"automatedShippingSettings": null,
"buyerCounty": "Vila Olimpia",
"buyerEmail": "5vlhEXAMPLEh9h5@marketplace.amazon.com.br",
"buyerName": "John Jones",
Expand Down Expand Up @@ -433,6 +439,7 @@ Object {
},
Object {
"amazonOrderId": "058-1233752-8214740",
"automatedShippingSettings": null,
"buyerCounty": null,
"buyerEmail": "5vlhEXAMPLEh9h5@marketplace.amazon.co.jp",
"buyerName": "Jane Smith",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Object {
"orders": Array [
Object {
"amazonOrderId": "902-3159896-1390916",
"automatedShippingSettings": null,
"buyerCounty": null,
"buyerEmail": null,
"buyerName": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Object {
"orders": Array [
Object {
"amazonOrderId": "902-3159896-1390916",
"automatedShippingSettings": null,
"buyerCounty": null,
"buyerEmail": null,
"buyerName": null,
Expand Down Expand Up @@ -59,7 +60,7 @@ Object {
}
`;

exports[`lib.client.parsers.orders.list-orders-response should parse the ListOrdersResponse example response from MWS doc 1`] = `
exports[`lib.client.parsers.orders.list-orders-response should parse the ListOrdersResponse example response from MWS doc (updated) 1`] = `
Object {
"listOrdersResult": Object {
"createdBefore": null,
Expand All @@ -68,6 +69,7 @@ Object {
"orders": Array [
Object {
"amazonOrderId": "902-3159896-1390916",
"automatedShippingSettings": null,
"buyerCounty": null,
"buyerEmail": "5vlhEXAMPLEh9h5@marketplace.amazon.com",
"buyerName": "Buyer name",
Expand All @@ -81,7 +83,20 @@ Object {
],
"taxingRegion": "US",
},
"defaultShipFromLocationAddress": null,
"defaultShipFromLocationAddress": Object {
"addressType": null,
"adressLine1": "15606 NE Any street",
"adressLine2": "Suite 2",
"adressLine3": null,
"city": "Redmond",
"countryCode": "US",
"county": null,
"district": null,
"name": "Seller name",
"phone": "555 555-5555",
"postalCode": "98052",
"stateOrRegion": "WA",
},
"earliestDeliveryDate": null,
"earliestShipDate": 2017-02-20T19:51:16.000Z,
"easyShipShipmentStatus": null,
Expand Down Expand Up @@ -131,11 +146,12 @@ Object {
"name": "Buyer name",
"phone": null,
"postalCode": "98103",
"stateOrRegion": null,
"stateOrRegion": "WA",
},
},
Object {
"amazonOrderId": "483-3488972-0896720",
"automatedShippingSettings": null,
"buyerCounty": "Vila Olimpia",
"buyerEmail": "5vlhEXAMPLEh9h5@marketplace.amazon.com.br",
"buyerName": "John Jones",
Expand Down Expand Up @@ -204,6 +220,11 @@ Object {
},
Object {
"amazonOrderId": "058-1233752-8214740",
"automatedShippingSettings": Object {
"automatedCarrier": "Name",
"automatedShipMethod": "Method",
"hasAutomatedShippingSettings": true,
},
"buyerCounty": null,
"buyerEmail": "5vlhEXAMPLEh9h5@marketplace.amazon.co.jp",
"buyerName": "Jane Smith",
Expand Down
19 changes: 18 additions & 1 deletion __tests__/lib/client/parsers/orders/list-orders-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const parseXml = require('../../../../../lib/client/parsers')
const parseListOrdersResponse = require('../../../../../lib/client/parsers/orders/list-orders-response')

describe('lib.client.parsers.orders.list-orders-response', () => {
it('should parse the ListOrdersResponse example response from MWS doc', () => {
it('should parse the ListOrdersResponse example response from MWS doc (updated)', () => {
const doc = parseXml(
`<?xml version="1.0"?>
<ListOrdersResponse xmlns="https://mws.amazonservices.com/Orders/2013-09-01">
Expand All @@ -21,10 +21,22 @@ describe('lib.client.parsers.orders.list-orders-response', () => {
<Name>Buyer name</Name>
<AddressLine1>1234 Any St.</AddressLine1>
<City>Seattle</City>
<StateOrRegion>WA</StateOrRegion>
<PostalCode>98103</PostalCode>
<CountryCode>US</CountryCode>
<AddressType>Commercial</AddressType>
</ShippingAddress>
<DefaultShipFromLocationAddress>
<Name>Seller name</Name>
<AddressLine1>15606 NE Any street</AddressLine1>
<AddressLine2>Suite 2</AddressLine2>
<City>Redmond</City>
<StateOrRegion>WA</StateOrRegion>
<PostalCode>98052</PostalCode>
<CountryCode>US</CountryCode>
<Phone>555 555-5555</Phone>
<isAddressSharingConfidential>false</isAddressSharingConfidential>
</DefaultShipFromLocationAddress>
<OrderTotal>
<CurrencyCode>USD</CurrencyCode>
<Amount>25.00</Amount>
Expand Down Expand Up @@ -159,6 +171,11 @@ describe('lib.client.parsers.orders.list-orders-response', () => {
<IsGlobalExpressEnabled>false</IsGlobalExpressEnabled>
<PromiseResponseDueDate>2017-08-31T23:58:44Z</PromiseResponseDueDate>
<IsEstimatedShipDateSet>true</IsEstimatedShipDateSet>
<AutomatedShippingSettings>
<hasAutomatedShippingSettings>true</hasAutomatedShippingSettings>
<automatedCarrier>Name</automatedCarrier>
<automatedShipMethod>Method</automatedShipMethod>
</AutomatedShippingSettings>
</Order>
</Orders>
</ListOrdersResult>
Expand Down
7 changes: 7 additions & 0 deletions lib/client/parsers/orders/automated-shipping-settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const {parseBool, parseStr} = require('../base')

module.exports = (key, node) => ({
hasAutomatedShippingSettings: parseBool(`${key}/orders:hasAutomatedShippingSettings`, node),
automatedCarrier: parseStr(`${key}/orders:automatedCarrier`, node),
automatedShipMethod: parseStr(`${key}/orders:automatedShipMethod`, node),
})
2 changes: 2 additions & 0 deletions lib/client/parsers/orders/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const parseMoney = require('./money')
const parsePaymentExecutionDetail = require('./payment-execution-detail')
const parsePaymentMethodDetail = require('./payment-method-detail')
const parseBuyerTaxInfo = require('./buyer-tax-info')
const parseAutomatedShippingSettings = require('./automated-shipping-settings')

module.exports = (key, node) => ({
amazonOrderId: parseStr(`${key}/orders:AmazonOrderId`, node),
Expand Down Expand Up @@ -49,4 +50,5 @@ module.exports = (key, node) => ({
isGlobalExpressEnabled: parseBool(`${key}/orders:IsGlobalExpressEnabled`, node),
promiseResponseDueDate: parseDate(`${key}/orders:PromiseResponseDueDate`, node),
isEstimatedShipDateSet: parseBool(`${key}/orders:IsEstimatedShipDateSet`, node),
automatedShippingSettings: nullable(parseAutomatedShippingSettings, `${key}/orders:AutomatedShippingSettings`, node),
})

0 comments on commit e009651

Please sign in to comment.