UNPKG

kotanipay-sdk

Version:

Official Kotani Pay SDK for Node.js and Browser

50 lines 2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WalletService = void 0; const validation_util_1 = require("../../utils/validation.util"); class WalletService { constructor(httpClient) { this.httpClient = httpClient; } validateCreateWalletRequest(request) { const requiredFields = [ 'name', 'currency' ]; validation_util_1.ValidationUtil.validateRequiredFields(request, requiredFields); async function validateCurrency(currency) { const supportedCurrencies = [ 'USD', 'EUR', 'GBP', 'GHS', 'KES', 'ZAR', 'NGN', 'TZS', 'UGX', 'RWF', 'MWK', 'ZMW' ]; if (!supportedCurrencies.includes(currency)) { throw new Error(`Unsupported currency: ${currency}. Supported currencies are: ${supportedCurrencies.join(', ')}`); } } validateCurrency(request.currency) .catch(error => { throw new Error(`Currency validation failed: ${error.message}`); }); } async create(request) { this.validateCreateWalletRequest(request); const response = await this.httpClient.post('/api/v3/wallet/fiat', request); return response.data; } getIntegratorFiatWallets() { return this.httpClient.get('/api/v3/wallet/fiat').then(response => response.data); } getIntegratorFiatWalletById(walletId) { if (!walletId) { throw new Error('Wallet ID is required'); } return this.httpClient.get(`/api/v3/wallet/fiat/${walletId}`).then(response => response.data); } getIntegratorFiatWalletsByCurrency(currency) { if (!currency) { throw new Error('Currency is required'); } return this.httpClient.get(`/api/v3/wallet/fiat/currency/${currency}`).then(response => response.data); } } exports.WalletService = WalletService; //# sourceMappingURL=wallet.service.js.map