Implemented groundwork for search configuration.
This commit is contained in:
@@ -15,7 +15,7 @@ namespace Props.Shop.Adafruit.Api
|
||||
private Dictionary<string, List<ProductListing>> listings = new Dictionary<string, List<ProductListing>>();
|
||||
private bool requested = false;
|
||||
public DateTime TimeOfLastRequest { get; private set; }
|
||||
public bool RequestReady => DateTime.Now - TimeOfLastRequest > TimeSpan.FromMinutes(minutesPerRequest);
|
||||
public bool RequestReady => !requested || DateTime.Now - TimeOfLastRequest > TimeSpan.FromMinutes(minutesPerRequest);
|
||||
|
||||
public ProductListingManager(int requestsPerMinute = 5)
|
||||
{
|
||||
@@ -27,10 +27,10 @@ namespace Props.Shop.Adafruit.Api
|
||||
requested = true;
|
||||
TimeOfLastRequest = DateTime.Now;
|
||||
HttpResponseMessage response = await http.GetAsync("/products");
|
||||
SetListings(await response.Content.ReadAsStringAsync());
|
||||
SetListingsData(await response.Content.ReadAsStringAsync());
|
||||
}
|
||||
|
||||
public void SetListings(string data)
|
||||
public void SetListingsData(string data)
|
||||
{
|
||||
ListingsParser listingsParser = new ListingsParser(data);
|
||||
foreach (ProductListing listing in listingsParser.ProductListings)
|
||||
|
Reference in New Issue
Block a user