An TypeScript SDK for OBP (Javascript developers might be interested in this)
Go to file
2023-05-05 18:21:47 +08:00
__tests__ REFACTOR: format and add new module for custom API request 2023-03-31 15:55:50 +08:00
docs REFACTOR: docs 2023-05-03 00:16:31 +08:00
examples REFACTOR: packaging and example 2023-05-05 18:21:47 +08:00
src REFACTOR: moved dotenv to dev dependency 2023-05-03 16:59:36 +08:00
.eslintrc.cjs OBP-TypeScript scripts 2023-03-08 21:44:31 +08:00
.gitignore FEATURE: update and delete function 2023-05-02 17:47:45 +08:00
.prettierignore OBP-TypeScript scripts 2023-03-08 21:44:31 +08:00
.prettierrc.json OBP-TypeScript scripts 2023-03-08 21:44:31 +08:00
jest.config.ts FEATURE: update and delete function 2023-05-02 17:47:45 +08:00
LICENSE Initial commit 2023-03-08 14:20:18 +01:00
NOTICE REFACTOR: change license to apache 2 2023-03-11 11:53:27 +08:00
package.json REFACTOR: packaging and example 2023-05-05 18:21:47 +08:00
README.md REFACTOR: revised response formatting 2023-05-03 14:08:07 +08:00
tsconfig.json REFACTOR: packaging and example 2023-05-05 18:21:47 +08:00
yarn.lock REFACTOR: Ouath 2023-04-25 16:37:50 +08:00

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";

(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);
})();