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

Commit

Permalink
fix(orders): parse ShippingAddress as string (#367)
Browse files Browse the repository at this point in the history
* fix(orders): parse `ShippingAddress` as string

* test(orders): add `ShippingAddress cases
  • Loading branch information
Roman991 committed May 4, 2021
1 parent df7a02d commit 7909ef4
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,19 @@ export const parseResponse = <T>(
parseTrueNumberOnly: true,
tagValueProcessor: (value) => decode(value),
// force to be parsed as string
stopNodes: ['Phone'],
stopNodes: [
'Name',
'AddressLine1',
'AddressLine2',
'AddressLine3',
'City',
'Municipality',
'StateOrRegion',
'PostalCode',
'CountryCode',
'Phone',
'AddressType',
],
},
true,
)
Expand Down
63 changes: 63 additions & 0 deletions test/unit/__fixtures__/orders_list_orders.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,69 @@
<PromiseResponseDueDate>2017-08-31T23:58:44Z</PromiseResponseDueDate>
<IsEstimatedShipDateSet>true</IsEstimatedShipDateSet>
</Order>
<Order>
<AmazonOrderId>058-1233752-8214740</AmazonOrderId>
<PurchaseDate>2017-02-05T00%3A06%3A07.000Z</PurchaseDate>
<LastUpdateDate>2017-02-07T12%3A43%3A16.000Z</LastUpdateDate>
<OrderStatus>Unshipped</OrderStatus>
<FulfillmentChannel>MFN</FulfillmentChannel>
<ShipServiceLevel>Std JP Kanto8</ShipServiceLevel>
<ShippingAddress>
<Name>Jane Smith</Name>
<AddressLine1>22</AddressLine1>
<AddressLine2>kebab st</AddressLine2>
<AddressLine3>321321321</AddressLine3>
<City>Tokyo</City>
<PostalCode>00148</PostalCode>
<Phone>05 55 555555</Phone>
<CountryCode>IT</CountryCode>
</ShippingAddress>
<OrderTotal>
<CurrencyCode>JPY</CurrencyCode>
<Amount>1507.00</Amount>
</OrderTotal>
<NumberOfItemsShipped>0</NumberOfItemsShipped>
<NumberOfItemsUnshipped>1</NumberOfItemsUnshipped>
<PaymentExecutionDetail>
<PaymentExecutionDetailItem>
<Payment>
<Amount>10.00</Amount>
<CurrencyCode>JPY</CurrencyCode>
</Payment>
<PaymentMethod>PointsAccount</PaymentMethod>
</PaymentExecutionDetailItem>
<PaymentExecutionDetailItem>
<Payment>
<Amount>317.00</Amount>
<CurrencyCode>JPY</CurrencyCode>
</Payment>
<PaymentMethod>GC</PaymentMethod>
</PaymentExecutionDetailItem>
<PaymentExecutionDetailItem>
<Payment>
<Amount>1180.00</Amount>
<CurrencyCode>JPY</CurrencyCode>
</Payment>
<PaymentMethod>COD</PaymentMethod>
</PaymentExecutionDetailItem>
</PaymentExecutionDetail>
<PaymentMethod>COD</PaymentMethod>
<PaymentMethodDetails>
<PaymentMethodDetail>COD</PaymentMethodDetail>
</PaymentMethodDetails>
<MarketplaceId>A1VC38T7YXB528</MarketplaceId>
<BuyerEmail>5vlhEXAMPLEh9h5@marketplace.amazon.co.jp</BuyerEmail>
<BuyerName>Jane Smith</BuyerName>
<ShipmentServiceLevelCategory>Standard </ShipmentServiceLevelCategory>
<OrderType>SourcingOnDemandOrder</OrderType>
<IsBusinessOrder>false</IsBusinessOrder>
<IsPrime>false</IsPrime>
<IsPremiumOrder>false</IsPremiumOrder>
<IsGlobalExpressEnabled>false</IsGlobalExpressEnabled>
<PromiseResponseDueDate>2017-08-31T23:58:44Z</PromiseResponseDueDate>
<IsEstimatedShipDateSet>true</IsEstimatedShipDateSet>
</Order>

</Orders>
</ListOrdersResult>
<ResponseMetadata>
Expand Down
62 changes: 62 additions & 0 deletions test/unit/__snapshots__/orders.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,68 @@ Array [
"PostalCode": "107-0053",
},
},
Object {
"AmazonOrderId": "058-1233752-8214740",
"BuyerEmail": "5vlhEXAMPLEh9h5@marketplace.amazon.co.jp",
"BuyerName": "Jane Smith",
"FulfillmentChannel": "MFN",
"IsBusinessOrder": false,
"IsEstimatedShipDateSet": true,
"IsGlobalExpressEnabled": false,
"IsPremiumOrder": false,
"IsPrime": false,
"LastUpdateDate": 2017-02-07T12:43:16.000Z,
"MarketplaceId": "A1VC38T7YXB528",
"NumberOfItemsShipped": 0,
"NumberOfItemsUnshipped": 1,
"OrderStatus": "Unshipped",
"OrderTotal": Object {
"Amount": 1507,
"CurrencyCode": "JPY",
},
"OrderType": "SourcingOnDemandOrder",
"PaymentExecutionDetail": Array [
Object {
"Payment": Object {
"Amount": 10,
"CurrencyCode": "JPY",
},
"PaymentMethod": "PointsAccount",
},
Object {
"Payment": Object {
"Amount": 317,
"CurrencyCode": "JPY",
},
"PaymentMethod": "GC",
},
Object {
"Payment": Object {
"Amount": 1180,
"CurrencyCode": "JPY",
},
"PaymentMethod": "COD",
},
],
"PaymentMethod": "COD",
"PaymentMethodDetails": Array [
"COD",
],
"PromiseResponseDueDate": 2017-08-31T23:58:44.000Z,
"PurchaseDate": 2017-02-05T00:06:07.000Z,
"ShipServiceLevel": "Std JP Kanto8",
"ShipmentServiceLevelCategory": "Standard",
"ShippingAddress": Object {
"AddressLine1": "22",
"AddressLine2": "kebab st",
"AddressLine3": "321321321",
"City": "Tokyo",
"CountryCode": "IT",
"Name": "Jane Smith",
"Phone": "05 55 555555",
"PostalCode": "00148",
},
},
],
},
Object {
Expand Down

0 comments on commit 7909ef4

Please sign in to comment.