Skip to content

Commit a33f0d7

Browse files
authored
Merge pull request #140 from J-W-Chan/main
added ProductAFNInventoryReport
2 parents b2e2046 + 61f0669 commit a33f0d7

File tree

2 files changed

+53
-5
lines changed

2 files changed

+53
-5
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Text;
6+
7+
namespace FikaAmazonAPI.ReportGeneration
8+
{
9+
public class ProductAFNInventoryReport
10+
{
11+
public List<ProductAFNInventoryRow> Data { get; set; } = new List<ProductAFNInventoryRow>();
12+
public ProductAFNInventoryReport(string path, string refNumber)
13+
{
14+
if (string.IsNullOrEmpty(path))
15+
return;
16+
var values = File.ReadAllLines(path)
17+
.Skip(1)
18+
.Select(v => ProductAFNInventoryRow.FromCsv(v, refNumber))
19+
.ToList();
20+
Data = values;
21+
}
22+
}
23+
24+
public class ProductAFNInventoryRow
25+
{
26+
public string SellerSku { get; set; }
27+
public string FulfillmentChannelSku { get; set; }
28+
public string ASIN { get; set; }
29+
public string ConditionType { get; set; }
30+
public string WarehouseConditionCode { get; set; }
31+
public int? QuantityAvailable { get; set; }
32+
33+
34+
public static ProductAFNInventoryRow FromCsv(string csvLine, string refNumber)
35+
{
36+
string[] values = csvLine.Split('\t');
37+
var row = new ProductAFNInventoryRow();
38+
row.SellerSku = values[0];
39+
row.FulfillmentChannelSku = values[1];
40+
row.ASIN = values[2];
41+
row.ConditionType = values[3];
42+
row.WarehouseConditionCode = values[4];
43+
row.QuantityAvailable = DataConverter.GetInt(values[5]);
44+
return row;
45+
}
46+
}
47+
}

Source/FikaAmazonAPI/ReportGeneration/ReportManager.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,15 @@ private async Task<IList<string>> GetSettlementOrderAsync(AmazonConnection amazo
155155
#endregion
156156

157157
#region GetInventoryQty
158-
public void GetInventoryQty()
158+
public async Task<List<ProductAFNInventoryRow>> GetAFNInventoryQtyAsync()
159159
{
160-
//var path = GetInventoryQty(_amazonConnections);
161-
throw new Exception("Report not finished");
160+
var path = await GetAFNInventoryQtyAsync(_amazonConnection);
161+
ProductAFNInventoryReport report = new ProductAFNInventoryReport(path, _amazonConnection.RefNumber);
162+
return report.Data;
162163
}
163-
private string GetInventoryQty(AmazonConnection amazonConnection)
164+
private async Task<string> GetAFNInventoryQtyAsync(AmazonConnection amazonConnection)
164165
{
165-
return amazonConnection.Reports.CreateReportAndDownloadFile(ReportTypes.GET_AFN_INVENTORY_DATA);
166+
return await amazonConnection.Reports.CreateReportAndDownloadFileAsync(ReportTypes.GET_AFN_INVENTORY_DATA);
166167
}
167168
#endregion
168169

0 commit comments

Comments
 (0)