/// <summary>
        ///     Get the weather for the specified location. Do not call this method often, typically only once per session.
        ///     Required scopes: talk_tower
        /// </summary>
        /// <param name="latLong">The location.</param>
        /// <returns>The weather info for the current conditions.</returns>
        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;
        }
Ejemplo n.º 2
0
 public ReportRequest(AircraftInfo aircraftInfo, FlightInfo flightInfo, params string[] reportTypes)
 {
     AircraftInfo = aircraftInfo;
     FlightInfo   = flightInfo;
     RequestedReportTypes.AddRange(reportTypes);
 }
Ejemplo n.º 3
0
 public ReportRequest(AircraftInfo aircraftInfo, FlightInfo flightInfo, params string[] reportTypes)
 {
     AircraftInfo         = aircraftInfo;
     FlightInfo           = flightInfo;
     RequestedReportTypes = new List <string>(reportTypes);
 }