File tree Expand file tree Collapse file tree 6 files changed +71
-21
lines changed
examples/javaScript/sample Expand file tree Collapse file tree 6 files changed +71
-21
lines changed Original file line number Diff line number Diff line change 110.0.24
22 - Add Subscription in Typescript definition
33 - Correct Documentation
4- - Allow response type into XML format
4+ - Allow user to change response type into XML format
5+ - Allow user to change content type for request
56
670.0.23
78 - Bug Fix for Feed Result charset
Original file line number Diff line number Diff line change @@ -790,6 +790,25 @@ Originally by [Bhushankumar L](mailto:bhushankumar.lilapara@gmail.com).
790790 });
791791```
792792
793+ #### Request Report Content Type
794+ ```
795+ amazonMws.setContentType('application/json');
796+
797+ amazonMws.reports.submit({
798+ 'Version': '2009-01-01',
799+ 'Action': 'RequestReport',
800+ 'SellerId': 'SELLER_ID',
801+ 'MWSAuthToken': 'MWS_AUTH_TOKEN',
802+ 'ReportType': '_GET_MERCHANT_LISTINGS_ALL_DATA_'
803+ }, function (error, response) {
804+ if (error) {
805+ console.log('error ', error);
806+ return;
807+ }
808+ console.log('response', response);
809+ });
810+ ```
811+
793812#### Request Report XML Response
794813```
795814 amazonMws.setResponseFormat('XML');
Original file line number Diff line number Diff line change 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+ * This example has been written to override/set the contentType of the request.
10+ */
11+
12+ var reportRequest = function ( ) {
13+ amazonMws . setContentType ( 'application/json' ) ;
14+
15+ amazonMws . reports . submit ( {
16+ 'Version' : '2009-01-01' ,
17+ 'Action' : 'RequestReport' ,
18+ 'SellerId' : 'SELLER_ID' ,
19+ 'MWSAuthToken' : 'MWS_AUTH_TOKEN' ,
20+ 'ReportType' : '_GET_MERCHANT_LISTINGS_ALL_DATA_'
21+ } , function ( error , response ) {
22+ if ( error ) {
23+ console . log ( 'error ' , error ) ;
24+ return ;
25+ }
26+ console . log ( 'response' , response ) ;
27+ } ) ;
28+ } ;
29+
30+ reportRequest ( ) ;
Original file line number Diff line number Diff line change @@ -74,38 +74,30 @@ declare class Subscriptions extends BaseAmazonMWS {
7474
7575declare class AmazonMWS {
7676
77- constructor ( )
78-
79- constructor ( key : string , token : string ) ;
80-
81- setApiKey ( key : string , secret : string ) : void ;
82-
83- setHost ( host ?: string , port ?: string , protocol ?: string ) : void ;
84-
85- setResponseFormat ( responseFormat : string ) : void ;
86-
8777 feeds : Feeds ;
88-
8978 finances : Finances ;
90-
9179 fulfillmentInboundShipment : FulfillmentInboundShipment ;
92-
9380 fulfillmentInventory : FulfillmentInventory ;
94-
9581 fulfillmentOutboundShipment : FulfillmentOutboundShipment ;
96-
9782 merchantFulfillment : MerchantFulfillment ;
98-
9983 orders : Orders ;
100-
10184 products : Products ;
102-
10385 reports : Reports ;
104-
10586 sellers : Sellers ;
106-
10787 subscriptions : Subscriptions ;
10888
89+ constructor ( )
90+
91+ constructor ( key : string , token : string ) ;
92+
93+ setApiKey ( key : string , secret : string ) : void ;
94+
95+ setHost ( host ?: string , port ?: string , protocol ?: string ) : void ;
96+
97+ setResponseFormat ( responseFormat : string ) : void ;
98+
99+ setContentType ( setContentType : string ) : void ;
100+
109101}
110102
111103
Original file line number Diff line number Diff line change @@ -482,6 +482,10 @@ AmazonMwsResource.prototype = {
482482 self . body = self . requestParams ;
483483 }
484484
485+ if ( self . _AmazonMws . getApiField ( 'contentType' ) ) {
486+ headers [ 'Content-Type' ] = self . _AmazonMws . getApiField ( 'contentType' ) ;
487+ }
488+
485489 // Make a deep copy of the request params, assign to block scoped variable
486490 var requestParamsCopy = JSON . parse ( JSON . stringify ( self . requestParams ) ) ;
487491 var requestParamsJSONCopy = JSON . parse ( JSON . stringify ( self . requestParamsJSON ) ) ;
Original file line number Diff line number Diff line change @@ -99,6 +99,10 @@ AmazonMws.prototype = {
9999 this . _setApiField ( 'format' , format ) ;
100100 } ,
101101
102+ setContentType : function ( contentType ) {
103+ this . _setApiField ( 'contentType' , contentType ) ;
104+ } ,
105+
102106 setApiVersion : function ( version ) {
103107 if ( version ) {
104108 this . _setApiField ( 'version' , version ) ;
You can’t perform that action at this time.
0 commit comments