public IApiResource GetApiResource(DataTypeConfig dataType, ITickerPeriodParameter parameter, bool isConfigureAwait = true, bool useCache = true) { UpdateApiKeyIfNeeded(); var useOndemand = config.IsForceOndemandApi ? true : taskHelper.ShouldUseOndemandEndpoint(dataType, parameter.GetTicker(), parameter.GetPeriod(), config.IsOndemandEndpointEnabled, isConfigureAwait, useCache); client.UpdateApiKey(config.ApiKey); var json = client.Get(dataType, parameter, useOndemand, isConfigureAwait, useCache); return(parser.Parse(dataType, json)); }
/// <summary> /// Handles the request for an <see cref="ApiResponse"/>. /// </summary> /// <param name="requestUrl">The URL to which the request should be sent, if needed.</param> /// <returns>An <see cref="ApiResponse"/> object.</returns> internal T HandleRequest(ApiRequestUrl requestUrl) { string url = requestUrl.Url; ApiResponse cachedResponse = ResponseCache.Get(url, ignoreCacheUntil); if (cachedResponse != null) { return((T)cachedResponse); } XmlDocument xmlDocument = Network.GetXml(url); T responseObject = parser.Parse(xmlDocument); ResponseCache.Set(url, responseObject); return(responseObject); }
private Company GetCompany(string ticker, bool isConfigureAwait, bool useCache) { var json = apiClient.Get(DataTypeConfig.Company, TickerEmptyPeriodParameter.Create(ticker, Snapshot.GetInstance()), false, isConfigureAwait, useCache); return(parser.Parse(DataTypeConfig.Company, json) as Company); }