Comments (1)
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:
SellerId
andMerchant
are synonyms.PurgeAndReplace
is a stringFeedOptions
is a string in the format specified in https://m.media-amazon.com/images/G/03/B2B/invoice-uploader-developer-documentation.pdfhostbycountry()
here is a function that return the host as listed in https://docs.developer.amazonservices.com/en_US/dev_guide/DG_Endpoints.html , by the country code of the merchant (the sellerId), not the marketplace! this means that the SellerId and AuthToken is paired with the platform, even if the merchant is selling in another country, butMarketplaceIdList.Id.1
is the marketplace where the order is placed (where the good was sold).amazonMws.setContentType('application/octet-stream')
, because it is not an 'x-www-form-urlencoded', it is an upload instead, this should be automatic, maybe, but I solved it without touching the code
from amazon-mws.
Related Issues (20)
- Several problems with how financial events are parsed HOT 4
- Is there any way to pass proxy params when create mws instance? HOT 2
- Problem with JSON response when multiple items are returned HOT 3
- Cannot read property 'createUrlData' of undefined @\node_modules\amazon-mws\lib\AmazonMwsMethod.js:33:28 HOT 2
- ListMarketplaceParticipations function NextToken response HOT 1
- GetEligibleShippingServices Return GenericError HOT 2
- Error in parsing to json HOT 4
- Add support for the Easy Ship API HOT 1
- Add support for the Shipment Invoicing API HOT 1
- Concurrent SumbitFeed requests fail because of md5 value. HOT 2
- Error: amazon_mws_1.default is not a constructor when using TypeScript and Nest.js HOT 1
- ListOrders not working
- Provide TypeScript type definitions for MWS JSON responses HOT 1
- Security vulnerability fast-csv HOT 2
- AmazonMwsAPIError 403 on any request
- 414 Request-URI too large HOT 3
- Is this application violated the Amazon Acceptable Use Policy(AUP) ?
- SignatureDoesNotMatch error
- Japanese support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amazon-mws.