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

GetMemesSubGalleryImageAsync() public method

View a single image in the memes gallery.
/// 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 GetMemesSubGalleryImageAsync ( string imageId ) : Task
imageId string The image id.
return Task
        public async Task<IGalleryImage> GetMemesSubGalleryImageAsync(string imageId)
        {
            if (string.IsNullOrWhiteSpace(imageId))
                throw new ArgumentNullException(nameof(imageId));

            var url = $"gallery/image/{imageId}";

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

Usage Example

コード例 #1
0
        public async Task GetMemesSubGalleryImageAsync_NotNull()
        {
            var mockUrl = "https://api.imgur.com/3/gallery/image/rNdMhHm";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockGalleryEndpointResponses.GetGalleryImage)
            };

            var client = new ImgurClient("123", "1234");
            var endpoint = new GalleryEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));
            var image = await endpoint.GetMemesSubGalleryImageAsync("rNdMhHm").ConfigureAwait(false);

            Assert.NotNull(image);
            Assert.Equal("rNdMhHm", image.Id);
            Assert.Equal("wanna make money quickly? follow the instruction below", image.Title);
            Assert.Equal("i am not lying. FP edit: may the money cat bless you all with wealth ^^", image.Description);
            Assert.Equal(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(1451524552), image.DateTime);
            Assert.Equal("image/png", image.Type);
            Assert.Equal(false, image.Animated);
            Assert.Equal(610, image.Width);
            Assert.Equal(558, image.Height);
            Assert.Equal(564133, image.Size);
            Assert.Equal(923523, image.Views);
            Assert.Equal(520989800559, image.Bandwidth);
            Assert.Equal(null, image.Vote);
            Assert.Equal(false, image.Favorite);
            Assert.Equal(false, image.Nsfw);
            Assert.Equal("pics", image.Section);
            Assert.Equal("Calasin", image.AccountUrl);
            Assert.Equal(22349254, image.AccountId);
            Assert.Equal(619, image.CommentCount);
            Assert.Equal("No Topic", image.Topic);
            Assert.Equal(29, image.TopicId);
            Assert.Equal("http://i.imgur.com/rNdMhHm.png", image.Link);
            Assert.Equal(28057, image.Ups);
            Assert.Equal(5924, image.Downs);
            Assert.Equal(22133, image.Points);
            Assert.Equal(22594, image.Score);
        }
All Usage Examples Of Imgur.API.Endpoints.Impl.GalleryEndpoint::GetMemesSubGalleryImageAsync