mirror of
https://github.com/OpenBankProject/OBP-TypeScript.git
synced 2026-02-06 18:57:16 +00:00
An TypeScript SDK for OBP (Javascript developers might be interested in this)
| __tests__ | ||
| docs | ||
| examples | ||
| src | ||
| .eslintrc.cjs | ||
| .gitignore | ||
| .prettierignore | ||
| .prettierrc.json | ||
| jest.config.ts | ||
| LICENSE | ||
| NOTICE | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
| yarn.lock | ||
OBP-TypeScript
Install
yarn
yarn add obp-typescript
npm
npm install obp-typescript
Example
import {
API,
APIClientConfig,
DirectLoginAuthentication,
Version,
get,
create,
Bank,
Account,
Transaction,
GetTransactionsForAccountFull,
TransactionRequestAccountBody,
CreateTransactionRequestAccount,
} from "obp-typescript/src";
(async () => {
const directLogin: DirectLoginAuthentication = {
username: process.env.OBP_USERNAME || "",
password: process.env.OBP_PASSWORD || "",
consumerKey: process.env.OBP_CONSUMER_KEY || "",
};
const clientConfig: APIClientConfig = {
baseUri: "https://apisandbox.openbankproject.com",
version: Version.v500,
authentication: directLogin,
};
const banks = await get<API.Bank>(clientConfig, Bank);
const account = await get<API.Account>(clientConfig, Account);
const transactionFn = get<API.Transaction>(clientConfig, Transaction);
// Get transaction for account full.
const transactionsForAccountFull = await transactionFn(
GetTransactionsForAccountFull
)("bankId", "accountId", "viewId");
// New transaction body.
const body: TransactionRequestAccountBody = {
description: "Dummy transaction full data",
to: {
bank_id: "bankId",
account_id: "accountId",
},
value: {
currency: "EUR",
amount: 1.0,
},
};
// Create transaction request account.
await create<API.Transaction>(
clientConfig,
Transaction
)(CreateTransactionRequestAccount)(
"bankId",
"accountId",
"viewId"
)(body);
})();