Skip to content

Commit

Permalink
Merge pull request #49 from bhushankumarl/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Bhushankumar L authored Sep 13, 2018
2 parents 19bbfc6 + b451ccb commit f927a5f
Show file tree
Hide file tree
Showing 14 changed files with 197 additions and 122 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
0.0.19
- Correct lint and increase test case timeout
- Added Status Code in Error Response.
- Added Status Code in Success Response
- Remove OS Dependent Modules
- Use the light version of the iconv
- Fix Tab delimited CSV Report
- Removes node-expat & xml2json
- Add xml parser package as xml2js

0.0.18
- Add basic Test cases
- Add jshint lint checking
Expand Down
63 changes: 41 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,54 @@

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)

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).
You can testify API through [Amazon MWS Scratchpad](https://mws.amazonservices.in/scratchpad/index.html) without any installation.

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).

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

## Installation
```bash
$ npm install amazon-mws --save
npm install amazon-mws --save
```

## Test Cases
```bash
$ npm run test.mocha
npm run test.mocha
```

## Debugging

Run the DEBUG:

```bash
export DEBUG=MWS:*
```


## Usage

```bash
export AWS_ACCESS_KEY_ID=KEY
export AWS_SECRET_ACCESS_KEY=SECRET
```

## Configuration Using JavaScript

Set your Access Key and Access Secret.

```js
var amazonMws = require('amazon-mws')('AWS_ACCESS_KEY_ID','AWS_SECRET_ACCESS_KEY');
```

## Configuration Using TypeScript

```
```typescript
import * as MwsApi from 'amazon-mws';

const amazonMws = new MwsApi();
amazonMws.setApiKey(accessKey, accessSecret);
```

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

### Feeds

Expand Down Expand Up @@ -119,7 +117,7 @@ amazonMws.setApiKey(accessKey, accessSecret);
'Action': 'ListFinancialEventGroups',
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'FinancialEventGroupStartedAfter': new Date(13, 12, 2016)
'FinancialEventGroupStartedAfter': new Date(2016, 11, 24)
}, function (error, response) {
if (error) {
console.log('error ', error);
Expand Down Expand Up @@ -159,7 +157,7 @@ amazonMws.setApiKey(accessKey, accessSecret);
'Action': 'ListAllFulfillmentOrders',
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'QueryStartDateTime': new Date(13, 12, 2016)
'QueryStartDateTime': new Date(2016, 11, 24)
}, function (error, response) {
if (error) {
console.log('error ', error);
Expand Down Expand Up @@ -219,7 +217,7 @@ amazonMws.setApiKey(accessKey, accessSecret);
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'MarketplaceId': 'MARKET_PLACE_ID',
'QueryStartDateTime': new Date(13, 12, 2016)
'QueryStartDateTime': new Date(2016, 11, 24)
}, function (error, response) {
if (error) {
console.log('error ', error);
Expand Down Expand Up @@ -312,7 +310,7 @@ amazonMws.setApiKey(accessKey, accessSecret);
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'MarketplaceId.Id.1': 'MARKET_PLEACE_ID_1',
'LastUpdatedAfter': new Date(13, 12, 2016)
'LastUpdatedAfter': new Date(2016, 11, 24)
}, function (error, response) {
if (error) {
console.log('error ', error);
Expand All @@ -330,7 +328,7 @@ amazonMws.setApiKey(accessKey, accessSecret);
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'MarketplaceId.Id.1': 'MARKET_PLEACE_ID_1',
'LastUpdatedAfter': new Date(13, 12, 2016),
'LastUpdatedAfter': new Date(2016, 11, 24),
'OrderStatus.Status.1': 'Pending',
'OrderStatus.Status.2': 'Canceled'
}, function (error, response) {
Expand Down Expand Up @@ -448,7 +446,6 @@ amazonMws.setApiKey(accessKey, accessSecret);
return;
}
console.log('response', response);
// asynchronously called
});
```

Expand All @@ -466,7 +463,6 @@ amazonMws.setApiKey(accessKey, accessSecret);
return;
}
console.log('response', response);
// asynchronously called
});
```

Expand Down Expand Up @@ -523,7 +519,7 @@ amazonMws.setApiKey(accessKey, accessSecret);
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'MarketplaceId.Id.1': 'MARKET_PLEACE_ID_1',
'LastUpdatedAfter': new Date(13, 12, 2016)
'LastUpdatedAfter': new Date(2016, 11, 24)
}, function (error, response) {
if (error) {
console.log('error ', error);
Expand All @@ -535,7 +531,7 @@ amazonMws.setApiKey(accessKey, accessSecret);

#### Get Report
###### Using TypeScript.
```
```typescript
const accessKey = process.env.AWS_ACCESS_KEY_ID || 'YOUR_KEY';
const accessSecret = process.env.AWS_SECRET_ACCESS_KEY || 'YOUR_SECRET';

Expand All @@ -558,6 +554,29 @@ amazonMws.setApiKey(accessKey, accessSecret);
}
```

#### Success or Error StatusCode can be obtained directly using StatusCode property of response. It will give you same as what Amazon MWS provides.
#### It is also sample of the error responses.
```
{
Type:'Sender',
Code:'InvalidRequestException',
Message:'Invalid xxxxx: ',
Headers: {
'x-mws-quota-max': '',
'x-mws-quota-remaining': '',
'x-mws-quota-resetson': '',
'x-mws-timestamp': '2018-09-05T06:13:00.276Z',
'content-type': 'text/xml',
'content-charset': '',
'content-length': '',
'content-md5': '',
'date': ''
},
StatusCode:400,
RequestId: 'XXXXX-XXXXXX-XXXXX'
}
```

#### Additionally all api returns Throttling: Limits to how often you can submit requests
Reference : http://docs.developer.amazonservices.com/en_CA/dev_guide/DG_Throttling.html
```json
Expand Down
32 changes: 32 additions & 0 deletions examples/javaScript/feeds/getFeedSubmissionResultCharset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';

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

var amazonMws = require('../../../lib/amazon-mws')(accessKey, accessSecret);
var fse = require('fs-extra');

/**
* Use __CHARSET__ to override charset option.;
* This along with __RAW__ do not get written in the request.
* */
function feedRequest() {
var FeedSubmissionId = '10101010XXX';
amazonMws.feeds.search({
'Version': '2009-01-01',
'Action': 'GetFeedSubmissionResult',
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'FeedSubmissionId': FeedSubmissionId,
__CHARSET__: 'latin1'
}, function (error, response) {
if (error) {
console.log('error ', error);
return;
}
fse.writeFileSync('response.txt', response.data);
console.log('Headers', response.Headers);
});
}

feedRequest();
1 change: 0 additions & 1 deletion examples/javaScript/feeds/getFeedSubmissionResultRaw.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';
var fs = require('fs');

var accessKey = process.env.AWS_ACCESS_KEY_ID || 'YOUR_KEY';
var accessSecret = process.env.AWS_SECRET_ACCESS_KEY || 'YOUR_SECRET';
Expand Down
2 changes: 1 addition & 1 deletion examples/javaScript/finances/listFinancialEventGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var financeRequest = function () {
'Action': 'ListFinancialEventGroups',
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'FinancialEventGroupStartedAfter': new Date(13, 12, 2016)
'FinancialEventGroupStartedAfter': new Date(2016, 11, 24)
}, function (error, response) {
if (error) {
console.log('error ', error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var fulfillmentInventoryRequest = function () {
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'MarketplaceId': 'MARKET_PLACE_ID',
'QueryStartDateTime': new Date(13, 12, 2016)
'QueryStartDateTime': new Date(2016, 11, 24)
}, function (error, response) {
if (error) {
console.log('error ', error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var fulfillmentOutboundShipmentRequest = function () {
'Action': 'ListAllFulfillmentOrders',
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'QueryStartDateTime': new Date(13, 12, 2016)
'QueryStartDateTime': new Date(2016, 11, 24)
}, function (error, response) {
if (error) {
console.log('error ', error);
Expand Down
2 changes: 1 addition & 1 deletion examples/javaScript/orders/listOrders.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var orderRequest = function () {
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'MarketplaceId.Id.1': 'MARKET_PLEACE_ID_1',
'LastUpdatedAfter': new Date(13, 12, 2016)
'LastUpdatedAfter': new Date(2016, 11, 24)
}, function (error, response) {
if (error) {
console.log('error ', error);
Expand Down
2 changes: 1 addition & 1 deletion examples/javaScript/orders/listOrdersFilterStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var orderRequest = function () {
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'MarketplaceId.Id.1': 'MARKET_PLEACE_ID_1',
'LastUpdatedAfter': new Date(13, 12, 2016),
'LastUpdatedAfter': new Date(2016, 11, 24),
'OrderStatus.Status.1': 'Pending',
'OrderStatus.Status.2': 'Canceled'
}, function (error, response) {
Expand Down
2 changes: 1 addition & 1 deletion examples/javaScript/sample/listOrders.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var orderRequest = function () {
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'MarketplaceId.Id.1': 'MARKET_PLEACE_ID_1',
'LastUpdatedAfter': new Date(13, 12, 2016)
'LastUpdatedAfter': new Date(2016, 11, 24)
}, function (error, response) {
if (error) {
console.log('error ', error);
Expand Down
Loading

0 comments on commit f927a5f

Please sign in to comment.