Created a sloppy api for home weather
This commit is contained in:
20
HomeApi/Models/ApiConfiguration.cs
Normal file
20
HomeApi/Models/ApiConfiguration.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace HomeApi;
|
||||
|
||||
public class ApiConfiguration
|
||||
{
|
||||
public Keys Keys { get; set; } = new();
|
||||
public BaseUrls BaseUrls { get; set; } = new();
|
||||
public string DefaultCity { get; set; } = "Vega stockholms lan";
|
||||
}
|
||||
|
||||
public class BaseUrls
|
||||
{
|
||||
public string Weather { get; set; } = string.Empty;
|
||||
public string SL { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class Keys
|
||||
{
|
||||
public string Weather { get; set; } = string.Empty;
|
||||
public string SL { get; set; } = string.Empty;
|
||||
}
|
||||
128
HomeApi/Models/AuroraForecast.cs
Normal file
128
HomeApi/Models/AuroraForecast.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
namespace HomeApi.Models;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
public class AuroraForecast
|
||||
{
|
||||
[JsonPropertyName("date")]
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
[JsonPropertyName("ace")]
|
||||
public AceData Ace { get; set; }
|
||||
|
||||
[JsonPropertyName("weather")]
|
||||
public bool Weather { get; set; }
|
||||
|
||||
[JsonPropertyName("probability")]
|
||||
public ProbabilityData Probability { get; set; }
|
||||
|
||||
[JsonPropertyName("message")]
|
||||
public List<string> Message { get; set; }
|
||||
}
|
||||
|
||||
public class AceData
|
||||
{
|
||||
[JsonPropertyName("date")]
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
[JsonPropertyName("bz")]
|
||||
public string Bz { get; set; }
|
||||
|
||||
[JsonPropertyName("density")]
|
||||
public string Density { get; set; }
|
||||
|
||||
[JsonPropertyName("speed")]
|
||||
public string Speed { get; set; }
|
||||
|
||||
[JsonPropertyName("kp1hour")]
|
||||
public string Kp1Hour { get; set; }
|
||||
|
||||
[JsonPropertyName("kp4hour")]
|
||||
public string Kp4Hour { get; set; }
|
||||
|
||||
[JsonPropertyName("kp")]
|
||||
public string Kp { get; set; }
|
||||
|
||||
[JsonPropertyName("colour")]
|
||||
public ColourData Colour { get; set; }
|
||||
}
|
||||
|
||||
public class ColourData
|
||||
{
|
||||
[JsonPropertyName("bz")]
|
||||
public string Bz { get; set; }
|
||||
|
||||
[JsonPropertyName("density")]
|
||||
public string Density { get; set; }
|
||||
|
||||
[JsonPropertyName("speed")]
|
||||
public string Speed { get; set; }
|
||||
|
||||
[JsonPropertyName("kp1hour")]
|
||||
public string Kp1Hour { get; set; }
|
||||
|
||||
[JsonPropertyName("kp4hour")]
|
||||
public string Kp4Hour { get; set; }
|
||||
|
||||
[JsonPropertyName("kp")]
|
||||
public string Kp { get; set; }
|
||||
}
|
||||
|
||||
public class ProbabilityData
|
||||
{
|
||||
[JsonPropertyName("date")]
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
[JsonPropertyName("calculated")]
|
||||
public CalculatedProbability Calculated { get; set; }
|
||||
|
||||
[JsonPropertyName("colour")]
|
||||
public string Colour { get; set; }
|
||||
|
||||
[JsonPropertyName("lat")]
|
||||
public string Lat { get; set; }
|
||||
|
||||
[JsonPropertyName("long")]
|
||||
public string Long { get; set; }
|
||||
|
||||
[JsonPropertyName("value")]
|
||||
public int Value { get; set; }
|
||||
|
||||
[JsonPropertyName("highest")]
|
||||
public HighestProbability Highest { get; set; }
|
||||
}
|
||||
|
||||
public class CalculatedProbability
|
||||
{
|
||||
[JsonPropertyName("lat")]
|
||||
public double Lat { get; set; }
|
||||
|
||||
[JsonPropertyName("long")]
|
||||
public double Long { get; set; }
|
||||
|
||||
[JsonPropertyName("value")]
|
||||
public int Value { get; set; }
|
||||
|
||||
[JsonPropertyName("colour")]
|
||||
public string Colour { get; set; }
|
||||
}
|
||||
|
||||
public class HighestProbability
|
||||
{
|
||||
[JsonPropertyName("date")]
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
[JsonPropertyName("colour")]
|
||||
public string Colour { get; set; }
|
||||
|
||||
[JsonPropertyName("lat")]
|
||||
public double Lat { get; set; }
|
||||
|
||||
[JsonPropertyName("long")]
|
||||
public double Long { get; set; }
|
||||
|
||||
[JsonPropertyName("value")]
|
||||
public int Value { get; set; }
|
||||
}
|
||||
67
HomeApi/Models/Home.cs
Normal file
67
HomeApi/Models/Home.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
namespace HomeApi.Models;
|
||||
|
||||
public class Home
|
||||
{
|
||||
public string CityName { get; set; } = string.Empty;
|
||||
public Current Current { get; set; } = new();
|
||||
public List<Forecast> Forecast { get; set; }
|
||||
}
|
||||
|
||||
public class Current
|
||||
{
|
||||
public string Date { get; set; }
|
||||
public double Feelslike { get; set; }
|
||||
public int IsDay { get; set; }
|
||||
public double WindPerHour { get; set; } = new();
|
||||
public double WindGustPerHour { get; set; } = new();
|
||||
public double Temperature { get; set; } = new();
|
||||
public Probability AuroraProbability { get; set; } = new();
|
||||
}
|
||||
|
||||
public class Probability
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
public CalculatedProbability Calculated { get; set; } // my location?
|
||||
public string Colour { get; set; }
|
||||
public int Value { get; set; }
|
||||
public Highest HighestProbability { get; set; }
|
||||
}
|
||||
|
||||
public class Highest
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
public string Colour { get; set; }
|
||||
public double Lat { get; set; }
|
||||
public double Long { get; set; }
|
||||
public int Value { get; set; }
|
||||
}
|
||||
|
||||
public class Forecast
|
||||
{
|
||||
public string Date { get; set; }
|
||||
public double MinTempC { get; set; }
|
||||
public double MaxTempC { get; set; }
|
||||
public string DayIcon { get; set; }
|
||||
public WeatherSummary Day { get; set; }
|
||||
public WeatherSummary Night { get; set; }
|
||||
public Astro Astro { get; set; }
|
||||
}
|
||||
public class Astro
|
||||
{
|
||||
public string Sunrise { get; set; }
|
||||
public string Sunset { get; set; }
|
||||
public string Moonrise { get; set; }
|
||||
public string Moonset { get; set; }
|
||||
public string Moon_Phase { get; set; }
|
||||
public double? Moon_Illumination { get; set; }
|
||||
}
|
||||
|
||||
public class WeatherSummary
|
||||
{
|
||||
public string ConditionText { get; set; }
|
||||
public string ConditionIcon { get; set; }
|
||||
public double AvgTempC { get; set; }
|
||||
public double AvgFeelslikeC { get; set; }
|
||||
public int TotalChanceOfRain { get; set; }
|
||||
public int TotalChanceOfSnow { get; set; }
|
||||
}
|
||||
172
HomeApi/Models/WeatherApiResponse.cs
Normal file
172
HomeApi/Models/WeatherApiResponse.cs
Normal file
@@ -0,0 +1,172 @@
|
||||
public class WeatherData
|
||||
{
|
||||
public Location Location { get; set; }
|
||||
public Current Current { get; set; }
|
||||
public Forecast Forecast { get; set; }
|
||||
public Alerts Alerts { get; set; }
|
||||
}
|
||||
|
||||
public class Location
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Region { get; set; }
|
||||
public string Country { get; set; }
|
||||
public double Lat { get; set; }
|
||||
public double Lon { get; set; }
|
||||
public string Tz_Id { get; set; }
|
||||
public long Localtime_Epoch { get; set; }
|
||||
public string Localtime { get; set; }
|
||||
}
|
||||
|
||||
public class Current
|
||||
{
|
||||
public long Last_Updated_Epoch { get; set; }
|
||||
public string Last_Updated { get; set; }
|
||||
public double Temp_C { get; set; }
|
||||
public double Temp_F { get; set; }
|
||||
public int Is_Day { get; set; }
|
||||
public Condition Condition { get; set; }
|
||||
public double Wind_Mph { get; set; }
|
||||
public double Wind_Kph { get; set; }
|
||||
public int Wind_Degree { get; set; }
|
||||
public string Wind_Dir { get; set; }
|
||||
public double Pressure_Mb { get; set; }
|
||||
public double Pressure_In { get; set; }
|
||||
public double Precip_Mm { get; set; }
|
||||
public double Precip_In { get; set; }
|
||||
public int Humidity { get; set; }
|
||||
public int Cloud { get; set; }
|
||||
public double Feelslike_C { get; set; }
|
||||
public double Feelslike_F { get; set; }
|
||||
public double Vis_Km { get; set; }
|
||||
public double Vis_Miles { get; set; }
|
||||
public double Uv { get; set; } // changed to double
|
||||
public double Gust_Mph { get; set; }
|
||||
public double Gust_Kph { get; set; } // i byarna
|
||||
public AirQuality Air_Quality { get; set; }
|
||||
}
|
||||
|
||||
public class Condition
|
||||
{
|
||||
public string Text { get; set; }
|
||||
public string Icon { get; set; }
|
||||
public int Code { get; set; }
|
||||
}
|
||||
|
||||
public class AirQuality
|
||||
{
|
||||
public double Co { get; set; }
|
||||
public double No2 { get; set; }
|
||||
public double O3 { get; set; }
|
||||
public double So2 { get; set; }
|
||||
public double Pm2_5 { get; set; }
|
||||
public double Pm10 { get; set; }
|
||||
public int Us_Epa_Index { get; set; }
|
||||
public int Gb_Defra_Index { get; set; }
|
||||
}
|
||||
|
||||
public class Forecast
|
||||
{
|
||||
public List<ForecastDay> Forecastday { get; set; }
|
||||
}
|
||||
|
||||
public class ForecastDay
|
||||
{
|
||||
public string Date { get; set; }
|
||||
public long Date_Epoch { get; set; }
|
||||
public Day Day { get; set; }
|
||||
public Astro Astro { get; set; }
|
||||
public List<Hour> Hour { get; set; }
|
||||
}
|
||||
|
||||
public class Day
|
||||
{
|
||||
public double Maxtemp_C { get; set; }
|
||||
public double Maxtemp_F { get; set; }
|
||||
public double Mintemp_C { get; set; }
|
||||
public double Mintemp_F { get; set; }
|
||||
public double Avgtemp_C { get; set; }
|
||||
public double Avgtemp_F { get; set; }
|
||||
public double Maxwind_Mph { get; set; }
|
||||
public double Maxwind_Kph { get; set; }
|
||||
public double Totalprecip_Mm { get; set; }
|
||||
public double Totalprecip_In { get; set; }
|
||||
public double Avgvis_Km { get; set; }
|
||||
public double Avgvis_Miles { get; set; }
|
||||
public int Avghumidity { get; set; }
|
||||
public int Daily_Will_It_Rain { get; set; }
|
||||
public int Daily_Chance_Of_Rain { get; set; }
|
||||
public int Daily_Will_It_Snow { get; set; }
|
||||
public int Daily_Chance_Of_Snow { get; set; }
|
||||
public Condition Condition { get; set; }
|
||||
public double Uv { get; set; } // changed to double
|
||||
}
|
||||
|
||||
public class Astro
|
||||
{
|
||||
public string Sunrise { get; set; }
|
||||
public string Sunset { get; set; }
|
||||
public string Moonrise { get; set; }
|
||||
public string Moonset { get; set; }
|
||||
public string Moon_Phase { get; set; }
|
||||
public double? Moon_Illumination { get; set; }
|
||||
}
|
||||
|
||||
public class Hour
|
||||
{
|
||||
public long Time_Epoch { get; set; }
|
||||
public string Time { get; set; }
|
||||
public double Temp_C { get; set; }
|
||||
public double Temp_F { get; set; }
|
||||
public int Is_Day { get; set; }
|
||||
public Condition Condition { get; set; }
|
||||
public double Wind_Mph { get; set; }
|
||||
public double Wind_Kph { get; set; }
|
||||
public int Wind_Degree { get; set; }
|
||||
public string Wind_Dir { get; set; }
|
||||
public double Pressure_Mb { get; set; }
|
||||
public double Pressure_In { get; set; }
|
||||
public double Precip_Mm { get; set; }
|
||||
public double Precip_In { get; set; }
|
||||
public int Humidity { get; set; }
|
||||
public int Cloud { get; set; }
|
||||
public double Feelslike_C { get; set; }
|
||||
public double Feelslike_F { get; set; }
|
||||
public double Windchill_C { get; set; }
|
||||
public double Windchill_F { get; set; }
|
||||
public double Heatindex_C { get; set; }
|
||||
public double Heatindex_F { get; set; }
|
||||
public double Dewpoint_C { get; set; }
|
||||
public double Dewpoint_F { get; set; }
|
||||
public int Will_It_Rain { get; set; }
|
||||
public int Chance_Of_Rain { get; set; }
|
||||
public int Will_It_Snow { get; set; }
|
||||
public int Chance_Of_Snow { get; set; }
|
||||
public double Vis_Km { get; set; }
|
||||
public double Vis_Miles { get; set; }
|
||||
public double Gust_Mph { get; set; }
|
||||
public double Gust_Kph { get; set; }
|
||||
public double Uv { get; set; } // changed to double
|
||||
}
|
||||
|
||||
public class Alerts
|
||||
{
|
||||
public List<Alert> Alert { get; set; }
|
||||
}
|
||||
|
||||
public class Alert
|
||||
{
|
||||
public string Headline { get; set; }
|
||||
public string Msgtype { get; set; }
|
||||
public string Severity { get; set; }
|
||||
public string Urgency { get; set; }
|
||||
public string Areas { get; set; }
|
||||
public string Category { get; set; }
|
||||
public string Certainty { get; set; }
|
||||
public string Event { get; set; }
|
||||
public string Note { get; set; }
|
||||
public string Effective { get; set; }
|
||||
public string Expires { get; set; }
|
||||
public string Desc { get; set; }
|
||||
public string Instruction { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user