-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the create fiat account API (#55)
* Adding the create fiat account API * Moving the files to wires folder and adding fetch details API * Updating the account to wires
- Loading branch information
1 parent
e55814e
commit 02f8e7a
Showing
9 changed files
with
489 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
}, | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.