@eczodex/issuers-sdk
Version:
SDK for interacting with Eczodex issuer APIs.
43 lines (42 loc) • 1.65 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createBraleAccount = createBraleAccount;
exports.getBraleAccountById = getBraleAccountById;
exports.listBraleAccounts = listBraleAccounts;
// src/adapters/braleAccountAdapter.ts
const axios_1 = __importDefault(require("axios"));
const BASE_URL = "https://api.brale.xyz";
async function createBraleAccount(accountData, token, idempotencyKey) {
const url = `${BASE_URL}/accounts`;
const headers = {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
"Idempotency-Key": idempotencyKey,
};
// TEMP: Add logs
console.log("Sending Brale accountData:", JSON.stringify(accountData));
console.log("Headers:", headers);
try {
const response = await axios_1.default.post(url, accountData, { headers });
return response.data;
}
catch (err) {
console.error("Brale API error:", err?.response?.data || err.message);
throw err;
}
}
async function getBraleAccountById(accountId, token) {
const url = `${BASE_URL}/accounts/${accountId}`;
const headers = { Authorization: `Bearer ${token}` };
const response = await axios_1.default.get(url, { headers });
return response.data;
}
async function listBraleAccounts(token) {
const url = `${BASE_URL}/accounts`;
const headers = { Authorization: `Bearer ${token}` };
const response = await axios_1.default.get(url, { headers });
return response.data;
}