@transferwise/sensible
Version:
Sensible default values
159 lines (147 loc) • 4.43 kB
JavaScript
Object.defineProperty(exports, '__esModule', { value: true });
var DEFAULT_AMOUNTS = {
"default": 1000,
"CZK": 10000,
"HUF": 10000,
"IDR": 1000000,
"INR": 10000,
"JPY": 10000,
"MXN": 10000,
"PHP": 10000
};
var DEFAULT_ROUTES = {
"default": "GBPEUR",
"at": "EURUSD",
"au": "AUDPHP",
"be": "EURUSD",
"bg": "EURUSD",
"br": "BRLEUR",
"ch": "CHFEUR",
"ca": "CADUSD",
"cn": "USDCNY",
"cy": "EURUSD",
"cz": "CZKEUR",
"de": "EURUSD",
"dk": "DKKEUR",
"ee": "EURUSD",
"es": "EURUSD",
"es-US": "USDMXN",
"fi": "EURTHB",
"fj": "NZDFJD",
"fr": "EURUSD",
"gr": "EURGBP",
"hu": "HUFEUR",
"id": "IDREUR",
"ie": "EURINR",
"it": "EURUSD",
"lu": "EURINR",
"mt": "EURUSD",
"nl": "EURUSD",
"no": "NOKTHB",
"nz": "NZDAUD",
"ma": "USDMAD",
"my": "MYRIDR",
"ph": "USDPHP",
"pk": "USDPKR",
"pl": "PLNEUR",
"pt": "EURBRL",
"ro": "RONEUR",
"ru": "USDEUR",
"se": "SEKINR",
"sg": "SGDUSD",
"hk": "HKDUSD",
"si": "EURUSD",
"sk": "EURHUF",
"th": "EURTHB",
"ua": "EURUSD",
"us": "USDPHP",
"jp": "JPYUSD",
"hr": "EURUSD",
"il": "USDEUR",
"np": "USDNPR",
"ng": "USDEUR",
"ke": "USDKES",
"eg": "USDEUR",
"tr": "TRYEUR",
"in": "INRUSD",
"tz": "USDTZS",
"tw": "USDEUR",
"ug": "USDUGX",
"ae": "USDAED",
"ar": "USDEUR",
"mx": "MXNUSD",
"kr": "USDKRW",
"vn": "USDVND"
};
var DEFAULT_TARGETS = {
"default": ["EUR", "GBP", "INR", "USD"],
"AED": ["EUR", "GBP", "USD", "EGP"],
"AUD": ["EUR", "GBP", "INR", "AUD"],
"BGN": ["EUR", "GBP", "USD", "BGN"],
"BRL": ["EUR", "USD", "AUD", "BRL"],
"CHF": ["EUR", "GBP", "INR", "CHF"],
"CZK": ["EUR", "GBP", "INR", "CZK"],
"DKK": ["INR", "EUR", "GBP", "DKK"],
"EUR": ["GBP", "INR", "USD", "EUR"],
"FJD": ["EUR", "USD", "AUD", "GBP"],
"GBP": ["EUR", "INR", "USD", "GBP"],
"HUF": ["EUR", "GBP", "USD", "HUF"],
"IDR": ["EUR", "USD", "AUD", "GBP"],
"JPY": ["USD", "GBP", "EUR", "JPY"],
"MXN": ["USD", "EUR", "GBP", "MXN"],
"NOK": ["INR", "PHP", "GBP", "NOK"],
"NZD": ["GBP", "EUR", "AUD", "NZD"],
"PHP": ["AUD", "SGD", "MYR", "CNY"],
"PLN": ["GBP", "EUR", "INR", "PLN"],
"RON": ["EUR", "USD", "INR", "RON"],
"SEK": ["INR", "GBP", "USD", "SEK"],
"TRY": ["EUR", "GBP", "USD", "AED"],
"USD": ["EUR", "GBP", "INR", "USD"]
};
/**
* Gets the default amount for a specific currency.
* @param {string} currency - The currency code (e.g "JPY").
* @returns {number} The default amount for the given currency or the fallback default amount.
*/
function getAmountForCurrency(currency) {
return DEFAULT_AMOUNTS[currency] || DEFAULT_AMOUNTS["default"];
}
/**
* Gets the currency pair for a specific country.
* @param {string} country - The country code (e.g "us").
* @returns {[sourceCurrency: string, targetCurrency: string]} The default currency pair for the given country or the fallback default currency pair.
*/
function getCurrencyPairForCountry(country) {
var route = getRouteForCountry(country);
return [route.slice(0, 3), route.slice(3)];
}
/**
* Gets the route for a specific country.
* @param {string} country - The country code (e.g "us").
* @returns {string} The default route for the given country or the fallback default route.
*/
function getRouteForCountry(country) {
return DEFAULT_ROUTES[country.toLowerCase()] || DEFAULT_ROUTES["default"];
}
/**
* Gets the default target currency for a specific source currency.
* @param {string} currency - The source currency code (e.g "USD").
* @returns {string} The default target currency for the given source currency or the fallback default target currency.
*/
function getTargetForSourceCurrency(currency) {
return getTargetsForSourceCurrency(currency)[0];
}
/**
* Gets all default target currencies for a specific source currency.
* @param {string} currency - The source currency code (e.g "USD").
* @returns {string[]} An array of default target currencies for the given source currency or the fallback default target currencies.
*/
function getTargetsForSourceCurrency(currency) {
return DEFAULT_TARGETS[currency] || DEFAULT_TARGETS["default"];
}
exports.getAmountForCurrency = getAmountForCurrency;
exports.getCurrencyPairForCountry = getCurrencyPairForCountry;
exports.getRouteForCountry = getRouteForCountry;
exports.getTargetForSourceCurrency = getTargetForSourceCurrency;
exports.getTargetsForSourceCurrency = getTargetsForSourceCurrency;
;