public VoteGalleryItemAsync ( string galleryItemId, VoteOption vote ) : Task |
||
galleryItemId | string | The gallery item id. |
vote | VoteOption | The vote. |
return | Task |
public async Task<bool> VoteGalleryItemAsync(string galleryItemId, VoteOption vote)
{
if (string.IsNullOrWhiteSpace(galleryItemId))
throw new ArgumentNullException(nameof(galleryItemId));
if (ApiClient.OAuth2Token == null)
throw new ArgumentNullException(nameof(ApiClient.OAuth2Token), OAuth2RequiredExceptionMessage);
var voteValue = $"{vote}".ToLower();
var url = $"gallery/{galleryItemId}/vote/{voteValue}";
using (var request = RequestBuilder.CreateRequest(HttpMethod.Post, url))
{
var voted = await SendRequestAsync<bool>(request).ConfigureAwait(false);
return voted;
}
}
}
public async Task VoteGalleryItemAsync_WithGalleryItemIdNull_ThrowsArgumentNullException() { var client = new ImgurClient("123", "1234", MockOAuth2Token); var endpoint = new GalleryEndpoint(client); var exception = await Record.ExceptionAsync( async () => await endpoint.VoteGalleryItemAsync(null, VoteOption.Down).ConfigureAwait(false)) .ConfigureAwait(false); Assert.NotNull(exception); Assert.IsType<ArgumentNullException>(exception); }