Ejemplo n.º 1
0
        /// <summary>
        /// Fetches a dynamic list of TV Shows
        /// </summary>
        /// <param name="list">Type of list to fetch</param>
        /// <param name="language">Language</param>
        /// <param name="page">Page</param>
        /// <param name="timezone">Only relevant for list type AiringToday</param>
        /// <param name="cancellationToken">A cancellation token</param>
        /// <returns></returns>
        public async Task <SearchContainer <SearchTv> > GetTvShowListAsync(TvShowListType list, string language, int page = 0, string timezone = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            RestRequest req = _client.Create("tv/{method}");

            req.AddUrlSegment("method", list.GetDescription());

            if (page > 0)
            {
                req.AddParameter("page", page.ToString());
            }

            if (!string.IsNullOrEmpty(timezone))
            {
                req.AddParameter("timezone", timezone);
            }

            language = language ?? DefaultLanguage;
            if (!string.IsNullOrWhiteSpace(language))
            {
                req.AddParameter("language", language);
            }

            RestResponse <SearchContainer <SearchTv> > resp = await req.ExecuteGet <SearchContainer <SearchTv> >(cancellationToken).ConfigureAwait(false);

            return(resp);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Fetches a dynamic list of TV Shows
        /// </summary>
        /// <param name="list">Type of list to fetch</param>
        /// <param name="language">Language</param>
        /// <param name="page">Page</param>
        /// <param name="timezone">Only relevant for list type AiringToday</param>
        /// <returns></returns>
        public async Task <SearchContainer <TvShow> > GetTvShowList(TvShowListType list, string language, int page = 0, string timezone = null)
        {
            RestRequest req = new RestRequest("tv/{method}");

            req.AddUrlSegment("method", list.GetDescription());

            if (page > 0)
            {
                req.AddParameter("page", page);
            }

            if (!string.IsNullOrEmpty(timezone))
            {
                req.AddParameter("timezone", timezone);
            }

            language = language ?? DefaultLanguage;
            if (!String.IsNullOrWhiteSpace(language))
            {
                req.AddParameter("language", language);
            }

            IRestResponse <SearchContainer <TvShow> > resp = await _client.ExecuteGetTaskAsync <SearchContainer <TvShow> >(req);

            return(resp.Data);
        }