@eczodex/issuers-sdk
Version:
SDK for interacting with Eczodex issuer APIs.
43 lines (42 loc) • 1.73 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.linkBraleBank = linkBraleBank;
exports.listBraleBankAccounts = listBraleBankAccounts;
exports.getBraleBankAccountById = getBraleBankAccountById;
// src/adapters/braleBankAdapter.ts
const axios_1 = __importDefault(require("axios"));
const BASE_URL = "https://api.brale.xyz";
/**
* Link an external bank account to a Brale account (ACH, wire).
*/
async function linkBraleBank(accountId, bankData, token, idempotencyKey) {
const url = `${BASE_URL}/accounts/${accountId}/financial-institutions/external`;
const headers = {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
"Idempotency-Key": idempotencyKey,
};
const response = await axios_1.default.post(url, bankData, { headers });
return response.data;
}
/**
* Fetch all financial institutions linked to a given account.
*/
async function listBraleBankAccounts(accountId, token) {
const url = `${BASE_URL}/accounts/${accountId}/financial-institutions`;
const headers = { Authorization: `Bearer ${token}` };
const response = await axios_1.default.get(url, { headers });
return response.data;
}
/**
* Fetch a specific financial institution by ID.
*/
async function getBraleBankAccountById(accountId, institutionId, token) {
const url = `${BASE_URL}/accounts/${accountId}/financial-institutions/${institutionId}`;
const headers = { Authorization: `Bearer ${token}` };
const response = await axios_1.default.get(url, { headers });
return response.data;
}