/// <summary> /// Asynchronously gets the whitelist with the bridge. /// </summary> /// <returns>An enumerable of <see cref="WhiteList"/>s registered with the bridge.</returns> public async Task <IEnumerable <WhiteList> > GetWhiteListAsync() { CheckInitialized(); BridgeConfig config = await GetConfigAsync().ConfigureAwait(false); return(config.WhiteList.Select(l => l.Value).ToList()); }
/// <summary> /// Asynchronously gets the whitelist with the bridge. /// </summary> /// <returns>An enumerable of <see cref="WhiteList"/>s registered with the bridge.</returns> public async Task <IEnumerable <WhiteList> > GetWhiteListAsync() { //Not needed to check if initialized, can be used without API key BridgeConfig config = await GetConfigAsync().ConfigureAwait(false); return(config.WhiteList.Select(l => l.Value).ToList()); }
/// <summary> /// Get bridge config /// </summary> /// <returns>BridgeConfig object</returns> public async Task <BridgeConfig> GetConfigAsync() { CheckInitialized(); HttpClient client = HueClient.GetHttpClient(); string stringResult = await client.GetStringAsync(new Uri(String.Format("{0}config", ApiBase))).ConfigureAwait(false); JToken token = JToken.Parse(stringResult); BridgeConfig config = null; if (token.Type == JTokenType.Object) { var jsonResult = (JObject)token; config = JsonConvert.DeserializeObject <BridgeConfig>(jsonResult.ToString()); } return(config); }
/// <summary> /// Get bridge config /// </summary> /// <returns>BridgeConfig object</returns> public async Task <BridgeConfig> GetConfigAsync() { //Not needed to check if initialized, can be used without API key HttpClient client = await GetHttpClient().ConfigureAwait(false); string stringResult = await client.GetStringAsync(new Uri(String.Format("{0}config", ApiBase))).ConfigureAwait(false); JToken token = JToken.Parse(stringResult); BridgeConfig config = null; if (token.Type == JTokenType.Object) { var jsonResult = (JObject)token; config = JsonConvert.DeserializeObject <BridgeConfig>(jsonResult.ToString()); //Fix whitelist IDs foreach (var whitelist in config.WhiteList) { whitelist.Value.Id = whitelist.Key; } } return(config); }