Skip to content

Commit

Permalink
Merge pull request #16 from peoray/accounts-methods
Browse files Browse the repository at this point in the history
Accounts methods
  • Loading branch information
peoray committed Jan 29, 2024
2 parents a54393c + ce3db1d commit da1f710
Show file tree
Hide file tree
Showing 18 changed files with 713 additions and 0 deletions.
185 changes: 185 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ A Nodejs API wrapper for [Bloc](https://www.blochq.io/) banking services written
- [Installation](#installation)
- [Usage](#usage)
- [Available Methods exposed by the SDK](#available-methods-exposed-by-the-sdk)
- [Accounts API](#accounts-api)
- [Create Fixed Account](#create-fixed-account)
- [Create Collection Account](#create-collection-account)
- [Get accounts](#get-accounts)
- [Get Account By ID](#get-account-by-id)
- [Get Collection Account](#get-collection-account)
- [Get Account by Account Number](#get-account-by-account-number)
- [Get Customer Accounts](#get-customer-accounts)
- [Get Organisation Default Accounts](#get-organisation-default-accounts)
- [Freeze Account](#freeze-account)
- [Unfreeze Account](#unfreeze-account)
- [Close Account](#close-account)
- [Reopen Account](#reopen-account)
- [Wallets API](#wallets-api)
- [Create Wallet](#create-wallet)
- [Get Wallets](#get-wallets)
Expand Down Expand Up @@ -114,6 +127,178 @@ const bloc = new Bloc('SECRET_KEY, PUBLIC_KEY');

## Available Methods exposed by the SDK

### Accounts API

Accounts API operations

#### Create Fixed Account

```ts
// import the accounts interfaces from the sdk
import type { ICreateFixedAccountRequest, IAccountResponse } from 'bloc-nodejs';

const payload: ICreateFixedAccountRequest = {
// payload data
}

const response = await bloc.createFixedAccount(payload)
console.log(response) // IAccountResponse
```

Find more details about the parameters and response for the above method [here](https://docs.blochq.io/reference/createfixedaccount)

#### Create Collection Account

```ts
// import the accounts interfaces from the sdk
import type { ICreateCollectionAccountRequest, ICreateCollectionAccountResponse } from 'bloc-nodejs';

const payload: ICreateCollectionAccountRequest = {
// payload data
}

const response = await bloc.createCollectionAccount(payload)
console.log(response) // ICreateCollectionAccountResponse
```

Find more details about the parameters and response for the above method [here](https://docs.blochq.io/reference/createcollectionaccount)

#### Get Accounts

```ts
// import the accounts interfaces from the sdk
import type { IGetAccountsResponse } from 'bloc-nodejs';

const response = await bloc.getAccounts(payload)
console.log(response) // IGetAccountsResponse
```

Find more details about the parameters and response for the above method [here](https://docs.blochq.io/reference/getaccounts)

#### Get Account By ID

```ts
// import the accounts interfaces from the sdk
import type { IAccountResponse } from 'bloc-nodejs';

const response = await bloc.getAccountById('account-id')
console.log(response) // IAccountResponse
```

Find more details about the parameters and response for the above method [here](https://docs.blochq.io/reference/getaccountbyid)

#### Get Collection Account

```ts
// import the accounts interfaces from the sdk
import type { IAccountResponse } from 'bloc-nodejs';

const response = await bloc.getCollectionAccount()
console.log(response) // IAccountResponse
```

Find more details about the parameters and response for the above method [here](https://docs.blochq.io/reference/getcollectionaccount)

#### Get Account by Account Number

```ts
// import the accounts interfaces from the sdk
import type { IAccountResponse } from 'bloc-nodejs';

const response = await bloc.getAccountByAccountNumber('account-number')
console.log(response) // IAccountResponse
```

Find more details about the parameters and response for the above method [here](https://docs.blochq.io/reference/getaccountbyaccountnumber)

#### Get Customer Accounts

```ts
// import the accounts interfaces from the sdk
import type { IGetAccountsResponse } from 'bloc-nodejs';

const response = await bloc.getCustomerAccounts('customer-id')
console.log(response) // IGetAccountsResponse
```

Find more details about the parameters and response for the above method [here](https://docs.blochq.io/reference/getcustomeraccounts)

#### Get Organisation Default Accounts

```ts
// import the accounts interfaces from the sdk
import type { IGetOrganisationDefaultAccountsResponse } from 'bloc-nodejs';

const response = await bloc.getOrganisationDefaultAccounts()
console.log(response) // IGetOrganisationDefaultAccountsResponse
```

Find more details about the parameters and response for the above method [here](https://docs.blochq.io/reference/getorganisationdefaultaccounts)

#### Freeze Account

```ts
// import the accounts interfaces from the sdk
import type { IUpdateAccountRequest, IUpdateAccountResponse } from 'bloc-nodejs';

const payload: IUpdateAccountRequest = {
// payload data
}

const response = await bloc.freezeAccount('account-id', data)
console.log(response) // IUpdateAccountResponse
```

Find more details about the parameters and response for the above method [here](https://docs.blochq.io/reference/freezeaccount)

#### Unfreeze Account

```ts
// import the accounts interfaces from the sdk
import type { IUpdateAccountRequest, IUpdateAccountResponse } from 'bloc-nodejs';

const payload: IUpdateAccountRequest = {
// payload data
}

const response = await bloc.unfreezeAccount('account-id', data)
console.log(response) // IUpdateAccountResponse
```

Find more details about the parameters and response for the above method [here](https://docs.blochq.io/reference/unfreezeaccount-1)

#### Close Account

```ts
// import the accounts interfaces from the sdk
import type { IUpdateAccountRequest, IUpdateAccountResponse } from 'bloc-nodejs';

const payload: IUpdateAccountRequest = {
// payload data
}

const response = await bloc.closeAccount('account-id', data)
console.log(response) // IUpdateAccountResponse
```

Find more details about the parameters and response for the above method [here](https://docs.blochq.io/reference/closeaccount)

#### Reopen Account

```ts
// import the accounts interfaces from the sdk
import type { IUpdateAccountRequest, IUpdateAccountResponse } from 'bloc-nodejs';

const payload: IUpdateAccountRequest = {
// payload data
}

const response = await bloc.reopenAccount('account-id', data)
console.log(response) // IUpdateAccountResponse
```

Find more details about the parameters and response for the above method [here](https://docs.blochq.io/reference/reopenaccount)

### Wallets API

Wallets API operations
Expand Down
17 changes: 17 additions & 0 deletions examples/accounts/close-account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Bloc, IUpdateAccountRequest } from '../../dist'

const bloc = new Bloc('secret-keyasfasfbahfb', 'public-key')

const closeAccount = async () => {
try {
const data: IUpdateAccountRequest = {
reason: 'bad kyc details',
}
const response = await bloc.closeAccount('account-id', data)
console.log(response)
} catch (error) {
console.error(error)
}
}

closeAccount()
22 changes: 22 additions & 0 deletions examples/accounts/create-collection-account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Bloc, ICreateCollectionAccountRequest } from '../../dist'

const bloc = new Bloc('secret-keyasfasfbahfb', 'public-key')

const createCollectionAccount = async () => {
try {
const data: ICreateCollectionAccountRequest = {
preferred_bank: 'Providus',
alias: 'Business',
collection_rules: {
amount: 30000,
frequency: 2,
},
}
const response = await bloc.createCollectionAccount(data)
console.log(response)
} catch (error) {
console.error(error)
}
}

createCollectionAccount()
23 changes: 23 additions & 0 deletions examples/accounts/create-fixed-account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Bloc, ICreateFixedAccountRequest } from '../../dist'

const bloc = new Bloc('secret-keyasfasfbahfb', 'public-key')

const createFixedAccount = async () => {
try {
const data: ICreateFixedAccountRequest = {
customer_id: '64c9e81497880d4b259cec77',
preferred_bank: 'Banc Corp',
alias: 'business',
collection_rules: {
amount: 30000,
frequency: 2,
},
}
const response = await bloc.createFixedAccount(data)
console.log(response)
} catch (error) {
console.error(error)
}
}

createFixedAccount()
17 changes: 17 additions & 0 deletions examples/accounts/freeze-account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Bloc, IUpdateAccountRequest } from '../../dist'

const bloc = new Bloc('secret-keyasfasfbahfb', 'public-key')

const freezeAccount = async () => {
try {
const data: IUpdateAccountRequest = {
reason: 'bad kyc details',
}
const response = await bloc.freezeAccount('account-id', data)
console.log(response)
} catch (error) {
console.error(error)
}
}

freezeAccount()
14 changes: 14 additions & 0 deletions examples/accounts/get-account-by-account-number.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Bloc } from '../../dist'

const bloc = new Bloc('secret-keyasfasfbahfb', 'public-key')

const getAccountByAccountNumber = async () => {
try {
const response = await bloc.getAccountByAccountNumber('account-id')
console.log(response)
} catch (error) {
console.error(error)
}
}

getAccountByAccountNumber()
14 changes: 14 additions & 0 deletions examples/accounts/get-account-by-id.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Bloc } from '../../dist'

const bloc = new Bloc('secret-keyasfasfbahfb', 'public-key')

const getAccountById = async () => {
try {
const response = await bloc.getAccountById('account-id')
console.log(response)
} catch (error) {
console.error(error)
}
}

getAccountById()
14 changes: 14 additions & 0 deletions examples/accounts/get-accounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Bloc } from '../../dist'

const bloc = new Bloc('secret-keyasfasfbahfb', 'public-key')

const getAccounts = async () => {
try {
const response = await bloc.getAccounts()
console.log(response)
} catch (error) {
console.error(error)
}
}

getAccounts()
14 changes: 14 additions & 0 deletions examples/accounts/get-collection-account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Bloc } from '../../dist'

const bloc = new Bloc('secret-keyasfasfbahfb', 'public-key')

const getCollectionAccount = async () => {
try {
const response = await bloc.getCollectionAccount()
console.log(response)
} catch (error) {
console.error(error)
}
}

getCollectionAccount()
14 changes: 14 additions & 0 deletions examples/accounts/get-customer-accounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Bloc } from '../../dist'

const bloc = new Bloc('secret-keyasfasfbahfb', 'public-key')

const getCustomerAccounts = async () => {
try {
const response = await bloc.getCustomerAccounts('customer-id')
console.log(response)
} catch (error) {
console.error(error)
}
}

getCustomerAccounts()
14 changes: 14 additions & 0 deletions examples/accounts/get-organization-default-accounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Bloc } from '../../dist'

const bloc = new Bloc('secret-keyasfasfbahfb', 'public-key')

const getOrganisationDefaultAccounts = async () => {
try {
const response = await bloc.getOrganisationDefaultAccounts()
console.log(response)
} catch (error) {
console.error(error)
}
}

getOrganisationDefaultAccounts()
17 changes: 17 additions & 0 deletions examples/accounts/reopen-account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Bloc, IUpdateAccountRequest } from '../../dist'

const bloc = new Bloc('secret-keyasfasfbahfb', 'public-key')

const reopenAccount = async () => {
try {
const data: IUpdateAccountRequest = {
reason: 'bad kyc details',
}
const response = await bloc.reopenAccount('account-id', data)
console.log(response)
} catch (error) {
console.error(error)
}
}

reopenAccount()
Loading

0 comments on commit da1f710

Please sign in to comment.