-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
42 lines (31 loc) · 1.71 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
export type Options = {
/**
If no exchange rate is available for the given date, the closest available rate prior to the given date will be provided.
@default false
*/
readonly defaultToClosestPriorRate?: boolean;
/**
If no exchange rate is available for the given date, `null` will be returned.
@default false
*/
readonly defaultToNull?: boolean;
};
/**
Retrieves exchange rates from the Reserve Bank of Australia's exchange rate datasets. Base currency is always AUD.
@param currency - Currency to retrieve exchange rate for. Must be one of the following currency codes: USD, TWI, CNY, JPY, EUR, KRW, GBP, SGD, INR, THB, NZD, TWD, MYR, IDR, VND, AED, PGK, HKD, CAD, ZAR, CHF, PHP, SDR
@param exchangeRateDate - Date to retrieve exchange rate for.
@returns Returns a Promise that resolves to the `currency`'s exchange rate with AUD. If an exchange rate is not available on a given date, the closest exchange rate after the date will be provided. If there is a gap of greater than 7 days between the closest exchange rate and the date provided, `null` will be returned. See options to instead provide the closest rate before the date, or return `null` if no rate is available on the given date.
@example
```
import getExchangeRate from 'exchange-rates-rba';
await getExchangeRate('USD', new Date(2023, 1, 22));
//=> 0.6789
await getExchangeRate('JPY', new Date(2017, 1, 1), { defaultToClosestPriorRate: true });
//=> 128.12
await getExchangeRate('USD', new Date(2023, 0, 1);
// => 0.6929
await getExchangeRate('USD', new Date(2023, 0, 1), { defaultToNull: true });
// => null
```
*/
export default function getExchangeRate(currency: string, exchangeRateDate: Date, options?: Options): Promise<number>;