public async Task <MajorIndex> GetMajorIndex(MajorIndexType type) { var url = $"majors-indexes/{GetUrlSuffix(type)}"; using var client = new FinancialModellingPrepHttpClient(); var majorIndex = await client.GetAsync <MajorIndex>(url); return(majorIndex); }
private string GetUriSuffix(MajorIndexType indexType) { return(indexType switch { MajorIndexType.DowJones => ".DJI", MajorIndexType.Nasdaq => ".IXIC", MajorIndexType.SP500 => ".INX", _ => ".DJI" });
public async Task <MajorIndex> GetMajorIndex(MajorIndexType indexType) { string uri = "majors-indexes/" + GetUriSuffix(indexType); MajorIndex majorIndex = await _client.GetAsync <MajorIndex>(uri); majorIndex.Type = indexType; return(majorIndex); }
public async Task <MajorIndex> GetMajorIndex(MajorIndexType indexType) { using (FinancialModelingPreHttpClient client = new FinancialModelingPreHttpClient()) { string uri = "major-indexes/" + GetUriSuffix(indexType); MajorIndex majorIndex = await client.GetAsync <MajorIndex>(uri); majorIndex.Type = indexType; return(majorIndex); } }
public async Task <MajorIndex> GetMajorIndexAsync(MajorIndexType indexType) { using (FinancialModelingHttpClient client = _httpClientFactory.CreateHttpClient()) { string uri = "majors-indexes/" + GetUriSuffix(indexType); MajorIndex majorIndex = await client.GetAsync <MajorIndex>(uri); majorIndex.Type = indexType; return(majorIndex); } }
private string GetUriSuffix(MajorIndexType indexType) { switch (indexType) { case MajorIndexType.DowJones: return(".DJI"); case MajorIndexType.Nasdaq: return(".IXIC"); case MajorIndexType.SP500: return(".INX"); default: throw new Exception("MajorIndexType does not have a suffix defined."); } }
public async Task <MajorIndex> GetMajorIndex(MajorIndexType indexType) { using (FinancialModelingPrepHttpClient client = new FinancialModelingPrepHttpClient()) { string uri = "majors-indexes/" + GetUriSuffix(indexType) + @"?apikey=b346753a14deb665d5489815d0a56b42"; MajorIndex majorIndex = await client.GetAsync <MajorIndex>(uri); majorIndex.Type = indexType; return(majorIndex); } }
public async Task <MajorIndex> GetMajorIndex(MajorIndexType indexType) { using (HttpClient client = new HttpClient()) { String uri = "https://financialmodelingprep.com/api/v3/majors-indexes/.DJI" + GetUriSuffix(indexType); HttpResponseMessage response = await client.GetAsync(uri); string jsonResponse = await response.Content.ReadAsStringAsync(); MajorIndex majorIndex = JsonConvert.DeserializeObject <MajorIndex>(jsonResponse); majorIndex.Type = indexType; return(majorIndex); } }
public async Task <MajorIndex> GetMajorIndex(MajorIndexType indexType) { using (FinancialModelingPrepHttpClient client = new FinancialModelingPrepHttpClient()) { string uri = @"majors-indexes/" + GetUriSuffix(indexType) + "?apikey=618edc49f868d97ae7a519ed762c4bf7"; MajorIndex majorIndex = await client.GetAsync <MajorIndex>(uri); majorIndex.Type = indexType; return(majorIndex); } }
public async Task <MajorIndex> GetMajorIndex(MajorIndexType indexType) { using var client = new FinancialModelingPrepHttpClient(); var uri = "majors-indexes/" + GetUriSuffix(indexType); const string apiKey = "f9640047997a5e29a933b2a86d1c337f"; var response = await client.GetAsync($"{uri}?apikey={apiKey}"); var jsonResponse = await response.Content.ReadAsStringAsync(); var majorIndex = JsonConvert.DeserializeObject <MajorIndex>(jsonResponse); majorIndex.Type = indexType; return(majorIndex); }
private string GetUriSuffix(MajorIndexType indexType) { switch (indexType) { case MajorIndexType.DownJones: return(".DJI"); case MajorIndexType.Nasdaq: return(".IXIC"); case MajorIndexType.SP500: return(".INX"); default: return(".DJI"); } }
private string GetUriSfx(MajorIndexType indexType) { switch (indexType) { case MajorIndexType.DowJones: return(".DJI"); case MajorIndexType.Nasdaq: return(".IXIC"); case MajorIndexType.SP500: return(".INX"); default: throw new Exception("MajorIndexType Suffix Not Defined!"); } }
private string GetUrlSuffix(MajorIndexType type) { switch (type) { case MajorIndexType.DowJones: return(".DJI"); case MajorIndexType.Nasdaq: return(".IXIC"); case MajorIndexType.SP500: return(".INX"); default: throw new Exception("major Index type does not have a suffix declared"); } }
public async Task <MajorIndex> GetMajorIndex(MajorIndexType IndexType) { using (ApiHttpClient client = new ApiHttpClient()) { string uri = "majors-indexes/" + GetUriSfx(IndexType) + "?apikey=" + APIKey; MajorIndex majorIndex = await client.GetAsync <MajorIndex>(uri); majorIndex.Type = IndexType; Debug.Write("\r\n************************************"); Debug.Write("\r\nURI: " + uri); Debug.Write("\r\nIndexName: " + majorIndex.IndexName); Debug.Write("\r\nIndexPrice: " + majorIndex.Price); Debug.Write("\r\nIndexChange: " + majorIndex.Changes); Debug.Write("\r\nIndexType: " + majorIndex.Type.ToString()); Debug.Write("\r\n************************************"); return(majorIndex); } }