Skip to content

Commit f927a5f

Browse files
author
Bhushankumar L
authored
Merge pull request #49 from bhushankumarl/development
Development
2 parents 19bbfc6 + b451ccb commit f927a5f

File tree

14 files changed

+197
-122
lines changed

14 files changed

+197
-122
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
0.0.19
2+
- Correct lint and increase test case timeout
3+
- Added Status Code in Error Response.
4+
- Added Status Code in Success Response
5+
- Remove OS Dependent Modules
6+
- Use the light version of the iconv
7+
- Fix Tab delimited CSV Report
8+
- Removes node-expat & xml2json
9+
- Add xml parser package as xml2js
10+
111
0.0.18
212
- Add basic Test cases
313
- Add jshint lint checking

README.md

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,54 @@
33

44
This API supported Amazon Marketplace Web Service(MWS)'s standard REST-style API that accepts/returns JSON requests and Here is the [API reference] (http://docs.developer.amazonservices.com/en_IN/dev_guide/DG_IfNew.html)
55

6-
You can find [examples here](https://github.com/bhushankumarl/amazon-mws/tree/master/examples). This will help you for faster implmentation of Amazon Marketplace Web Service's(MWS).
6+
You can testify API through [Amazon MWS Scratchpad](https://mws.amazonservices.in/scratchpad/index.html) without any installation.
7+
8+
You can find [examples of JavaScript and TypeScript here](https://github.com/bhushankumarl/amazon-mws/tree/master/examples). This will help you for faster implementation of Amazon Marketplace Web Service's(MWS).
79

810
##### It does supports EcmaScript 5, EcmaScript 6, EcmaScript 8, TypeScript, async-await, Promises, Callback !
11+
##### It does also supports for AWS Lambda like serverless cloud function call.
912
##### It supports pure JSON response.
1013
##### All methods support Promise and Callback both.
1114
##### Please Feel free to create Issue for any help !
15+
##### All developers/contributors are requested to open Pull Request/Merge Request on development branch. Please make sure Test Cases be passed.
1216

1317
## Installation
1418
```bash
15-
$ npm install amazon-mws --save
19+
npm install amazon-mws --save
1620
```
1721

1822
## Test Cases
1923
```bash
20-
$ npm run test.mocha
24+
npm run test.mocha
2125
```
2226

2327
## Debugging
24-
25-
Run the DEBUG:
26-
2728
```bash
2829
export DEBUG=MWS:*
2930
```
3031

31-
3232
## Usage
33-
3433
```bash
3534
export AWS_ACCESS_KEY_ID=KEY
3635
export AWS_SECRET_ACCESS_KEY=SECRET
3736
```
3837

3938
## Configuration Using JavaScript
40-
41-
Set your Access Key and Access Secret.
42-
4339
```js
4440
var amazonMws = require('amazon-mws')('AWS_ACCESS_KEY_ID','AWS_SECRET_ACCESS_KEY');
4541
```
4642

4743
## Configuration Using TypeScript
48-
49-
```
44+
```typescript
5045
import * as MwsApi from 'amazon-mws';
5146

5247
const amazonMws = new MwsApi();
5348
amazonMws.setApiKey(accessKey, accessSecret);
5449
```
5550

51+
## Pull Request
52+
- Contributors can send their Pull Request to `development` branch.
53+
- Kindly validate test cases & linting before opening new PR.
5654

5755
### Feeds
5856

@@ -119,7 +117,7 @@ amazonMws.setApiKey(accessKey, accessSecret);
119117
'Action': 'ListFinancialEventGroups',
120118
'SellerId': 'SELLER_ID',
121119
'MWSAuthToken': 'MWS_AUTH_TOKEN',
122-
'FinancialEventGroupStartedAfter': new Date(13, 12, 2016)
120+
'FinancialEventGroupStartedAfter': new Date(2016, 11, 24)
123121
}, function (error, response) {
124122
if (error) {
125123
console.log('error ', error);
@@ -159,7 +157,7 @@ amazonMws.setApiKey(accessKey, accessSecret);
159157
'Action': 'ListAllFulfillmentOrders',
160158
'SellerId': 'SELLER_ID',
161159
'MWSAuthToken': 'MWS_AUTH_TOKEN',
162-
'QueryStartDateTime': new Date(13, 12, 2016)
160+
'QueryStartDateTime': new Date(2016, 11, 24)
163161
}, function (error, response) {
164162
if (error) {
165163
console.log('error ', error);
@@ -219,7 +217,7 @@ amazonMws.setApiKey(accessKey, accessSecret);
219217
'SellerId': 'SELLER_ID',
220218
'MWSAuthToken': 'MWS_AUTH_TOKEN',
221219
'MarketplaceId': 'MARKET_PLACE_ID',
222-
'QueryStartDateTime': new Date(13, 12, 2016)
220+
'QueryStartDateTime': new Date(2016, 11, 24)
223221
}, function (error, response) {
224222
if (error) {
225223
console.log('error ', error);
@@ -312,7 +310,7 @@ amazonMws.setApiKey(accessKey, accessSecret);
312310
'SellerId': 'SELLER_ID',
313311
'MWSAuthToken': 'MWS_AUTH_TOKEN',
314312
'MarketplaceId.Id.1': 'MARKET_PLEACE_ID_1',
315-
'LastUpdatedAfter': new Date(13, 12, 2016)
313+
'LastUpdatedAfter': new Date(2016, 11, 24)
316314
}, function (error, response) {
317315
if (error) {
318316
console.log('error ', error);
@@ -330,7 +328,7 @@ amazonMws.setApiKey(accessKey, accessSecret);
330328
'SellerId': 'SELLER_ID',
331329
'MWSAuthToken': 'MWS_AUTH_TOKEN',
332330
'MarketplaceId.Id.1': 'MARKET_PLEACE_ID_1',
333-
'LastUpdatedAfter': new Date(13, 12, 2016),
331+
'LastUpdatedAfter': new Date(2016, 11, 24),
334332
'OrderStatus.Status.1': 'Pending',
335333
'OrderStatus.Status.2': 'Canceled'
336334
}, function (error, response) {
@@ -448,7 +446,6 @@ amazonMws.setApiKey(accessKey, accessSecret);
448446
return;
449447
}
450448
console.log('response', response);
451-
// asynchronously called
452449
});
453450
```
454451

@@ -466,7 +463,6 @@ amazonMws.setApiKey(accessKey, accessSecret);
466463
return;
467464
}
468465
console.log('response', response);
469-
// asynchronously called
470466
});
471467
```
472468

@@ -523,7 +519,7 @@ amazonMws.setApiKey(accessKey, accessSecret);
523519
'SellerId': 'SELLER_ID',
524520
'MWSAuthToken': 'MWS_AUTH_TOKEN',
525521
'MarketplaceId.Id.1': 'MARKET_PLEACE_ID_1',
526-
'LastUpdatedAfter': new Date(13, 12, 2016)
522+
'LastUpdatedAfter': new Date(2016, 11, 24)
527523
}, function (error, response) {
528524
if (error) {
529525
console.log('error ', error);
@@ -535,7 +531,7 @@ amazonMws.setApiKey(accessKey, accessSecret);
535531

536532
#### Get Report
537533
###### Using TypeScript.
538-
```
534+
```typescript
539535
const accessKey = process.env.AWS_ACCESS_KEY_ID || 'YOUR_KEY';
540536
const accessSecret = process.env.AWS_SECRET_ACCESS_KEY || 'YOUR_SECRET';
541537

@@ -558,6 +554,29 @@ amazonMws.setApiKey(accessKey, accessSecret);
558554
}
559555
```
560556

557+
#### Success or Error StatusCode can be obtained directly using StatusCode property of response. It will give you same as what Amazon MWS provides.
558+
#### It is also sample of the error responses.
559+
```
560+
{
561+
Type:'Sender',
562+
Code:'InvalidRequestException',
563+
Message:'Invalid xxxxx: ',
564+
Headers: {
565+
'x-mws-quota-max': '',
566+
'x-mws-quota-remaining': '',
567+
'x-mws-quota-resetson': '',
568+
'x-mws-timestamp': '2018-09-05T06:13:00.276Z',
569+
'content-type': 'text/xml',
570+
'content-charset': '',
571+
'content-length': '',
572+
'content-md5': '',
573+
'date': ''
574+
},
575+
StatusCode:400,
576+
RequestId: 'XXXXX-XXXXXX-XXXXX'
577+
}
578+
```
579+
561580
#### Additionally all api returns Throttling: Limits to how often you can submit requests
562581
Reference : http://docs.developer.amazonservices.com/en_CA/dev_guide/DG_Throttling.html
563582
```json
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use strict';
2+
3+
var accessKey = process.env.AWS_ACCESS_KEY_ID || 'YOUR_KEY';
4+
var accessSecret = process.env.AWS_SECRET_ACCESS_KEY || 'YOUR_SECRET';
5+
6+
var amazonMws = require('../../../lib/amazon-mws')(accessKey, accessSecret);
7+
var fse = require('fs-extra');
8+
9+
/**
10+
* Use __CHARSET__ to override charset option.;
11+
* This along with __RAW__ do not get written in the request.
12+
* */
13+
function feedRequest() {
14+
var FeedSubmissionId = '10101010XXX';
15+
amazonMws.feeds.search({
16+
'Version': '2009-01-01',
17+
'Action': 'GetFeedSubmissionResult',
18+
'SellerId': 'SELLER_ID',
19+
'MWSAuthToken': 'MWS_AUTH_TOKEN',
20+
'FeedSubmissionId': FeedSubmissionId,
21+
__CHARSET__: 'latin1'
22+
}, function (error, response) {
23+
if (error) {
24+
console.log('error ', error);
25+
return;
26+
}
27+
fse.writeFileSync('response.txt', response.data);
28+
console.log('Headers', response.Headers);
29+
});
30+
}
31+
32+
feedRequest();

examples/javaScript/feeds/getFeedSubmissionResultRaw.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
'use strict';
2-
var fs = require('fs');
32

43
var accessKey = process.env.AWS_ACCESS_KEY_ID || 'YOUR_KEY';
54
var accessSecret = process.env.AWS_SECRET_ACCESS_KEY || 'YOUR_SECRET';

examples/javaScript/finances/listFinancialEventGroups.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var financeRequest = function () {
1212
'Action': 'ListFinancialEventGroups',
1313
'SellerId': 'SELLER_ID',
1414
'MWSAuthToken': 'MWS_AUTH_TOKEN',
15-
'FinancialEventGroupStartedAfter': new Date(13, 12, 2016)
15+
'FinancialEventGroupStartedAfter': new Date(2016, 11, 24)
1616
}, function (error, response) {
1717
if (error) {
1818
console.log('error ', error);

examples/javaScript/fulfillmentInventory/listInventorySupply.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var fulfillmentInventoryRequest = function () {
1313
'SellerId': 'SELLER_ID',
1414
'MWSAuthToken': 'MWS_AUTH_TOKEN',
1515
'MarketplaceId': 'MARKET_PLACE_ID',
16-
'QueryStartDateTime': new Date(13, 12, 2016)
16+
'QueryStartDateTime': new Date(2016, 11, 24)
1717
}, function (error, response) {
1818
if (error) {
1919
console.log('error ', error);

examples/javaScript/fulfillmentOutboundShipment/listAllFulfillmentOrders.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var fulfillmentOutboundShipmentRequest = function () {
1212
'Action': 'ListAllFulfillmentOrders',
1313
'SellerId': 'SELLER_ID',
1414
'MWSAuthToken': 'MWS_AUTH_TOKEN',
15-
'QueryStartDateTime': new Date(13, 12, 2016)
15+
'QueryStartDateTime': new Date(2016, 11, 24)
1616
}, function (error, response) {
1717
if (error) {
1818
console.log('error ', error);

examples/javaScript/orders/listOrders.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var orderRequest = function () {
1212
'SellerId': 'SELLER_ID',
1313
'MWSAuthToken': 'MWS_AUTH_TOKEN',
1414
'MarketplaceId.Id.1': 'MARKET_PLEACE_ID_1',
15-
'LastUpdatedAfter': new Date(13, 12, 2016)
15+
'LastUpdatedAfter': new Date(2016, 11, 24)
1616
}, function (error, response) {
1717
if (error) {
1818
console.log('error ', error);

examples/javaScript/orders/listOrdersFilterStatus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var orderRequest = function () {
1313
'SellerId': 'SELLER_ID',
1414
'MWSAuthToken': 'MWS_AUTH_TOKEN',
1515
'MarketplaceId.Id.1': 'MARKET_PLEACE_ID_1',
16-
'LastUpdatedAfter': new Date(13, 12, 2016),
16+
'LastUpdatedAfter': new Date(2016, 11, 24),
1717
'OrderStatus.Status.1': 'Pending',
1818
'OrderStatus.Status.2': 'Canceled'
1919
}, function (error, response) {

examples/javaScript/sample/listOrders.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var orderRequest = function () {
2222
'SellerId': 'SELLER_ID',
2323
'MWSAuthToken': 'MWS_AUTH_TOKEN',
2424
'MarketplaceId.Id.1': 'MARKET_PLEACE_ID_1',
25-
'LastUpdatedAfter': new Date(13, 12, 2016)
25+
'LastUpdatedAfter': new Date(2016, 11, 24)
2626
}, function (error, response) {
2727
if (error) {
2828
console.log('error ', error);

0 commit comments

Comments
 (0)