Skip to content

Commit b0ddcc4

Browse files
author
Bhushankumar L
authored
Merge pull request #63 from bhushankumarl/development
Development
2 parents cf7df40 + ac1ef2b commit b0ddcc4

25 files changed

+610
-69
lines changed

.jshintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
examples/typeScript
3-
test/
3+
test/
4+
examples/javaScript/sample/getMatchingProductAsyncAwait.js

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
0.0.22
2+
- Bug Fix Default value for XML parsing
3+
- Add Support for the Subscription APIs, Recommendations API
4+
- Add Example for CreateSubscription, DeleteSubscription, ListSubscriptions, RegisterDestination
5+
- Add Example for GetLastUpdatedTimeForRecommendations, ListRecommendations
6+
17
0.0.21
28
- Handle for non content type responses
39
- Bug fix for GetMyPriceForASIN and similar other products API

README.md

Lines changed: 142 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,41 @@ amazonMws.setApiKey(accessKey, accessSecret);
5353
- Contributors can send their Pull Request to `development` branch.
5454
- Kindly validate test cases & linting before opening new PR.
5555

56+
#### Success or Error StatusCode can be obtained directly using StatusCode property of response. It will give you same as what Amazon MWS provides.
57+
#### It is also sample of the error responses.
58+
```
59+
{
60+
Type:'Sender',
61+
Code:'InvalidRequestException',
62+
Message:'Invalid xxxxx: ',
63+
Headers: {
64+
'x-mws-quota-max': '',
65+
'x-mws-quota-remaining': '',
66+
'x-mws-quota-resetson': '',
67+
'x-mws-timestamp': '2018-09-05T06:13:00.276Z',
68+
'content-type': 'text/xml',
69+
'content-charset': '',
70+
'content-length': '',
71+
'content-md5': '',
72+
'date': ''
73+
},
74+
StatusCode:400,
75+
RequestId: 'XXXXX-XXXXXX-XXXXX'
76+
}
77+
```
78+
79+
#### Additionally all api returns Throttling: Limits to how often you can submit requests
80+
Reference : http://docs.developer.amazonservices.com/en_CA/dev_guide/DG_Throttling.html
81+
```json
82+
{
83+
"x-mws-quota-max": "60.0",
84+
"x-mws-quota-remaining": "38.0",
85+
"x-mws-quota-resetson": "2017-12-08T08:21:00.000Z",
86+
"x-mws-timestamp": "2017-12-08T07:52:15.567Z"
87+
}
88+
```
89+
Originally by [Bhushankumar Lilapara](https://github.com/bhushankumarl) (bhushankumar.lilapara@gmail.com).
90+
5691
### Feeds
5792

5893
#### Submit Feed
@@ -300,7 +335,6 @@ amazonMws.setApiKey(accessKey, accessSecret);
300335
});
301336
```
302337

303-
304338
### Orders
305339

306340
#### List Orders
@@ -432,15 +466,16 @@ amazonMws.setApiKey(accessKey, accessSecret);
432466
});
433467
```
434468

435-
### Sellers
469+
### Recommendations
436470

437-
#### List Marketplace Participations
471+
#### Get Last Updated Time For Recommendations
438472
```js
439-
amazonMws.sellers.search({
440-
'Version': '2011-07-01',
441-
'Action': 'ListMarketplaceParticipations',
473+
amazonMws.recommendations.searchFor({
474+
'Version': '2013-04-01',
475+
'Action': 'GetLastUpdatedTimeForRecommendations',
442476
'SellerId': 'SELLER_ID',
443-
'MWSAuthToken': 'MWS_AUTH_TOKEN'
477+
'MWSAuthToken': 'MWS_AUTH_TOKEN',
478+
'MarketplaceId': 'MARKET_PLACE_ID'
444479
}, function (error, response) {
445480
if (error) {
446481
console.log('error ', error);
@@ -450,14 +485,17 @@ amazonMws.setApiKey(accessKey, accessSecret);
450485
});
451486
```
452487

453-
#### List Marketplace Participations By Next Token
488+
#### List Recommendations
454489
```js
455-
amazonMws.sellers.search({
456-
'Version': '2011-07-01',
457-
'Action': 'ListMarketplaceParticipationsByNextToken',
490+
amazonMws.recommendations.searchFor({
491+
'Version': '2013-04-01',
492+
'Action': 'ListRecommendations',
458493
'SellerId': 'SELLER_ID',
459494
'MWSAuthToken': 'MWS_AUTH_TOKEN',
460-
'NextToken': 'NEXT_TOKEN'
495+
'MarketplaceId': 'MARKET_PLACE_ID',
496+
'CategoryQueryList.CategoryQuery.1.FilterOptions.FilterOption.1': 'QualitySet=Defect',
497+
'CategoryQueryList.CategoryQuery.1.FilterOptions.FilterOption.2': 'ListingStatus=Active',
498+
'CategoryQueryList.CategoryQuery.1.RecommendationCategory': 'ListingQuality'
461499
}, function (error, response) {
462500
if (error) {
463501
console.log('error ', error);
@@ -555,37 +593,99 @@ amazonMws.setApiKey(accessKey, accessSecret);
555593
}
556594
```
557595

558-
#### Success or Error StatusCode can be obtained directly using StatusCode property of response. It will give you same as what Amazon MWS provides.
559-
#### It is also sample of the error responses.
596+
### Sellers
597+
598+
#### List Marketplace Participations
599+
```js
600+
amazonMws.sellers.search({
601+
'Version': '2011-07-01',
602+
'Action': 'ListMarketplaceParticipations',
603+
'SellerId': 'SELLER_ID',
604+
'MWSAuthToken': 'MWS_AUTH_TOKEN'
605+
}, function (error, response) {
606+
if (error) {
607+
console.log('error ', error);
608+
return;
609+
}
610+
console.log('response', response);
611+
});
560612
```
561-
{
562-
Type:'Sender',
563-
Code:'InvalidRequestException',
564-
Message:'Invalid xxxxx: ',
565-
Headers: {
566-
'x-mws-quota-max': '',
567-
'x-mws-quota-remaining': '',
568-
'x-mws-quota-resetson': '',
569-
'x-mws-timestamp': '2018-09-05T06:13:00.276Z',
570-
'content-type': 'text/xml',
571-
'content-charset': '',
572-
'content-length': '',
573-
'content-md5': '',
574-
'date': ''
575-
},
576-
StatusCode:400,
577-
RequestId: 'XXXXX-XXXXXX-XXXXX'
578-
}
613+
614+
#### List Marketplace Participations By Next Token
615+
```js
616+
amazonMws.sellers.search({
617+
'Version': '2011-07-01',
618+
'Action': 'ListMarketplaceParticipationsByNextToken',
619+
'SellerId': 'SELLER_ID',
620+
'MWSAuthToken': 'MWS_AUTH_TOKEN',
621+
'NextToken': 'NEXT_TOKEN'
622+
}, function (error, response) {
623+
if (error) {
624+
console.log('error ', error);
625+
return;
626+
}
627+
console.log('response', response);
628+
});
579629
```
580630

581-
#### Additionally all api returns Throttling: Limits to how often you can submit requests
582-
Reference : http://docs.developer.amazonservices.com/en_CA/dev_guide/DG_Throttling.html
583-
```json
584-
{
585-
"x-mws-quota-max": "60.0",
586-
"x-mws-quota-remaining": "38.0",
587-
"x-mws-quota-resetson": "2017-12-08T08:21:00.000Z",
588-
"x-mws-timestamp": "2017-12-08T07:52:15.567Z"
589-
}
631+
### Subscriptions
632+
633+
#### Create Subscription
634+
```js
635+
amazonMws.subscriptions.create({
636+
'Version': '2013-07-01',
637+
'Action': 'CreateSubscription',
638+
'SellerId': 'SELLER_ID',
639+
'MWSAuthToken': 'MWS_AUTH_TOKEN',
640+
'MarketplaceId': 'MARKET_PLACE_ID',
641+
'Subscription.Destination.AttributeList.member.1.Key': 'DESTINATION_KEY',
642+
'Subscription.Destination.AttributeList.member.1.Value': 'DESTINATION_VALUE',
643+
'Subscription.Destination.DeliveryChannel': 'DESTINATION_CHANNEL',
644+
'Subscription.IsEnabled': 'true',
645+
'Subscription.NotificationType': 'AnyOfferChanged'
646+
}, function (error, response) {
647+
if (error) {
648+
console.log('error ', error);
649+
return;
650+
}
651+
console.log('response', response);
652+
});
590653
```
591-
Originally by [Bhushankumar Lilapara](https://github.com/bhushankumarl) (bhushankumar.lilapara@gmail.com).
654+
655+
#### Delete Subscription
656+
```js
657+
amazonMws.subscriptions.remove({
658+
'Version': '2013-07-01',
659+
'Action': 'DeleteSubscription',
660+
'SellerId': 'SELLER_ID',
661+
'MWSAuthToken': 'MWS_AUTH_TOKEN',
662+
'MarketplaceId': 'MARKET_PLACE_ID',
663+
'Destination.AttributeList.member.1.Key': 'DESTINATION_KEY',
664+
'Destination.AttributeList.member.1.Value': 'DESTINATION_VALUE',
665+
'Destination.DeliveryChannel': 'DESTINATION_CHANNEL',
666+
'NotificationType': 'AnyOfferChanged'
667+
}, function (error, response) {
668+
if (error) {
669+
console.log('error ', error);
670+
return;
671+
}
672+
console.log('response', response);
673+
});
674+
```
675+
676+
#### List Subscription
677+
```js
678+
amazonMws.subscriptions.searchFor({
679+
'Version': '2013-07-01',
680+
'Action': 'ListSubscriptions',
681+
'SellerId': 'SELLER_ID',
682+
'MWSAuthToken': 'MWS_AUTH_TOKEN',
683+
'MarketplaceId': 'MARKET_PLACE_ID'
684+
}, function (error, response) {
685+
if (error) {
686+
console.log('error ', error);
687+
return;
688+
}
689+
console.log('response', response);
690+
});
691+
```

examples/javaScript/orders/listOrders.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var orderRequest = function () {
1111
'Action': 'ListOrders',
1212
'SellerId': 'SELLER_ID',
1313
'MWSAuthToken': 'MWS_AUTH_TOKEN',
14-
'MarketplaceId.Id.1': 'MARKET_PLEACE_ID_1',
14+
'MarketplaceId.Id.1': 'MARKET_PLACE_ID_1',
1515
'LastUpdatedAfter': new Date(2016, 11, 24)
1616
}, function (error, response) {
1717
if (error) {

examples/javaScript/orders/listOrdersFilterStatus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var orderRequest = function () {
1212
'Action': 'ListOrders',
1313
'SellerId': 'SELLER_ID',
1414
'MWSAuthToken': 'MWS_AUTH_TOKEN',
15-
'MarketplaceId.Id.1': 'MARKET_PLEACE_ID_1',
15+
'MarketplaceId.Id.1': 'MARKET_PLACE_ID_1',
1616
'LastUpdatedAfter': new Date(2016, 11, 24),
1717
'OrderStatus.Status.1': 'Pending',
1818
'OrderStatus.Status.2': 'Canceled'
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
8+
var productRequest = function () {
9+
amazonMws.products.searchFor({
10+
'Version': '2011-10-01',
11+
'Action': 'GetCompetitivePricingForASIN',
12+
'SellerId': 'SELLER_ID',
13+
'MWSAuthToken': 'MWS_AUTH_TOKEN',
14+
'MarketplaceId': 'MARKET_PLACE_ID',
15+
'ASINList.ASIN.1': 'ASIN'
16+
}, function (error, response) {
17+
if (error) {
18+
console.log('error products', error);
19+
return;
20+
}
21+
console.log('response ', response);
22+
});
23+
};
24+
25+
productRequest();
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
8+
var productRequest = function () {
9+
10+
amazonMws.products.search({
11+
'Version': '2011-10-01',
12+
'Action': 'GetMatchingProductForId',
13+
'SellerId': 'SELLER_ID',
14+
'MWSAuthToken': 'MWS_AUTH_TOKEN',
15+
'MarketplaceId': 'MARKET_PLACE_ID',
16+
'IdType': 'SellerSKU',
17+
'IdList.Id.1': 'SKU'
18+
}, function (error, response) {
19+
if (error) {
20+
console.log('error products', error);
21+
return;
22+
}
23+
console.log('response', response);
24+
});
25+
};
26+
27+
productRequest();
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
8+
/**
9+
* If the response is empty than it means their is no recommendation.
10+
*/
11+
var recommendationRequest = function () {
12+
amazonMws.recommendations.searchFor({
13+
'Version': '2013-04-01',
14+
'Action': 'GetLastUpdatedTimeForRecommendations',
15+
'SellerId': 'SELLER_ID',
16+
'MWSAuthToken': 'MWS_AUTH_TOKEN',
17+
'MarketplaceId': 'MARKET_PLACE_ID'
18+
}, function (error, response) {
19+
if (error) {
20+
console.log('error ', error);
21+
return;
22+
}
23+
console.log('response', response);
24+
});
25+
};
26+
27+
recommendationRequest();
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
8+
/**
9+
* If the response is empty than it means their is no recommendation.
10+
*/
11+
var recommendationRequest = function () {
12+
amazonMws.recommendations.searchFor({
13+
'Version': '2013-04-01',
14+
'Action': 'ListRecommendations',
15+
'SellerId': 'SELLER_ID',
16+
'MWSAuthToken': 'MWS_AUTH_TOKEN',
17+
'MarketplaceId': 'MARKET_PLACE_ID',
18+
'CategoryQueryList.CategoryQuery.1.FilterOptions.FilterOption.1': 'QualitySet=Defect',
19+
'CategoryQueryList.CategoryQuery.1.FilterOptions.FilterOption.2': 'ListingStatus=Active',
20+
'CategoryQueryList.CategoryQuery.1.RecommendationCategory': 'ListingQuality'
21+
}, function (error, response) {
22+
if (error) {
23+
console.log('error ', error);
24+
return;
25+
}
26+
console.log('response', response);
27+
});
28+
};
29+
30+
recommendationRequest();

0 commit comments

Comments
 (0)