Skip to content

Commit 886bc99

Browse files
authored
Merge pull request #280 from mucahitimre/main
2 parents e923737 + 68e37e0 commit 886bc99

File tree

3 files changed

+144
-8
lines changed

3 files changed

+144
-8
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
using System.Collections.Generic;
2+
using System.IO;
3+
using System.Xml.Serialization;
4+
5+
namespace FikaAmazonAPI.ReportGeneration
6+
{
7+
public class CategoiesReport
8+
{
9+
public CategoiesData Data { get; set; } = new CategoiesData();
10+
11+
public CategoiesReport(string path, string refNumber)
12+
{
13+
if (string.IsNullOrEmpty(path))
14+
return;
15+
16+
var xml = File.ReadAllText(path);
17+
var serializer = new XmlSerializer(typeof(CategoiesData));
18+
19+
try
20+
{
21+
using (StringReader reader = new StringReader(xml))
22+
{
23+
Data = (CategoiesData)serializer.Deserialize(reader);
24+
}
25+
}
26+
catch (System.Exception e)
27+
{
28+
throw e;
29+
}
30+
}
31+
}
32+
33+
[XmlRoot(ElementName = "attribute")]
34+
public class CategoryAttribute
35+
{
36+
37+
[XmlAttribute(AttributeName = "name")]
38+
public string Name { get; set; }
39+
40+
[XmlText]
41+
public string Text { get; set; }
42+
}
43+
44+
[XmlRoot(ElementName = "browseNodeAttributes")]
45+
public class CategoryBrowseNodeAttributes
46+
{
47+
48+
[XmlElement(ElementName = "attribute")]
49+
public CategoryAttribute Attribute { get; set; }
50+
51+
[XmlAttribute(AttributeName = "count")]
52+
public string Count { get; set; }
53+
54+
[XmlText]
55+
public string Text { get; set; }
56+
}
57+
58+
[XmlRoot(ElementName = "childNodes")]
59+
public class ChildNodes
60+
{
61+
62+
[XmlElement(ElementName = "id")]
63+
public List<string> Id { get; set; }
64+
65+
[XmlAttribute(AttributeName = "count")]
66+
public string Count { get; set; }
67+
68+
[XmlText]
69+
public string Text { get; set; }
70+
}
71+
72+
[XmlRoot(ElementName = "refinementsInformation")]
73+
public class RefinementsInformation
74+
{
75+
76+
[XmlAttribute(AttributeName = "count")]
77+
public string Count { get; set; }
78+
}
79+
80+
[XmlRoot(ElementName = "Node")]
81+
public class CategoiesRow
82+
{
83+
84+
[XmlElement(ElementName = "browseNodeId")]
85+
public string BrowseNodeId { get; set; }
86+
87+
[XmlElement(ElementName = "browseNodeAttributes")]
88+
public CategoryBrowseNodeAttributes BrowseNodeAttributes { get; set; }
89+
90+
[XmlElement(ElementName = "browseNodeName")]
91+
public string BrowseNodeName { get; set; }
92+
93+
[XmlElement(ElementName = "browseNodeStoreContextName")]
94+
public string BrowseNodeStoreContextName { get; set; }
95+
96+
[XmlElement(ElementName = "browsePathById")]
97+
public string BrowsePathById { get; set; }
98+
99+
[XmlElement(ElementName = "browsePathByName")]
100+
public string BrowsePathByName { get; set; }
101+
102+
[XmlElement(ElementName = "hasChildren")]
103+
public bool HasChildren { get; set; }
104+
105+
[XmlElement(ElementName = "childNodes")]
106+
public ChildNodes ChildNodes { get; set; }
107+
108+
[XmlElement(ElementName = "productTypeDefinitions")]
109+
public string ProductTypeDefinitions { get; set; }
110+
111+
[XmlElement(ElementName = "refinementsInformation")]
112+
public RefinementsInformation RefinementsInformation { get; set; }
113+
}
114+
115+
[XmlRoot(ElementName = "Result")]
116+
public class CategoiesData
117+
{
118+
119+
[XmlElement(ElementName = "Node")]
120+
public List<CategoiesRow> Node { get; set; }
121+
}
122+
}

Source/FikaAmazonAPI/ReportGeneration/FeedbackOrderReport.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.IO;
44
using System.Linq;
55

6-
76
namespace FikaAmazonAPI.ReportGeneration
87
{
98
public class FeedbackOrderReport

Source/FikaAmazonAPI/ReportGeneration/ReportManager.cs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,27 @@ private async Task<string> GetProductsAsync(AmazonConnection amazonConnection)
198198
}
199199
#endregion
200200

201+
#region Categries
202+
203+
public List<CategoiesRow> GetCategries()
204+
{
205+
return Task.Run(() => GetCategriesAsync()).ConfigureAwait(false).GetAwaiter().GetResult();
206+
}
207+
208+
public async Task<List<CategoiesRow>> GetCategriesAsync()
209+
{
210+
var path = await GetCategriesAsync(_amazonConnection);
211+
CategoiesReport report = new CategoiesReport(path, _amazonConnection.RefNumber);
212+
return report.Data.Node;
213+
}
214+
215+
private async Task<string> GetCategriesAsync(AmazonConnection amazonConnection)
216+
{
217+
return await amazonConnection.Reports.CreateReportAndDownloadFileAsync(ReportTypes.GET_XML_BROWSE_TREE_DATA);
218+
}
219+
220+
#endregion
221+
201222
#region Orders
202223
public List<OrdersRow> GetOrdersByLastUpdate(int days) =>
203224
Task.Run(() => GetOrdersByLastUpdateAsync(days)).ConfigureAwait(false).GetAwaiter().GetResult();
@@ -250,7 +271,7 @@ private async Task<string> GetOrdersByOrderDateAsync(AmazonConnection amazonConn
250271
{
251272
return await amazonConnection.Reports.CreateReportAndDownloadFileAsync(ReportTypes.GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL, fromDate, toDate);
252273
}
253-
274+
254275
public List<OrderInvoicingReportRow> GetOrderInvoicingData(DateTime fromDate, DateTime toDate, List<MarketPlace> marketplaces = null) =>
255276
Task.Run(() => GetOrderInvoicingDataAsync(fromDate, toDate, marketplaces)).ConfigureAwait(false).GetAwaiter().GetResult();
256277
public async Task<List<OrderInvoicingReportRow>> GetOrderInvoicingDataAsync(DateTime fromDate, DateTime toDate, List<MarketPlace> marketplaces = null)
@@ -273,11 +294,5 @@ private async Task<string> GetOrderInvoicingDataAsync(AmazonConnection amazonCon
273294
return await amazonConnection.Reports.CreateReportAndDownloadFileAsync(ReportTypes.GET_FLAT_FILE_ORDER_REPORT_DATA_INVOICING, fromDate, toDate, options, false, marketplaces);
274295
}
275296
#endregion
276-
277-
278-
279-
280297
}
281-
282-
283298
}

0 commit comments

Comments
 (0)