/// <summary> /// A nowcast call provides forecasting data on a minute-by-minute basis. /// </summary> /// <param name="latitude">Latitude to request data for in decimal degrees, -87 to 89.</param> /// <param name="longitude">Longitude to request data for in decimal degrees, -180 to 180.</param> /// <param name="fields">Fields to request from climacell.</param> /// <param name="paramters">Optional request paramaters <see cref="OptionalParamters"/>.</param> /// <returns>A climacell <see cref="Nowcast"/> response.</returns> public async Task <Nowcast> GetNowcast(double latitude, double longitude, List <string> fields, OptionalParamters paramters = null) { if (fields.Count <= 0) { throw new ArgumentException($"{nameof(fields)} cannot be empty."); } var query = BuildRequestUri(latitude, longitude, fields, paramters, Endpoint.NowCast); var response = await httpClient.HttpRequestAsync($"{baseUri}{query}").ConfigureAwait(false); return(await Nowcast.Deserialize(response, jsonSerializerService)); }
/// <summary> /// Attempts to initalize a new <see cref="Hourly"/> from the responding <see cref="HttpResponseMessage"/>, and deserializes the response content /// using the <see cref="IJsonSerializerService"/> defined in the calling <see cref="ClimaCellService"/> instance and appends all model objects into the <see cref="ForecastResponse{T}.DataPoints"/> collection. /// </summary> public static new async Task <Nowcast> Deserialize(HttpResponseMessage responseMessage, IJsonSerializerService jsonSerializerService) { Nowcast h = new Nowcast() { Response = new ClimaCellResponse(responseMessage) }; try { h._dataPoints = await jsonSerializerService.DeserializeJsonAsync <List <Nowcast.Model> >(responseMessage.Content?.ReadAsStringAsync()).ConfigureAwait(false); } catch (FormatException e) { h.Response.IsSuccessStatus = false; h.Response.ReasonPhrase = $"Error parsing results: {e?.InnerException?.Message ?? e.Message}"; } return(h); }