예제 #1
0
        /// <summary>
        /// Call the Accounts API, on behalf of a User, to debit an account by some amount.
        /// Note that <c>amount</c> should be unsigned, and that only it's absolute value
        /// will be taken in any event.
        /// </summary>
        /// <param name="accountNumber">The account to be modified.</param>
        /// <param name="amount">The (unsigned) amount to be debited from the account.</param>
        /// <param name="memo">A short note to be attached to this transaction.</param>
        /// <param name="userCredentialsCallback">A delegate that, if invoked, returns the User's credentials.</param>
        /// <returns>The new balance for the modified account.</returns>
        ///
        public async Task <double> DebitAccount(string accountNumber, double amount, string memo,
                                                UserCredentialsCallback userCredentialsCallback)
        {
            double balance;

            var accessToken = await GetCurrentAccessToken(userCredentialsCallback);

            using (var accountsApi = new AccountsApiClient(_accountsApiUrl, accessToken))
            {
                balance = await accountsApi.DebitAccount(accountNumber, amount, memo);
            }

            return(balance);
        }