AltitudeAngelWings.ApiClient.Client.AltitudeAngelClient.GetWeather C# (CSharp) Method

GetWeather() public method

Get the weather for the specified location. Do not call this method often, typically only once per session. Required scopes: talk_tower
public GetWeather ( GMap.NET.PointLatLng latLong ) : Task
latLong GMap.NET.PointLatLng The location.
return Task
        public async Task<WeatherInfo> GetWeather(PointLatLng latLong)
        {
            var flightInfo = new FlightInfo
            {
                Position = new LatLong(latLong)
            };

            var aircraftInfo = new AircraftInfo
            {
                Id = "Id"
            };

            // Load this as a JObject as reports are extensible
            JObject reportResponse = await _apiUrl
                .AppendPathSegments("ops", "tower", "report")
                .WithClient(_client)
                .PostJsonAsync(new ReportRequest(aircraftInfo, flightInfo, "weather"))
                .ReceiveJson<JObject>();

            // Grab the weather for now if there is one and process it
            var currentWeather = reportResponse.SelectToken("weather.forecast.current")?.ToObject<WeatherInfo>();

            return currentWeather;
        }