@squadco/js
Version:
Simplify the integration process with Squad's comprehensive payment solutions using the Squad JavaScript SDK.
44 lines (43 loc) • 2.38 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const transfer_1 = __importDefault(require("./transfer"));
class SquadWalletBalance extends transfer_1.default {
constructor(publicKey, privateKey, environment) {
super(publicKey, privateKey, environment);
this.baseWalletBalanceUrl = "/merchant";
}
/**
* @desc This method allows you get your Squad Wallet Balance.
* Please be informed that the wallet balance is in KOBO.
* (Please note that you can't get wallet balance for Dollar transactions)
* @param {String} currencyId - The currency Id. This supports only NGN -> Naria
*/
getWalletBalance(currencyId = "NGN") {
var _a, _b, _c;
return __awaiter(this, void 0, void 0, function* () {
if (typeof currencyId !== "string")
throw new Error("Validation Error: currencyId must be a string");
try {
const squadResponse = yield this.Axios.get(`${this.baseWalletBalanceUrl}/balance?currency_id=${currencyId}`);
return squadResponse.data;
}
catch (error) {
console.warn((_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message);
return (_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.data;
}
});
}
}
exports.default = SquadWalletBalance;