Skip to content

Commit 76e18ef

Browse files
authored
Merge pull request #874 from abuzuhri/codex/add-memorystream-version-of-createreportanddownloadfileasync
Add generic parser for report streams
2 parents eaf0eca + 0b392ee commit 76e18ef

20 files changed

+428
-77
lines changed

Source/FikaAmazonAPI/ReportGeneration/CategoriesReport.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using System.IO;
33
using System.Xml.Serialization;
4+
using System.Text;
45

56
namespace FikaAmazonAPI.ReportGeneration
67
{
@@ -28,6 +29,24 @@ public CategoriesReport(string path, string refNumber)
2829
throw e;
2930
}
3031
}
32+
33+
public CategoriesReport(Stream stream, string refNumber)
34+
{
35+
if (stream == null || stream.Length == 0)
36+
return;
37+
38+
stream.Position = 0;
39+
var serializer = new XmlSerializer(typeof(CategoriesData));
40+
41+
try
42+
{
43+
Data = (CategoriesData)serializer.Deserialize(stream);
44+
}
45+
catch (System.Exception e)
46+
{
47+
throw e;
48+
}
49+
}
3150
}
3251

3352
[XmlRoot(ElementName = "attribute")]

Source/FikaAmazonAPI/ReportGeneration/FbaEstimateFeeReport.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using FikaAmazonAPI.ReportGeneration.ReportDataTable;
22
using System;
33
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Text;
46

57
namespace FikaAmazonAPI.ReportGeneration
68
{
@@ -21,6 +23,11 @@ public FbaEstimateFeeReport(string path, string refNumber)
2123
}
2224
Data = values;
2325
}
26+
27+
public FbaEstimateFeeReport(Stream stream, string refNumber)
28+
{
29+
Data = ReportParser.ParseTableRows(stream, FbaEstimateFeeReportRow.FromRow, refNumber);
30+
}
2431
}
2532
public class FbaEstimateFeeReportRow
2633
{

Source/FikaAmazonAPI/ReportGeneration/FeedbackOrderReport.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
5+
using System.Text;
56

67
namespace FikaAmazonAPI.ReportGeneration
78
{
@@ -19,6 +20,11 @@ public FeedbackOrderReport(string path, string refNumber)
1920
Data = values;
2021
}
2122

23+
public FeedbackOrderReport(Stream stream, string refNumber)
24+
{
25+
Data = ReportParser.ParseCsvLines(stream, FeedbackOrderRow.FromCsv, refNumber);
26+
}
27+
2228

2329
}
2430
public class FeedbackOrderRow

Source/FikaAmazonAPI/ReportGeneration/InventoryAgingReport.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
using FikaAmazonAPI.ReportGeneration.ReportDataTable;
1+
using FikaAmazonAPI.ReportGeneration.ReportDataTable;
22
using System;
33
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Text;
46

57
namespace FikaAmazonAPI.ReportGeneration
68
{
@@ -21,6 +23,11 @@ public InventoryAgingReport(string path, string refNumber)
2123
}
2224
Data = values;
2325
}
26+
27+
public InventoryAgingReport(Stream stream, string refNumber)
28+
{
29+
Data = ReportParser.ParseTableRows(stream, InventoryAgingRow.FromRow, refNumber);
30+
}
2431
}
2532
public class InventoryAgingRow
2633
{

Source/FikaAmazonAPI/ReportGeneration/InventoryPlanningDataReport.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Text;
44
using FikaAmazonAPI.ReportGeneration.ReportDataTable;
5+
using System.IO;
56

67
namespace FikaAmazonAPI.ReportGeneration
78
{
@@ -22,6 +23,11 @@ public InventoryPlanningDataReport(string path, string refNumber)
2223
}
2324
Data = values;
2425
}
26+
27+
public InventoryPlanningDataReport(Stream stream, string refNumber)
28+
{
29+
Data = ReportParser.ParseTableRows(stream, InventoryPlanningDataRow.FromRow, refNumber);
30+
}
2531
}
2632

2733
public class InventoryPlanningDataRow

Source/FikaAmazonAPI/ReportGeneration/LedgerDetailReport.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
using FikaAmazonAPI.ReportGeneration.ReportDataTable;
1+
using FikaAmazonAPI.ReportGeneration.ReportDataTable;
22
using System;
33
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Text;
46

57
namespace FikaAmazonAPI.ReportGeneration
68
{
@@ -21,6 +23,11 @@ public LedgerDetailReport(string path, string refNumber)
2123
}
2224
Data = values;
2325
}
26+
27+
public LedgerDetailReport(Stream stream, string refNumber)
28+
{
29+
Data = ReportParser.ParseTableRows(stream, LedgerDetailReportRow.FromRow, refNumber);
30+
}
2431
}
2532
public class LedgerDetailReportRow
2633
{

Source/FikaAmazonAPI/ReportGeneration/OrderInvoicingReport.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.Generic;
44
using System.IO;
55
using System.Linq;
6+
using System.Text;
67

78
namespace FikaAmazonAPI.ReportGeneration
89
{
@@ -23,6 +24,11 @@ public OrderInvoicingReport(string path, string refNumber)
2324
}
2425
Data = values;
2526
}
27+
28+
public OrderInvoicingReport(Stream stream, string refNumber)
29+
{
30+
Data = ReportParser.ParseTableRows(stream, OrderInvoicingReportRow.FromRow, refNumber);
31+
}
2632
}
2733

2834

Source/FikaAmazonAPI/ReportGeneration/OrdersReport.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
5+
using System.Text;
56

67
namespace FikaAmazonAPI.ReportGeneration
78
{
@@ -19,6 +20,11 @@ public OrdersReport(string path, string refNumber)
1920
Data = values;
2021
}
2122

23+
public OrdersReport(Stream stream, string refNumber)
24+
{
25+
Data = ReportParser.ParseCsvLines(stream, OrdersRow.FromCsv, refNumber);
26+
}
27+
2228

2329
}
2430
public class OrdersRow

Source/FikaAmazonAPI/ReportGeneration/ProductAFNInventoryReport.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public ProductAFNInventoryReport(string path, string refNumber)
1919
.ToList();
2020
Data = values;
2121
}
22+
23+
public ProductAFNInventoryReport(Stream stream, string refNumber)
24+
{
25+
Data = ReportParser.ParseCsvLines(stream, ProductAFNInventoryRow.FromCsv, refNumber);
26+
}
2227
}
2328

2429
public class ProductAFNInventoryRow

Source/FikaAmazonAPI/ReportGeneration/ProductsReport.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
using FikaAmazonAPI.ReportGeneration.ReportDataTable;
1+
using FikaAmazonAPI.ReportGeneration.ReportDataTable;
22
using System.Collections.Generic;
33
using System.Text;
4+
using System.IO;
45

56
namespace FikaAmazonAPI.ReportGeneration
67
{
@@ -22,6 +23,11 @@ public ProductsReport(string path, Encoding encoding = default)
2223
Data = values;
2324
}
2425

26+
public ProductsReport(Stream stream, Encoding encoding = default)
27+
{
28+
Data = ReportParser.ParseTableRows(stream, ProductsRow.FromRow, encoding: encoding);
29+
}
30+
2531

2632
}
2733
public class ProductsRow

0 commit comments

Comments
 (0)