/// <summary> /// Gets the full schedule - a list of all future episodes know to TvMaze, /// regardless of their country. /// </summary> /// <example>http://api.tvmaze.com/schedule/full</example> /// <returns>Full schedule</returns> /// <exception cref="HttpRequestExtException">HttpRequest exception with included HttpStatusCode</exception> public async Task <Schedule> GetFullScheduleAsync() { const string relativeUrl = "/schedule/full"; //var response = await httpClient.GetStringAsync(new Uri(baseApiUrl, relativeUrl)); var httpResponse = await httpClient.GetAsync(new Uri(baseApiUrl, relativeUrl)); try { httpResponse.EnsureSuccessStatusCode(); } catch (HttpRequestException ex) { throw new HttpRequestExtException(httpResponse.StatusCode, ex.Message, ex); } var response = await httpResponse.Content.ReadAsStringAsync(); Schedule schedule = DomainObjectFactory.CreateSchedule(response); return(schedule); }
/// <summary> /// Gets schedule that air in a given country on a given date. /// Episodes are returned in the order in which they are aired, and full information about /// the episode and the corresponding show is included /// </summary> /// <example> /// http://api.tvmaze.com/schedule?country=US&date=2014-12-01 /// http://api.tvmaze.com/schedule /// </example> /// <param name="countryCode">Country for which schedule is requestd. An ISO 3166-1 code of the country; defaults to US</param> /// <param name="date">Date for which schedule is requested. Defaults to the current day</param> /// <returns>Schedule</returns> /// <exception cref="HttpRequestExtException">HttpRequest exception with included HttpStatusCode</exception> public async Task <Schedule> GetScheduleAsync(string countryCode = null, DateTime?date = null) { const string relativeUrl = "/schedule"; var uriBuilder = new UriBuilder(baseApiUrl) { Path = relativeUrl }; var queryParams = new NameValueCollection(); // (optional) countrycode: an ISO 3166-1 code of the country; defaults to US if (countryCode != null) { queryParams["country"] = countryCode; } // (optional) date: an ISO 8601 formatted date; defaults to the current day if (date != null) { queryParams["date"] = date.Value.ToString(DATE_ISO_8601, CultureInfo.InvariantCulture); } 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(); Schedule schedule = DomainObjectFactory.CreateSchedule(response); return(schedule); }