static public String GallerySearch(GallerySort sort, GallerySearchWindow window, int page, String queryString = "") { String queryBase = String.Format(_gallerySearch, Utilities.convertToString(sort), Utilities.convertToString(window), page ); if (queryString == "") { return(queryBase); } else { UriBuilder builder = new UriBuilder(queryBase); if (queryString.StartsWith("q=")) { builder.Query = queryString; } else { builder.Query = "q=" + queryString; } return(builder.ToString()); } }
static public String Gallery(GallerySection section, GallerySort sort, int page) { return(String.Format(_gallery, Utilities.convertToString(section), Utilities.convertToString(sort), page)); }
/// <summary> /// Search the gallery with a given query string /// </summary> /// <param name="searchQuery">A valid search query</param> /// <param name="page">The current page</param> /// <param name="sort">The sort method (can't be viral)</param> public async Task <ImgurResponse <IGalleryObject[]> > SearchGalleryAsync(string searchQuery, int page = 0, GallerySort sort = GallerySort.Time) { if (ImgurClient.Authentication == null) { throw new InvalidAuthenticationException("Authentication can not be null. Set it in the main Imgur class."); } var endpoint = String.Format(GallerySearchUrl, sort.ToString().ToLowerInvariant(), page, searchQuery); return (await Request.SubmitImgurRequestAsync(Request.HttpMethod.Get, endpoint, ImgurClient.Authentication, customParser : ParseGalleryObjectArrayResponse)); }
/// <summary> /// Search the gallery with a given query string. /// </summary> /// <param name="sorting">time | viral | top - defaults to time</param> /// <param name="window">Change the date range of the request if the sort is 'top', day | week | month | year | all, defaults to all.</param> /// <param name="page">the data paging number</param> /// <param name="query">Query string. This parameter also supports boolean operators (AND, OR, NOT) and indices (tag: user: title: ext: subreddit: album: meme:). An example compound query would be 'title: cats AND dogs ext: gif'</param> /// <returns></returns> public async Task <ImgurGalleryImageList> GallerySearchAsync(GallerySort sorting = GallerySort.time, GallerySearchWindow window = GallerySearchWindow.all, int page = 0, string query = "") { String responseString = await GetAnonymousImgurDataAsync(ImgurEndpoints.GallerySearch(sorting, window, page, query)); return(await Task.Run(() => JsonConvert.DeserializeObject <ImgurGalleryImageList>(responseString, _defaultSerializerSettings))); }
/// <summary> /// Returns the list of images in the Main gallery in the given section and with the given sort method /// </summary> /// <param name="section">The section to get the images from.</param> /// <param name="sorting">The sorting method to use to sort the returned images. Default is the viral sorting method.</param> /// <param name="page">The page number to return images from. Default is the first page (0).</param> /// <returns>The list of images in the chosen gallery</returns> public async Task <ImgurGalleryImageList> GalleryDetailsAsync(GallerySection section, GallerySort sorting = GallerySort.viral, int page = 0) { string responseString = await GetAnonymousImgurDataAsync(ImgurEndpoints.Gallery(section, sorting, page)); return(await Task.Run(() => JsonConvert.DeserializeObject <ImgurGalleryImageList>(responseString, _defaultSerializerSettings))); }
/// <summary> /// Returns the images in the gallery /// </summary> /// <param name="page">The current page</param> /// <param name="section">The section of the site</param> /// <param name="sort">The sort method</param> /// <param name="window">Change the date range of the request if the section is "top"</param> /// <param name="showVirual">Show or hide viral images from the 'user' section.</param> public async Task <ImgurResponse <IGalleryObject[]> > GetGalleryImagesAsync(int page = 0, GallerySection section = GallerySection.Hot, GallerySort sort = GallerySort.Viral, GalleryWindow window = GalleryWindow.Day, bool showVirual = true) { if (ImgurClient.Authentication == null) { throw new InvalidAuthenticationException("Authentication can not be null. Set it in the main Imgur class."); } var endpoint = String.Format(GalleryUrl, section.ToString().ToLowerInvariant(), sort.ToString().ToLowerInvariant(), window.ToString().ToLowerInvariant(), page, showVirual.ToString().ToLowerInvariant()); return (await Request.SubmitImgurRequestAsync(Request.HttpMethod.Get, endpoint, ImgurClient.Authentication, customParser : ParseGalleryObjectArrayResponse)); }