mirror of
https://github.com/OpenBankProject/OBP-TypeScript.git
synced 2026-02-06 10:48:07 +00:00
OBP-TypeScript scripts
This commit is contained in:
parent
1b729381e9
commit
cedb78fbb0
16
.eslintrc.cjs
Normal file
16
.eslintrc.cjs
Normal file
@ -0,0 +1,16 @@
|
||||
module.exports = {
|
||||
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
|
||||
parser: "@typescript-eslint/parser",
|
||||
plugins: ["@typescript-eslint", "eslint-plugin-tsdoc"],
|
||||
root: true,
|
||||
rules: {
|
||||
"@typescript-eslint/no-namespace": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
semi: [2, "always"],
|
||||
quotes: [2, "double", { avoidEscape: true }],
|
||||
},
|
||||
plugins: ["jest"],
|
||||
env: {
|
||||
"jest/globals": true,
|
||||
},
|
||||
};
|
||||
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/config.json
|
||||
/node_modules
|
||||
/dist
|
||||
yarn-error.log
|
||||
3
.prettierignore
Normal file
3
.prettierignore
Normal file
@ -0,0 +1,3 @@
|
||||
dist
|
||||
node_modules
|
||||
docs
|
||||
0
.prettierrc.json
Normal file
0
.prettierrc.json
Normal file
80
README.md
Normal file
80
README.md
Normal file
@ -0,0 +1,80 @@
|
||||
# obp-sdk-ts
|
||||
|
||||
## Usage
|
||||
|
||||
#### Symlink
|
||||
|
||||
Checkout the obp-sdk-ts library from https://github.com/mark-tesobe/OBP-SDK.
|
||||
Inside the obp-sdk repository folder, execute the **yarn link** command.
|
||||
|
||||
```
|
||||
yarn link
|
||||
```
|
||||
|
||||
To link the **obp-sdk-ts** library into your app, run the command inside your app.
|
||||
|
||||
```
|
||||
yarn link obp-sdk-ts
|
||||
```
|
||||
|
||||
#### Example
|
||||
|
||||
```typescript
|
||||
import {
|
||||
API,
|
||||
APIClientConfig,
|
||||
DirectLoginAuthentication,
|
||||
Version,
|
||||
get,
|
||||
create,
|
||||
Bank,
|
||||
Account,
|
||||
Transaction,
|
||||
GetTransactionsForAccountFull,
|
||||
TransactionRequestAccountBody,
|
||||
CreateTransactionRequestAccount,
|
||||
} from "obp-sdk-ts/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);
|
||||
})();
|
||||
```
|
||||
55
__tests__/account.test.ts
Normal file
55
__tests__/account.test.ts
Normal file
@ -0,0 +1,55 @@
|
||||
import { describe, test, expect } from "@jest/globals";
|
||||
import {
|
||||
API,
|
||||
Version,
|
||||
APIClientConfig,
|
||||
DirectLoginAuthentication,
|
||||
get,
|
||||
Account,
|
||||
} from "../src";
|
||||
import { GetAccountsByBankId } from "../src/api/account";
|
||||
import { getRequest, apiCallWithCustomURIPath } from "../src/api/client";
|
||||
|
||||
const directLogin: DirectLoginAuthentication = {
|
||||
username: global.obpUsername,
|
||||
password: global.obpPassword,
|
||||
consumerKey: global.obpConsumerKey,
|
||||
};
|
||||
|
||||
const clientConfig: APIClientConfig = {
|
||||
baseUri: global.obpBaseUri,
|
||||
version: global.obpVersion as Version,
|
||||
authentication: directLogin,
|
||||
};
|
||||
|
||||
describe("Account", () => {
|
||||
test("get<API.Account> ByBankId should be able to get the OBP Accounts data.", async () => {
|
||||
const accounts = await get<API.Account>(
|
||||
clientConfig,
|
||||
Account
|
||||
)(GetAccountsByBankId)(global.obpTestBankId);
|
||||
|
||||
expect(accounts).toBeDefined();
|
||||
});
|
||||
|
||||
test("get<API.Account> should be able to get the OBP Accounts data.", async () => {
|
||||
const accounts = await get<API.Account>(
|
||||
clientConfig,
|
||||
Account
|
||||
)(`/banks/${global.obpTestBankId}/accounts`);
|
||||
|
||||
expect(accounts).toBeDefined();
|
||||
});
|
||||
|
||||
test("apiCallWithCustomURIPath should be able to get the OBP Accounts data.", async () => {
|
||||
const customPathCall = apiCallWithCustomURIPath<API.Account>(
|
||||
clientConfig,
|
||||
getRequest
|
||||
);
|
||||
const accounts = await customPathCall(
|
||||
`/banks/${global.obpTestBankId}/accounts`
|
||||
);
|
||||
|
||||
expect(accounts).toBeDefined();
|
||||
});
|
||||
});
|
||||
27
__tests__/bank.test.ts
Normal file
27
__tests__/bank.test.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { describe, test, expect } from "@jest/globals";
|
||||
import {
|
||||
API,
|
||||
APIClientConfig,
|
||||
DirectLoginAuthentication,
|
||||
Version,
|
||||
get,
|
||||
Bank,
|
||||
GetBanks,
|
||||
} from "../src/api";
|
||||
|
||||
describe("Bank", () => {
|
||||
test("get<API.Bank> should be able to get the OBP Bank data.", async () => {
|
||||
const directLogin: DirectLoginAuthentication = {
|
||||
username: global.obpUsername,
|
||||
password: global.obpPassword,
|
||||
consumerKey: global.obpConsumerKey,
|
||||
};
|
||||
const clientConfig: APIClientConfig = {
|
||||
baseUri: global.obpBaseUri,
|
||||
version: global.obpVersion as Version,
|
||||
authentication: directLogin,
|
||||
};
|
||||
const banks = await get<API.Bank>(clientConfig, Bank)(GetBanks);
|
||||
expect(banks).toBeDefined();
|
||||
});
|
||||
});
|
||||
38
__tests__/customer.test.ts
Normal file
38
__tests__/customer.test.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import { describe, test, expect } from "@jest/globals";
|
||||
import {
|
||||
API,
|
||||
APIClientConfig,
|
||||
DirectLoginAuthentication,
|
||||
Version,
|
||||
get,
|
||||
Customer,
|
||||
GetCustomersAtBank,
|
||||
GetCustomersAtAnyBank,
|
||||
} from "../src/api";
|
||||
|
||||
const directLogin: DirectLoginAuthentication = {
|
||||
username: global.obpUsername,
|
||||
password: global.obpPassword,
|
||||
consumerKey: global.obpConsumerKey,
|
||||
};
|
||||
const clientConfig: APIClientConfig = {
|
||||
baseUri: global.obpBaseUri,
|
||||
version: global.obpVersion as Version,
|
||||
authentication: directLogin,
|
||||
};
|
||||
describe("Customer", () => {
|
||||
test("get<API.Customer> GetCustomersAtBank should be able to get the OBP Customer data.", async () => {
|
||||
const customers = await get<API.Customer>(
|
||||
clientConfig,
|
||||
Customer
|
||||
)(GetCustomersAtBank)(global.obpTestBankId);
|
||||
expect(customers).toBeDefined();
|
||||
});
|
||||
test("get<API.Customer> GetCustomersAtAnyBank should be able to get the OBP Customer data.", async () => {
|
||||
const customers = await get<API.Customer>(
|
||||
clientConfig,
|
||||
Customer
|
||||
)(GetCustomersAtAnyBank);
|
||||
expect(customers).toBeDefined();
|
||||
});
|
||||
});
|
||||
29
__tests__/kyc.test.ts
Normal file
29
__tests__/kyc.test.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { describe, test, expect } from "@jest/globals";
|
||||
import {
|
||||
API,
|
||||
APIClientConfig,
|
||||
DirectLoginAuthentication,
|
||||
Version,
|
||||
get,
|
||||
KYC,
|
||||
GetKYCStatus,
|
||||
} from "../src/api";
|
||||
|
||||
describe("KYC", () => {
|
||||
test("get<API.KYC> GetKYCStatus should be able to get the OBP KYC Status data.", async () => {
|
||||
const directLogin: DirectLoginAuthentication = {
|
||||
username: global.obpUsername,
|
||||
password: global.obpPassword,
|
||||
consumerKey: global.obpConsumerKey,
|
||||
};
|
||||
const clientConfig: APIClientConfig = {
|
||||
baseUri: global.obpBaseUri,
|
||||
version: global.obpVersion as Version,
|
||||
authentication: directLogin,
|
||||
};
|
||||
const kycStatus = await get<API.KYC>(clientConfig, KYC)(GetKYCStatus)(
|
||||
"9e6b2f45-a449-4e87-b772-e74cc9d42448"
|
||||
);
|
||||
expect(kycStatus).toBeDefined();
|
||||
});
|
||||
});
|
||||
35
__tests__/metadata.test.ts
Normal file
35
__tests__/metadata.test.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import { describe, test, expect } from "@jest/globals";
|
||||
import {
|
||||
API,
|
||||
APIClientConfig,
|
||||
DirectLoginAuthentication,
|
||||
Version,
|
||||
get,
|
||||
Metadata,
|
||||
GetTagsOnAccount,
|
||||
} from "../src/api";
|
||||
|
||||
describe("Metadata", () => {
|
||||
test("get<API.Metadata> should be able to get the OBP Metadata data.", async () => {
|
||||
const directLogin: DirectLoginAuthentication = {
|
||||
username: global.obpUsername,
|
||||
password: global.obpPassword,
|
||||
consumerKey: global.obpConsumerKey,
|
||||
};
|
||||
const clientConfig: APIClientConfig = {
|
||||
baseUri: global.obpBaseUri,
|
||||
version: global.obpVersion as Version,
|
||||
authentication: directLogin,
|
||||
};
|
||||
const tagsOnAccount = await get<API.Metadata>(
|
||||
clientConfig,
|
||||
Metadata
|
||||
)(GetTagsOnAccount)(
|
||||
global.obpTestBankId,
|
||||
"9e6b2f45-a449-4e87-b772-e74cc9d42448",
|
||||
"owner"
|
||||
);
|
||||
console.log(tagsOnAccount);
|
||||
expect(tagsOnAccount).toBeDefined();
|
||||
});
|
||||
});
|
||||
74
__tests__/transaction.test.ts
Normal file
74
__tests__/transaction.test.ts
Normal file
@ -0,0 +1,74 @@
|
||||
import { describe, test, expect } from "@jest/globals";
|
||||
import {
|
||||
API,
|
||||
Version,
|
||||
APIClientConfig,
|
||||
DirectLoginAuthentication,
|
||||
create,
|
||||
get,
|
||||
Transaction,
|
||||
} from "../src/api";
|
||||
import {
|
||||
GetTransactionsForAccountFull,
|
||||
CreateTransactionRequestAccount,
|
||||
TransactionRequestAccountBody,
|
||||
} from "../src/api/transaction";
|
||||
|
||||
const directLogin: DirectLoginAuthentication = {
|
||||
username: global.obpUsername,
|
||||
password: global.obpPassword,
|
||||
consumerKey: global.obpConsumerKey,
|
||||
};
|
||||
const clientConfig: APIClientConfig = {
|
||||
baseUri: global.obpBaseUri,
|
||||
version: global.obpVersion as Version,
|
||||
authentication: directLogin,
|
||||
};
|
||||
const bankId = global.obpTestBankId;
|
||||
const accountId = "9e6b2f45-a449-4e87-b772-e74cc9d42448";
|
||||
const viewId = "owner";
|
||||
|
||||
describe("Transaction", () => {
|
||||
test("get<API.Transaction> ByBankId should be able to get the OBP Transactions data.", async () => {
|
||||
const transactions = await get<API.Transaction>(
|
||||
clientConfig,
|
||||
Transaction
|
||||
)(GetTransactionsForAccountFull)(bankId, accountId, viewId);
|
||||
|
||||
expect(transactions).toBeDefined();
|
||||
});
|
||||
|
||||
test("get<API.Transaction> should be able to get the OBP Transactions data.", async () => {
|
||||
const transactions = await get<API.Transaction>(
|
||||
clientConfig,
|
||||
Transaction
|
||||
)(`/banks/${bankId}/accounts/${accountId}/${viewId}/transactions`);
|
||||
|
||||
expect(transactions).toBeDefined();
|
||||
});
|
||||
|
||||
test("create<API.Transaction, TransactionFullBody> should be able to createn an OBP Transaction Full data.", async () => {
|
||||
const body: TransactionRequestAccountBody = {
|
||||
description: "test transaction full data",
|
||||
to: {
|
||||
bank_id: bankId,
|
||||
account_id: accountId,
|
||||
},
|
||||
value: {
|
||||
currency: "EUR",
|
||||
amount: 1.0,
|
||||
},
|
||||
};
|
||||
const transactions = await create<API.Transaction>(
|
||||
clientConfig,
|
||||
Transaction
|
||||
)(CreateTransactionRequestAccount)(
|
||||
bankId,
|
||||
accountId,
|
||||
viewId,
|
||||
"SANDBOX_TAN"
|
||||
)(body);
|
||||
|
||||
expect(transactions).toBeDefined();
|
||||
});
|
||||
});
|
||||
27
__tests__/user.test.ts
Normal file
27
__tests__/user.test.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { describe, test, expect } from "@jest/globals";
|
||||
import {
|
||||
API,
|
||||
APIClientConfig,
|
||||
DirectLoginAuthentication,
|
||||
Version,
|
||||
get,
|
||||
User,
|
||||
Current,
|
||||
} from "../src/api";
|
||||
|
||||
describe("User", () => {
|
||||
test("get<API.User> Current should be able to get the Current User.", async () => {
|
||||
const directLogin: DirectLoginAuthentication = {
|
||||
username: global.obpUsername,
|
||||
password: global.obpPassword,
|
||||
consumerKey: global.obpConsumerKey,
|
||||
};
|
||||
const clientConfig: APIClientConfig = {
|
||||
baseUri: global.obpBaseUri,
|
||||
version: global.obpVersion as Version,
|
||||
authentication: directLogin,
|
||||
};
|
||||
const users = await get<API.User>(clientConfig, User)(Current);
|
||||
expect(users).toBeDefined();
|
||||
});
|
||||
});
|
||||
1
docs/.nojekyll
Normal file
1
docs/.nojekyll
Normal file
@ -0,0 +1 @@
|
||||
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
|
||||
82
docs/README.md
Normal file
82
docs/README.md
Normal file
@ -0,0 +1,82 @@
|
||||
obp-sdk-ts / [Modules](modules.md)
|
||||
|
||||
# obp-sdk-ts
|
||||
|
||||
## Usage
|
||||
|
||||
#### Symlink
|
||||
|
||||
Checkout the obp-sdk-ts library from https://github.com/mark-tesobe/OBP-SDK.
|
||||
Inside the obp-sdk repository folder, execute the **yarn link** command.
|
||||
|
||||
```
|
||||
yarn link
|
||||
```
|
||||
|
||||
To link the **obp-sdk-ts** library into your app, run the command inside your app.
|
||||
|
||||
```
|
||||
yarn link obp-sdk-ts
|
||||
```
|
||||
|
||||
#### Example
|
||||
|
||||
```typescript
|
||||
import {
|
||||
API,
|
||||
APIClientConfig,
|
||||
DirectLoginAuthentication,
|
||||
Version,
|
||||
get,
|
||||
create,
|
||||
Bank,
|
||||
Account,
|
||||
Transaction,
|
||||
GetTransactionsForAccountFull,
|
||||
TransactionRequestAccountBody,
|
||||
CreateTransactionRequestAccount,
|
||||
} from "obp-sdk-ts/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);
|
||||
})();
|
||||
```
|
||||
100
docs/enums/api.API.md
Normal file
100
docs/enums/api.API.md
Normal file
@ -0,0 +1,100 @@
|
||||
[obp-sdk-ts](../README.md) / [Modules](../modules.md) / [api](../modules/api.md) / API
|
||||
|
||||
# Enumeration: API
|
||||
|
||||
[api](../modules/api.md).API
|
||||
|
||||
Types of OBP API.
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Enumeration Members
|
||||
|
||||
- [Account](api.API.md#account)
|
||||
- [Bank](api.API.md#bank)
|
||||
- [Customer](api.API.md#customer)
|
||||
- [KYC](api.API.md#kyc)
|
||||
- [Metadata](api.API.md#metadata)
|
||||
- [Payment](api.API.md#payment)
|
||||
- [Transaction](api.API.md#transaction)
|
||||
- [User](api.API.md#user)
|
||||
|
||||
## Enumeration Members
|
||||
|
||||
### Account
|
||||
|
||||
• **Account** = ``1``
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/client.ts:20](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/client.ts#L20)
|
||||
|
||||
___
|
||||
|
||||
### Bank
|
||||
|
||||
• **Bank** = ``0``
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/client.ts:19](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/client.ts#L19)
|
||||
|
||||
___
|
||||
|
||||
### Customer
|
||||
|
||||
• **Customer** = ``5``
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/client.ts:24](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/client.ts#L24)
|
||||
|
||||
___
|
||||
|
||||
### KYC
|
||||
|
||||
• **KYC** = ``6``
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/client.ts:25](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/client.ts#L25)
|
||||
|
||||
___
|
||||
|
||||
### Metadata
|
||||
|
||||
• **Metadata** = ``7``
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/client.ts:26](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/client.ts#L26)
|
||||
|
||||
___
|
||||
|
||||
### Payment
|
||||
|
||||
• **Payment** = ``2``
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/client.ts:21](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/client.ts#L21)
|
||||
|
||||
___
|
||||
|
||||
### Transaction
|
||||
|
||||
• **Transaction** = ``3``
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/client.ts:22](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/client.ts#L22)
|
||||
|
||||
___
|
||||
|
||||
### User
|
||||
|
||||
• **User** = ``4``
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/client.ts:23](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/client.ts#L23)
|
||||
34
docs/enums/api.Version.md
Normal file
34
docs/enums/api.Version.md
Normal file
@ -0,0 +1,34 @@
|
||||
[obp-sdk-ts](../README.md) / [Modules](../modules.md) / [api](../modules/api.md) / Version
|
||||
|
||||
# Enumeration: Version
|
||||
|
||||
[api](../modules/api.md).Version
|
||||
|
||||
OBP API Versions.
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Enumeration Members
|
||||
|
||||
- [v500](api.Version.md#v500)
|
||||
- [v510](api.Version.md#v510)
|
||||
|
||||
## Enumeration Members
|
||||
|
||||
### v500
|
||||
|
||||
• **v500** = ``"v5.0.0"``
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/client.ts:9](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/client.ts#L9)
|
||||
|
||||
___
|
||||
|
||||
### v510
|
||||
|
||||
• **v510** = ``"v5.1.0"``
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/client.ts:10](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/client.ts#L10)
|
||||
10
docs/modules.md
Normal file
10
docs/modules.md
Normal file
@ -0,0 +1,10 @@
|
||||
[obp-sdk-ts](README.md) / Modules
|
||||
|
||||
# obp-sdk-ts
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Modules
|
||||
|
||||
- [api](modules/api.md)
|
||||
- [index](modules/index.md)
|
||||
887
docs/modules/api.md
Normal file
887
docs/modules/api.md
Normal file
@ -0,0 +1,887 @@
|
||||
[obp-sdk-ts](../README.md) / [Modules](../modules.md) / api
|
||||
|
||||
# Module: api
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Enumerations
|
||||
|
||||
- [API](../enums/api.API.md)
|
||||
- [Version](../enums/api.Version.md)
|
||||
|
||||
### Type Aliases
|
||||
|
||||
- [APIClientConfig](api.md#apiclientconfig)
|
||||
- [APIRequest](api.md#apirequest)
|
||||
- [DirectLoginAuthentication](api.md#directloginauthentication)
|
||||
- [MethodCall](api.md#methodcall)
|
||||
- [TransactionRequestAccountBody](api.md#transactionrequestaccountbody)
|
||||
|
||||
### Variables
|
||||
|
||||
- [Account](api.md#account)
|
||||
- [Bank](api.md#bank)
|
||||
- [Customer](api.md#customer)
|
||||
- [KYC](api.md#kyc)
|
||||
- [Metadata](api.md#metadata)
|
||||
- [Transaction](api.md#transaction)
|
||||
- [User](api.md#user)
|
||||
|
||||
### Functions
|
||||
|
||||
- [CreateTransactionRequestAccount](api.md#createtransactionrequestaccount)
|
||||
- [Current](api.md#current)
|
||||
- [GetAccountsByBankId](api.md#getaccountsbybankid)
|
||||
- [GetBanks](api.md#getbanks)
|
||||
- [GetBanksById](api.md#getbanksbyid)
|
||||
- [GetCustomersAtAnyBank](api.md#getcustomersatanybank)
|
||||
- [GetCustomersAtBank](api.md#getcustomersatbank)
|
||||
- [GetKYCStatus](api.md#getkycstatus)
|
||||
- [GetTagsOnAccount](api.md#gettagsonaccount)
|
||||
- [GetTransactionsForAccountFull](api.md#gettransactionsforaccountfull)
|
||||
- [create](api.md#create)
|
||||
- [get](api.md#get)
|
||||
|
||||
## Type Aliases
|
||||
|
||||
### APIClientConfig
|
||||
|
||||
Ƭ **APIClientConfig**: `Object`
|
||||
|
||||
Alias for APIClientConfig properties.
|
||||
|
||||
**`Property`**
|
||||
|
||||
baseUri
|
||||
|
||||
**`Property`**
|
||||
|
||||
version
|
||||
|
||||
**`Property`**
|
||||
|
||||
authentication
|
||||
|
||||
**`Property`**
|
||||
|
||||
[token]
|
||||
|
||||
**`See`**
|
||||
|
||||
- [Version](../enums/api.Version.md)
|
||||
- [DirectLoginAuthentication](api.md#directloginauthentication)
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `authentication` | [`DirectLoginAuthentication`](api.md#directloginauthentication) |
|
||||
| `baseUri` | `string` |
|
||||
| `token?` | `string` |
|
||||
| `version` | [`Version`](../enums/api.Version.md) |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/client.ts:58](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/client.ts#L58)
|
||||
|
||||
___
|
||||
|
||||
### APIRequest
|
||||
|
||||
Ƭ **APIRequest**<`T`\>: `Object`
|
||||
|
||||
Alias for APIRequest properties.
|
||||
|
||||
**`Property`**
|
||||
|
||||
[get]
|
||||
|
||||
**`Property`**
|
||||
|
||||
[create]
|
||||
|
||||
**`See`**
|
||||
|
||||
- [APIClientConfig](api.md#apiclientconfig)
|
||||
- [MethodCall](api.md#methodcall)
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name | Description |
|
||||
| :------ | :------ |
|
||||
| `T` | Type of object |
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `create?` | (`config`: [`APIClientConfig`](api.md#apiclientconfig), `methodCall`: [`MethodCall`](api.md#methodcall)<`T`\>) => `any` |
|
||||
| `get?` | (`config`: [`APIClientConfig`](api.md#apiclientconfig), `methodCall`: [`MethodCall`](api.md#methodcall)<`T`\>) => `any` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/client.ts:97](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/client.ts#L97)
|
||||
|
||||
___
|
||||
|
||||
### DirectLoginAuthentication
|
||||
|
||||
Ƭ **DirectLoginAuthentication**: `Object`
|
||||
|
||||
Alias for DirectLogin properties.
|
||||
|
||||
**`Property`**
|
||||
|
||||
username
|
||||
|
||||
**`Property`**
|
||||
|
||||
passowrd
|
||||
|
||||
**`Property`**
|
||||
|
||||
consumerKey
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `consumerKey` | `string` |
|
||||
| `password` | `string` |
|
||||
| `username` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/client.ts:38](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/client.ts#L38)
|
||||
|
||||
___
|
||||
|
||||
### MethodCall
|
||||
|
||||
Ƭ **MethodCall**<`T`\>: (`config`: [`APIClientConfig`](api.md#apiclientconfig), `path`: `string`, `body?`: `any`) => `Promise`<`T`\>
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name | Description |
|
||||
| :------ | :------ |
|
||||
| `T` | Type of object |
|
||||
|
||||
#### Type declaration
|
||||
|
||||
▸ (`config`, `path`, `body?`): `Promise`<`T`\>
|
||||
|
||||
Alias for HTTP MethodCall properties.
|
||||
|
||||
**`Property`**
|
||||
|
||||
config
|
||||
|
||||
**`Property`**
|
||||
|
||||
path
|
||||
|
||||
**`Property`**
|
||||
|
||||
[body]
|
||||
|
||||
**`See`**
|
||||
|
||||
APIClientConfig
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `config` | [`APIClientConfig`](api.md#apiclientconfig) |
|
||||
| `path` | `string` |
|
||||
| `body?` | `any` |
|
||||
|
||||
##### Returns
|
||||
|
||||
`Promise`<`T`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/client.ts:78](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/client.ts#L78)
|
||||
|
||||
___
|
||||
|
||||
### TransactionRequestAccountBody
|
||||
|
||||
Ƭ **TransactionRequestAccountBody**: `Object`
|
||||
|
||||
Alias for TransactionRequestAccountBody properties.
|
||||
|
||||
**`Property`**
|
||||
|
||||
description
|
||||
|
||||
**`Property`**
|
||||
|
||||
to
|
||||
|
||||
**`Property`**
|
||||
|
||||
value
|
||||
|
||||
#### Type declaration
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `description` | `string` |
|
||||
| `to` | { `account_id`: `string` ; `bank_id`: `string` } |
|
||||
| `to.account_id` | `string` |
|
||||
| `to.bank_id` | `string` |
|
||||
| `value` | { `amount`: `number` ; `currency`: `string` } |
|
||||
| `value.amount` | `number` |
|
||||
| `value.currency` | `string` |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/transaction.ts:18](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/transaction.ts#L18)
|
||||
|
||||
## Variables
|
||||
|
||||
### Account
|
||||
|
||||
• `Const` **Account**: [`APIRequest`](api.md#apirequest)<[`Account`](../enums/api.API.md#account)\>
|
||||
|
||||
Returns an anonymous function for creating or getting an Account data.
|
||||
|
||||
**`Param`**
|
||||
|
||||
The APIClientConfig object
|
||||
|
||||
**`Param`**
|
||||
|
||||
A higher order function
|
||||
|
||||
**`See`**
|
||||
|
||||
- [APIClientConfig](api.md#apiclientconfig)
|
||||
- [APIRequest](api.md#apirequest)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/account.ts:42](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/account.ts#L42)
|
||||
|
||||
___
|
||||
|
||||
### Bank
|
||||
|
||||
• `Const` **Bank**: [`APIRequest`](api.md#apirequest)<[`Bank`](../enums/api.API.md#bank)\>
|
||||
|
||||
Returns an anonymous function for creating or getting Bank data.
|
||||
|
||||
**`Param`**
|
||||
|
||||
The APIClientConfig object
|
||||
|
||||
**`Param`**
|
||||
|
||||
A higher order function
|
||||
|
||||
**`See`**
|
||||
|
||||
- [APIClientConfig](api.md#apiclientconfig)
|
||||
- [APIRequest](api.md#apirequest)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/bank.ts:61](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/bank.ts#L61)
|
||||
|
||||
___
|
||||
|
||||
### Customer
|
||||
|
||||
• `Const` **Customer**: [`APIRequest`](api.md#apirequest)<[`Customer`](../enums/api.API.md#customer)\>
|
||||
|
||||
Returns an anonymous function for creating or getting Customer data.
|
||||
|
||||
**`Param`**
|
||||
|
||||
The APIClientConfig object
|
||||
|
||||
**`Param`**
|
||||
|
||||
A higher order function
|
||||
|
||||
**`See`**
|
||||
|
||||
- [APIClientConfig](api.md#apiclientconfig)
|
||||
- [APIRequest](api.md#apirequest)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/customer.ts:147](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/customer.ts#L147)
|
||||
|
||||
___
|
||||
|
||||
### KYC
|
||||
|
||||
• `Const` **KYC**: [`APIRequest`](api.md#apirequest)<[`KYC`](../enums/api.API.md#kyc)\>
|
||||
|
||||
Returns an anonymous function for creating or getting KYC data.
|
||||
|
||||
**`Param`**
|
||||
|
||||
The APIClientConfig object
|
||||
|
||||
**`Param`**
|
||||
|
||||
A higher order function
|
||||
|
||||
**`See`**
|
||||
|
||||
- [APIClientConfig](api.md#apiclientconfig)
|
||||
- [APIRequest](api.md#apirequest)
|
||||
|
||||
#### Defined in
|
||||
|
||||
api/kyc.ts:40
|
||||
|
||||
___
|
||||
|
||||
### Metadata
|
||||
|
||||
• `Const` **Metadata**: [`APIRequest`](api.md#apirequest)<[`Metadata`](../enums/api.API.md#metadata)\>
|
||||
|
||||
Returns an anonymous function for creating or getting Metadata data.
|
||||
|
||||
**`Param`**
|
||||
|
||||
The APIClientConfig object
|
||||
|
||||
**`Param`**
|
||||
|
||||
A higher order function
|
||||
|
||||
**`See`**
|
||||
|
||||
- [APIClientConfig](api.md#apiclientconfig)
|
||||
- [APIRequest](api.md#apirequest)
|
||||
|
||||
#### Defined in
|
||||
|
||||
api/metadata.ts:43
|
||||
|
||||
___
|
||||
|
||||
### Transaction
|
||||
|
||||
• `Const` **Transaction**: [`APIRequest`](api.md#apirequest)<[`Transaction`](../enums/api.API.md#transaction)\>
|
||||
|
||||
Returns an anonymous function for creating or getting Transaction data.
|
||||
|
||||
**`Param`**
|
||||
|
||||
The APIClientConfig object
|
||||
|
||||
**`Param`**
|
||||
|
||||
A higher order function
|
||||
|
||||
**`See`**
|
||||
|
||||
- [APIClientConfig](api.md#apiclientconfig)
|
||||
- [APIRequest](api.md#apirequest)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/transaction.ts:97](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/transaction.ts#L97)
|
||||
|
||||
___
|
||||
|
||||
### User
|
||||
|
||||
• `Const` **User**: [`APIRequest`](api.md#apirequest)<[`User`](../enums/api.API.md#user)\>
|
||||
|
||||
Returns an anonymous function for creating or getting a User data.
|
||||
|
||||
**`Param`**
|
||||
|
||||
The APIClientConfig object
|
||||
|
||||
**`Param`**
|
||||
|
||||
A higher order function
|
||||
|
||||
**`See`**
|
||||
|
||||
- [APIClientConfig](api.md#apiclientconfig)
|
||||
- [APIRequest](api.md#apirequest)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/user.ts:39](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/user.ts#L39)
|
||||
|
||||
## Functions
|
||||
|
||||
### CreateTransactionRequestAccount
|
||||
|
||||
▸ **CreateTransactionRequestAccount**(`config`, `methodCall`): (`bankId`: `string`, `accountId`: `string`, `viewId`: `string`, `account`: `string`) => (`body`: [`TransactionRequestAccountBody`](api.md#transactionrequestaccountbody)) => `Promise`<[`Transaction`](../enums/api.API.md#transaction)\>
|
||||
|
||||
Create Transaction Request (ACCOUNT).
|
||||
|
||||
**`See`**
|
||||
|
||||
- [APIClientConfig](api.md#apiclientconfig)
|
||||
- [TransactionRequestAccountBody](api.md#transactionrequestaccountbody)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `config` | [`APIClientConfig`](api.md#apiclientconfig) | The APIClientConfig object |
|
||||
| `methodCall` | (`config`: [`APIClientConfig`](api.md#apiclientconfig), `path`: `string`, `body`: [`TransactionRequestAccountBody`](api.md#transactionrequestaccountbody)) => `Promise`<`any`\> | A higher order function |
|
||||
|
||||
#### Returns
|
||||
|
||||
`fn`
|
||||
|
||||
A curried function
|
||||
|
||||
▸ (`bankId`, `accountId`, `viewId`, `account`): (`body`: [`TransactionRequestAccountBody`](api.md#transactionrequestaccountbody)) => `Promise`<[`Transaction`](../enums/api.API.md#transaction)\>
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `bankId` | `string` |
|
||||
| `accountId` | `string` |
|
||||
| `viewId` | `string` |
|
||||
| `account` | `string` |
|
||||
|
||||
##### Returns
|
||||
|
||||
`fn`
|
||||
|
||||
▸ (`body`): `Promise`<[`Transaction`](../enums/api.API.md#transaction)\>
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `body` | [`TransactionRequestAccountBody`](api.md#transactionrequestaccountbody) |
|
||||
|
||||
##### Returns
|
||||
|
||||
`Promise`<[`Transaction`](../enums/api.API.md#transaction)\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/transaction.ts:69](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/transaction.ts#L69)
|
||||
|
||||
___
|
||||
|
||||
### Current
|
||||
|
||||
▸ **Current**(`config`, `methodCall`): `Promise`<[`User`](../enums/api.API.md#user)\>
|
||||
|
||||
Get the logged in user
|
||||
Returns information about the logged in user.
|
||||
|
||||
**`See`**
|
||||
|
||||
[APIClientConfig](api.md#apiclientconfig)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `config` | [`APIClientConfig`](api.md#apiclientconfig) | The APIClientConfig object |
|
||||
| `methodCall` | (`config`: [`APIClientConfig`](api.md#apiclientconfig), `path`: `string`) => `Promise`<[`User`](../enums/api.API.md#user)\> | A higher order function |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`User`](../enums/api.API.md#user)\>
|
||||
|
||||
A curried function
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/user.ts:20](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/user.ts#L20)
|
||||
|
||||
___
|
||||
|
||||
### GetAccountsByBankId
|
||||
|
||||
▸ **GetAccountsByBankId**(`config`, `methodCall`): (`id`: `string`) => `Promise`<[`Account`](../enums/api.API.md#account)\>
|
||||
|
||||
Get Accounts at Bank.
|
||||
Returns the list of accounts at BANK_ID that the user has access to.
|
||||
|
||||
**`See`**
|
||||
|
||||
[APIClientConfig](api.md#apiclientconfig)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `config` | [`APIClientConfig`](api.md#apiclientconfig) | The APIClientConfig object |
|
||||
| `methodCall` | (`config`: [`APIClientConfig`](api.md#apiclientconfig), `path`: `string`) => `Promise`<[`Account`](../enums/api.API.md#account)\> | A higher order function |
|
||||
|
||||
#### Returns
|
||||
|
||||
`fn`
|
||||
|
||||
A curried function
|
||||
|
||||
▸ (`id`): `Promise`<[`Account`](../enums/api.API.md#account)\>
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
|
||||
##### Returns
|
||||
|
||||
`Promise`<[`Account`](../enums/api.API.md#account)\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/account.ts:21](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/account.ts#L21)
|
||||
|
||||
___
|
||||
|
||||
### GetBanks
|
||||
|
||||
▸ **GetBanks**(`config`, `methodCall`): `Promise`<`any`\>
|
||||
|
||||
Get banks on this API instance.
|
||||
Returns a list of banks.
|
||||
|
||||
**`See`**
|
||||
|
||||
[APIClientConfig](api.md#apiclientconfig)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `config` | [`APIClientConfig`](api.md#apiclientconfig) | The APIClientConfig object |
|
||||
| `methodCall` | (`config`: [`APIClientConfig`](api.md#apiclientconfig), `path`: `string`) => `Promise`<`any`\> | A higher order function |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
A curried function
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/bank.ts:42](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/bank.ts#L42)
|
||||
|
||||
___
|
||||
|
||||
### GetBanksById
|
||||
|
||||
▸ **GetBanksById**(`config`, `methodCall`): (`id`: `string`) => `Promise`<[`Account`](../enums/api.API.md#account)\>
|
||||
|
||||
Get the bank specified by BANK_ID.
|
||||
Returns information about a single bank specified by BANK_ID.
|
||||
|
||||
**`See`**
|
||||
|
||||
[APIClientConfig](api.md#apiclientconfig)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `config` | [`APIClientConfig`](api.md#apiclientconfig) | The APIClientConfig object |
|
||||
| `methodCall` | (`config`: [`APIClientConfig`](api.md#apiclientconfig), `path`: `string`) => `Promise`<`any`\> | A higher order function |
|
||||
|
||||
#### Returns
|
||||
|
||||
`fn`
|
||||
|
||||
A curried function
|
||||
|
||||
▸ (`id`): `Promise`<[`Account`](../enums/api.API.md#account)\>
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `id` | `string` |
|
||||
|
||||
##### Returns
|
||||
|
||||
`Promise`<[`Account`](../enums/api.API.md#account)\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/bank.ts:21](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/bank.ts#L21)
|
||||
|
||||
___
|
||||
|
||||
### GetCustomersAtAnyBank
|
||||
|
||||
▸ **GetCustomersAtAnyBank**(`config`, `methodCall`): `Promise`<`any`\>
|
||||
|
||||
Get Customers at Any Bank.
|
||||
|
||||
**`See`**
|
||||
|
||||
[APIClientConfig](api.md#apiclientconfig)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `config` | [`APIClientConfig`](api.md#apiclientconfig) | The APIClientConfig object |
|
||||
| `methodCall` | (`config`: [`APIClientConfig`](api.md#apiclientconfig), `path`: `string`) => `Promise`<`any`\> | A higher order function |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
A curried function
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/customer.ts:74](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/customer.ts#L74)
|
||||
|
||||
___
|
||||
|
||||
### GetCustomersAtBank
|
||||
|
||||
▸ **GetCustomersAtBank**(`config`, `methodCall`): (`bankId`: `string`) => `Promise`<[`Customer`](../enums/api.API.md#customer)\>
|
||||
|
||||
Get Customers at Bank.
|
||||
|
||||
**`See`**
|
||||
|
||||
[APIClientConfig](api.md#apiclientconfig)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `config` | [`APIClientConfig`](api.md#apiclientconfig) | The APIClientConfig object |
|
||||
| `methodCall` | (`config`: [`APIClientConfig`](api.md#apiclientconfig), `path`: `string`) => `Promise`<`any`\> | A higher order function |
|
||||
|
||||
#### Returns
|
||||
|
||||
`fn`
|
||||
|
||||
A curried function
|
||||
|
||||
▸ (`bankId`): `Promise`<[`Customer`](../enums/api.API.md#customer)\>
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `bankId` | `string` |
|
||||
|
||||
##### Returns
|
||||
|
||||
`Promise`<[`Customer`](../enums/api.API.md#customer)\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/customer.ts:93](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/customer.ts#L93)
|
||||
|
||||
___
|
||||
|
||||
### GetKYCStatus
|
||||
|
||||
▸ **GetKYCStatus**(`config`, `methodCall`): (`customerId`: `string`) => `Promise`<`any`\>
|
||||
|
||||
Get the KYC statuses for a customer specified by CUSTOMER_ID over time.
|
||||
|
||||
**`See`**
|
||||
|
||||
[APIClientConfig](api.md#apiclientconfig)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `config` | [`APIClientConfig`](api.md#apiclientconfig) | The APIClientConfig object |
|
||||
| `methodCall` | (`config`: [`APIClientConfig`](api.md#apiclientconfig), `path`: `string`) => `Promise`<`any`\> | A higher order function |
|
||||
|
||||
#### Returns
|
||||
|
||||
`fn`
|
||||
|
||||
A curried function
|
||||
|
||||
▸ (`customerId`): `Promise`<`any`\>
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `customerId` | `string` |
|
||||
|
||||
##### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
api/kyc.ts:20
|
||||
|
||||
___
|
||||
|
||||
### GetTagsOnAccount
|
||||
|
||||
▸ **GetTagsOnAccount**(`config`, `methodCall`): (`bankId`: `string`, `accountId`: `string`, `viewId`: `string`) => `Promise`<`any`\>
|
||||
|
||||
Returns the account ACCOUNT_ID tags made on a view (VIEW_ID).
|
||||
|
||||
**`See`**
|
||||
|
||||
[APIClientConfig](api.md#apiclientconfig)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `config` | [`APIClientConfig`](api.md#apiclientconfig) | The APIClientConfig object |
|
||||
| `methodCall` | (`config`: [`APIClientConfig`](api.md#apiclientconfig), `path`: `string`) => `Promise`<`any`\> | A higher order function |
|
||||
|
||||
#### Returns
|
||||
|
||||
`fn`
|
||||
|
||||
A curried function
|
||||
|
||||
▸ (`bankId`, `accountId`, `viewId`): `Promise`<`any`\>
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `bankId` | `string` |
|
||||
| `accountId` | `string` |
|
||||
| `viewId` | `string` |
|
||||
|
||||
##### Returns
|
||||
|
||||
`Promise`<`any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
api/metadata.ts:20
|
||||
|
||||
___
|
||||
|
||||
### GetTransactionsForAccountFull
|
||||
|
||||
▸ **GetTransactionsForAccountFull**(`config`, `methodCall`): (`bankId`: `string`, `accountId`: `string`, `viewId`: `string`) => `Promise`<[`Account`](../enums/api.API.md#account)\>
|
||||
|
||||
Get Transactions for Account (Full).
|
||||
Returns transactions list of the account specified by ACCOUNT_ID and moderated by the view (VIEW_ID).
|
||||
|
||||
**`See`**
|
||||
|
||||
[APIClientConfig](api.md#apiclientconfig)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `config` | [`APIClientConfig`](api.md#apiclientconfig) | The APIClientConfig object |
|
||||
| `methodCall` | (`config`: [`APIClientConfig`](api.md#apiclientconfig), `path`: `string`) => `Promise`<`any`\> | A higher order function |
|
||||
|
||||
#### Returns
|
||||
|
||||
`fn`
|
||||
|
||||
A curried function
|
||||
|
||||
▸ (`bankId`, `accountId`, `viewId`): `Promise`<[`Account`](../enums/api.API.md#account)\>
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `bankId` | `string` |
|
||||
| `accountId` | `string` |
|
||||
| `viewId` | `string` |
|
||||
|
||||
##### Returns
|
||||
|
||||
`Promise`<[`Account`](../enums/api.API.md#account)\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/transaction.ts:43](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/transaction.ts#L43)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
▸ **create**<`T`\>(`config`, `request`): `any`
|
||||
|
||||
A POST request function that creates an API data and returns the result.
|
||||
|
||||
**`See`**
|
||||
|
||||
- APIClientConfig
|
||||
- APIRequest<T>
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `T` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `config` | [`APIClientConfig`](api.md#apiclientconfig) | The APIClientConfig object |
|
||||
| `request` | [`APIRequest`](api.md#apirequest)<`T`\> | The APIRequest object |
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
An
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/client.ts:303](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/client.ts#L303)
|
||||
|
||||
___
|
||||
|
||||
### get
|
||||
|
||||
▸ **get**<`T`\>(`config`, `request`): `any`
|
||||
|
||||
A GET request function that returns the API data.
|
||||
|
||||
**`See`**
|
||||
|
||||
- APIClientConfig
|
||||
- APIRequest<T>
|
||||
|
||||
#### Type parameters
|
||||
|
||||
| Name |
|
||||
| :------ |
|
||||
| `T` |
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `config` | [`APIClientConfig`](api.md#apiclientconfig) | The APIClientConfig object |
|
||||
| `request` | [`APIRequest`](api.md#apirequest)<`T`\> | The APIRequest object |
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
An
|
||||
|
||||
#### Defined in
|
||||
|
||||
[api/client.ts:284](https://github.com/mark-tesobe/OBP-SDK/blob/92f681c/src/api/client.ts#L284)
|
||||
190
docs/modules/index.md
Normal file
190
docs/modules/index.md
Normal file
@ -0,0 +1,190 @@
|
||||
[obp-sdk-ts](../README.md) / [Modules](../modules.md) / index
|
||||
|
||||
# Module: index
|
||||
|
||||
## Table of contents
|
||||
|
||||
### References
|
||||
|
||||
- [API](index.md#api)
|
||||
- [APIClientConfig](index.md#apiclientconfig)
|
||||
- [APIRequest](index.md#apirequest)
|
||||
- [Account](index.md#account)
|
||||
- [Bank](index.md#bank)
|
||||
- [CreateTransactionRequestAccount](index.md#createtransactionrequestaccount)
|
||||
- [Current](index.md#current)
|
||||
- [Customer](index.md#customer)
|
||||
- [DirectLoginAuthentication](index.md#directloginauthentication)
|
||||
- [GetAccountsByBankId](index.md#getaccountsbybankid)
|
||||
- [GetBanks](index.md#getbanks)
|
||||
- [GetBanksById](index.md#getbanksbyid)
|
||||
- [GetCustomersAtAnyBank](index.md#getcustomersatanybank)
|
||||
- [GetCustomersAtBank](index.md#getcustomersatbank)
|
||||
- [GetKYCStatus](index.md#getkycstatus)
|
||||
- [GetTagsOnAccount](index.md#gettagsonaccount)
|
||||
- [GetTransactionsForAccountFull](index.md#gettransactionsforaccountfull)
|
||||
- [KYC](index.md#kyc)
|
||||
- [Metadata](index.md#metadata)
|
||||
- [MethodCall](index.md#methodcall)
|
||||
- [Transaction](index.md#transaction)
|
||||
- [TransactionRequestAccountBody](index.md#transactionrequestaccountbody)
|
||||
- [User](index.md#user)
|
||||
- [Version](index.md#version)
|
||||
- [create](index.md#create)
|
||||
- [get](index.md#get)
|
||||
|
||||
## References
|
||||
|
||||
### API
|
||||
|
||||
Re-exports [API](../enums/api.API.md)
|
||||
|
||||
___
|
||||
|
||||
### APIClientConfig
|
||||
|
||||
Re-exports [APIClientConfig](api.md#apiclientconfig)
|
||||
|
||||
___
|
||||
|
||||
### APIRequest
|
||||
|
||||
Re-exports [APIRequest](api.md#apirequest)
|
||||
|
||||
___
|
||||
|
||||
### Account
|
||||
|
||||
Re-exports [Account](api.md#account)
|
||||
|
||||
___
|
||||
|
||||
### Bank
|
||||
|
||||
Re-exports [Bank](api.md#bank)
|
||||
|
||||
___
|
||||
|
||||
### CreateTransactionRequestAccount
|
||||
|
||||
Re-exports [CreateTransactionRequestAccount](api.md#createtransactionrequestaccount)
|
||||
|
||||
___
|
||||
|
||||
### Current
|
||||
|
||||
Re-exports [Current](api.md#current)
|
||||
|
||||
___
|
||||
|
||||
### Customer
|
||||
|
||||
Re-exports [Customer](api.md#customer)
|
||||
|
||||
___
|
||||
|
||||
### DirectLoginAuthentication
|
||||
|
||||
Re-exports [DirectLoginAuthentication](api.md#directloginauthentication)
|
||||
|
||||
___
|
||||
|
||||
### GetAccountsByBankId
|
||||
|
||||
Re-exports [GetAccountsByBankId](api.md#getaccountsbybankid)
|
||||
|
||||
___
|
||||
|
||||
### GetBanks
|
||||
|
||||
Re-exports [GetBanks](api.md#getbanks)
|
||||
|
||||
___
|
||||
|
||||
### GetBanksById
|
||||
|
||||
Re-exports [GetBanksById](api.md#getbanksbyid)
|
||||
|
||||
___
|
||||
|
||||
### GetCustomersAtAnyBank
|
||||
|
||||
Re-exports [GetCustomersAtAnyBank](api.md#getcustomersatanybank)
|
||||
|
||||
___
|
||||
|
||||
### GetCustomersAtBank
|
||||
|
||||
Re-exports [GetCustomersAtBank](api.md#getcustomersatbank)
|
||||
|
||||
___
|
||||
|
||||
### GetKYCStatus
|
||||
|
||||
Re-exports [GetKYCStatus](api.md#getkycstatus)
|
||||
|
||||
___
|
||||
|
||||
### GetTagsOnAccount
|
||||
|
||||
Re-exports [GetTagsOnAccount](api.md#gettagsonaccount)
|
||||
|
||||
___
|
||||
|
||||
### GetTransactionsForAccountFull
|
||||
|
||||
Re-exports [GetTransactionsForAccountFull](api.md#gettransactionsforaccountfull)
|
||||
|
||||
___
|
||||
|
||||
### KYC
|
||||
|
||||
Re-exports [KYC](api.md#kyc)
|
||||
|
||||
___
|
||||
|
||||
### Metadata
|
||||
|
||||
Re-exports [Metadata](api.md#metadata)
|
||||
|
||||
___
|
||||
|
||||
### MethodCall
|
||||
|
||||
Re-exports [MethodCall](api.md#methodcall)
|
||||
|
||||
___
|
||||
|
||||
### Transaction
|
||||
|
||||
Re-exports [Transaction](api.md#transaction)
|
||||
|
||||
___
|
||||
|
||||
### TransactionRequestAccountBody
|
||||
|
||||
Re-exports [TransactionRequestAccountBody](api.md#transactionrequestaccountbody)
|
||||
|
||||
___
|
||||
|
||||
### User
|
||||
|
||||
Re-exports [User](api.md#user)
|
||||
|
||||
___
|
||||
|
||||
### Version
|
||||
|
||||
Re-exports [Version](../enums/api.Version.md)
|
||||
|
||||
___
|
||||
|
||||
### create
|
||||
|
||||
Re-exports [create](api.md#create)
|
||||
|
||||
___
|
||||
|
||||
### get
|
||||
|
||||
Re-exports [get](api.md#get)
|
||||
37
examples/account.ts
Normal file
37
examples/account.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import {
|
||||
API,
|
||||
Version,
|
||||
APIClientConfig,
|
||||
DirectLoginAuthentication,
|
||||
get,
|
||||
Account,
|
||||
} from "../src";
|
||||
import { GetAccountsByBankId } from "../src/api/account";
|
||||
|
||||
const directLogin: DirectLoginAuthentication = {
|
||||
username: process.env.OBP_USERNAME,
|
||||
password: process.env.OBP_PASSWORD,
|
||||
consumerKey: process.env.OBP_CONSUMER_KEY,
|
||||
};
|
||||
const clientConfig: APIClientConfig = {
|
||||
baseUri: "https://obp-apisandbox.joinfincubator.com",
|
||||
version: Version.v510,
|
||||
authentication: directLogin,
|
||||
};
|
||||
|
||||
(async () => {
|
||||
// Get Accounts
|
||||
console.log(
|
||||
await get<API.Account>(clientConfig, Account)(GetAccountsByBankId)(
|
||||
"d8839721-ad8f-45dd-9f78-2080414b93f9"
|
||||
)
|
||||
);
|
||||
|
||||
// Or with custom relative path
|
||||
console.log(
|
||||
await get<API.Account>(
|
||||
clientConfig,
|
||||
Account
|
||||
)(`/banks/d8839721-ad8f-45dd-9f78-2080414b93f9/accounts`)
|
||||
);
|
||||
})();
|
||||
33
examples/bank.ts
Normal file
33
examples/bank.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import {
|
||||
API,
|
||||
APIClientConfig,
|
||||
DirectLoginAuthentication,
|
||||
Version,
|
||||
get,
|
||||
Bank,
|
||||
GetBanks,
|
||||
GetBanksById,
|
||||
} from "../src/api";
|
||||
|
||||
const directLogin: DirectLoginAuthentication = {
|
||||
username: process.env.OBP_USERNAME,
|
||||
password: process.env.OBP_PASSWORD,
|
||||
consumerKey: process.env.OBP_CONSUMER_KEY,
|
||||
};
|
||||
const clientConfig: APIClientConfig = {
|
||||
baseUri: "https://obp-apisandbox.joinfincubator.com",
|
||||
version: Version.v510,
|
||||
authentication: directLogin,
|
||||
};
|
||||
|
||||
(async () => {
|
||||
// Get Banks
|
||||
console.log(await get<API.Bank>(clientConfig, Bank)(GetBanks));
|
||||
|
||||
// Get Bank specified by BANK_ID
|
||||
console.log(
|
||||
await get<API.Bank>(clientConfig, Bank)(GetBanksById)(
|
||||
"d8839721-ad8f-45dd-9f78-2080414b93f9"
|
||||
)
|
||||
);
|
||||
})();
|
||||
35
examples/customer.ts
Normal file
35
examples/customer.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import {
|
||||
API,
|
||||
APIClientConfig,
|
||||
DirectLoginAuthentication,
|
||||
Version,
|
||||
get,
|
||||
Customer,
|
||||
GetCustomersAtBank,
|
||||
GetCustomersAtAnyBank,
|
||||
} from "../src/api";
|
||||
|
||||
const directLogin: DirectLoginAuthentication = {
|
||||
username: process.env.OBP_USERNAME,
|
||||
password: process.env.OBP_PASSWORD,
|
||||
consumerKey: process.env.OBP_CONSUMER_KEY,
|
||||
};
|
||||
const clientConfig: APIClientConfig = {
|
||||
baseUri: "https://obp-apisandbox.joinfincubator.com",
|
||||
version: Version.v510,
|
||||
authentication: directLogin,
|
||||
};
|
||||
|
||||
(async () => {
|
||||
// Get Customer at one Bank.
|
||||
console.log(
|
||||
await get<API.Customer>(clientConfig, Customer)(GetCustomersAtBank)(
|
||||
"joinfincubator.01.uk.bk0"
|
||||
)
|
||||
);
|
||||
|
||||
// Get Customer at any Bank.
|
||||
console.log(
|
||||
await get<API.Customer>(clientConfig, Customer)(GetCustomersAtAnyBank)
|
||||
);
|
||||
})();
|
||||
29
examples/kyc.ts
Normal file
29
examples/kyc.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import {
|
||||
API,
|
||||
APIClientConfig,
|
||||
DirectLoginAuthentication,
|
||||
Version,
|
||||
get,
|
||||
KYC,
|
||||
GetKYCStatus,
|
||||
} from "../src/api";
|
||||
|
||||
const directLogin: DirectLoginAuthentication = {
|
||||
username: process.env.OBP_USERNAME,
|
||||
password: process.env.OBP_PASSWORD,
|
||||
consumerKey: process.env.OBP_CONSUMER_KEY,
|
||||
};
|
||||
const clientConfig: APIClientConfig = {
|
||||
baseUri: "https://obp-apisandbox.joinfincubator.com",
|
||||
version: Version.v510,
|
||||
authentication: directLogin,
|
||||
};
|
||||
|
||||
(async () => {
|
||||
// Get KYC status
|
||||
console.log(
|
||||
await get<API.KYC>(clientConfig, KYC)(GetKYCStatus)(
|
||||
"9e6b2f45-a449-4e87-b772-e74cc9d42448"
|
||||
)
|
||||
);
|
||||
})();
|
||||
31
examples/metadata.ts
Normal file
31
examples/metadata.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import {
|
||||
API,
|
||||
APIClientConfig,
|
||||
DirectLoginAuthentication,
|
||||
Version,
|
||||
get,
|
||||
Metadata,
|
||||
GetTagsOnAccount,
|
||||
} from "../src/api";
|
||||
|
||||
const directLogin: DirectLoginAuthentication = {
|
||||
username: process.env.OBP_USERNAME,
|
||||
password: process.env.OBP_PASSWORD,
|
||||
consumerKey: process.env.OBP_CONSUMER_KEY,
|
||||
};
|
||||
const clientConfig: APIClientConfig = {
|
||||
baseUri: "https://obp-apisandbox.joinfincubator.com",
|
||||
version: Version.v510,
|
||||
authentication: directLogin,
|
||||
};
|
||||
|
||||
(async () => {
|
||||
// Get TagsOnAccount
|
||||
console.log(
|
||||
await get<API.Metadata>(clientConfig, Metadata)(GetTagsOnAccount)(
|
||||
"obp1",
|
||||
"9e6b2f45-a449-4e87-b772-e74cc9d42448",
|
||||
"owner"
|
||||
)
|
||||
);
|
||||
})();
|
||||
64
examples/transaction.ts
Normal file
64
examples/transaction.ts
Normal file
@ -0,0 +1,64 @@
|
||||
import {
|
||||
API,
|
||||
Version,
|
||||
APIClientConfig,
|
||||
DirectLoginAuthentication,
|
||||
create,
|
||||
get,
|
||||
Transaction,
|
||||
} from "../src/api";
|
||||
import {
|
||||
GetTransactionsForAccountFull,
|
||||
CreateTransactionRequestAccount,
|
||||
TransactionRequestAccountBody,
|
||||
} from "../src/api/transaction";
|
||||
|
||||
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.v510,
|
||||
authentication: directLogin,
|
||||
};
|
||||
const bankId = "rbs";
|
||||
const accountId = "9e6b2f45-a449-4e87-b772-e74cc9d42448";
|
||||
const viewId = "owner";
|
||||
|
||||
(async () => {
|
||||
//Get Transaction
|
||||
await get<API.Transaction>(
|
||||
clientConfig,
|
||||
Transaction
|
||||
)(GetTransactionsForAccountFull)(bankId, accountId, viewId);
|
||||
|
||||
//Get Transaction with custom relative path
|
||||
await get<API.Transaction>(
|
||||
clientConfig,
|
||||
Transaction
|
||||
)(`/banks/${bankId}/accounts/${accountId}/${viewId}/transactions`);
|
||||
|
||||
// Requst body for creating a transaction
|
||||
const body: TransactionRequestAccountBody = {
|
||||
description: "test transaction full data",
|
||||
to: {
|
||||
bank_id: bankId,
|
||||
account_id: accountId,
|
||||
},
|
||||
value: {
|
||||
currency: "EUR",
|
||||
amount: 1.0,
|
||||
},
|
||||
};
|
||||
await create<API.Transaction>(
|
||||
clientConfig,
|
||||
Transaction
|
||||
)(CreateTransactionRequestAccount)(
|
||||
bankId,
|
||||
accountId,
|
||||
viewId,
|
||||
"SANDBOX_TAN"
|
||||
)(body);
|
||||
})();
|
||||
25
examples/user.ts
Normal file
25
examples/user.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import {
|
||||
API,
|
||||
APIClientConfig,
|
||||
DirectLoginAuthentication,
|
||||
Version,
|
||||
get,
|
||||
User,
|
||||
Current,
|
||||
} from "../src/api";
|
||||
|
||||
const directLogin: DirectLoginAuthentication = {
|
||||
username: process.env.OBP_USERNAME,
|
||||
password: process.env.OBP_PASSWORD,
|
||||
consumerKey: process.env.OBP_CONSUMER_KEY,
|
||||
};
|
||||
const clientConfig: APIClientConfig = {
|
||||
baseUri: "https://obp-apisandbox.joinfincubator.com",
|
||||
version: Version.v510,
|
||||
authentication: directLogin,
|
||||
};
|
||||
|
||||
(async () => {
|
||||
// Get current User
|
||||
console.log(await get<API.User>(clientConfig, User)(Current));
|
||||
})();
|
||||
24
jest.config.ts
Normal file
24
jest.config.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import type { JestConfigWithTsJest } from "ts-jest";
|
||||
|
||||
const jestConfig: JestConfigWithTsJest = {
|
||||
preset: "ts-jest",
|
||||
testEnvironment: "node",
|
||||
testTimeout: 1000000,
|
||||
modulePathIgnorePatterns: ["<rootDir>/dist/"],
|
||||
moduleNameMapper: {
|
||||
"^@obp-sdk-ts/(.*)$": "<rootDir>/src/$1",
|
||||
},
|
||||
reporters: ["default", "jest-junit"],
|
||||
globals: {
|
||||
obpUsername: process.env.OBP_USERNAME,
|
||||
obpPassword: process.env.OBP_PASSWORD,
|
||||
obpConsumerKey: process.env.OBP_CONSUMER_KEY,
|
||||
//obpBaseUri: "https://apisandbox.openbankproject.com",
|
||||
obpBaseUri: "https://obp-apisandbox.joinfincubator.com",
|
||||
obpVersion: "v5.1.0",
|
||||
//obpTestBank: "rbs",
|
||||
obpTestBankId: "joinfincubator.01.uk.bk0",
|
||||
},
|
||||
};
|
||||
|
||||
export default jestConfig;
|
||||
15
junit.xml
Normal file
15
junit.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<testsuites name="jest tests" tests="1" failures="1" errors="0" time="3.507">
|
||||
<testsuite name="Metadata" errors="0" failures="1" skipped="0" timestamp="2023-03-06T08:37:35" time="3.44" tests="1">
|
||||
<testcase classname="Metadata get<API.Metadata> should be able to get the OBP Metadata data." name="Metadata get<API.Metadata> should be able to get the OBP Metadata data." time="2.394">
|
||||
<failure>Error: Not Found
|
||||
at Request.callback (/Users/ron/tesobe/gh/OBP-Oauth-SDK/node_modules/superagent/src/node/index.js:901:17)
|
||||
at fn (/Users/ron/tesobe/gh/OBP-Oauth-SDK/node_modules/superagent/src/node/index.js:1166:18)
|
||||
at IncomingMessage.<anonymous> (/Users/ron/tesobe/gh/OBP-Oauth-SDK/node_modules/superagent/src/node/parsers/json.js:19:7)
|
||||
at IncomingMessage.emit (node:events:525:35)
|
||||
at IncomingMessage.emit (node:domain:489:12)
|
||||
at endReadableNT (node:internal/streams/readable:1359:12)
|
||||
at processTicksAndRejections (node:internal/process/task_queues:82:21)</failure>
|
||||
</testcase>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
52
package.json
Normal file
52
package.json
Normal file
@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "obp-sdk-ts",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "tsc && tsc-alias",
|
||||
"test": "jest --setupFiles dotenv/config",
|
||||
"lint": "yarn prettier --w . && yarn eslint src __tests__"
|
||||
},
|
||||
"dependencies": {
|
||||
"dotenv": "^16.0.3",
|
||||
"global": "^4.4.0",
|
||||
"multer": "^1.4.5-lts.1",
|
||||
"superagent": "^8.0.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jest/globals": "^29.3.1",
|
||||
"@types/jest": "^29.2.3",
|
||||
"@types/superagent": "^4.1.16",
|
||||
"@typescript-eslint/eslint-plugin": "^5.45.0",
|
||||
"@typescript-eslint/parser": "^5.45.0",
|
||||
"eslint": "^8.28.0",
|
||||
"eslint-plugin-jest": "^27.1.6",
|
||||
"eslint-plugin-tsdoc": "^0.2.17",
|
||||
"husky": "^8.0.3",
|
||||
"jest": "^29.3.1",
|
||||
"jest-junit": "^15.0.0",
|
||||
"pre-commit": "^1.2.2",
|
||||
"prettier": "2.8.0",
|
||||
"ts-jest": "^29.0.3",
|
||||
"ts-node": "^10.9.1",
|
||||
"tsc-alias": "^1.7.1",
|
||||
"typedoc": "^0.23.26",
|
||||
"typedoc-github-wiki-theme": "^1.0.1",
|
||||
"typedoc-plugin-markdown": "^3.14.0",
|
||||
"typescript": "^4.9.5",
|
||||
"typescript-language-server": "^3.0.3"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"src/**/*.ts": [
|
||||
"yarn lint"
|
||||
],
|
||||
"__tests__/**/*.ts": [
|
||||
"yarn lint"
|
||||
]
|
||||
}
|
||||
}
|
||||
49
src/api/account.ts
Normal file
49
src/api/account.ts
Normal file
@ -0,0 +1,49 @@
|
||||
import {
|
||||
API,
|
||||
APIRequest,
|
||||
APIClientConfig,
|
||||
apiCallWithCustomURIPath,
|
||||
} from "./client";
|
||||
|
||||
/**
|
||||
* Get Accounts at Bank.
|
||||
* Returns the list of accounts at BANK_ID that the user has access to.
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param methodCall - A higher order function
|
||||
* @returns A curried function
|
||||
*
|
||||
* @see {@link APIClientConfig}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const GetAccountsByBankId =
|
||||
(
|
||||
config: APIClientConfig,
|
||||
methodCall: (config: APIClientConfig, path: string) => Promise<API.Account>
|
||||
) =>
|
||||
async (id: string): Promise<API.Account> => {
|
||||
const path = `/banks/${id}/accounts`;
|
||||
return await methodCall(config, path);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an anonymous function for creating or getting an Account data.
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param methodCall - A higher order function
|
||||
* @returns A higher order function
|
||||
*
|
||||
* @see {@link APIClientConfig}
|
||||
* @see {@link APIRequest}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const Account: APIRequest<API.Account> = {
|
||||
get: (
|
||||
config: APIClientConfig,
|
||||
methodCall: (config: APIClientConfig, path: string) => Promise<API.Account>
|
||||
) => {
|
||||
return apiCallWithCustomURIPath<API.Account>(config, methodCall);
|
||||
},
|
||||
};
|
||||
68
src/api/bank.ts
Normal file
68
src/api/bank.ts
Normal file
@ -0,0 +1,68 @@
|
||||
import {
|
||||
API,
|
||||
APIRequest,
|
||||
APIClientConfig,
|
||||
apiCallWithCustomURIPath,
|
||||
} from "./client";
|
||||
|
||||
/**
|
||||
* Get the bank specified by BANK_ID.
|
||||
* Returns information about a single bank specified by BANK_ID.
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param methodCall - A higher order function
|
||||
* @returns A curried function
|
||||
*
|
||||
* @see {@link APIClientConfig}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const GetBanksById =
|
||||
(
|
||||
config: APIClientConfig,
|
||||
methodCall: (config: APIClientConfig, path: string) => Promise<any>
|
||||
) =>
|
||||
async (id: string): Promise<API.Account> => {
|
||||
const path = `/banks/${id}`;
|
||||
return await methodCall(config, path);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get banks on this API instance.
|
||||
* Returns a list of banks.
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param methodCall - A higher order function
|
||||
* @returns A curried function
|
||||
*
|
||||
* @see {@link APIClientConfig}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const GetBanks = async (
|
||||
config: APIClientConfig,
|
||||
methodCall: (config: APIClientConfig, path: string) => Promise<any>
|
||||
) => {
|
||||
return await methodCall(config, "banks");
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an anonymous function for creating or getting Bank data.
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param methodCall - A higher order function
|
||||
* @returns A higher order function
|
||||
*
|
||||
* @see {@link APIClientConfig}
|
||||
* @see {@link APIRequest}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const Bank: APIRequest<API.Bank> = {
|
||||
get: (
|
||||
config: APIClientConfig,
|
||||
methodCall: (config: APIClientConfig, path: string) => Promise<any>
|
||||
) => {
|
||||
return apiCallWithCustomURIPath<API.Bank>(config, methodCall);
|
||||
},
|
||||
};
|
||||
308
src/api/client.ts
Normal file
308
src/api/client.ts
Normal file
@ -0,0 +1,308 @@
|
||||
import superagent from "superagent";
|
||||
|
||||
/**
|
||||
* OBP API Versions.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export enum Version {
|
||||
v500 = "v5.0.0",
|
||||
v510 = "v5.1.0",
|
||||
}
|
||||
|
||||
/**
|
||||
* Types of OBP API.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export enum API {
|
||||
Bank,
|
||||
Account,
|
||||
Payment,
|
||||
Transaction,
|
||||
User,
|
||||
Customer,
|
||||
KYC,
|
||||
Metadata,
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for DirectLogin properties.
|
||||
*
|
||||
* @Property {string} username
|
||||
* @Property {string} passowrd
|
||||
* @Property {string} consumerKey
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type DirectLoginAuthentication = {
|
||||
username: string;
|
||||
password: string;
|
||||
consumerKey: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Alias for APIClientConfig properties.
|
||||
* @type {Object}
|
||||
*
|
||||
* @Property {string} baseUri
|
||||
* @Property {Version} version
|
||||
* @Property {DirectLoginAuthentication} authentication
|
||||
* @Property {string} [token]
|
||||
*
|
||||
* @see {@link Version}
|
||||
* @see {@link DirectLoginAuthentication}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type APIClientConfig = {
|
||||
baseUri: string;
|
||||
version: Version;
|
||||
authentication: DirectLoginAuthentication;
|
||||
token?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Alias for HTTP MethodCall properties.
|
||||
* @type {Object}
|
||||
* @typeParam T - Type of object
|
||||
*
|
||||
* @Property {APIClientConfig} config
|
||||
* @Property {string} path
|
||||
* @Property {any} [body]
|
||||
*
|
||||
* @see APIClientConfig
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type MethodCall<T> = (
|
||||
config: APIClientConfig,
|
||||
path: string,
|
||||
body?: any
|
||||
) => Promise<T>;
|
||||
|
||||
/**
|
||||
* Alias for APIRequest properties.
|
||||
* @type {Object}
|
||||
* @typeParam T - Type of object
|
||||
*
|
||||
* @Property {(config: APIClientConfig, methodCall: MethodCall<T>) => any} [get]
|
||||
* @Property {(config: APIClientConfig, methodCall: MethodCall<T>) => any} [create]
|
||||
*
|
||||
* @see {@link APIClientConfig}
|
||||
* @see {@link MethodCall}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type APIRequest<T> = {
|
||||
get?: (config: APIClientConfig, methodCall: MethodCall<T>) => any;
|
||||
create?: (config: APIClientConfig, methodCall: MethodCall<T>) => any;
|
||||
};
|
||||
|
||||
/**
|
||||
* Alias for RequestParameter properties.
|
||||
* @type {Object}
|
||||
* @typeParam T - Type of object
|
||||
*
|
||||
* @Property {APIClientConfig} config
|
||||
* @Property {MethodCall<T>} methodCall
|
||||
*
|
||||
* @see APIClientConfig
|
||||
* @see MethodCall<T>
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type RequestParameter<T> = (
|
||||
config: APIClientConfig,
|
||||
methodCall: MethodCall<T>
|
||||
) => T;
|
||||
|
||||
/**
|
||||
* Returns the absolute URI path.
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param path - The relative path
|
||||
* @returns The absolute URI
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
const uri = (config: APIClientConfig, path: string): string => {
|
||||
const base = config.baseUri;
|
||||
const version = config.version;
|
||||
if (path.startsWith("/")) {
|
||||
return `${base}/obp/${version}${path}`;
|
||||
} else {
|
||||
return `${base}/obp/${version}/${path}`;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an anonymous function.
|
||||
* @typeParam T - Type of API
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param methodCall<T> - The HTTP method function
|
||||
* @returns A curried function
|
||||
*
|
||||
* @see API
|
||||
* @see APIClientConfig
|
||||
* @see MethodCall<T>
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const apiCallWithCustomURIPath =
|
||||
<T>(config: APIClientConfig, methodCall: MethodCall<T>) =>
|
||||
(path: string | RequestParameter<T>) => {
|
||||
if (typeof path === "string") {
|
||||
return methodCall(config, path.toString());
|
||||
} else {
|
||||
return path(config, methodCall);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an anonymous function.
|
||||
* @typeParam T - Type of API
|
||||
* @typeParam E - The response type
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param path - The URI path
|
||||
* @param methodCall<T> - The HTTP method function
|
||||
* @returns A curried function
|
||||
*
|
||||
* @see API
|
||||
* @see APIClientConfig
|
||||
* @see MethodCall<T>
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const apiCallWithCustomBody =
|
||||
<T, E>(config: APIClientConfig, path: string, methodCall: MethodCall<T>) =>
|
||||
(body: E) => {
|
||||
return methodCall(config, path, body);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the Authorization DirectLogin header value.
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @returns A {string} value
|
||||
*
|
||||
* @see APIClientConfig
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
const getDirectLoginToken = async (
|
||||
config: APIClientConfig
|
||||
): Promise<string> => {
|
||||
if (!config.authentication) {
|
||||
console.warn("Authentication is not set.");
|
||||
return "";
|
||||
}
|
||||
const loginUri = config.baseUri + "/my/logins/direct";
|
||||
const username = config.authentication.username;
|
||||
const password = config.authentication.password;
|
||||
const consumerKey = config.authentication.consumerKey;
|
||||
const directLogin = `DirectLogin username=${username},password=${password},consumer_key=${consumerKey}`;
|
||||
const response = JSON.parse(
|
||||
(
|
||||
await superagent
|
||||
.post(loginUri)
|
||||
.set("Content-Type", "application/json")
|
||||
.set("Authorization", directLogin)
|
||||
).text
|
||||
);
|
||||
return "DirectLogin token=" + response.token;
|
||||
};
|
||||
|
||||
/**
|
||||
* Send a GET request and returns a response.
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @returns An {object} value
|
||||
*
|
||||
* @see APIClientConfig
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const getRequest = async (
|
||||
config: APIClientConfig,
|
||||
path: string
|
||||
): Promise<any> => {
|
||||
const pathUri = uri(config, path);
|
||||
if (!config.token) {
|
||||
config.token = await getDirectLoginToken(config);
|
||||
}
|
||||
return JSON.parse(
|
||||
(await superagent.get(pathUri).set("Authorization", config.token)).text
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Send a POST request and returns a response.
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param path - The URI path
|
||||
* @param body - The request body
|
||||
* @returns An {object} value
|
||||
*
|
||||
* @see APIClientConfig
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const postRequest = async (
|
||||
config: APIClientConfig,
|
||||
path: string,
|
||||
body: any
|
||||
): Promise<any> => {
|
||||
const pathUri = uri(config, path);
|
||||
if (!config.token) {
|
||||
config.token = await getDirectLoginToken(config);
|
||||
}
|
||||
return JSON.parse(
|
||||
(
|
||||
await superagent
|
||||
.post(pathUri)
|
||||
.set("Authorization", config.token)
|
||||
.send(body)
|
||||
).text
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* A GET request function that returns the API data.
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param request - The APIRequest object
|
||||
* @returns An @typeParam {Object} value
|
||||
*
|
||||
* @see APIClientConfig
|
||||
* @see APIRequest<T>
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const get = <T>(
|
||||
config: APIClientConfig,
|
||||
request: APIRequest<T>
|
||||
): any => {
|
||||
return request.get(config, getRequest);
|
||||
};
|
||||
|
||||
/**
|
||||
* A POST request function that creates an API data and returns the result.
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param request - The APIRequest object
|
||||
* @returns An @typeParam {Object} value
|
||||
*
|
||||
* @see APIClientConfig
|
||||
* @see APIRequest<T>
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const create = <T>(
|
||||
config: APIClientConfig,
|
||||
request: APIRequest<T>
|
||||
): any => {
|
||||
return request.create(config, postRequest);
|
||||
};
|
||||
164
src/api/customer.ts
Normal file
164
src/api/customer.ts
Normal file
@ -0,0 +1,164 @@
|
||||
import {
|
||||
API,
|
||||
APIRequest,
|
||||
APIClientConfig,
|
||||
apiCallWithCustomURIPath,
|
||||
apiCallWithCustomBody,
|
||||
} from "./client";
|
||||
|
||||
/**
|
||||
* Alias for CustomerBody properties.
|
||||
*
|
||||
* @Property {{currency: string, amount: number}} credit_limit
|
||||
* @Property {{url: string, date: string}} face_image
|
||||
* @Property {string} legal_name
|
||||
* @Property {string} mobile_phone_number
|
||||
* @Property {{rating:string, source:string}} credit_rating
|
||||
* @Property {string} [customer_number]
|
||||
* @Property {string} [email]
|
||||
* @Property {string} [date_of_birth]
|
||||
* @Property {string} [relationship_status]
|
||||
* @Property {string} [dependants]
|
||||
* @Property {Array.<string>} [dob_of_dependants]
|
||||
* @Property {string} [highest_education_attained]
|
||||
* @Property {string} [employment_status]
|
||||
* @Property {boolean} [kyc_status]
|
||||
* @Property {string} [last_ok_date]
|
||||
* @Property {string} [title]
|
||||
* @Property {string} [branch_id]
|
||||
* @Property {string} [name_suffix]
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type CustomerBody = {
|
||||
credit_limit: {
|
||||
currency: string;
|
||||
amount: number;
|
||||
};
|
||||
face_image: {
|
||||
url: string;
|
||||
date: string;
|
||||
};
|
||||
legal_name: string;
|
||||
mobile_phone_number: string;
|
||||
credit_rating: {
|
||||
rating: string;
|
||||
source: string;
|
||||
};
|
||||
customer_number?: number;
|
||||
email?: string;
|
||||
date_of_birth?: string;
|
||||
relationship_status?: string;
|
||||
dependants?: number;
|
||||
dob_of_dependants?: Array<string>;
|
||||
highest_education_attained?: string;
|
||||
employment_status?: string;
|
||||
kyc_status?: boolean;
|
||||
last_ok_date?: string;
|
||||
title?: string;
|
||||
branch_id?: string;
|
||||
name_suffix?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Customers at Any Bank.
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param methodCall - A higher order function
|
||||
* @returns A curried function
|
||||
*
|
||||
* @see {@link APIClientConfig}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const GetCustomersAtAnyBank = async (
|
||||
config: APIClientConfig,
|
||||
methodCall: (config: APIClientConfig, path: string) => Promise<any>
|
||||
) => {
|
||||
return await methodCall(config, "/customers");
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Customers at Bank.
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param methodCall - A higher order function
|
||||
* @returns A curried function
|
||||
*
|
||||
* @see {@link APIClientConfig}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const GetCustomersAtBank =
|
||||
(
|
||||
config: APIClientConfig,
|
||||
methodCall: (config: APIClientConfig, path: string) => Promise<any>
|
||||
) =>
|
||||
async (bankId: string): Promise<API.Customer> => {
|
||||
const path = `/banks/${bankId}/customers`;
|
||||
return await methodCall(config, path);
|
||||
};
|
||||
|
||||
/**
|
||||
* Create Customer.
|
||||
* The Customer resource stores the customer number (which is set by the backend), legal name, email, phone number,
|
||||
* their date of birth, relationship status, education attained, a url for a profile image, KYC status etc.
|
||||
* Dates need to be in the format 2013-01-21T23:08:00Z
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param methodCall - A higher order function
|
||||
* @returns A curried function
|
||||
*
|
||||
* @see {@link APIClientConfig}
|
||||
* @see {@link CustomerBody}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const CreateCustomers =
|
||||
(
|
||||
config: APIClientConfig,
|
||||
methodCall: (
|
||||
config: APIClientConfig,
|
||||
path: string,
|
||||
body: CustomerBody
|
||||
) => Promise<any>
|
||||
) =>
|
||||
(bankId: string) => {
|
||||
const path = `banks/${bankId}/customers`;
|
||||
return apiCallWithCustomBody<API.Transaction, CustomerBody>(
|
||||
config,
|
||||
path,
|
||||
methodCall
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an anonymous function for creating or getting Customer data.
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param methodCall - A higher order function
|
||||
* @returns A higher order function
|
||||
*
|
||||
* @see {@link APIClientConfig}
|
||||
* @see {@link APIRequest}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const Customer: APIRequest<API.Customer> = {
|
||||
get: (
|
||||
config: APIClientConfig,
|
||||
methodCall: (config: APIClientConfig, path: string) => Promise<any>
|
||||
) => {
|
||||
return apiCallWithCustomURIPath<API.Customer>(config, methodCall);
|
||||
},
|
||||
create: (
|
||||
config: APIClientConfig,
|
||||
methodCall: (
|
||||
config: APIClientConfig,
|
||||
path: string,
|
||||
body: CustomerBody
|
||||
) => Promise<any>
|
||||
) => {
|
||||
return apiCallWithCustomURIPath<API.Customer>(config, methodCall);
|
||||
},
|
||||
};
|
||||
27
src/api/index.ts
Normal file
27
src/api/index.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import "dotenv/config";
|
||||
export { Bank, GetBanks, GetBanksById } from "./bank";
|
||||
export { Account, GetAccountsByBankId } from "./account";
|
||||
export { KYC, GetKYCStatus } from "./kyc";
|
||||
export { Metadata, GetTagsOnAccount } from "./metadata";
|
||||
export {
|
||||
Customer,
|
||||
GetCustomersAtBank,
|
||||
GetCustomersAtAnyBank,
|
||||
} from "./customer";
|
||||
export {
|
||||
Transaction,
|
||||
TransactionRequestAccountBody,
|
||||
GetTransactionsForAccountFull,
|
||||
CreateTransactionRequestAccount,
|
||||
} from "./transaction";
|
||||
export { User, Current } from "./user";
|
||||
export {
|
||||
API,
|
||||
Version,
|
||||
APIRequest,
|
||||
MethodCall,
|
||||
APIClientConfig,
|
||||
DirectLoginAuthentication,
|
||||
get,
|
||||
create,
|
||||
} from "./client";
|
||||
47
src/api/kyc.ts
Normal file
47
src/api/kyc.ts
Normal file
@ -0,0 +1,47 @@
|
||||
import {
|
||||
API,
|
||||
APIRequest,
|
||||
APIClientConfig,
|
||||
apiCallWithCustomURIPath,
|
||||
} from "./client";
|
||||
|
||||
/**
|
||||
* Get the KYC statuses for a customer specified by CUSTOMER_ID over time.
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param methodCall - A higher order function
|
||||
* @returns A curried function
|
||||
*
|
||||
* @see {@link APIClientConfig}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const GetKYCStatus =
|
||||
(
|
||||
config: APIClientConfig,
|
||||
methodCall: (config: APIClientConfig, path: string) => Promise<any>
|
||||
) =>
|
||||
async (customerId: string) => {
|
||||
return await methodCall(config, `/customers/${customerId}/kyc_statuses`);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an anonymous function for creating or getting KYC data.
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param methodCall - A higher order function
|
||||
* @returns A higher order function
|
||||
*
|
||||
* @see {@link APIClientConfig}
|
||||
* @see {@link APIRequest}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const KYC: APIRequest<API.KYC> = {
|
||||
get: (
|
||||
config: APIClientConfig,
|
||||
methodCall: (config: APIClientConfig, path: string) => Promise<any>
|
||||
) => {
|
||||
return apiCallWithCustomURIPath<API.KYC>(config, methodCall);
|
||||
},
|
||||
};
|
||||
50
src/api/metadata.ts
Normal file
50
src/api/metadata.ts
Normal file
@ -0,0 +1,50 @@
|
||||
import {
|
||||
API,
|
||||
APIRequest,
|
||||
APIClientConfig,
|
||||
apiCallWithCustomURIPath,
|
||||
} from "./client";
|
||||
|
||||
/**
|
||||
* Returns the account ACCOUNT_ID tags made on a view (VIEW_ID).
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param methodCall - A higher order function
|
||||
* @returns A curried function
|
||||
*
|
||||
* @see {@link APIClientConfig}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const GetTagsOnAccount =
|
||||
(
|
||||
config: APIClientConfig,
|
||||
methodCall: (config: APIClientConfig, path: string) => Promise<any>
|
||||
) =>
|
||||
async (bankId: string, accountId: string, viewId: string) => {
|
||||
return await methodCall(
|
||||
config,
|
||||
`/banks/${bankId}/accounts/${accountId}/${viewId}/metadata/tags`
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an anonymous function for creating or getting Metadata data.
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param methodCall - A higher order function
|
||||
* @returns A higher order function
|
||||
*
|
||||
* @see {@link APIClientConfig}
|
||||
* @see {@link APIRequest}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const Metadata: APIRequest<API.Metadata> = {
|
||||
get: (
|
||||
config: APIClientConfig,
|
||||
methodCall: (config: APIClientConfig, path: string) => Promise<any>
|
||||
) => {
|
||||
return apiCallWithCustomURIPath<API.Metadata>(config, methodCall);
|
||||
},
|
||||
};
|
||||
114
src/api/transaction.ts
Normal file
114
src/api/transaction.ts
Normal file
@ -0,0 +1,114 @@
|
||||
import {
|
||||
API,
|
||||
APIRequest,
|
||||
APIClientConfig,
|
||||
apiCallWithCustomURIPath,
|
||||
apiCallWithCustomBody,
|
||||
} from "./client";
|
||||
|
||||
/**
|
||||
* Alias for TransactionRequestAccountBody properties.
|
||||
*
|
||||
* @Property {string} description
|
||||
* @Property {{bank_id: string, account_id: string}} to
|
||||
* @Property {{curreny: string, amount: number}} value
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type TransactionRequestAccountBody = {
|
||||
description: string;
|
||||
to: {
|
||||
bank_id: string;
|
||||
account_id: string;
|
||||
};
|
||||
value: {
|
||||
currency: string;
|
||||
amount: number;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Transactions for Account (Full).
|
||||
* Returns transactions list of the account specified by ACCOUNT_ID and moderated by the view (VIEW_ID).
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param methodCall - A higher order function
|
||||
* @returns A curried function
|
||||
*
|
||||
* @see {@link APIClientConfig}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const GetTransactionsForAccountFull =
|
||||
(
|
||||
config: APIClientConfig,
|
||||
methodCall: (config: APIClientConfig, path: string) => Promise<any>
|
||||
) =>
|
||||
async (
|
||||
bankId: string,
|
||||
accountId: string,
|
||||
viewId: string
|
||||
): Promise<API.Account> => {
|
||||
const path = `/banks/${bankId}/accounts/${accountId}/${viewId}/transactions`;
|
||||
return await methodCall(config, path);
|
||||
};
|
||||
|
||||
/**
|
||||
* Create Transaction Request (ACCOUNT).
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param methodCall - A higher order function
|
||||
* @returns A curried function
|
||||
*
|
||||
* @see {@link APIClientConfig}
|
||||
* @see {@link TransactionRequestAccountBody}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const CreateTransactionRequestAccount =
|
||||
(
|
||||
config: APIClientConfig,
|
||||
methodCall: (
|
||||
config: APIClientConfig,
|
||||
path: string,
|
||||
body: TransactionRequestAccountBody
|
||||
) => Promise<any>
|
||||
) =>
|
||||
(bankId: string, accountId: string, viewId: string, account: string) => {
|
||||
const path = `banks/${bankId}/accounts/${accountId}/${viewId}/transaction-request-types/${account}/transaction-requests`;
|
||||
return apiCallWithCustomBody<
|
||||
API.Transaction,
|
||||
TransactionRequestAccountBody
|
||||
>(config, path, methodCall);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an anonymous function for creating or getting Transaction data.
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param methodCall - A higher order function
|
||||
* @returns A higher order function
|
||||
*
|
||||
* @see {@link APIClientConfig}
|
||||
* @see {@link APIRequest}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const Transaction: APIRequest<API.Transaction> = {
|
||||
get: (
|
||||
config: APIClientConfig,
|
||||
methodCall: (config: APIClientConfig, path: string) => Promise<any>
|
||||
) => {
|
||||
return apiCallWithCustomURIPath<API.Transaction>(config, methodCall);
|
||||
},
|
||||
create: (
|
||||
config: APIClientConfig,
|
||||
methodCall: (
|
||||
config: APIClientConfig,
|
||||
path: string,
|
||||
body: TransactionRequestAccountBody
|
||||
) => Promise<any>
|
||||
) => {
|
||||
return apiCallWithCustomURIPath<API.Transaction>(config, methodCall);
|
||||
},
|
||||
};
|
||||
46
src/api/user.ts
Normal file
46
src/api/user.ts
Normal file
@ -0,0 +1,46 @@
|
||||
import {
|
||||
API,
|
||||
APIRequest,
|
||||
APIClientConfig,
|
||||
apiCallWithCustomURIPath,
|
||||
} from "./client";
|
||||
|
||||
/**
|
||||
* Get the logged in user
|
||||
* Returns information about the logged in user.
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param methodCall - A higher order function
|
||||
* @returns A curried function
|
||||
*
|
||||
* @see {@link APIClientConfig}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const Current = async (
|
||||
config: APIClientConfig,
|
||||
methodCall: (config: APIClientConfig, path: string) => Promise<API.User>
|
||||
) => {
|
||||
return await methodCall(config, "/users/current");
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an anonymous function for creating or getting a User data.
|
||||
*
|
||||
* @param config - The APIClientConfig object
|
||||
* @param methodCall - A higher order function
|
||||
* @returns A higher order function
|
||||
*
|
||||
* @see {@link APIClientConfig}
|
||||
* @see {@link APIRequest}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const User: APIRequest<API.User> = {
|
||||
get: (
|
||||
config: APIClientConfig,
|
||||
methodCall: (config: APIClientConfig, path: string) => Promise<API.User>
|
||||
) => {
|
||||
return apiCallWithCustomURIPath<API.User>(config, methodCall);
|
||||
},
|
||||
};
|
||||
27
src/index.ts
Normal file
27
src/index.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import "dotenv/config";
|
||||
export { Bank, GetBanks, GetBanksById } from "./api/bank";
|
||||
export { Account, GetAccountsByBankId } from "./api/account";
|
||||
export { KYC, GetKYCStatus } from "./api/kyc";
|
||||
export { Metadata, GetTagsOnAccount } from "./api/metadata";
|
||||
export {
|
||||
Customer,
|
||||
GetCustomersAtBank,
|
||||
GetCustomersAtAnyBank,
|
||||
} from "./api/customer";
|
||||
export {
|
||||
Transaction,
|
||||
TransactionRequestAccountBody,
|
||||
GetTransactionsForAccountFull,
|
||||
CreateTransactionRequestAccount,
|
||||
} from "./api/transaction";
|
||||
export { User, Current } from "./api/user";
|
||||
export {
|
||||
API,
|
||||
Version,
|
||||
APIRequest,
|
||||
MethodCall,
|
||||
APIClientConfig,
|
||||
DirectLoginAuthentication,
|
||||
get,
|
||||
create,
|
||||
} from "./api/client";
|
||||
15
tsconfig.json
Normal file
15
tsconfig.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"esModuleInterop": true,
|
||||
"target": "ES6",
|
||||
"outDir": "dist",
|
||||
"baseUrl": "src",
|
||||
"resolveJsonModule": true,
|
||||
"paths": {
|
||||
"*": ["node_modules/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*", "src/*.json"],
|
||||
"exclude": ["__tests__"]
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user