Currency Converter
The Currency Converter function allows you to convert monetary values between different currencies by providing exchange rates.
Function Overview
Parameter | Required | Description |
---|---|---|
functionName | Yes | Must be set to "CurrencyConverter" |
methodName | Yes | Must be set to "Convert" |
fromCurrencySymbol | Yes | Source currency symbol (e.g., "EUR", "USD") |
toCurrencySymbol | Yes | Target currency symbol (e.g., "EUR", "USD") |
date | No | The date for which to get the exchange rate (defaults to current date) |
Usage Example
// Convert from EUR to USD
// The app variable represents the brixxApi instance
let rate = app.businessBrixx({
functionName: "CurrencyConverter",
methodName: "Convert",
fromCurrencySymbol: "EUR",
toCurrencySymbol: "USD",
date: moment().subtract(7, 'days') // optional, defaults to current date if omitted
});
console.log(rate);
Return Value
The function returns the exchange rate between the specified currencies as a numeric value.
Implementation Details
The Currency Converter uses the Frankfurter API (https://api.frankfurter.app) to retrieve exchange rates. The API supports historical data by specifying a date parameter.
Error Handling
If the conversion fails, an error message will be returned. Ensure that:
- Currency symbols are valid
- The date is within the range supported by the API
- Your network connection allows access to the external API endpoint