-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from bhushankumarl/development
Development
- Loading branch information
Showing
27 changed files
with
1,022 additions
and
667 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[vcbuild.bat] | ||
end_of_line = crlf | ||
|
||
[Makefile] | ||
indent_size = 8 | ||
indent_style = tab | ||
|
||
[{deps}/**] | ||
charset = unset | ||
end_of_line = unset | ||
indent_size = unset | ||
indent_style = unset | ||
trim_trailing_whitespace = unset | ||
|
||
[{test/fixtures,deps,tools/node_modules,tools/gyp,tools/icu,tools/msvs}/**] | ||
insert_final_newline = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,12 @@ export DEBUG=MWS:* | |
```bash | ||
export AWS_ACCESS_KEY_ID=KEY | ||
export AWS_SECRET_ACCESS_KEY=SECRET | ||
|
||
#optional MWS Token | ||
export MWS_AUTH_TOKEN=TOKEN | ||
|
||
#optional proxy | ||
export MARKETPLACE_PROXY=http://your.proxy.domain | ||
``` | ||
|
||
## Configuration Using JavaScript | ||
|
@@ -174,9 +180,47 @@ Originally by [Bhushankumar L](mailto:[email protected]). | |
}); | ||
``` | ||
|
||
#### Submit Feed | ||
#### Get Feed Submission Result as Stream | ||
``` | ||
/** | ||
* Use __STREAM__ to get the request in response; | ||
*/ | ||
var FeedSubmissionId = '10101010XXX'; | ||
amazonMws.feeds.search({ | ||
'Version': '2009-01-01', | ||
'Action': 'GetFeedSubmissionResult', | ||
'SellerId': 'SELLER_ID', | ||
'MWSAuthToken': 'MWS_AUTH_TOKEN', | ||
'FeedSubmissionId': FeedSubmissionId, | ||
__STREAM__: true | ||
}, function (error, response) { | ||
if (error) { | ||
console.log('error ', error); | ||
return; | ||
} | ||
response | ||
.pipe(iconv.decodeStream('ISO-8859-1')) | ||
.pipe( | ||
csv.parse({ | ||
delimiter: '\t', | ||
headers: true, | ||
discardUnmappedColumns: true, | ||
quote: null, | ||
ignoreEmpty: true, | ||
trim: true | ||
}) | ||
) | ||
.on('data', row => { | ||
processRow(row); | ||
}) | ||
.on('error', error => { console.error(error); }) | ||
.on('end', rowCount => { console.log(`Processed rows ${rowCount}`); }); | ||
}); | ||
``` | ||
|
||
#### Submit Feed [more feed xml demo](https://github.com/bhushankumarl/amazon-mws/tree/master/examples/javascript/feeds). or see https://images-cn.ssl-images-amazon.com/images/G/28/rainier/help/XML_Documentation_Intl._V158771171_.pdf | ||
``` | ||
var FeedContent = fse.readFileSync('./file.txt', 'UTF-8'); | ||
var FeedContent = fse.readFileSync('./good.xml', 'UTF-8'); | ||
console.log('FeedContent ', FeedContent); | ||
amazonMws.feeds.submit({ | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amznenvelope.xsd"> | ||
<Header> | ||
<DocumentVersion>1.01</DocumentVersion> | ||
<MerchantIdentifier>SellerID</MerchantIdentifier> | ||
</Header> | ||
<MessageType>Product</MessageType> | ||
<PurgeAndReplace>false</PurgeAndReplace> | ||
<Message> | ||
<MessageID>1</MessageID> | ||
<OperationType>Update</OperationType> | ||
<Product> | ||
<SKU>xxx-9527</SKU> | ||
<StandardProductID> | ||
<Type>EAN</Type> | ||
<Value>xxxxx</Value> | ||
</StandardProductID> | ||
<ProductTaxCode>A_GEN_NOTAX</ProductTaxCode> | ||
<DescriptionData> | ||
<Title>Example Product Title</Title> | ||
<Brand>Example Product Brand</Brand> | ||
<Description>This is an example product description.</Description> | ||
<BulletPoint>Example Bullet Point 1</BulletPoint> | ||
<BulletPoint>Example Bullet Point 2</BulletPoint> | ||
<MSRP currency="JPY">55.55</MSRP> | ||
<Manufacturer>Example Product Manufacturer</Manufacturer> | ||
<SearchTerms>yaodian1</SearchTerms> | ||
<SearchTerms>yaodian2</SearchTerms> | ||
<ItemType>example-item-type</ItemType> | ||
</DescriptionData> | ||
<ProductData> | ||
<Health> | ||
<ProductType> | ||
<HealthMisc> | ||
<Ingredients>Example Ingredients</Ingredients> | ||
<Directions>Example Directions</Directions> | ||
</HealthMisc> | ||
</ProductType> | ||
</Health> | ||
</ProductData> | ||
</Product> | ||
</Message> | ||
</AmazonEnvelope> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amznenvelope.xsd"> | ||
<Header> | ||
<DocumentVersion>1.01</DocumentVersion> | ||
<MerchantIdentifier>SellerID</MerchantIdentifier> | ||
</Header> | ||
<MessageType>ProductImage</MessageType> | ||
<Message> | ||
<MessageID>1</MessageID> | ||
<OperationType>Update</OperationType> | ||
<ProductImage> | ||
<SKU>sku</SKU> | ||
<ImageType>Swatch</ImageType> | ||
<ImageLocation>http://images.pexels.com/photos/104827/cat-pet-animal-domestic-104827.jpeg</ImageLocation> | ||
</ProductImage> | ||
</Message> | ||
</AmazonEnvelope> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amznenvelope.xsd"> | ||
<Header> | ||
<DocumentVersion>1.01</DocumentVersion> | ||
<MerchantIdentifier>SellerID</MerchantIdentifier> | ||
</Header> | ||
<MessageType>Inventory</MessageType> | ||
<Message> | ||
<MessageID>1</MessageID> | ||
<OperationType>Update</OperationType> | ||
<Inventory> | ||
<SKU>SKU</SKU> | ||
<Quantity>9527</Quantity> | ||
<FulfillmentLatency>1</FulfillmentLatency> | ||
</Inventory> | ||
</Message> | ||
</AmazonEnvelope> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amznenvelope.xsd"> | ||
<Header> | ||
<DocumentVersion>1.01</DocumentVersion> | ||
<MerchantIdentifier>SellerID</MerchantIdentifier> | ||
</Header> | ||
<MessageType>Price</MessageType> | ||
<Message> | ||
<MessageID>1</MessageID> | ||
<Price> | ||
<SKU>SKU</SKU> | ||
<StandardPrice currency="DEFAULT">99.99</StandardPrice> | ||
</Price> | ||
</Message> | ||
</AmazonEnvelope> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amznenvelope.xsd"> | ||
<Header> | ||
<DocumentVersion>1.01</DocumentVersion> | ||
<MerchantIdentifier>SellerID</MerchantIdentifier> | ||
</Header> | ||
<MessageType>Relationship</MessageType> | ||
<Message> | ||
<MessageID>1</MessageID> | ||
<OperationType>Update</OperationType> | ||
<Relationship> | ||
<ParentSKU>paret-sku</ParentSKU> | ||
<Relation> | ||
<SKU>child-sku</SKU> | ||
<Type>Variation</Type> | ||
</Relation> | ||
</Relationship> | ||
</Message> | ||
</AmazonEnvelope> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0" encoding="iso-8859-1"?> | ||
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="amzn-envelope.xsd"> | ||
<Header> | ||
<DocumentVersion>1.01</DocumentVersion> | ||
<MerchantIdentifier>SellerID</MerchantIdentifier> | ||
</Header> | ||
<MessageType>Product</MessageType> | ||
<PurgeAndReplace>false</PurgeAndReplace> | ||
<Message> | ||
<MessageID>1</MessageID> | ||
<OperationType>Update</OperationType> | ||
<Product> | ||
<SKU>SKU</SKU> | ||
<StandardProductID> | ||
<Type>EAN</Type> | ||
<Value>XXX</Value> | ||
</StandardProductID> | ||
<ProductTaxCode>A_GEN_NOTAX</ProductTaxCode> | ||
<DescriptionData> | ||
<Title>Example Parent</Title> | ||
<Brand>Example Product Brand</Brand> | ||
<Description>This is an example product description.</Description> | ||
<BulletPoint>Example Bullet Point 1</BulletPoint> | ||
<BulletPoint>Example Bullet Point 2</BulletPoint> | ||
<MSRP currency="JPY">55.55</MSRP> | ||
<Manufacturer>Example Product Manufacturer</Manufacturer> | ||
<SearchTerms>yaodian1</SearchTerms> | ||
<SearchTerms>yaodian2</SearchTerms> | ||
<ItemType>example-item-type</ItemType> | ||
<RecommendedBrowseNode>4284945031</RecommendedBrowseNode> | ||
</DescriptionData> | ||
<ProductData> | ||
<Home> | ||
<ProductType> | ||
<OutdoorLiving></OutdoorLiving> | ||
</ProductType> | ||
<Parentage>variation-parent</Parentage> | ||
<VariationData> | ||
<VariationTheme>Size-Color</VariationTheme> | ||
<Size>XXL</Size> | ||
<Color>RED</Color> | ||
</VariationData> | ||
<Material>cotton</Material> | ||
<ThreadCount>500</ThreadCount> | ||
</Home> | ||
</ProductData> | ||
</Product> | ||
</Message> | ||
</AmazonEnvelope> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
'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 csv = require('fast-csv'); | ||
var iconv = require('iconv-lite'); | ||
|
||
var reportRequest = function () { | ||
/** | ||
* This will not provide you Throttling details in Header. | ||
* Amazon MWS itself not providing Throttling detail in GetReport call. | ||
*/ | ||
amazonMws.setHost('YOUR HOST'); | ||
amazonMws.reports.search({ | ||
'Version': '2009-01-01', | ||
'Action': 'GetReport', | ||
'SellerId': 'SELLER_ID', | ||
'MWSAuthToken': 'MWS_AUTH_TOKEN', | ||
'ReportId': 'REPORT_ID', | ||
'__STREAM__': true | ||
}, function (error, response) { | ||
if (error) { | ||
console.log('error ', error); | ||
return; | ||
} | ||
|
||
var rows = []; | ||
function processRowsInBatches(row, end, callback) { | ||
if (typeof end === 'undefined') { | ||
end = false; | ||
} | ||
if (row) { | ||
rows.push(row); | ||
} | ||
if (rows.length >= 5000 || (end && rows.length)) { | ||
sendToDB(rows.splice(0, 0), callback); | ||
rows = []; | ||
} | ||
} | ||
|
||
function sendToDB(data, callback) { | ||
// Send your data to the db | ||
console.log(data.length); | ||
callback(); | ||
} | ||
|
||
var decodeStream = iconv.decodeStream('ISO-8859-1'); | ||
response.pipe(decodeStream); | ||
var csvStream = csv.parse({ | ||
delimiter: '\t', | ||
headers: true, | ||
discardUnmappedColumns: true, | ||
ignoreEmpty: true, | ||
trim: true | ||
}); | ||
decodeStream.pipe(csvStream); | ||
csvStream.transform(function (data, cb) { | ||
processRowsInBatches(data, false, cb); | ||
}); | ||
csvStream | ||
.on('error', function (error) { console.error(error); }) | ||
.on('finish', function () { | ||
console.log('Finished proccessing stream'); | ||
// Call processRowsInBatches to proccess remaining rows | ||
processRowsInBatches(undefined, true, function () { | ||
console.log('Saved last rows in the db'); | ||
}); | ||
}); | ||
}); | ||
}; | ||
|
||
reportRequest(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.