public BonAppService(BonAppSetup setup) { this.setup = setup; // allow data caching to 20 min cache = new Utils.Cache <JsonValue>(200, TimeSpan.FromMinutes(20), async(string key) => { JsonValue res = null; var url = new Uri(setup.url); using (HttpClient client = await HttpClient.CreateAsync(url)) { HttpClientRequest request = new HttpClientRequest(); request.Method = "GET"; request.Path = key; request.Headers["menuapi-key"] = setup.apiKey; await client.SendRequestAsync(request); HttpClientResponse response = await client.GetResponseAsync(); if (response.StatusCode == 200) { res = await response.ReadAsJsonAsync(); } else { Console.WriteLine(await response.ReadAsStringAsync()); } } return(res); }); }