コード例 #1
0
        public async Task <GetMultipleResponse <TVShow> > DiscoverTVShowsAsync(DiscoverTVShowsRequest request)
        {
            return(await ExecuteAsync <GetMultipleResponse <TVShow> >(request, async response =>
            {
                var uriQuery = $"api_key={_v3Key}&page={request.page}&with_genres={string.Join(',', request.genres.ToArray())}&language={request.language}&region={request.region}";
                var getResponse = await _httpClient.GetAsync($"{_baseAddress}/discover/tv?{uriQuery}");

                if (getResponse.IsSuccessStatusCode)
                {
                    var tmdbResponse = JsonConvert.DeserializeObject <TMDbResponse <TVShow> >(await getResponse.Content.ReadAsStringAsync());
                    response.Page = tmdbResponse.page;
                    response.Results = tmdbResponse.results;
                    response.TotalPages = tmdbResponse.total_pages;
                    //response.TotalResults = tmdbResponse.total_results;
                }
                else
                {
                    throw new ApiException(await getResponse.Content.ReadAsStringAsync(), statusCode: (int)getResponse.StatusCode);
                }
            }));
        }
コード例 #2
0
 public async Task <IActionResult> DiscoverTVShows([FromQuery] DiscoverTVShowsRequest request)
 {
     return(Ok(await _client.DiscoverTVShowsAsync(request)));
 }