Skip to content

Commit

Permalink
Merge pull request #1 from bhushankumarl/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
beastmike1 committed Nov 4, 2019
2 parents ce5a068 + d5231dd commit aabc243
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 21 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ Originally by [Bhushankumar L](mailto:bhushankumar.lilapara@gmail.com).
});
```

#### Submit Feed
#### 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({
Expand Down
17 changes: 0 additions & 17 deletions examples/javaScript/feeds/file.txt

This file was deleted.

43 changes: 43 additions & 0 deletions examples/javaScript/feeds/good.xml
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>
17 changes: 17 additions & 0 deletions examples/javaScript/feeds/image.xml
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>
17 changes: 17 additions & 0 deletions examples/javaScript/feeds/inventory.xml
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>
15 changes: 15 additions & 0 deletions examples/javaScript/feeds/price.xml
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>
19 changes: 19 additions & 0 deletions examples/javaScript/feeds/relation.xml
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>
2 changes: 1 addition & 1 deletion examples/javaScript/feeds/submitFeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var amazonMws = require('../../../lib/amazon-mws')(accessKey, accessSecret);
var fse = require('fs-extra');

var feedRequest = function () {
var FeedContent = fse.readFileSync('./file.txt', 'UTF-8');
var FeedContent = fse.readFileSync('./good.xml', 'UTF-8');
console.log('FeedContent ', FeedContent);

amazonMws.feeds.submit({
Expand Down
50 changes: 50 additions & 0 deletions examples/javaScript/feeds/variation-good.xml
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>
7 changes: 6 additions & 1 deletion lib/AmazonMwsMethod.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ function amazonMwsMethod(spec) {

function requestCallback(err, response) {
if (err) {
reject(err);
//Sometimes errors coming back are not true errors, just objects.
if(!(err instanceof Error)){
reject(new Error(err));
}else{
reject(err);
}
} else {
resolve(
spec.transformResponseData ?
Expand Down

0 comments on commit aabc243

Please sign in to comment.