Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose business account APIs #81

Merged
merged 29 commits into from
Oct 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b51324c
Add page to trigger creation of an incoming wire
jcantwell Sep 21, 2020
cb89cb6
Fix import path
jcantwell Sep 21, 2020
2ea6f91
Use correct lifecycle hook for adding mock endpoints
jcantwell Sep 21, 2020
1cce939
fix compiliation errors
jcantwell Sep 21, 2020
10780fe
Fix lint errors
jcantwell Sep 21, 2020
bddc7e0
add bank account endpoints for biz acct API
alandn-circle Sep 28, 2020
163e343
add transfer endpoints in bizacct api
alandn-circle Sep 28, 2020
fb157b4
refactor biz acct library, add balance endpoint to biz acct API
alandn-circle Sep 28, 2020
1555855
implement biz acct plugins
alandn-circle Sep 29, 2020
3b30968
add bankAccountsApi pages
alandn-circle Oct 2, 2020
aeeaee0
implement transfers pages
alandn-circle Oct 2, 2020
cf4760b
implement deposit addresses pages
alandn-circle Oct 2, 2020
ae212eb
implement balances and recipient address pages
alandn-circle Oct 2, 2020
04c18c0
fix syntax errors, implement payouts endpoint
alandn-circle Oct 5, 2020
81a7fbf
Merge branch 'master' into expose-apis
alandn-circle Oct 5, 2020
a4afd26
update branch
alandn-circle Oct 5, 2020
ef8ea0d
update master
alandn-circle Oct 5, 2020
000e807
remove merged file: incomingWire
alandn-circle Oct 5, 2020
0151388
implement wire instructions for biz acct api
alandn-circle Oct 6, 2020
ae15352
add business account index + biz acct endpoints to nav
alandn-circle Oct 7, 2020
7353ec9
fix eslint by removing nullIfEmpty
alandn-circle Oct 7, 2020
eb0dc19
make labels more consistent re: fields in payments API vs business ac…
alandn-circle Oct 8, 2020
878c3a5
refactor transfers/create, include prefilled IBAN in bank account tes…
alandn-circle Oct 9, 2020
d3dd729
Fix import path
MasterXen Oct 9, 2020
4847174
Copy changes
MasterXen Oct 9, 2020
128c121
Coalesce IBAN to null
MasterXen Oct 9, 2020
d7be19e
Remove empty lines (linter)
MasterXen Oct 9, 2020
1965ce3
Remove empty lines (linter)
MasterXen Oct 9, 2020
db9d2ae
Remove empty lines (linter)
MasterXen Oct 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,32 @@
</v-list-item-content>
</v-list-item>
</v-list-group>

<v-list-group>
<template v-slot:activator>
<v-list-item-title>Business Account APIs</v-list-item-title>
</template>

<v-list-item to="/debug/businessAccount" router exact>
<v-list-item-content>
<v-list-item-title class="list-items pl-2">
Overview
</v-list-item-title>
</v-list-item-content>
</v-list-item>

<v-list-item
v-for="(item, i) in businessAccountLinks"
:key="`businessAccountLinks-${i}`"
:to="item.to"
router
exact
>
<v-list-item-content>
<v-list-item-title class="list-items pl-2" v-text="item.title" />
</v-list-item-content>
</v-list-item>
</v-list-group>
</v-list>
</v-navigation-drawer>
<v-app-bar clipped-left fixed app dark color="primary" dense>
Expand Down Expand Up @@ -378,6 +404,65 @@ export default class DefaultLayoutsClass extends Vue {
},
]

businessAccountLinks = [
{
title: 'GET /businessAccount/banks/wires',
to: '/debug/businessAccount/bankAccounts/fetch',
},
{
title: 'GET /businessAccount/banks/wires/{id}',
to: '/debug/businessAccount/bankAccounts/details',
},
{
title: 'GET /businessAccount/banks/wires/{id}/instructions',
to: '/debug/businessAccount/bankAccounts/instructions',
},
{
title: 'POST /businessAccount/banks/wires',
to: '/debug/businessAccount/bankAccounts/create',
},
{
title: 'GET /businessAccount/transfers',
to: '/debug/businessAccount/transfers/fetch',
},
{
title: 'GET /businessAccount/transfers/{id}',
to: '/debug/businessAccount/transfers/details',
},
{
title: 'POST /businessAccount/transfers',
to: '/debug/businessAccount/transfers/create',
},
{
title: 'GET /businessAccount/wallets/addresses/deposit',
to: '/debug/businessAccount/addresses/deposit/fetch',
},
{
title: 'POST /businessAccount/wallets/addresses/deposit',
to: '/debug/businessAccount/addresses/deposit/create',
},
{
title: 'GET /businessAccount/wallets/addresses/recipient',
to: '/debug/businessAccount/addresses/recipient/fetch',
},
{
title: 'POST /businessAccount/wallets/addresses/recipient',
to: '/debug/businessAccount/addresses/recipient/create',
},
{
title: 'GET /businessAccount/payouts/{id}',
to: '/debug/businessAccount/payouts/details',
},
{
title: 'POST /businessAccount/payouts',
to: '/debug/businessAccount/payouts/create',
},
{
title: 'GET /businessAccount/balances',
to: '/debug/businessAccount/balances/fetch',
},
]

miniVariant = false
right = true
showRightDrawer = false
Expand Down
97 changes: 97 additions & 0 deletions lib/businessAccount/addressesApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import { get } from 'lodash'
import axios from 'axios'

import { getAPIHostname } from '../apiTarget'

export interface CreateDepositAddressPayload {
idempotencyKey: string
currency: string
chain: string
}

export interface CreateRecipientAddressPayload {
idempotencyKey: string
address: string
chain: string
description: string
}

const instance = axios.create({
baseURL: getAPIHostname(),
})

/**
* Global error handler:
* Intercepts all axios reponses and maps
* to errorHandler object
*/
instance.interceptors.response.use(
function (response) {
if (get(response, 'data.data')) {
return response.data.data
}
return response
},
function (error) {
let response = get(error, 'response')
if (!response) {
response = error.toJSON()
}
return Promise.reject(response)
}
)

/** Returns the axios instance */
function getInstance() {
return instance
}

/**
* Create deposit address
* @param {*} payload (contains form data and encrypted Address details)
*/
function createDepositAddress(payload: CreateDepositAddressPayload) {
const url = '/v1/businessAccount/wallets/addresses/deposit'
return instance.post(url, payload)
}

/**
* Get deposit addresses
* @param {String} walletId
* @param {String} from
* @param {String} to
* @param {String} pageBefore
* @param {String} pageAfter
* @param {String} pageSize
*/
function getDepositAddresses() {
const url = '/v1/businessAccount/wallets/addresses/deposit'

return instance.get(url)
}

/**
* Create deposit address
* @param {*} payload (contains form data and encrypted Address details)
*/
function createRecipientAddress(payload: CreateRecipientAddressPayload) {
const url = '/v1/businessAccount/wallets/addresses/recipient'
return instance.post(url, payload)
}

/**
* Get deposit addresses
*/
function getRecipientAddresses() {
const url = '/v1/businessAccount/wallets/addresses/recipient'

return instance.get(url)
}

export default {
getInstance,
createDepositAddress,
getDepositAddresses,
createRecipientAddress,
getRecipientAddresses,
}
48 changes: 48 additions & 0 deletions lib/businessAccount/balancesApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { get } from 'lodash'
import axios from 'axios'

import { getAPIHostname } from '../apiTarget'

const instance = axios.create({
baseURL: getAPIHostname(),
})

/**
* Global error handler:
* Intercepts all axios reponses and maps
* to errorHandler object
*/
instance.interceptors.response.use(
function (response) {
if (get(response, 'data.data')) {
return response.data.data
}
return response
},
function (error) {
let response = get(error, 'response')
if (!response) {
response = error.toJSON()
}
return Promise.reject(response)
}
)

/** Returns the axios instance */
function getInstance() {
return instance
}

/**
* Get balances
*/
function getBalances() {
const url = '/v1/businessAccount/balances'

return instance.get(url)
}

export default {
getInstance,
getBalances,
}
121 changes: 121 additions & 0 deletions lib/businessAccount/bankAccountsApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import { get } from 'lodash'
import axios from 'axios'

import { getAPIHostname } from '../apiTarget'

export interface CreateWireAccountPayload {
idempotencyKey: string
beneficiaryName: string
accountNumber?: string
routingNumber?: string
iban?: string
billingDetails: {
name: string
city: string
country: string
line1: string
line2: string
district: string
postalCode: string
}
bankAddress: {
bankName?: string
city?: string
country: string
line1?: string
line2?: string
district?: string
postalCode?: string
}
}

const instance = axios.create({
baseURL: getAPIHostname(),
})

/**
* Global error handler:
* Intercepts all axios reponses and maps
* to errorHandler object
*/
instance.interceptors.response.use(
function (response) {
if (get(response, 'data.data')) {
return response.data.data
}
return response
},
function (error) {
let response = get(error, 'response')
if (!response) {
response = error.toJSON()
}
return Promise.reject(response)
}
)

const nullIfEmpty = (prop: string | undefined) => {
if (prop === '') {
return undefined
}
return prop
}

/** Returns the axios instance */
function getInstance() {
return instance
}

/**
* Create wire bank account
* @param {*} payload (contains form data)
*/
function createBankAccount(payload: CreateWireAccountPayload) {
const url = '/v1/businessAccount/banks/wires'
payload.accountNumber = nullIfEmpty(payload.accountNumber)
payload.routingNumber = nullIfEmpty(payload.routingNumber)
payload.iban = nullIfEmpty(payload.iban)
payload.bankAddress.bankName = nullIfEmpty(payload.bankAddress.bankName)
payload.bankAddress.city = nullIfEmpty(payload.bankAddress.city)
payload.bankAddress.line1 = nullIfEmpty(payload.bankAddress.line1)
payload.bankAddress.line2 = nullIfEmpty(payload.bankAddress.line2)
payload.bankAddress.district = nullIfEmpty(payload.bankAddress.district)
payload.bankAddress.postalCode = nullIfEmpty(payload.bankAddress.postalCode)
return instance.post(url, payload)
}

/**
* Get wire bank accounts
*/
function getBankAccounts() {
const url = '/v1/businessAccount/banks/wires'
return instance.get(url)
}

/**
* Get wire bank account by id
* @param {String} bankId
*/
function getBankAccountById(bankId: string) {
const url = `/v1/businessAccount/banks/wires/${bankId}`

return instance.get(url)
}

/**
* Get wire bank account instructions
* @param {String} bankId
*/
function getBankAccountInstructions(bankId: string) {
const url = `/v1/businessAccount/banks/wires/${bankId}/instructions`

return instance.get(url)
}

export default {
getInstance,
createBankAccount,
getBankAccounts,
getBankAccountById,
getBankAccountInstructions,
}
Loading