-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from RileyEv/transactions
Add Transactions API
- Loading branch information
Showing
4 changed files
with
236 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,55 @@ | ||
module Bank.TrueLayer.DataAPI.Cards | ||
( cards | ||
, card | ||
, cardBalance | ||
) where | ||
|
||
import Bank.TrueLayer.Internal | ||
(AccessToken, Endpoint, defaults, fromString, getWithAuthAndOptions, header, (&), (.~), (</>)) | ||
( AccessToken | ||
, Endpoint | ||
, Options | ||
, defaults | ||
, fromString | ||
, getWithAuthAndOptions | ||
, header | ||
, param | ||
, (&) | ||
, (.~) | ||
, (</>) | ||
) | ||
|
||
import Bank.TrueLayer.DataAPI.Schema (AccountId (..), CardBalances, Cards) | ||
import Bank.TrueLayer.DataAPI.Schema | ||
( AccountId (..) | ||
, Card | ||
, CardBalances | ||
, Cards | ||
, Ip (..) | ||
, TransactionParams | ||
, Transactions | ||
, addTransactionParams | ||
) | ||
|
||
cards :: String -> Endpoint -> AccessToken -> IO (Maybe Cards) | ||
cards ip = do | ||
cards :: Ip -> Endpoint -> AccessToken -> IO (Maybe Cards) | ||
cards (Ip ip) = do | ||
let opts = defaults & header "X-PSU-IP" .~ [fromString ip] | ||
getWithAuthAndOptions defaults "/data/v1/cards" | ||
getWithAuthAndOptions opts "/data/v1/cards" | ||
|
||
card :: Ip -> AccountId -> Endpoint -> AccessToken -> IO (Maybe Cards) | ||
card (Ip ip) (AccountId accountId) = do | ||
let opts = defaults & header "X-PSU-IP" .~ [fromString ip] | ||
getWithAuthAndOptions opts ("/data/v1/cards" </> accountId) | ||
|
||
cardBalance :: String -> AccountId -> Endpoint -> AccessToken -> IO (Maybe CardBalances) | ||
cardBalance ip (AccountId accountId) = do | ||
cardBalance :: Ip -> AccountId -> Endpoint -> AccessToken -> IO (Maybe CardBalances) | ||
cardBalance (Ip ip) (AccountId accountId) = do | ||
let opts = defaults & header "X-PSU-IP" .~ [fromString ip] | ||
getWithAuthAndOptions defaults ("/data/v1/cards" </> accountId </> "balance") | ||
getWithAuthAndOptions opts ("/data/v1/cards" </> accountId </> "balance") | ||
|
||
transactions :: Ip -> AccountId -> Maybe TransactionParams -> Endpoint -> AccessToken -> IO (Maybe Transactions) | ||
transactions (Ip ip) (AccountId accountId) params endpoint accessToken = do | ||
opts <- addTransactionParams params (defaults & header "X-PSU-IP" .~ [fromString ip]) | ||
getWithAuthAndOptions opts ("/data/v1/cards" </> accountId </> "transactions") endpoint accessToken | ||
|
||
pendingTransactions :: Ip -> AccountId -> Maybe TransactionParams -> Endpoint -> AccessToken -> IO (Maybe Transactions) | ||
pendingTransactions (Ip ip) (AccountId accountId) params endpoint accessToken = do | ||
opts <- addTransactionParams params (defaults & header "X-PSU-IP" .~ [fromString ip]) | ||
getWithAuthAndOptions opts ("/data/v1/cards" </> accountId </> "transactions/pending") endpoint accessToken |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters