Esempio n. 1
0
        /// <summary>
        ///     Retrieve detailed information about an account identified by its ID.
        /// </summary>
        /// <exception cref="ApiException">Thrown when fails to make API call</exception>
        /// <param name="accessToken"></param>
        /// <param name="accountId"></param>
        /// <param name="cents">If true amounts will be shown in cents. (optional, default to false)</param>
        /// <returns>Account</returns>
        public async Task <Account> GetDetailAsync(AccessTokenDto accessToken, string accountId, bool cents = false)
        {
            if (accessToken == null)
            {
                throw new ArgumentNullException(nameof(accessToken));
            }

            if (!accessToken.IsValid)
            {
                throw new ArgumentException($"{nameof(accessToken)} is expired.");
            }

            if (string.IsNullOrEmpty(accountId))
            {
                throw new ArgumentException("Value cannot be null or empty.", nameof(accountId));
            }

            this.Configuration.AccessToken = accessToken.AccessToken;
            var accountService = new AccountsApi(this.Configuration, this.Logger);

            return(await accountService.GetAccountAsync(accountId, cents).ConfigureAwait(false));
        }