afrimomo-sdk
Version:
A unified SDK for African payment providers
82 lines • 4.94 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.OneKhusaDisbursements = void 0;
const logger_1 = require("../../../utils/logger");
const serviceWrapper_1 = require("../../../utils/serviceWrapper");
const queryBuilder_1 = require("../../../utils/queryBuilder");
class OneKhusaDisbursements {
network;
constructor(network) {
this.network = network;
}
wrap(operation, context) {
return (0, serviceWrapper_1.wrapServiceCall)(operation, this.network.handleApiError.bind(this.network), context);
}
async addSingle(request) {
logger_1.logger.info("OneKhusa: Adding single disbursement", {
amount: request.amount,
currency: request.currency,
recipient: request.recipient.name,
});
return this.wrap(() => this.network.post("/disbursements/single", request, "adding single disbursement"), "adding single disbursement");
}
async approveSingle(disbursementId, request) {
logger_1.logger.info("OneKhusa: Approving single disbursement", { disbursementId });
return this.wrap(() => this.network.patch(`/disbursements/single/${disbursementId}/approve`, request || {}, "approving single disbursement"), "approving single disbursement");
}
async reviewSingle(disbursementId, request) {
logger_1.logger.info("OneKhusa: Reviewing single disbursement", { disbursementId });
return this.wrap(() => this.network.patch(`/disbursements/single/${disbursementId}/review`, request || {}, "reviewing single disbursement"), "reviewing single disbursement");
}
async rejectSingle(disbursementId, request) {
logger_1.logger.info("OneKhusa: Rejecting single disbursement", { disbursementId });
return this.wrap(() => this.network.patch(`/disbursements/single/${disbursementId}/reject`, request, "rejecting single disbursement"), "rejecting single disbursement");
}
async getSingle(disbursementId) {
logger_1.logger.info("OneKhusa: Getting single disbursement", { disbursementId });
return this.wrap(() => this.network.get(`/disbursements/single/${disbursementId}`, "getting single disbursement"), "getting single disbursement");
}
async addBatch(request) {
logger_1.logger.info("OneKhusa: Adding batch disbursement", {
name: request.name,
itemCount: request.items.length,
});
return this.wrap(() => this.network.post("/disbursements/batches", request, "adding batch disbursement"), "adding batch disbursement");
}
async approveBatch(batchId, request) {
logger_1.logger.info("OneKhusa: Approving batch", { batchId });
return this.wrap(() => this.network.patch(`/disbursements/batches/${batchId}/approve`, request || {}, "approving batch"), "approving batch");
}
async reviewBatch(batchId, request) {
logger_1.logger.info("OneKhusa: Reviewing batch", { batchId });
return this.wrap(() => this.network.patch(`/disbursements/batches/${batchId}/review`, request || {}, "reviewing batch"), "reviewing batch");
}
async rejectBatch(batchId, request) {
logger_1.logger.info("OneKhusa: Rejecting batch", { batchId });
return this.wrap(() => this.network.patch(`/disbursements/batches/${batchId}/reject`, request, "rejecting batch"), "rejecting batch");
}
async cancelBatch(batchId, request) {
logger_1.logger.info("OneKhusa: Cancelling batch", { batchId });
return this.wrap(() => this.network.patch(`/disbursements/batches/${batchId}/cancel`, request || {}, "cancelling batch"), "cancelling batch");
}
async transferBatchFunds(batchId, request) {
logger_1.logger.info("OneKhusa: Transferring batch funds", { batchId });
return this.wrap(() => this.network.post(`/disbursements/batches/${batchId}/transfer`, request || {}, "transferring batch funds"), "transferring batch funds");
}
async getBatches(params) {
logger_1.logger.info("OneKhusa: Getting batches");
const endpoint = (0, queryBuilder_1.appendQueryString)("/disbursements/batches", params);
return this.wrap(() => this.network.get(endpoint, "getting batches"), "getting batches");
}
async getBatch(batchId) {
logger_1.logger.info("OneKhusa: Getting batch", { batchId });
return this.wrap(() => this.network.get(`/disbursements/batches/${batchId}`, "getting batch"), "getting batch");
}
async getBatchTransactions(batchId, params) {
logger_1.logger.info("OneKhusa: Getting batch transactions", { batchId });
const endpoint = (0, queryBuilder_1.appendQueryString)(`/disbursements/batches/${batchId}/transactions`, params);
return this.wrap(() => this.network.get(endpoint, "getting batch transactions"), "getting batch transactions");
}
}
exports.OneKhusaDisbursements = OneKhusaDisbursements;
//# sourceMappingURL=index.js.map