From 41811ef2c057f3f492335b23ffc44b63c36fe48a Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 20 May 2023 22:06:16 -0400 Subject: [PATCH] send console data to gotify --- WeatherDashboard.Console/Program.cs | 12 +++++++++--- WeatherDashboard.Console/appsettings.json | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/WeatherDashboard.Console/Program.cs b/WeatherDashboard.Console/Program.cs index 153bd14..b42a93c 100644 --- a/WeatherDashboard.Console/Program.cs +++ b/WeatherDashboard.Console/Program.cs @@ -6,7 +6,7 @@ using WeatherDashboard; var builder = Host.CreateDefaultBuilder(args); -builder.ConfigureAppConfiguration((context, config) => +builder.ConfigureAppConfiguration((context, config) => { var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); @@ -15,7 +15,7 @@ builder.ConfigureAppConfiguration((context, config) => config.AddJsonFile($"appsettings.{environment}.json", true); }); -builder.ConfigureServices(services => +builder.ConfigureServices(services => { services.AddHttpClient(); }); @@ -27,7 +27,13 @@ var httpClientFactory = app.Services.GetService(); var httpClient = httpClientFactory.CreateClient(); var apiUrl = configuration["ApiUrl"]; +var gotifyUrl = configuration["GotifyUrl"]; var weatherSet = await httpClient.GetFromJsonAsync(apiUrl); -Console.WriteLine(weatherSet.Current.ConditionName); \ No newline at end of file +var notificationResponse = await httpClient.PostAsJsonAsync(gotifyUrl, new +{ + title = "Weather Conditions", + message = $"{weatherSet.Current.ConditionName} and {weatherSet.Current.Temperature} degrees", + priority = 5 +}); \ No newline at end of file diff --git a/WeatherDashboard.Console/appsettings.json b/WeatherDashboard.Console/appsettings.json index 2da2e90..bff7e6b 100644 --- a/WeatherDashboard.Console/appsettings.json +++ b/WeatherDashboard.Console/appsettings.json @@ -1,3 +1,4 @@ { - "ApiUrl": "https://weather.binarydad.com/api" + "ApiUrl": "https://weather.binarydad.com/api", + "GotifyUrl": "https://push.binarydad.com/message?token=AaYB_oOYlFz1nnp" } \ No newline at end of file