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;
}
}
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); }