/
HelixCharityCampaignAmount.ts
41 lines (37 loc) · 1.44 KB
/
HelixCharityCampaignAmount.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
import { DataObject, rawDataSymbol, rtfm } from '@twurple/common';
import { type HelixCharityCampaignAmountData } from '../../interfaces/endpoints/charity.external';
/**
* An object representing monetary amount and currency information for charity donations/goals.
*/
@rtfm('api', 'HelixCharityCampaignAmount')
export class HelixCharityCampaignAmount extends DataObject<HelixCharityCampaignAmountData> {
/**
* The monetary amount. The amount is specified in the currency’s minor unit.
* For example, the minor units for USD is cents, so if the amount is $5.50 USD, `value` is set to 550.
*/
get value(): number {
return this[rawDataSymbol].value;
}
/**
* The number of decimal places used by the currency. For example, USD uses two decimal places.
* Use this number to translate `value` from minor units to major units by using the formula:
*
* `value / 10^decimalPlaces`
*/
get decimalPlaces(): number {
return this[rawDataSymbol].decimal_places;
}
/**
* The localized monetary amount based on the value and the decimal places of the currency.
* For example, the minor units for USD is cents which uses two decimal places, so if `value` is 550, `localizedValue` is set to 5.50.
*/
get localizedValue(): number {
return this.value / 10 ** this.decimalPlaces;
}
/**
* The ISO-4217 three-letter currency code that identifies the type of currency in `value`.
*/
get currency(): string {
return this[rawDataSymbol].currency;
}
}