kotanipay-sdk
Version:
Official Kotani Pay SDK for Node.js and Browser
46 lines • 1.83 kB
JavaScript
import { ValidationUtil } from '../../utils/validation.util';
export class WalletService {
constructor(httpClient) {
this.httpClient = httpClient;
}
validateCreateWalletRequest(request) {
const requiredFields = [
'name', 'currency'
];
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);
}
}
//# sourceMappingURL=wallet.service.js.map