コード例 #1
0
        // Exchange the code for a jwt access token
        public async Task <bool> DoExchangeAsync(string code)
        {
            if (string.IsNullOrEmpty(code))
            {
                return(false);
            }

            string uri = _trueLayerCredentials.Value.BaseAuthUrl + "/connect/token";

            ExchangeRequestDTO exchangeDTO = new ExchangeRequestDTO()
            {
                GrantType    = "authorization_code",
                ClientId     = _trueLayerCredentials.Value.ClientId,
                ClientSecret = _trueLayerCredentials.Value.ClientSecret,
                RedirectUri  = _trueLayerCredentials.Value.RedirectUrl,
                Code         = code
            };

            ExchangeResponseDTO responseObj = (ExchangeResponseDTO) await DoRequest <ExchangeResponseDTO>(HttpMethod.Post, uri, false, exchangeDTO);

            if (responseObj == null)
            {
                return(false);
            }

            Cache cache = new Cache {
                ExchangeResponseDTO = responseObj
            };

            _cacheService.SetCache(cache);

            return(true);
        }
コード例 #2
0
        public HttpRequestServiceTests()
        {
            trueLayerCredentialsOptions = Options.Create(trueLayerCredentials);
            dummyExchangeResponseDTO    = new ExchangeResponseDTO {
                AccessToken = dummyAccessToken
            };

            Account account1 = new Account {
                AccountId = "1"
            };
            Account account2 = new Account {
                AccountId = "2"
            };

            dummyAccountsResponseDTO = new AccountsResponseDTO
            {
                Accounts = new List <Account> {
                    account1, account2
                }
            };
            dummyCacheWithCodeAndAccessToken = new Cache {
                ExchangeResponseDTO = dummyExchangeResponseDTO
            };
            dummyCacheWithAccounts = new Cache
            {
                ExchangeResponseDTO = dummyExchangeResponseDTO,
                AccountsResponseDTO = dummyAccountsResponseDTO
            };

            Transaction transaction1 = new Transaction
            {
                Amount = -1.0m,
                TransactionCategory = "PURCHASE",
                Timestamp           = DateTime.Parse("2020-03-06T00:00:00+00:00")
            };

            Transaction transaction2 = new Transaction
            {
                Amount = 2.0m,
                TransactionCategory = "BILL_PAYMENT",
                Timestamp           = DateTime.Parse("2020-04-06T00:00:00+00:00")
            };

            dummyTransactions = new List <Transaction> {
                transaction1, transaction2
            };
            dummyTransactionsResponseDTO = new TransactionsResponseDTO {
                Transactions = dummyTransactions
            };
        }