UNPKG

argy-usd

Version:

A simple and efficient library for fetching Argentine dollar exchange rates and performing currency conversions.

33 lines (30 loc) 1.37 kB
interface DollarQuote { name: string; buy: number; sell: number; source: string; timestamp: Date; } type BluelyticsDollarType = "oficial" | "blue" | "all"; type DolarApiDollarType = "blue" | "oficial" | "bolsa" | "cll" | "mayorista" | "cripto" | "tarjeta" | "all"; type Source = "bluelytics" | "dolarapi"; type GetDollarRatesOptions = { source?: Source; cache?: boolean; dollarType?: DolarApiDollarType | BluelyticsDollarType; }; declare function getDollarRates({ source, cache, dollarType }?: GetDollarRatesOptions): Promise<DollarQuote[]>; declare function convertUsdToArs(amount: number, rateType: string, type: "buy" | "sell", source?: Source): Promise<number>; declare function convertArsToUsd(amount: number, rateType: string, type: "buy" | "sell", source?: Source): Promise<number>; type PollDollarRatesOptions = GetDollarRatesOptions & { interval?: number; onUpdate?: (rates: DollarQuote[]) => void; onError?: (error: Error) => void; }; /** * Polls for dollar rates at specified intervals and triggers a callback when rates are updated * @param options Configuration options for polling * @returns A function that can be called to stop the polling */ declare function pollDollarRates(options?: PollDollarRatesOptions): () => void; export { convertArsToUsd, convertUsdToArs, getDollarRates, pollDollarRates };