コード例 #1
0
        public async Task Connect()
        {
            var configRequest = new RestRequest("/whatever/config", DataFormat.Json);

            var configurationResponse = client.Get <BridgeConfigurationResponse>(configRequest);

            mac = configurationResponse.Data.mac;

            credentials = credentialsStorage.GetCredentials(this.mac);

            if (credentials == null)
            {
                await CreateBridgeUser();
            }
            else
            {
                // TODO Test credentials pair.
                var testConfigRequest = new RestRequest(string.Format("/{0}/config", credentials.Username), DataFormat.Json);

                var testConfigResponse = client.Get <BridgeConfigurationResponse>(testConfigRequest);

                if (testConfigResponse.Data.whitelist == null)
                {
                    await CreateBridgeUser();
                }
            }
        }