public BranchesRespV1 GetBranches() { string url = string.Format(_urlRoot + "/v1/branches"); HttpResponseMessage response = WebbCall(url, _authKey); if (response.IsSuccessStatusCode) { string json = response.Content.ReadAsStringAsync().Result; BranchesRespV1 res = JsonConvert.DeserializeObject <BranchesRespV1>(json); return(res); } else { Console.WriteLine("GetBranches {0} ({1})", (int)response.StatusCode, response.ReasonPhrase); } return(null); }
// Get all Meta data about Instruments and connect data to Instrument Object. static void InstrumentsWithMetadata() { ApiClient api = new ApiClient(_apiKey); // get all Meta data CountriesRespV1 cr = api.GetCountries(); BranchesRespV1 br = api.GetBranches(); SectorsRespV1 sr = api.GetSectors(); MarketsRespV1 mr = api.GetMarkets(); // Get all Instruments InstrumentRespV1 inst = api.GetInstruments(); // Connect Meta data to Instruments foreach (InstrumentV1 c in inst.Instruments) { CountryV1 country = cr.Countries.FirstOrDefault(o => o.Id == c.CountryId); c.CountryModel = country; MarketV1 Market = mr.Markets.FirstOrDefault(o => o.Id == c.MarketId); c.MarketModel = Market; BranchV1 Branch = br.Branches.FirstOrDefault(o => o.Id == c.BranchId); c.BranchModel = Branch; SectorV1 Sector = sr.Sectors.FirstOrDefault(o => o.Id == c.SectorId); c.SectorModel = Sector; } // Print Data to see all is ok foreach (InstrumentV1 c in inst.Instruments) { if (c.Instrument == Instrument.Index) // Index don't have any Branch or Sector { Console.WriteLine(c.Name + " : " + c.CountryModel.Name + " : " + c.MarketModel.Name); } else { Console.WriteLine(c.Name + " : " + c.CountryModel.Name + " : " + c.MarketModel.Name + " : " + c.BranchModel.Name + " : " + c.SectorModel.Name); } } }