Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
abuzuhri committed Nov 23, 2022
2 parents 803451e + e4e1552 commit 0527d0e
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 145 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ AmazonConnection amazonConnection = new AmazonConnection(new AmazonCredential()

```

### Order List, For more orders sample please check [Here](https://github.com/abuzuhri/Amazon-SP-API-CSharp/blob/main/Source/FikaAmazonAPI.Test/Reports.cs).
### Order List, For more orders sample please check [Here](https://github.com/abuzuhri/Amazon-SP-API-CSharp/blob/main/Source/FikaAmazonAPI.SampleCode/ReportsSample.cs).
```CSharp
ParameterOrderList serachOrderList = new ParameterOrderList();
serachOrderList.CreatedAfter = DateTime.UtcNow.AddMinutes(-600000);
Expand Down Expand Up @@ -184,7 +184,7 @@ var orders = amazonConnection.Orders.GetOrders
);
```

### Report List, For more report sample please check [Here](https://github.com/abuzuhri/Amazon-SP-API-CSharp/blob/main/Source/FikaAmazonAPI.Test/Orders.cs).
### Report List, For more report sample please check [Here](https://github.com/abuzuhri/Amazon-SP-API-CSharp/blob/main/Source/FikaAmazonAPI.SampleCode/OrdersSample.cs).
```CSharp
var parameters = new ParameterReportList();
parameters.pageSize = 100;
Expand Down Expand Up @@ -301,7 +301,7 @@ var data = await amazonConnection.CatalogItem.SearchCatalogItems202204Async(



### Product Pricing, For more Pricing sample please check [Here](https://github.com/abuzuhri/Amazon-SP-API-CSharp/blob/main/Source/FikaAmazonAPI.Test/ProductPricing.cs).
### Product Pricing, For more Pricing sample please check [Here](https://github.com/abuzuhri/Amazon-SP-API-CSharp/blob/main/Source/FikaAmazonAPI.SampleCode/ProductPricingSample.cs).
```CSharp

var data = amazonConnection.ProductPricing.GetPricing(
Expand All @@ -325,7 +325,7 @@ var data = amazonConnection.ProductPricing.GetCompetitivePricing(
```


### Notifications Create Destination, For more Notifications sample please check [Here](https://github.com/abuzuhri/Amazon-SP-API-CSharp/blob/main/Source/FikaAmazonAPI.Test/Notifications.cs).
### Notifications Create Destination, For more Notifications sample please check [Here](https://github.com/abuzuhri/Amazon-SP-API-CSharp/blob/main/Source/FikaAmazonAPI.SampleCode/NotificationsSample.cs).
```CSharp

//EventBridge
Expand All @@ -351,7 +351,7 @@ var dataSqs = amazonConnection.Notification.CreateDestination(
});
```

### Notifications Create Subscription, For more Notifications sample please check [Here](https://github.com/abuzuhri/Amazon-SP-API-CSharp/blob/main/Source/FikaAmazonAPI.Test/Notifications.cs).
### Notifications Create Subscription, For more Notifications sample please check [Here](https://github.com/abuzuhri/Amazon-SP-API-CSharp/blob/main/Source/FikaAmazonAPI.SampleCode/NotificationsSample.cs).
```CSharp

//SQS
Expand Down Expand Up @@ -396,7 +396,7 @@ public class CustomMessageReceiver : IMessageReceiver
Here full sample for submit feed to change price and generate XML and get final report for result same as in [doc](https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/use-case-guides/feeds-api-use-case-guide/feeds-api-use-case-guide_2021-06-30.md).
Notes: not all [feed type](https://github.com/amzn/selling-partner-api-docs/blob/main/references/feeds-api/feedtype-values.md) finished as it's big work and effort but all classes are partial for easy change and you can generate XML outside and use our library to get data, now we support only submit existing product, change quantity and change price , I list most of XSD here Source\FikaAmazonAPI\ConstructFeed\xsd its will help you easy generate class and add it in your app to generate final feed xml.

#### Feed Submit for change price
#### Feed Submit for change price , For more Feed sample please check [Here](https://github.com/abuzuhri/Amazon-SP-API-CSharp/blob/main/Source/FikaAmazonAPI.SampleCode/FeedsSample.cs).
```CSharp
ConstructFeedService createDocument = new ConstructFeedService("{SellerID}", "1.02");

Expand Down
119 changes: 51 additions & 68 deletions Source/FikaAmazonAPI.SampleCode/FeedsSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,14 @@ public void SubmitFeedInventory()
var list = new List<InventoryMessage>();
list.Add(new InventoryMessage()
{
SKU = "8432225129778...",
Quantity = 0,
FulfillmentLatency = "2",
SKU = "API.853038006021.20789.1001",
Quantity = 1
});
createDocument.AddInventoryMessage(list);
var xml = createDocument.GetXML();

var feedID = amazonConnection.Feed.SubmitFeed(xml, FeedType.POST_INVENTORY_AVAILABILITY_DATA);

GetFeedDetails(feedID);
}

/// <summary>
Expand All @@ -119,42 +118,9 @@ public void SubmitFeedAddProductMessage()

var feedID = amazonConnection.Feed.SubmitFeed(xml, FeedType.POST_PRODUCT_DATA);


string ResultFeedDocumentId = string.Empty;
while (string.IsNullOrEmpty(ResultFeedDocumentId))
{
var feedOutput = amazonConnection.Feed.GetFeed(feedID);
if (feedOutput.ProcessingStatus == Feed.ProcessingStatusEnum.DONE)
{
var outPut = amazonConnection.Feed.GetFeedDocument(feedOutput.ResultFeedDocumentId);

var reportOutput = outPut.Url;

var processingReport = amazonConnection.Feed.GetFeedDocumentProcessingReport(reportOutput);

Console.WriteLine("Amazon KSA Change Price");
Console.WriteLine("MessagesProcessed=" + processingReport.ProcessingSummary.MessagesProcessed);
Console.WriteLine("MessagesSuccessful= " + processingReport.ProcessingSummary.MessagesSuccessful);
Console.WriteLine("MessagesWithError=" + processingReport.ProcessingSummary.MessagesWithError);
Console.WriteLine("MessagesWithWarning=" + processingReport.ProcessingSummary.MessagesWithWarning);

if (processingReport.Result != null && processingReport.Result.Count > 0)
{
foreach (var itm in processingReport.Result)
{
Console.WriteLine("ResultDescription=" + itm.AdditionalInfo?.SKU ?? string.Empty + " > " + itm.ResultDescription);
}
}

break;
}

if (!(feedOutput.ProcessingStatus == Feed.ProcessingStatusEnum.INPROGRESS ||
feedOutput.ProcessingStatus == Feed.ProcessingStatusEnum.INQUEUE))
break;
else Thread.Sleep(10000);
}
GetFeedDetails(feedID);
}

public async void SubmitFeedPRICING(double PRICE, string SKU)
{

Expand All @@ -176,32 +142,7 @@ public async void SubmitFeedPRICING(double PRICE, string SKU)

var feedID = await amazonConnection.Feed.SubmitFeedAsync(xml, FeedType.POST_PRODUCT_PRICING_DATA);

string ResultFeedDocumentId = string.Empty;
while (string.IsNullOrEmpty(ResultFeedDocumentId))
{
var feedOutput = await amazonConnection.Feed.GetFeedAsync(feedID);
if (feedOutput.ProcessingStatus == AmazonSpApiSDK.Models.Feeds.Feed.ProcessingStatusEnum.DONE)
{
var outPut = await amazonConnection.Feed.GetFeedDocumentAsync(feedOutput.ResultFeedDocumentId);

var reportOutput = outPut.Url;

var processingReport = await amazonConnection.Feed.GetFeedDocumentProcessingReportAsync(reportOutput);

Console.WriteLine("MessagesProcessed=" + processingReport.ProcessingSummary.MessagesProcessed);
Console.WriteLine("MessagesSuccessful= " + processingReport.ProcessingSummary.MessagesSuccessful);
Console.WriteLine("MessagesWithError=" + processingReport.ProcessingSummary.MessagesWithError);
Console.WriteLine("MessagesWithWarning=" + processingReport.ProcessingSummary.MessagesWithWarning);
Console.WriteLine("ResultDescription=" + processingReport.Result.FirstOrDefault()?.ResultDescription);
}

if (!(feedOutput.ProcessingStatus == AmazonSpApiSDK.Models.Feeds.Feed.ProcessingStatusEnum.INPROGRESS ||
feedOutput.ProcessingStatus == AmazonSpApiSDK.Models.Feeds.Feed.ProcessingStatusEnum.INQUEUE))
break;
else Thread.Sleep(10000);
}


GetFeedDetails(feedID);

}

Expand Down Expand Up @@ -229,9 +170,7 @@ public void FeebPostOrderFullfillment()
var feedID = amazonConnection.Feed.SubmitFeed(xml, FeedType.POST_ORDER_FULFILLMENT_DATA);


var feedOutput = amazonConnection.Feed.GetFeed(feedID);
var outPut = amazonConnection.Feed.GetFeedDocument(feedOutput.ResultFeedDocumentId);
var processingReport = amazonConnection.Feed.GetFeedDocumentProcessingReport(outPut.Url);
GetFeedDetails(feedID);
}

public void SubmitFeedOrderAcknowledgement()
Expand All @@ -254,6 +193,7 @@ public void SubmitFeedOrderAcknowledgement()
var xml = createDocument.GetXML();

var feedID = amazonConnection.Feed.SubmitFeed(xml, FeedType.POST_ORDER_ACKNOWLEDGEMENT_DATA);
GetFeedDetails(feedID);
}

public void SubmitFeedOrderAdjustment()
Expand Down Expand Up @@ -291,6 +231,7 @@ public void SubmitFeedOrderAdjustment()
var xml = createDocument.GetXML();

var feedID = amazonConnection.Feed.SubmitFeed(xml, FeedType.POST_PAYMENT_ADJUSTMENT_DATA);
GetFeedDetails(feedID);
}

public void CartonContentsRequestFeed()
Expand Down Expand Up @@ -331,6 +272,48 @@ public void CartonContentsRequestFeed()
var xml222 = createDocument2.GetXML();

var feedID = amazonConnection.Feed.SubmitFeed(xml222, FeedType.POST_FBA_INBOUND_CARTON_CONTENTS);
GetFeedDetails(feedID);
}

private void GetFeedDetails(string feedID)
{
string ResultFeedDocumentId = string.Empty;
while (string.IsNullOrEmpty(ResultFeedDocumentId))
{
var feedOutput = amazonConnection.Feed.GetFeed(feedID);
if (feedOutput.ProcessingStatus == Feed.ProcessingStatusEnum.DONE)
{
var outPut = amazonConnection.Feed.GetFeedDocument(feedOutput.ResultFeedDocumentId);

var reportOutput = outPut.Url;

var processingReport = amazonConnection.Feed.GetFeedDocumentProcessingReport(outPut);

DisplayProcessingReportMessage(processingReport);

break;
}

if (!(feedOutput.ProcessingStatus == Feed.ProcessingStatusEnum.INPROGRESS ||
feedOutput.ProcessingStatus == Feed.ProcessingStatusEnum.INQUEUE))
break;
else Thread.Sleep(10000);
}
}
private void DisplayProcessingReportMessage(ProcessingReportMessage processingReport)
{
Console.WriteLine("MessagesProcessed=" + processingReport.ProcessingSummary.MessagesProcessed);
Console.WriteLine("MessagesSuccessful= " + processingReport.ProcessingSummary.MessagesSuccessful);
Console.WriteLine("MessagesWithError=" + processingReport.ProcessingSummary.MessagesWithError);
Console.WriteLine("MessagesWithWarning=" + processingReport.ProcessingSummary.MessagesWithWarning);

if (processingReport.Result != null && processingReport.Result.Count > 0)
{
foreach (var itm in processingReport.Result)
{
Console.WriteLine("ResultDescription=" + itm.AdditionalInfo?.SKU ?? string.Empty + " > " + itm.ResultDescription);
}
}
}
}
}
4 changes: 3 additions & 1 deletion Source/FikaAmazonAPI.SampleCode/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ static async Task Main(string[] args)

var offfers = amazonConnection.ProductPricing.GetItemOffers(new Parameter.ProductPricing.ParameterGetItemOffers
{
Asin = "B07WYJF6KJ"
Asin = "B0000512CU",
CustomerType=CustomerType.Business,
ItemCondition = ItemCondition.New,
});


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public QuantityDiscountPriceType() { }
/// <param name="quantityTier">Indicates at what quantity this price becomes active. (required).</param>
/// <param name="quantityDiscountType">Indicates the type of quantity discount this price applies to. (required).</param>
/// <param name="listingPrice">The price at this quantity tier. (required).</param>
public QuantityDiscountPriceType(int? quantityTier = default(int?), QuantityDiscountType quantityDiscountType = default(QuantityDiscountType), MoneyType listingPrice = default(MoneyType))
public QuantityDiscountPriceType(int? quantityTier = default(int?), QuantityDiscountType quantityDiscountType = default(QuantityDiscountType), MoneyType price = default(MoneyType))
{
// to ensure "quantityTier" is required (not null)
if (quantityTier == null)
Expand All @@ -63,13 +63,13 @@ public QuantityDiscountPriceType() { }
this.QuantityDiscountType = quantityDiscountType;
}
// to ensure "listingPrice" is required (not null)
if (listingPrice == null)
if (price == null)
{
throw new InvalidDataException("listingPrice is a required property for QuantityDiscountPriceType and cannot be null");
}
else
{
this.ListingPrice = listingPrice;
this.Price = price;
}
}

Expand All @@ -85,8 +85,8 @@ public QuantityDiscountPriceType() { }
/// The price at this quantity tier.
/// </summary>
/// <value>The price at this quantity tier.</value>
[DataMember(Name="listingPrice", EmitDefaultValue=false)]
public MoneyType ListingPrice { get; set; }
[DataMember(Name= "price", EmitDefaultValue=false)]
public MoneyType Price { get; set; }

/// <summary>
/// Returns the string presentation of the object
Expand All @@ -98,7 +98,7 @@ public override string ToString()
sb.Append("class QuantityDiscountPriceType {\n");
sb.Append(" QuantityTier: ").Append(QuantityTier).Append("\n");
sb.Append(" QuantityDiscountType: ").Append(QuantityDiscountType).Append("\n");
sb.Append(" ListingPrice: ").Append(ListingPrice).Append("\n");
sb.Append(" ListingPrice: ").Append(Price).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
Expand Down Expand Up @@ -144,9 +144,9 @@ public bool Equals(QuantityDiscountPriceType input)
this.QuantityDiscountType.Equals(input.QuantityDiscountType))
) &&
(
this.ListingPrice == input.ListingPrice ||
(this.ListingPrice != null &&
this.ListingPrice.Equals(input.ListingPrice))
this.Price == input.Price ||
(this.Price != null &&
this.Price.Equals(input.Price))
);
}

Expand All @@ -163,8 +163,8 @@ public override int GetHashCode()
hashCode = hashCode * 59 + this.QuantityTier.GetHashCode();
if (this.QuantityDiscountType != null)
hashCode = hashCode * 59 + this.QuantityDiscountType.GetHashCode();
if (this.ListingPrice != null)
hashCode = hashCode * 59 + this.ListingPrice.GetHashCode();
if (this.Price != null)
hashCode = hashCode * 59 + this.Price.GetHashCode();
return hashCode;
}
}
Expand Down
6 changes: 3 additions & 3 deletions Source/FikaAmazonAPI/FikaAmazonAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<Product>CSharp Amazon Sp API</Product>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<LangVersion>8.0</LangVersion>
<Version>1.5.17</Version>
<AssemblyVersion>1.5.17</AssemblyVersion>
<FileVersion>1.5.17</FileVersion>
<Version>1.5.19</Version>
<AssemblyVersion>1.5.19</AssemblyVersion>
<FileVersion>1.5.19</FileVersion>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageProjectUrl>https://github.com/abuzuhri/Amazon-SP-API-CSharp</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Loading

0 comments on commit 0527d0e

Please sign in to comment.