Beispiel #1
0
        /// <inheritdoc />
        public async Task<PlaidResult<IList<Account>>> GetAuthAccountDataAsync(AccessToken accessToken)
        {
            Condition.Requires(accessToken).IsNotNull();

            PlaidRequest dataRequest = new PlaidRequest(this.clientId, this.clientSecret, accessToken.Value);
            HttpResponseMessage response = await this.httpClient.PostAsJsonAsync(GetEndpoint(ApiType.Auth, "get"), dataRequest);
            string responseJson = await response.Content.ReadAsStringAsync();

            if (response.StatusCode == HttpStatusCode.OK)
            {
                // Can re-use AddUserResponse since it has accounts, just ignore transactions
                AddUserResponse dataResponse = JsonConvert.DeserializeObject<AddUserResponse>(responseJson);

                return new PlaidResult<IList<Account>>(dataResponse?.Accounts?.Select(a => a.ToAccount()).ToList());
            }

            PlaidResult<IList<Account>> errorResult = new PlaidResult<IList<Account>>();
            errorResult.Exception = await this.ParseException(response, responseJson);
            return errorResult;
        }
Beispiel #2
0
        /// <inheritdoc />
        public async Task<PlaidResult<bool>> DeleteUserAsync(AccessToken accessToken, ApiType api = ApiType.Connect)
        {
            Condition.Requires(accessToken).IsNotNull();

            PlaidRequest deleteRequest = new PlaidRequest(this.clientId, this.clientSecret, accessToken.Value);

            HttpResponseMessage response = await this.httpClient.DeleteAsJsonAsync(GetEndpoint(api), deleteRequest);

            PlaidResult<bool> result = new PlaidResult<bool>(response.StatusCode == HttpStatusCode.OK);
            result.Exception = await this.ParseException(response);

            return result;
        }
Beispiel #3
-1
        /// <inheritdoc />
        public async Task<PlaidResult<IList<Account>>> GetAccountsAsync(AccessToken accessToken)
        {
            Condition.Requires(accessToken).IsNotNull();

            PlaidRequest balanceRequest = new PlaidRequest(this.clientId, this.clientSecret, accessToken.Value);
            HttpResponseMessage response = await this.httpClient.PostAsJsonAsync("balance", balanceRequest);

            // Re-use add user result since it contains the account objects of interest
            AddUserResult userResult = await this.ProcessAddOrAuthResponse(response);
            PlaidResult<IList<Account>> result = new PlaidResult<IList<Account>>();

            if (userResult.Accounts != null) result.Value = new List<Account>(userResult.Accounts);

            result.Exception = userResult.Exception;

            return result;
        }