Exemplo n.º 1
0
        /// <summary>
        ///     Retrieve the balance of an account identified by its ID.
        /// </summary>
        /// <exception cref="ApiException">Thrown when fails to make API call</exception>
        /// <param name="accountId"></param>
        /// <param name="accessToken"></param>
        /// <param name="cents">If true amounts will be shown in cents. (optional, default to false)</param>
        /// <returns>AccountBalance</returns>
        public async Task <AccountBalance> GetAccountBalanceAsync(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 (accountId == null)
            {
                throw new ArgumentNullException(nameof(accountId));
            }

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

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