Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
BL committed Oct 22, 2018
2 parents 8e50985 + 9d9d35d commit ac1ef2b
Show file tree
Hide file tree
Showing 22 changed files with 501 additions and 52 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
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();
25 changes: 25 additions & 0 deletions examples/javaScript/sample/getMatchingProductAsyncAwait.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 = async function () {

try {
var response = await amazonMws.products.search({
'Version': '2011-10-01',
'Action': 'GetMatchingProduct',
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'MarketplaceId': 'MARKET_PLACE_ID',
'ASINList.ASIN.1': 'ASIN_1'
});
console.log('response', response);
} catch (error) {
console.log('error products', error);
}
};

productRequest();
2 changes: 1 addition & 1 deletion examples/javaScript/sample/listOrders.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,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
29 changes: 29 additions & 0 deletions examples/javaScript/subscriptions/createSubscription.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'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 subscriptionRequest = function () {
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);
});
};

subscriptionRequest();
Loading

0 comments on commit ac1ef2b

Please sign in to comment.