Imgur.API.Endpoints.Impl.GalleryEndpoint.GetGalleryTagAsync C# (CSharp) Method

GetGalleryTagAsync() public method

View images for a gallery tag.
/// Thrown when a null reference is passed to a method that does not accept it as a /// valid argument. /// Thrown when an error is found in a response from an Imgur endpoint. Thrown when an error is found in a response from a Mashape endpoint.
public GetGalleryTagAsync ( string tag, GalleryTagSortOrder sort = GalleryTagSortOrder.Viral, TimeWindow window = TimeWindow.Week, int page = null ) : Task
tag string The name of the tag.
sort GalleryTagSortOrder The order that the images in the gallery tag should be sorted by. Default: Viral
window TimeWindow The time period that should be used in filtering requests. Default: Week
page int The data paging number. Default: null
return Task
        public async Task<ITag> GetGalleryTagAsync(string tag, GalleryTagSortOrder? sort = GalleryTagSortOrder.Viral,
            TimeWindow? window = TimeWindow.Week, int? page = null)
        {
            if (string.IsNullOrWhiteSpace(tag))
                throw new ArgumentNullException(nameof(tag));

            sort = sort ?? GalleryTagSortOrder.Viral;
            window = window ?? TimeWindow.Week;

            var sortValue = $"{sort}".ToLower();
            var windowValue = $"{window}".ToLower();

            var url = $"gallery/t/{tag}/{sortValue}/{windowValue}/{page}";

            using (var request = RequestBuilder.CreateRequest(HttpMethod.Get, url))
            {
                var returnTag = await SendRequestAsync<Tag>(request).ConfigureAwait(false);
                return returnTag;
            }
        }

Usage Example

コード例 #1
0
        public async Task GetGalleryTagAsync_WithGalleryItemIdNull_ThrowsArgumentNullException()
        {
            var client = new ImgurClient("123", "1234");
            var endpoint = new GalleryEndpoint(client);

            var exception =
                await
                    Record.ExceptionAsync(
                        async () => await endpoint.GetGalleryTagAsync(null).ConfigureAwait(false))
                        .ConfigureAwait(false);
            Assert.NotNull(exception);
            Assert.IsType<ArgumentNullException>(exception);
        }
All Usage Examples Of Imgur.API.Endpoints.Impl.GalleryEndpoint::GetGalleryTagAsync