/// <summary> /// Retrieve user's filtered out gallery. /// OAuth authentication required. /// </summary> /// <param name="sort">The order that the gallery should be sorted by. Default: Viral</param> /// <param name="window">The time period that should be used in filtering requests. Default: Week</param> /// <param name="page">Set the page number so you don't have to retrieve all the data at once. Default: null</param> /// <exception cref="ArgumentNullException"> /// Thrown when a null reference is passed to a method that does not accept it as a /// valid argument. /// </exception> /// <exception cref="ImgurException">Thrown when an error is found in a response from an Imgur endpoint.</exception> /// <exception cref="MashapeException">Thrown when an error is found in a response from a Mashape endpoint.</exception> /// <returns></returns> public async Task<ICustomGallery> GetFilteredOutGalleryAsync( CustomGallerySortOrder? sort = CustomGallerySortOrder.Viral, TimeWindow? window = TimeWindow.Week, int? page = null) { if (ApiClient.OAuth2Token == null) throw new ArgumentNullException(nameof(ApiClient.OAuth2Token), OAuth2RequiredExceptionMessage); sort = sort ?? CustomGallerySortOrder.Viral; window = window ?? TimeWindow.Week; var sortValue = $"{sort}".ToLower(); var windowValue = $"{window}".ToLower(); var url = $"g/filtered/{sortValue}/{windowValue}/{page}"; using (var request = RequestBuilder.CreateRequest(HttpMethod.Get, url)) { var gallery = await SendRequestAsync<CustomGallery>(request).ConfigureAwait(false); return gallery; } }
/// <summary> /// View gallery items for a topic. /// </summary> /// <param name="topicId"> /// The ID or URL-formatted name of the topic. If using a topic's name, replace its spaces with /// underscores (Mother's_Day). /// </param> /// <param name="sort">The order that the gallery should be sorted by. Default: Viral</param> /// <param name="window">The time period that should be used in filtering requests. Default: Week</param> /// <param name="page">The data paging number. Default: null</param> /// <exception cref="ArgumentNullException"> /// Thrown when a null reference is passed to a method that does not accept it as a /// valid argument. /// </exception> /// <exception cref="ImgurException">Thrown when an error is found in a response from an Imgur endpoint.</exception> /// <exception cref="MashapeException">Thrown when an error is found in a response from a Mashape endpoint.</exception> /// <returns></returns> public async Task<IEnumerable<IGalleryItem>> GetGalleryTopicItemsAsync(string topicId, CustomGallerySortOrder? sort = CustomGallerySortOrder.Viral, TimeWindow? window = TimeWindow.Week, int? page = null) { if (string.IsNullOrWhiteSpace(topicId)) throw new ArgumentNullException(nameof(topicId)); sort = sort ?? CustomGallerySortOrder.Viral; window = window ?? TimeWindow.Week; var sortValue = $"{sort}".ToLower(); var windowValue = $"{window}".ToLower(); var url = $"topics/{topicId.Replace(" ", "_")}/{sortValue}/{windowValue}/{page}"; using (var request = RequestBuilder.CreateRequest(HttpMethod.Get, url)) { var items = await SendRequestAsync<IEnumerable<GalleryItem>>(request).ConfigureAwait(false); return items; } }