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

[Orders] error when parsing data #365

Closed
Roman991 opened this issue May 3, 2021 · 4 comments
Closed

[Orders] error when parsing data #365

Roman991 opened this issue May 3, 2021 · 4 comments
Labels

Comments

@Roman991
Copy link
Contributor

Roman991 commented May 3, 2021

seems there's some problems when parsing orders json (or xml?).

error

ERRORE ParsingError: Problem with the value of property `ListOrdersResponse`: Problem with the value of property `ListOrdersResult`: Problem with the value of property `Orders`: Problem with the value at index 0: Problem with the value of property `ShippingAddress`: One of the following problems occured: (0) Problem with the value of property `Phone`: One of the following problems occured: (0) Expected a string, but received a number with value 333333333333, (1) Expected 
an undefined, but received a number with value 333333333333, (1) Expected an undefined, but received an object with value {"City":"string","PostalCode":11111,"isAddressSharingConfidential":false,"StateOrRegion":"AA","Phone":333333333333,"CountryCode":"IT","Name":"string","AddressLine1":"string","AddressLine2":"string"}
    at Object.Left (D:\QdL\qdl\mws_service\node_modules\mws\lib\sections\orders.js:264:23)
    at Left.caseOf (D:\QdL\qdl\mws_service\node_modules\purify-ts\Either.js:267:58)
    at Orders.listOrders (D:\QdL\qdl\mws_service\node_modules\mws\lib\sections\orders.js:261:52)

\mws\lib\sections\orders.js:261:52)

    async listOrders(parameters) {
        const [response, meta] = await this.httpClient.request('POST', {
            resource: http_1.Resource.Orders,
            version: ORDERS_API_VERSION,
            action: 'ListOrders',
            parameters: canonicalizeParameters(parameters),
        });
        console.log(JSON.stringify(response))


        return ListOrdersResponse.decode(response).caseOf({
            Right: (x) => [x.ListOrdersResponse.ListOrdersResult, meta],
            Left: (error) => {
                throw new error_1.ParsingError(error);      //  <<<<<<<<<<< ERROR IS THROWED HERE
            },
        });
    }

json.stringify

......
{
"ShippingAddress":{
"City":"string",
"PostalCode":11111,           // <<<<<<<<<< number here
"isAddressSharingConfidential":false,
"StateOrRegion":"string",
"Phone":3333333333,   // <<<<< number here
"CountryCode":"string"
,"Name":"string",
"AddressLine1":"string",
"AddressLine2":"string"
}
.....

the httpCliente returns the object with those 2 fields as numbers,
later I'll check also the http class

@moltar
Copy link
Contributor

moltar commented May 3, 2021

Hi Roman, which version of the package are you using?

@Roman991
Copy link
Contributor Author

Roman991 commented May 3, 2021

Oh, Hi Roman! :)
I just installed it "version": "1.9.47"

@repo-ranger repo-ranger bot closed this as completed in fcc83cd May 3, 2021
github-actions bot pushed a commit that referenced this issue May 3, 2021
## [1.9.48](v1.9.47...v1.9.48) (2021-05-03)

### Bug Fixes

* parse phone as string ([fcc83cd](fcc83cd)), closes [#365](#365)
@github-actions
Copy link

github-actions bot commented May 3, 2021

🎉 This issue has been resolved in version 1.9.48 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Roman991
Copy link
Contributor Author

Roman991 commented May 3, 2021

thanks, it worked.
But all fields under ShippingAddress should be fixed as strings.
Those fields are filled by customers, and they somethimes know to be very creative:

{
City: "Italy",
AddressLine1: 333333333,
AddressLine2: "41",
AdrressLine3: "kebab st",
PostalCode: "Rome"
}

That's why parsing by content on that fields should be off XD

https://docs.developer.amazonservices.com/en_US/orders-2013-09-01/Orders_Datatypes.html#Address

ERRORE ParsingError: Problem with the value of property `ListOrdersResponse` : 
Problem with the value of property `ListOrdersResult`: 
Problem with the value of property `Orders`: 
Problem with the value at index 7: 
Problem with the value of property `ShippingAddress`: 
One of the following problems occured: 
(0) Problem with the value of property `AddressLine2`: 
One of the following problems occured: 
(0) Expected a string, but received a number with value 36, 
(1) Expected an undefined, but received a number with value 36, ...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants