Ejemplo n.º 1
0
        static async Task Main(string[] args)
        {
            var bc = new BlueClientBuilder()
                     .UseHttpClient(new HttpClient(new SocketsHttpHandler
            {
                // Set a proxy if available. Suggestion: Fiddler.
                Proxy = new WebProxy(new Uri("http://127.0.0.1:8888"))
            }))
                     .UseUsernamePassword("*****@*****.**", "g5Y9B8n94dMiHbjt7AVZsBZK")
                     .Build();

            var user = await bc.GetUser();

            var pools = await bc.GetSwimmingPools();

            var pool = pools.Data.First();

            var blueDevicesPool = await bc.GetSwimmingPoolBlueDevices(pool.SwimmingPoolId);

            var blueDevice = blueDevicesPool.Data.First();

            var a = await bc.GetSwimmingPoolLastMeasurements(pool.SwimmingPoolId);

            var b = await bc.GetBlueLastMeasurements(pool.SwimmingPoolId, blueDevice.BlueDeviceSerial);

            var blueDevice2 = await bc.GetBlue(blueDevice.BlueDeviceSerial);

            var blueCompatibility = await bc.GetBlueCompatibility(blueDevice.BlueDeviceSerial);

            var pool2 = await bc.GetSwimmingPool(pool.SwimmingPoolId);

            var feed = await bc.GetSwimmingPoolFeed(pool.SwimmingPoolId);

            var lastMeasurements = await bc.GetSwimmingPoolLastMeasurements(pool.SwimmingPoolId);

            var chemistry = await bc.GetSwimmingPoolChemistry(pool.SwimmingPoolId);

            var status = await bc.GetSwimmingPoolStatus(pool.SwimmingPoolId);

            foreach (var swimmingPoolTask in status.Tasks)
            {
                var task = await bc.GetSwimmingPoolStatusTask(pool.SwimmingPoolId, swimmingPoolTask.TaskIdentifier);
            }

            var blues = await bc.GetSwimmingPoolBlueDevices(pool.SwimmingPoolId);

            var guidance = await bc.GetSwimmingPoolGuidance(pool.SwimmingPoolId);

            var guidanceHistory = await bc.GetSwimmingPoolGuidanceHistory(pool.SwimmingPoolId);

            var weather = await bc.GetSwimmingPoolWeather(pool.SwimmingPoolId);

            var weather2 = await bc.GetSwimmingPoolWeatherForecast(pool.SwimmingPoolId, DateTime.UtcNow);
        }
Ejemplo n.º 2
0
        public static IServiceCollection AddBlueRiiotClient(this IServiceCollection services, Action <IServiceProvider, BlueClientBuilder> configure)
        {
            return(services
                   .AddHttpClient()
                   .AddSingleton(x =>
            {
                BlueClientBuilder builder = new BlueClientBuilder()
                                            .UseLogger(x.GetRequiredService <ILogger <BlueClient> >())
                                            .UseHttpClientFactory(x.GetRequiredService <IHttpClientFactory>(), string.Empty);

                configure(x, builder);

                return builder.Build();
            }));
        }