Skip to content

Commit a6b17ae

Browse files
author
KevinVenclovas
committed
added multiple marketplaces support on report GET_FLAT_FILE_ORDER_REPORT_DATA_INVOICING
1 parent 81a02fc commit a6b17ae

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

Source/FikaAmazonAPI/ReportGeneration/ReportManager.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using FikaAmazonAPI.Utils;
2+
using System;
23
using System.Collections.Generic;
34
using System.Threading.Tasks;
45
using static FikaAmazonAPI.Utils.Constants;
@@ -250,25 +251,25 @@ private async Task<string> GetOrdersByOrderDateAsync(AmazonConnection amazonConn
250251
return await amazonConnection.Reports.CreateReportAndDownloadFileAsync(ReportTypes.GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL, fromDate, toDate);
251252
}
252253

253-
public List<OrderInvoicingReportRow> GetOrderInvoicingData(DateTime fromDate, DateTime toDate) =>
254-
Task.Run(() => GetOrderInvoicingDataAsync(fromDate, toDate)).ConfigureAwait(false).GetAwaiter().GetResult();
255-
public async Task<List<OrderInvoicingReportRow>> GetOrderInvoicingDataAsync(DateTime fromDate, DateTime toDate)
254+
public List<OrderInvoicingReportRow> GetOrderInvoicingData(DateTime fromDate, DateTime toDate, List<MarketPlace> marketplaces = null) =>
255+
Task.Run(() => GetOrderInvoicingDataAsync(fromDate, toDate, marketplaces)).ConfigureAwait(false).GetAwaiter().GetResult();
256+
public async Task<List<OrderInvoicingReportRow>> GetOrderInvoicingDataAsync(DateTime fromDate, DateTime toDate, List<MarketPlace> marketplaces = null)
256257
{
257258
List<OrderInvoicingReportRow> list = new List<OrderInvoicingReportRow>();
258259
var dateList = ReportDateRange.GetDateRange(fromDate, toDate, DAY_30);
259260
foreach (var range in dateList)
260261
{
261-
var path = await GetOrderInvoicingDataAsync(_amazonConnection, range.StartDate, range.EndDate);
262+
var path = await GetOrderInvoicingDataAsync(_amazonConnection, range.StartDate, range.EndDate, marketplaces);
262263
OrderInvoicingReport report = new OrderInvoicingReport(path, _amazonConnection.RefNumber);
263264
list.AddRange(report.Data);
264265
}
265266
return list;
266267
}
267-
private async Task<string> GetOrderInvoicingDataAsync(AmazonConnection amazonConnection, DateTime fromDate, DateTime toDate)
268+
private async Task<string> GetOrderInvoicingDataAsync(AmazonConnection amazonConnection, DateTime fromDate, DateTime toDate, List<MarketPlace> marketplaces = null)
268269
{
269270
var options = new AmazonSpApiSDK.Models.Reports.ReportOptions();
270271
options.Add("ShowSalesChannel", "true");
271-
return await amazonConnection.Reports.CreateReportAndDownloadFileAsync(ReportTypes.GET_FLAT_FILE_ORDER_REPORT_DATA_INVOICING, fromDate, toDate, options, false);
272+
return await amazonConnection.Reports.CreateReportAndDownloadFileAsync(ReportTypes.GET_FLAT_FILE_ORDER_REPORT_DATA_INVOICING, fromDate, toDate, options, false, marketplaces);
272273
}
273274
#endregion
274275

Source/FikaAmazonAPI/Services/ReportService.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System;
88
using System.Collections.Generic;
99
using System.IO;
10+
using System.Linq;
1011
using System.Threading.Tasks;
1112
using static FikaAmazonAPI.Utils.Constants;
1213

@@ -247,7 +248,7 @@ public async Task<bool> CancelReportScheduleAsync(string reportScheduleId)
247248

248249
public string CreateReportAndDownloadFile(ReportTypes reportType, DateTime? dataStartTime = null, DateTime? dataEndTime = null, ReportOptions reportOptions = null, bool isRestrictedReport = false) =>
249250
Task.Run(() => CreateReportAndDownloadFileAsync(reportType, dataStartTime, dataEndTime, reportOptions, isRestrictedReport)).ConfigureAwait(false).GetAwaiter().GetResult();
250-
public async Task<string> CreateReportAndDownloadFileAsync(ReportTypes reportType, DateTime? dataStartTime = null, DateTime? dataEndTime = null, ReportOptions reportOptions = null, bool isRestrictedReport = false)
251+
public async Task<string> CreateReportAndDownloadFileAsync(ReportTypes reportType, DateTime? dataStartTime = null, DateTime? dataEndTime = null, ReportOptions reportOptions = null, bool isRestrictedReport = false, List<MarketPlace> marketplaces = null)
251252
{
252253
if (!isRestrictedReport && Enum.TryParse<RestrictedReportTypes>(reportType.ToString(), out _))
253254
{
@@ -259,7 +260,14 @@ public async Task<string> CreateReportAndDownloadFileAsync(ReportTypes reportTyp
259260

260261
parameters.marketplaceIds = new MarketplaceIds();
261262

262-
parameters.marketplaceIds.Add(AmazonCredential.MarketPlace.ID);
263+
if (marketplaces == null)
264+
{
265+
parameters.marketplaceIds.Add(AmazonCredential.MarketPlace.ID);
266+
}
267+
else
268+
{
269+
parameters.marketplaceIds.AddRange(marketplaces.Select(x => x.ID).ToList());
270+
}
263271

264272
if (reportOptions != null)
265273
parameters.reportOptions = reportOptions;

0 commit comments

Comments
 (0)