Skip to content

Commit

Permalink
Merge pull request #63 from bhushankumarl/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Bhushankumar L authored Oct 22, 2018
2 parents cf7df40 + ac1ef2b commit b0ddcc4
Show file tree
Hide file tree
Showing 25 changed files with 610 additions and 69 deletions.
3 changes: 2 additions & 1 deletion .jshintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
examples/typeScript
test/
test/
examples/javaScript/sample/getMatchingProductAsyncAwait.js
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
0.0.22
- Bug Fix Default value for XML parsing
- Add Support for the Subscription APIs, Recommendations API
- Add Example for CreateSubscription, DeleteSubscription, ListSubscriptions, RegisterDestination
- Add Example for GetLastUpdatedTimeForRecommendations, ListRecommendations

0.0.21
- Handle for non content type responses
- Bug fix for GetMyPriceForASIN and similar other products API
Expand Down
184 changes: 142 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,41 @@ amazonMws.setApiKey(accessKey, accessSecret);
- Contributors can send their Pull Request to `development` branch.
- Kindly validate test cases & linting before opening new PR.

#### 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
{
"x-mws-quota-max": "60.0",
"x-mws-quota-remaining": "38.0",
"x-mws-quota-resetson": "2017-12-08T08:21:00.000Z",
"x-mws-timestamp": "2017-12-08T07:52:15.567Z"
}
```
Originally by [Bhushankumar Lilapara](https://github.com/bhushankumarl) ([email protected]).

### Feeds

#### Submit Feed
Expand Down Expand Up @@ -300,7 +335,6 @@ amazonMws.setApiKey(accessKey, accessSecret);
});
```


### Orders

#### List Orders
Expand Down Expand Up @@ -432,15 +466,16 @@ amazonMws.setApiKey(accessKey, accessSecret);
});
```

### Sellers
### Recommendations

#### List Marketplace Participations
#### Get Last Updated Time For Recommendations
```js
amazonMws.sellers.search({
'Version': '2011-07-01',
'Action': 'ListMarketplaceParticipations',
amazonMws.recommendations.searchFor({
'Version': '2013-04-01',
'Action': 'GetLastUpdatedTimeForRecommendations',
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN'
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'MarketplaceId': 'MARKET_PLACE_ID'
}, function (error, response) {
if (error) {
console.log('error ', error);
Expand All @@ -450,14 +485,17 @@ amazonMws.setApiKey(accessKey, accessSecret);
});
```

#### List Marketplace Participations By Next Token
#### List Recommendations
```js
amazonMws.sellers.search({
'Version': '2011-07-01',
'Action': 'ListMarketplaceParticipationsByNextToken',
amazonMws.recommendations.searchFor({
'Version': '2013-04-01',
'Action': 'ListRecommendations',
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'NextToken': 'NEXT_TOKEN'
'MarketplaceId': 'MARKET_PLACE_ID',
'CategoryQueryList.CategoryQuery.1.FilterOptions.FilterOption.1': 'QualitySet=Defect',
'CategoryQueryList.CategoryQuery.1.FilterOptions.FilterOption.2': 'ListingStatus=Active',
'CategoryQueryList.CategoryQuery.1.RecommendationCategory': 'ListingQuality'
}, function (error, response) {
if (error) {
console.log('error ', error);
Expand Down Expand Up @@ -555,37 +593,99 @@ 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.
### Sellers

#### List Marketplace Participations
```js
amazonMws.sellers.search({
'Version': '2011-07-01',
'Action': 'ListMarketplaceParticipations',
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN'
}, function (error, response) {
if (error) {
console.log('error ', error);
return;
}
console.log('response', response);
});
```
{
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'
}

#### List Marketplace Participations By Next Token
```js
amazonMws.sellers.search({
'Version': '2011-07-01',
'Action': 'ListMarketplaceParticipationsByNextToken',
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'NextToken': 'NEXT_TOKEN'
}, function (error, response) {
if (error) {
console.log('error ', error);
return;
}
console.log('response', response);
});
```

#### 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
{
"x-mws-quota-max": "60.0",
"x-mws-quota-remaining": "38.0",
"x-mws-quota-resetson": "2017-12-08T08:21:00.000Z",
"x-mws-timestamp": "2017-12-08T07:52:15.567Z"
}
### Subscriptions

#### Create Subscription
```js
amazonMws.subscriptions.create({
'Version': '2013-07-01',
'Action': 'CreateSubscription',
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'MarketplaceId': 'MARKET_PLACE_ID',
'Subscription.Destination.AttributeList.member.1.Key': 'DESTINATION_KEY',
'Subscription.Destination.AttributeList.member.1.Value': 'DESTINATION_VALUE',
'Subscription.Destination.DeliveryChannel': 'DESTINATION_CHANNEL',
'Subscription.IsEnabled': 'true',
'Subscription.NotificationType': 'AnyOfferChanged'
}, function (error, response) {
if (error) {
console.log('error ', error);
return;
}
console.log('response', response);
});
```
Originally by [Bhushankumar Lilapara](https://github.com/bhushankumarl) ([email protected]).

#### Delete Subscription
```js
amazonMws.subscriptions.remove({
'Version': '2013-07-01',
'Action': 'DeleteSubscription',
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'MarketplaceId': 'MARKET_PLACE_ID',
'Destination.AttributeList.member.1.Key': 'DESTINATION_KEY',
'Destination.AttributeList.member.1.Value': 'DESTINATION_VALUE',
'Destination.DeliveryChannel': 'DESTINATION_CHANNEL',
'NotificationType': 'AnyOfferChanged'
}, function (error, response) {
if (error) {
console.log('error ', error);
return;
}
console.log('response', response);
});
```

#### List Subscription
```js
amazonMws.subscriptions.searchFor({
'Version': '2013-07-01',
'Action': 'ListSubscriptions',
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'MarketplaceId': 'MARKET_PLACE_ID'
}, function (error, response) {
if (error) {
console.log('error ', error);
return;
}
console.log('response', response);
});
```
2 changes: 1 addition & 1 deletion examples/javaScript/orders/listOrders.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var orderRequest = function () {
'Action': 'ListOrders',
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'MarketplaceId.Id.1': 'MARKET_PLEACE_ID_1',
'MarketplaceId.Id.1': 'MARKET_PLACE_ID_1',
'LastUpdatedAfter': new Date(2016, 11, 24)
}, function (error, response) {
if (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 @@ -12,7 +12,7 @@ var orderRequest = function () {
'Action': 'ListOrders',
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'MarketplaceId.Id.1': 'MARKET_PLEACE_ID_1',
'MarketplaceId.Id.1': 'MARKET_PLACE_ID_1',
'LastUpdatedAfter': new Date(2016, 11, 24),
'OrderStatus.Status.1': 'Pending',
'OrderStatus.Status.2': 'Canceled'
Expand Down
25 changes: 25 additions & 0 deletions examples/javaScript/products/getCompetitivePricingForASIN.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'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 productRequest = function () {
amazonMws.products.searchFor({
'Version': '2011-10-01',
'Action': 'GetCompetitivePricingForASIN',
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'MarketplaceId': 'MARKET_PLACE_ID',
'ASINList.ASIN.1': 'ASIN'
}, function (error, response) {
if (error) {
console.log('error products', error);
return;
}
console.log('response ', response);
});
};

productRequest();
27 changes: 27 additions & 0 deletions examples/javaScript/products/getMatchingProductForId.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'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 productRequest = function () {

amazonMws.products.search({
'Version': '2011-10-01',
'Action': 'GetMatchingProductForId',
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'MarketplaceId': 'MARKET_PLACE_ID',
'IdType': 'SellerSKU',
'IdList.Id.1': 'SKU'
}, function (error, response) {
if (error) {
console.log('error products', error);
return;
}
console.log('response', response);
});
};

productRequest();
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'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);

/**
* If the response is empty than it means their is no recommendation.
*/
var recommendationRequest = function () {
amazonMws.recommendations.searchFor({
'Version': '2013-04-01',
'Action': 'GetLastUpdatedTimeForRecommendations',
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'MarketplaceId': 'MARKET_PLACE_ID'
}, function (error, response) {
if (error) {
console.log('error ', error);
return;
}
console.log('response', response);
});
};

recommendationRequest();
30 changes: 30 additions & 0 deletions examples/javaScript/recommendations/listRecommendations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'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);

/**
* If the response is empty than it means their is no recommendation.
*/
var recommendationRequest = function () {
amazonMws.recommendations.searchFor({
'Version': '2013-04-01',
'Action': 'ListRecommendations',
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'MarketplaceId': 'MARKET_PLACE_ID',
'CategoryQueryList.CategoryQuery.1.FilterOptions.FilterOption.1': 'QualitySet=Defect',
'CategoryQueryList.CategoryQuery.1.FilterOptions.FilterOption.2': 'ListingStatus=Active',
'CategoryQueryList.CategoryQuery.1.RecommendationCategory': 'ListingQuality'
}, function (error, response) {
if (error) {
console.log('error ', error);
return;
}
console.log('response', response);
});
};

recommendationRequest();
Loading

0 comments on commit b0ddcc4

Please sign in to comment.