Skip to content

Commit

Permalink
Add AddBank function
Browse files Browse the repository at this point in the history
  • Loading branch information
TaslimOseni committed Jul 9, 2021
1 parent 5ae1d75 commit 31ee603
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ api.accounts.updateIdentity('ACCOUNT_ID', {
identity_type: 'bvn',
identity_value: '0123456789'})
.then(result => console.log(result));

// Add a bank account
api.accounts.addBank('ACCOUNT_ID', {
bank_code: '058',
account_number: '0149541957'})
.then(result => console.log(result));
```

#### WALLETS
Expand Down
17 changes: 17 additions & 0 deletions src/endpoints/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,23 @@ class Accounts {
});
}


/**
* Add Bank
*
* Add a bank account connected to an account
* @param {String} uid The UID of the investment account
* @param {String} data.bank_code The bank code of the bank
* @param {String} data.account_number The account number
*/
addBank(uid, data) {
return request.perform(this.config, {
method: "POST",
endpoint: "/accounts/" +uid +"/bank",
data: data
});
}


}

Expand Down
14 changes: 10 additions & 4 deletions testapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const api = new Client({
// .then(result => console.log(result));


// api.accounts.updateAddress("033f5d3d00354d28961031efe9ae2938", {
// api.accounts.updateAddress('033f5d3d00354d28961031efe9ae2938', {
// street: 'Broadway',
// lga: 'Eti-Osa',
// area_code: '231',
Expand All @@ -56,7 +56,7 @@ const api = new Client({
// .then(result => console.log(result));


// api.accounts.updateNextOfKin("033f5d3d00354d28961031efe9ae2938", {
// api.accounts.updateNextOfKin('033f5d3d00354d28961031efe9ae2938', {
// first_name: 'John',
// last_name: 'Doe',
// email: '[email protected]',
Expand All @@ -67,7 +67,7 @@ const api = new Client({
// .then(result => console.log(result));


// api.accounts.updateProfile("033f5d3d00354d28961031efe9ae2938", {
// api.accounts.updateProfile('033f5d3d00354d28961031efe9ae2938', {
// first_name: 'Taslim',
// last_name: 'Oseni',
// email: '[email protected]',
Expand All @@ -78,13 +78,19 @@ const api = new Client({
// .then(result => console.log(result));


// api.accounts.updateIdentity("033f5d3d00354d28961031efe9ae2938", {
// api.accounts.updateIdentity('033f5d3d00354d28961031efe9ae2938', {
// identity_type: 'bvn',
// identity_value: '0123456789'
// })
// .then(result => console.log(result));


// api.accounts.addBank('033f5d3d00354d28961031efe9ae2938', {
// bank_code: '058',
// account_number: '0149541957'
// })
// .then(result => console.log(result));




Expand Down
10 changes: 10 additions & 0 deletions tests/integrations/accounts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const updateAddressResponse = require('../responses/update_address_200.json')
const updateNokResponse = require('../responses/update_nok_200.json')
const updateProfileResponse = require('../responses/update_profile_200.json')
const updateIdentityResponse = require('../responses/update_identity_200.json')
const addBankResponse = require('../responses/add_bank_200.json')
const errorResponse = require('../responses/error_response_400_401.json')

const Client = require('../../src/client')
Expand Down Expand Up @@ -98,4 +99,13 @@ describe('Account functions work properly', function () {
expect(await api.accounts.updateIdentity("uid", { identity_type: 'bvn', identity_value: '0123456789' })).to.eql(updateIdentityResponse)
})


it('test_can_add_bank', async function() {
nock(url)
.post('/accounts/uid/bank', { bank_code: '058', account_number: '0149541957' })
.reply(200, addBankResponse);

expect(await api.accounts.addBank("uid", { bank_code: '058', account_number: '0149541957' })).to.eql(addBankResponse)
})

})
1 change: 1 addition & 0 deletions tests/responses/add_bank_200.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}

0 comments on commit 31ee603

Please sign in to comment.