public async Task <ApiCallResult <FundaApiResponse <T> > > GetOffer(string searchQuery) { if (memoryCache.TryGetValue(searchQuery, out ApiCallResult <FundaApiResponse <T> > offerResponse)) { return(offerResponse); } offerResponse = await decoratedClient.GetOffer(searchQuery); //TODO: Move cache time to configuration memoryCache.Set(searchQuery, offerResponse, TimeSpan.FromSeconds(cachingTimeInSeconds)); return(offerResponse); }
public async Task <IEnumerable <T> > GetCollatedData(string baseQuery) { IFundaOfferHttpClient <T> client = fundaOfferHttpClientfactory.GetFundaOfferHttpClient(); ApiCallResult <FundaApiResponse <T> > response; List <T> results = new List <T>(); int currentPage = 0; do { currentPage++; response = await client.GetOffer(GetPaginatedQuery(baseQuery, currentPage)); if (!response.IsSuccess) { return(null); } results.AddRange(response.Body.Objects); }while (response.Body.Paging.AantalPaginas > response.Body.Paging.HuidigePagina); return(results); }
public async Task <ApiCallResult <FundaApiResponse <T> > > GetOffer(string searchQuery) { await requestThrottling.Throttle(); return(await decoratedClient.GetOffer(searchQuery)); }