Imgur.API.Endpoints.Impl.AccountEndpoint.GetAccountGalleryFavoritesAsync C# (CSharp) Method

GetAccountGalleryFavoritesAsync() public method

Return the images the user has favorited in the 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 GetAccountGalleryFavoritesAsync ( string username = "me", int page = null, AccountGallerySortOrder sort = AccountGallerySortOrder.Newest ) : Task>
username string The user account. Default: me
page int Set the page number so you don't have to retrieve all the data at once. Default: null
sort AccountGallerySortOrder The order that the account gallery should be sorted by. Default: Newest
return Task>
        public async Task<IEnumerable<IGalleryItem>> GetAccountGalleryFavoritesAsync(string username = "me",
            int? page = null,
            AccountGallerySortOrder? sort = AccountGallerySortOrder.Newest)
        {
            if (string.IsNullOrWhiteSpace(username))
                throw new ArgumentNullException(nameof(username));

            if (username.Equals("me", StringComparison.OrdinalIgnoreCase)
                && ApiClient.OAuth2Token == null)
                throw new ArgumentNullException(nameof(ApiClient.OAuth2Token), OAuth2RequiredExceptionMessage);

            sort = sort ?? AccountGallerySortOrder.Newest;

            var sortValue = $"{sort}".ToLower();
            var url = $"account/{username}/gallery_favorites/{page}/{sortValue}";

            using (var request = ImageRequestBuilder.CreateRequest(HttpMethod.Get, url))
            {
                var favorites = await SendRequestAsync<IEnumerable<GalleryItem>>(request).ConfigureAwait(false);
                return favorites;
            }
        }

Usage Example

コード例 #1
0
 public async Task GetAccountGalleryFavoritesAsync_WithDefaultUsernameAndOAuth2Null_ThrowsArgumentNullException
     ()
 {
     var client = new ImgurClient("123", "1234");
     var endpoint = new AccountEndpoint(client);
     await endpoint.GetAccountGalleryFavoritesAsync();
 }
All Usage Examples Of Imgur.API.Endpoints.Impl.AccountEndpoint::GetAccountGalleryFavoritesAsync