Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update product report to accept List of marketplaces #658

Merged
merged 1 commit into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Source/FikaAmazonAPI/ReportGeneration/ProductsReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace FikaAmazonAPI.ReportGeneration
public class ProductsReport
{
public List<ProductsRow> Data { get; set; } = new List<ProductsRow>();
public ProductsReport(string path, string refNumber, Encoding encoding = default)
public ProductsReport(string path, Encoding encoding = default)
{
if (string.IsNullOrEmpty(path))
return;
Expand All @@ -17,7 +17,7 @@ public ProductsReport(string path, string refNumber, Encoding encoding = default
List<ProductsRow> values = new List<ProductsRow>();
foreach (var row in table.Rows)
{
values.Add(ProductsRow.FromRow(row, refNumber));
values.Add(ProductsRow.FromRow(row));
}
Data = values;
}
Expand Down Expand Up @@ -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");
Expand Down
16 changes: 8 additions & 8 deletions Source/FikaAmazonAPI/ReportGeneration/ReportManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,20 @@ private async Task<string> GetInventoryAgingAsync(AmazonConnection amazonConnect
#endregion

#region Products
public List<ProductsRow> GetProducts() =>
Task.Run(() => GetProductsAsync()).ConfigureAwait(false).GetAwaiter().GetResult();
public async Task<List<ProductsRow>> GetProductsAsync()
public List<ProductsRow> GetProducts(List<MarketPlace> marketplaces = null) =>
Task.Run(() => GetProductsAsync(marketplaces)).ConfigureAwait(false).GetAwaiter().GetResult();
public async Task<List<ProductsRow>> GetProductsAsync(List<MarketPlace> 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<string> GetProductsAsync(AmazonConnection amazonConnection)
private async Task<string> GetProductsAsync(AmazonConnection amazonConnection, List<MarketPlace> 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<CategoriesRow> GetCategories()
Expand Down
2 changes: 1 addition & 1 deletion Source/FikaAmazonAPI/Services/ReportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public async Task<string> CreateReportAndDownloadFileAsync(ReportTypes reportTyp

parameters.marketplaceIds = new MarketplaceIds();

if (marketplaces == null)
if (marketplaces == null || marketplaces.Count() == 0)
{
parameters.marketplaceIds.Add(AmazonCredential.MarketPlace.ID);
}
Expand Down
Loading