@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.createBraleTransfer = createBraleTransfer;
exports.getBraleTransferById = getBraleTransferById;
exports.listBraleTransfers = listBraleTransfers;
// src/adapters/braleTransferAdapter.ts
const axios_1 = __importDefault(require("axios"));
const BASE_URL = "https://api.brale.xyz";
/**
* Create a new transfer for the given account.
*/
async function createBraleTransfer(accountId, transferData, token, idempotencyKey) {
const url = `${BASE_URL}/accounts/${accountId}/transfers`;
const headers = {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
"Idempotency-Key": idempotencyKey,
};
const response = await axios_1.default.post(url, transferData, { headers });
return response.data;
}
/**
* Retrieve a specific transfer by ID.
*/
async function getBraleTransferById(accountId, transferId, token) {
const url = `${BASE_URL}/accounts/${accountId}/transfers/${transferId}`;
const headers = { Authorization: `Bearer ${token}` };
const response = await axios_1.default.get(url, { headers });
return response.data;
}
/**
* Get all transfers associated with the specified account.
*/
async function listBraleTransfers(accountId, token) {
const url = `${BASE_URL}/accounts/${accountId}/transfers`;
const headers = { Authorization: `Bearer ${token}` };
const response = await axios_1.default.get(url, { headers });
return response.data;
}