ropods-cashify
Version:
Modern, lightweight currency conversion library with real-time exchange rates, INR support, and free API integration. Production-ready TypeScript library for RoPods organization with zero dependencies and comprehensive testing.
87 lines • 2.85 kB
JavaScript
import convert from './convert.js';
// Note: Import will be added when rate-fetcher service is available
/**
* RoPodsCashify - Currency conversion library for RoPods organization
* Based on the original Cashify library with organizational enhancements
*/
export default class RoPodsCashify {
options;
/**
* Get library information
* @return {Object} Library metadata
*/
static getInfo() {
return {
name: '@ropods/cashify',
version: '1.0.0',
organization: 'RoPods',
description: 'Lightweight currency conversion library for RoPods organization',
};
}
/**
* @constructor
* @param {Object} [options] Conversion options.
*/
constructor(options) {
this.options = options;
}
/**
* Function, which converts currencies based on provided rates.
* Enhanced for RoPods organization requirements.
*
* @param {number | string} amount - Amount of money you want to convert.
* @param {Object} [options] - Conversion options.
* @return {number} Conversion result.
* * @example
* const rates = {
* GBP: 0.737,
* EUR: 0.851,
* USD: 1.00,
* INR: 86.42
* };
*
* const ropodsCashify = new RoPodsCashify({base: 'USD', rates});
*
* ropodsCashify.convert(10, {from: 'USD', to: 'INR'}); //=> 864.2
*/
convert(amount, options) {
return convert(amount, { ...this.options, ...options });
}
/**
* Convert with live rates (placeholder for future implementation)
* @param {number | string} amount - Amount to convert
* @param {Object} options - Conversion options
* @returns {Promise<number>} Conversion result
*/
async convertWithLiveRates(amount, options) {
console.log('[RoPods Cashify] Live rates feature will be available in future updates');
// For now, use static rates
return this.convert(amount, options);
}
/**
* Get information about supported free APIs
*/
static getSupportedFreeAPIs() {
return [
{
name: 'ExchangeRate-API',
url: 'https://api.exchangerate-api.com/v4/latest/USD',
description: 'Free tier: 1500 requests/month',
noApiKey: true,
},
{
name: 'Open Exchange Rates (Free)',
url: 'https://open.er-api.com/v6/latest/USD',
description: 'Completely free, no API key required',
noApiKey: true,
},
{
name: 'FloatRates',
url: 'https://www.floatrates.com/daily/usd.json',
description: 'Free JSON format rates',
noApiKey: true,
},
];
}
}
//# sourceMappingURL=cashify.js.map