Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { System } from "../../util/system";
- import { Url } from "../../util/url";
- /**
- * Class for currency requests on frontend side
- *
- * Singleton - access with Rum_Currency.Instance()
- */
- export class Rum_Currency
- {
- /**
- * Singleton instance
- */
- private static instance: Rum_Currency;
- /**
- * Default constructor (private = non-instantiable object)
- */
- private constructor()
- {
- }
- /**
- * Instance function (get object) - singleton pattern
- * @returns Object instance
- */
- public static Instance()
- {
- if (!Rum_Currency.instance)
- {
- Rum_Currency.instance = new Rum_Currency();
- }
- return Rum_Currency.instance;
- }
- /**
- * Request server to obtain list of all currencies
- * @returns JSON - result (status code), error (in case of any), currency (list of currencies)
- */
- public GetCurrencies(): Promise<any>
- {
- return Url.FetchJson(System.BaseURL() + "api/v1/rum/currency/read.php", true, {}, System.progress);
- }
- /**
- * Request server to obtain single currency
- * @param currency ID of the currency to request
- * @returns JSON - result (status code), error (in case of any), currency (array containing single element with specific currency)
- */
- public GetCurrency(currency: number): Promise<any>
- {
- var json = { "id": currency };
- return Url.FetchJson(System.BaseURL() + "api/v1/rum/currency/read.php", true, json, System.progress);
- }
- /**
- * Request currency rates from specified currency to others (base currency - EUR, or all others if requested on EUR)
- * @param from_id ID of the currency for which we request rates
- * @returns JSON - result (status code), error (in case of any), currency_rate (array containing currency rates for specified currency)
- */
- public GetRates(from_id: number): Promise<any>
- {
- var json = { "from_id": from_id };
- return Url.FetchJson(System.BaseURL() + "api/v1/rum/currency_rate/read.php", true, json, System.progress);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement