From 0088acd5f9627767a8adf6a7bd6f45614b9fcd9e Mon Sep 17 00:00:00 2001 From: Raksha Date: Thu, 21 Sep 2023 12:17:30 +0100 Subject: [PATCH] Update product report to accept List of marketplaces --- .../ReportGeneration/ProductsReport.cs | 6 +++--- .../ReportGeneration/ReportManager.cs | 16 ++++++++-------- Source/FikaAmazonAPI/Services/ReportService.cs | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/FikaAmazonAPI/ReportGeneration/ProductsReport.cs b/Source/FikaAmazonAPI/ReportGeneration/ProductsReport.cs index e24f1ad9..251d368e 100644 --- a/Source/FikaAmazonAPI/ReportGeneration/ProductsReport.cs +++ b/Source/FikaAmazonAPI/ReportGeneration/ProductsReport.cs @@ -7,7 +7,7 @@ namespace FikaAmazonAPI.ReportGeneration public class ProductsReport { public List Data { get; set; } = new List(); - public ProductsReport(string path, string refNumber, Encoding encoding = default) + public ProductsReport(string path, Encoding encoding = default) { if (string.IsNullOrEmpty(path)) return; @@ -17,7 +17,7 @@ public ProductsReport(string path, string refNumber, Encoding encoding = default List values = new List(); foreach (var row in table.Rows) { - values.Add(ProductsRow.FromRow(row, refNumber)); + values.Add(ProductsRow.FromRow(row)); } Data = values; } @@ -144,7 +144,7 @@ public class ProductsRow public string refNumber { get; set; } public string MerchantShippingGroup { get; set; } - public static ProductsRow FromRow(TableRow rowData, string refNumber) + public static ProductsRow FromRow(TableRow rowData) { var row = new ProductsRow(); row.ItemName = rowData.GetString("item-name"); diff --git a/Source/FikaAmazonAPI/ReportGeneration/ReportManager.cs b/Source/FikaAmazonAPI/ReportGeneration/ReportManager.cs index 035ceddd..17da9887 100644 --- a/Source/FikaAmazonAPI/ReportGeneration/ReportManager.cs +++ b/Source/FikaAmazonAPI/ReportGeneration/ReportManager.cs @@ -186,20 +186,20 @@ private async Task GetInventoryAgingAsync(AmazonConnection amazonConnect #endregion #region Products - public List GetProducts() => - Task.Run(() => GetProductsAsync()).ConfigureAwait(false).GetAwaiter().GetResult(); - public async Task> GetProductsAsync() + public List GetProducts(List marketplaces = null) => + Task.Run(() => GetProductsAsync(marketplaces)).ConfigureAwait(false).GetAwaiter().GetResult(); + public async Task> GetProductsAsync(List marketplaces = null, CancellationToken cancellationToken = default) { - var path = await GetProductsAsync(_amazonConnection); - ProductsReport report = new ProductsReport(path, _amazonConnection.RefNumber); + var path = await GetProductsAsync(_amazonConnection, marketplaces, cancellationToken); + ProductsReport report = new ProductsReport(path); return report.Data; } - private async Task GetProductsAsync(AmazonConnection amazonConnection) + private async Task GetProductsAsync(AmazonConnection amazonConnection, List marketplaces = null, CancellationToken cancellationToken = default) { - return await amazonConnection.Reports.CreateReportAndDownloadFileAsync(ReportTypes.GET_MERCHANT_LISTINGS_ALL_DATA); + return await amazonConnection.Reports.CreateReportAndDownloadFileAsync(ReportTypes.GET_MERCHANT_LISTINGS_ALL_DATA, marketplaces: marketplaces, cancellationToken: cancellationToken); } #endregion - + #region Categories public List GetCategories() diff --git a/Source/FikaAmazonAPI/Services/ReportService.cs b/Source/FikaAmazonAPI/Services/ReportService.cs index 0671a8b9..bedcbf49 100644 --- a/Source/FikaAmazonAPI/Services/ReportService.cs +++ b/Source/FikaAmazonAPI/Services/ReportService.cs @@ -285,7 +285,7 @@ public async Task CreateReportAndDownloadFileAsync(ReportTypes reportTyp parameters.marketplaceIds = new MarketplaceIds(); - if (marketplaces == null) + if (marketplaces == null || marketplaces.Count() == 0) { parameters.marketplaceIds.Add(AmazonCredential.MarketPlace.ID); }