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

Adding the create fiat account API #55

Merged
merged 3 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,14 @@ export default class DefaultLayoutsClass extends Vue {
title: 'GET /settlements/{id}',
to: '/debug/settlements/details',
},
{
title: 'GET /wires/{id}',
to: '/debug/wires/details',
},
{
title: 'POST /wires',
to: '/debug/wires/create',
},
]

walletsLinks = [
Expand Down
84 changes: 84 additions & 0 deletions lib/wiresApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { get } from 'lodash'
import axios from 'axios'

import { getAPIHostname } from './apiTarget'

export interface CreateWireAccountPayload {
idempotencyKey: string
beneficiaryName: string
bankName: string
accountNumber: string
bankIdentifier: string
billingDetails: {
name: string
city: string
country: string
line1: string
line2: string
district: string
postalCode: string
}
bankAddress: {
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)
}
)

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

/**
* Create Wire Account
* @param {*} payload (contains form data)
*/
function createWireAccount(payload: CreateWireAccountPayload) {
const url = '/v1/wires'
return instance.post(url, payload)
}

/**
* Get Wire Account By Id
* @param {String} accountId
*/
function getWireAccountById(accountId: string) {
const url = `/v1/wires/${accountId}`

return instance.get(url)
}

export default {
getInstance,
createWireAccount,
getWireAccountById,
}
28 changes: 28 additions & 0 deletions lib/wiresTestData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export const exampleWireAccounts = [
{
title: 'Test Data',
formData: {
beneficiaryName: 'Satoshi Nakamoto',
bankName: 'WELLS FARGO BANK',
accountNumber: '11111111111',
bankIdentifier: '121000248',
billingDetails: {
name: 'Satoshi Nakamoto',
city: 'Boston',
country: 'US',
line1: '100 Money Street',
line2: 'Suite 1',
district: 'MA',
postalCode: '01234',
},
bankAddress: {
city: 'SAN FRANCISCO',
country: 'US',
line1: 'line1',
line2: 'line2',
district: 'CA',
postalCode: '11111',
},
},
},
]
1 change: 1 addition & 0 deletions nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default {
'~/plugins/walletsApi',
'~/plugins/transfersApi',
'~/plugins/addressesApi',
'~/plugins/wiresApi',
],
/*
** Nuxt.js dev-modules
Expand Down
50 changes: 12 additions & 38 deletions pages/debug/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,54 +153,28 @@
</p>
</v-card>

<v-card class="body-1 px-6 py-8 mb-4" max-width="800" outlined>
<h2 class="title">Wallets endpoints</h2>
<span class="caption">Requires: api key</span>
<br /><br />
<p>
Api endpoints to manage wallets.
</p>
<p>
<v-chip small color="primary">GET</v-chip>
<a href="/debug/wallets/fetch">Get all wallets</a>
</p>
<p>
<v-chip small color="primary">GET</v-chip>

<a href="/debug/wallets/details">
Get wallet details by id
</a>
</p>
<p>
<v-chip small color="primary warning">POST</v-chip>
<a href="/debug/wallets/create">
Add wallet
</a>
</p>
</v-card>

<v-card class="body-1 px-6 py-8 mb-4" max-width="800" outlined>
<h2 class="title">Transfers endpoints</h2>
<v-card
v-if="!isMarketplace"
class="body-1 px-6 py-8 mb-4"
max-width="800"
outlined
>
<h2 class="title">Wires endpoints</h2>
<span class="caption">Requires: api key</span>
<br /><br />
<p>
Api endpoints to manage transfers.
Api endpoints to manage wire accounts.
</p>
<p>
<v-chip small color="primary">GET</v-chip>
<a href="/debug/transfers/fetch">Get all transfers</a>
</p>
<p>
<v-chip small color="primary">GET</v-chip>

<a href="/debug/transfers/details">
Get transfer details by id
<a href="/debug/wires/details">
Get wire account details by id
</a>
</p>
<p>
<v-chip small color="primary warning">POST</v-chip>
<a href="/debug/transfers/create">
Add transfer
<a href="/debug/wires/create">
Create wire account
</a>
</p>
</v-card>
Expand Down
1 change: 0 additions & 1 deletion pages/debug/wallets/transfers/create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ export default class CreateTransferClass extends Vue {

try {
const res = await this.$walletsApi.getMasterWallet()
console.log(res)
if (res.payments.masterWalletId) {
this.formData.source.id = res.payments.masterWalletId
}
Expand Down
Loading