/// <summary> /// Find a tv show by providing ID from external tv show providers /// </summary> /// <param name="showId">External provider's show id</param> /// <param name="externalTvShowProvider">External tv show provider</param> public async Task <Show> ShowLookupAsync(string showId, ExternalTvShowProvider externalTvShowProvider) { // lookup/shows?tvrage=24493 const string relativeUrl = "/lookup/shows"; var uriBuilder = new UriBuilder(baseApiUrl) { Path = relativeUrl }; NameValueCollection queryParams = new NameValueCollection { { externalTvShowProvider.GetEnumDisplayName(), showId.ToString() } }; uriBuilder.BuildQueryString(queryParams); //var response = await httpClient.GetStringAsync(uriBuilder.Uri); var httpResponse = await httpClient.GetAsync(uriBuilder.Uri); try { httpResponse.EnsureSuccessStatusCode(); } catch (HttpRequestException ex) { throw new HttpRequestExtException(httpResponse.StatusCode, ex.Message, ex); } var response = await httpResponse.Content.ReadAsStringAsync(); Show show = DomainObjectFactory.CreateShow(response); return(show); }
/// <summary> /// Find a tv show by providing ID from external tv show providers /// </summary> /// <param name="showId">External provider's show id</param> /// <param name="externalTvShowProvider">External tv show provider</param> public Show ShowLookup(string showId, ExternalTvShowProvider externalTvShowProvider) { return(ShowLookupAsync(showId, externalTvShowProvider).Result); }