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

GetAccountAsync() public method

Request standard user information. If you need the username for the account that is logged in, it is returned in the request for an access token.
/// 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 GetAccountAsync ( string username = "me" ) : Task
username string The user account. Default: me
return Task
        public async Task<IAccount> GetAccountAsync(string username = "me")
        {
            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);

            var url = $"account/{username}";

            using (var request = RequestBuilder.CreateRequest(HttpMethod.Get, url))
            {
                var account = await SendRequestAsync<Account>(request).ConfigureAwait(false);
                return account;
            }
        }

Usage Example

コード例 #1
0
        public async Task GetAccountAsync_WithUsername_AreEqual()
        {
            var client = new ImgurClient(ClientId, ClientSecret);
            var endpoint = new AccountEndpoint(client);

            var account = await endpoint.GetAccountAsync("sarah");

            Assert.IsTrue("sarah".Equals(account.Url, StringComparison.OrdinalIgnoreCase));
        }
All Usage Examples Of Imgur.API.Endpoints.Impl.AccountEndpoint::GetAccountAsync