bhushankummar / amazon-mws

Amazon MWS NodeJS Wrapper
MIT License
197 stars 78 forks source link

Invoice Upload Feed does not work #147

Open danielecr opened 3 years ago

danielecr commented 3 years ago

rif. #116

Describe the bug Document upload does not work

please reopen #116

the url is wrong. The api reply user not allowed. See #116

Add you Amazon MWS Request

What Response are you receiving?

nothing
danielecr commented 3 years ago

I found a way. First of all the host must be setted, and currently documentation does not provide any details about amazonMws.setHost() call There is no information about setContentType() also ...

There are a lot of set[thing]() method, but there is no setSocket() function, I would like to use amazonMws.setSocket(http), or amazonMws.setSocket(httpmock), and provide some mock for testing. I found something good in this code, but unit tests are not real unit test, the .spec.js test everything from request to the end of handling of response, that is generally called functional tests.

To split those parts the code should be splitted from AmazonMwsResource.js, and really that source file is too much big.

@bhushankumarl , You ask to contributor to run all tests before making a pull request, but the tests must be ran against a real alive amazon api, and this is a real problem if you want the tests to be automatic (you should inject SellerId, auth key, private key, ... and where does the automatic test get this data?)

Tests must be automatic, so tests as of now are not usable.

There are a number of option to mock http, like nock, https://github.com/nock/nock, I do not know it, but maybe there are other things that could be used.

OK. I Stop here the code review. I come back to "how to submit document":

        let host = hostbycountry(PlatformCountry);
        amazonMws.setHost(host);
        amazonMws.setContentType('application/octet-stream');
        const mwsRequestData = {
            Version: '2009-01-01',
            Action: 'SubmitFeed',
            FeedType: '_UPLOAD_VAT_INVOICE_',
            PurgeAndReplace: 'false',
            FeedContent: docData,
            SellerId: 'merchantid',
            MWSAuthToken: 'mws_auth_token',
            'MarketplaceIdList.Id.1': 'marketplaceid',
            FeedOptions: 'metadata:orderid=....'
        };
        return amazonMws.feeds.submit(mwsRequestData)

Something to note: