File tree Expand file tree Collapse file tree 2 files changed +53
-5
lines changed
Source/FikaAmazonAPI/ReportGeneration Expand file tree Collapse file tree 2 files changed +53
-5
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change @@ -155,14 +155,15 @@ private async Task<IList<string>> GetSettlementOrderAsync(AmazonConnection amazo
155
155
#endregion
156
156
157
157
#region GetInventoryQty
158
- public void GetInventoryQty ( )
158
+ public async Task < List < ProductAFNInventoryRow > > GetAFNInventoryQtyAsync ( )
159
159
{
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 ;
162
163
}
163
- private string GetInventoryQty ( AmazonConnection amazonConnection )
164
+ private async Task < string > GetAFNInventoryQtyAsync ( AmazonConnection amazonConnection )
164
165
{
165
- return amazonConnection . Reports . CreateReportAndDownloadFile ( ReportTypes . GET_AFN_INVENTORY_DATA ) ;
166
+ return await amazonConnection . Reports . CreateReportAndDownloadFileAsync ( ReportTypes . GET_AFN_INVENTORY_DATA ) ;
166
167
}
167
168
#endregion
168
169
You can’t perform that action at this time.
0 commit comments