Imgur.API.Endpoints.Impl.AlbumEndpoint.CreateAlbumAsync C# (CSharp) Method

CreateAlbumAsync() public method

Create a new album.
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 CreateAlbumAsync ( string title = null, string description = null, AlbumPrivacy privacy = null, AlbumLayout layout = null, string coverId = null, IEnumerable imageIds = null ) : Task
title string The title of the album.
description string The description of the album.
privacy AlbumPrivacy Sets the privacy level of the album.
layout AlbumLayout Sets the layout to display the album.
coverId string The Id of an image that you want to be the cover of the album.
imageIds IEnumerable The imageIds that you want to be included in the album.
return Task
        public async Task<IAlbum> CreateAlbumAsync(string title = null, string description = null,
            AlbumPrivacy? privacy = null, AlbumLayout? layout = null, string coverId = null,
            IEnumerable<string> imageIds = null)
        {
            var url = "album";

            using (var request = RequestBuilder.CreateAlbumRequest(url, title, description,
                privacy, layout, coverId, imageIds))
            {
                var album = await SendRequestAsync<Album>(request).ConfigureAwait(false);
                return album;
            }
        }

Usage Example

        public async Task CreateAlbumAsync_Equal()
        {
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockAlbumEndpointResponses.Imgur.CreateAlbum)
            };

            var mockUrl = "https://api.imgur.com/3/album";
            var client = new ImgurClient("123", "1234");
            var endpoint = new AlbumEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));
            var album = await endpoint.CreateAlbumAsync().ConfigureAwait(false);

            Assert.NotNull(album);
            Assert.Equal("3gfxo", album.Id);
            Assert.Equal("iIFJnFpVbYOvzvv", album.DeleteHash);
        }