ImgurNet.ApiEndpoints.AccountEndpoint.GetAccountAlbumsAsync C# (CSharp) Method

GetAccountAlbumsAsync() public method

Gets all albums uploaded by an account. This endpoint is pagniated.
public GetAccountAlbumsAsync ( int page, string username = "me" ) : Task>
page int The page of albums to load.
username string The username to get the album from. Can be ignored if using OAuth2, and it will use that account.
return Task>
		public async Task<ImgurResponse<Album[]>> GetAccountAlbumsAsync(int page = 0, string username = "me")
		{
			if (ImgurClient.Authentication == null)
				throw new InvalidAuthenticationException("Authentication can not be null. Set it in the main Imgur class.");

			if (username == "me" && !(ImgurClient.Authentication is OAuth2Authentication))
				throw new InvalidAuthenticationException("You need to use OAuth2Authentication to call this Endpoint.");

			return
				await
					Request.SubmitImgurRequestAsync<Album[]>(Request.HttpMethod.Get, String.Format(AccountAlbumsUrl, username, page),
						ImgurClient.Authentication);
		}

Usage Example

		public async Task TestGetAccountAlbums()
		{
			var imgurClient = await AuthenticationHelpers.CreateOAuth2AuthenticatedImgurClient();
			var accountEndpoint = new AccountEndpoint(imgurClient);
			var accountAlbums = await accountEndpoint.GetAccountAlbumsAsync(0);

			// Assert the Response
			Assert.IsNotNull(accountAlbums.Data);
			Assert.AreEqual(accountAlbums.Success, true);
			Assert.AreEqual(accountAlbums.Status, HttpStatusCode.OK);
		}