diff --git a/layouts/default.vue b/layouts/default.vue index 3234e775..e358c6a0 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -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 = [ diff --git a/lib/wiresApi.ts b/lib/wiresApi.ts new file mode 100644 index 00000000..d22b36a4 --- /dev/null +++ b/lib/wiresApi.ts @@ -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, +} diff --git a/lib/wiresTestData.ts b/lib/wiresTestData.ts new file mode 100644 index 00000000..ce3ba3d0 --- /dev/null +++ b/lib/wiresTestData.ts @@ -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', + }, + }, + }, +] diff --git a/nuxt.config.js b/nuxt.config.js index cb200a6d..cc70ea79 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -44,6 +44,7 @@ export default { '~/plugins/walletsApi', '~/plugins/transfersApi', '~/plugins/addressesApi', + '~/plugins/wiresApi', ], /* ** Nuxt.js dev-modules diff --git a/pages/debug/index.vue b/pages/debug/index.vue index 1c67ce17..774032a2 100644 --- a/pages/debug/index.vue +++ b/pages/debug/index.vue @@ -153,54 +153,28 @@
-- Api endpoints to manage wallets. -
-
-
-
-
- Api endpoints to manage transfers. + Api endpoints to manage wire accounts.
-