using MediaBrowser.Controller;
using MediaBrowser.Model.Weather;
using ServiceStack.ServiceHost;
using System.Linq;
using System.Threading;
namespace MediaBrowser.Api
{
    /// 
    /// Class Weather
    /// 
    [Route("/Weather", "GET")]
    [Api(Description = "Gets weather information for a given location")]
    public class GetWeather : IReturn
    {
        /// 
        /// Gets or sets the location.
        /// 
        /// The location.
        [ApiMember(Name = "Location", Description = "Us zip / City, State, Country / City, Country", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
        public string Location { get; set; }
    }
    /// 
    /// Class WeatherService
    /// 
    public class WeatherService : BaseApiService
    {
        /// 
        /// Gets the specified request.
        /// 
        /// The request.
        /// System.Object.
        public object Get(GetWeather request)
        {
            var result = Kernel.Instance.WeatherProviders.First().GetWeatherInfoAsync(request.Location, CancellationToken.None).Result;
            return ToOptimizedResult(result);
        }
    }
}