TheM.fxrates Reference
Constructor
The parent TheM class contains functionality enabling the initialization of any TheM subclass or submodule instance by simply calling TheM.doInit('subclassName'), where the input string is a case sensitive space-delimited string containing the names of all submodules that may be required in the current session. Most TheM subclasses also require the 'common' submodule. It is common to initialize the target submodule and any other submodule dependencies concurrently. The following example will initialize a new instance of the necessary submodules using a proxy constructor in TheM parent class.
Example
Properties
Property table for TheM.fxrates
Property | Description | Required | Schema |
---|---|---|---|
baseCurrency | Gets (returns) the base currency for foreign exchange rates. When doing conversions, if there is no direct route from one currency to another, then the baseCurrency is used as an intermediary step in conversion. | No | { "title": "TheM.fxrates.baseCurrency", "type": "string", "description": "Gets (returns) the base currency for foreign exchange rates. When doing conversions, if there is no direct route from one currency to another, then the baseCurrency is used as an intermediary step in conversion.", "$comment": "getter", "examples": [ "USD" ], "default": "USD" } |
length | Gets (returns) the length of the fxrates array. | Yes | { "title": "TheM.fxrates.length", "type": "number", "description": "Gets (returns) the length of the fxrates array.", "examples": [ 1 ], "default": 0, "nullable": false } |
isReady | Gets (returns) true if TheM.fxrates is fully ready. | Yes | { "title": "TheM.fxrates.isReady", "type": "boolean", "description": "Gets (returns) true if TheM.fxrates is fully ready.", "$comment": "getter", "examples": [ true, false ], "default": false, "nullable": false } |
Methods
Method Name | Parameter Descriptions | Description | Example |
---|---|---|---|
doSave | [] |
Saves fxrates data in local storage. Normally, there is no need to use this method as the framework knows automatically when to save and when to load the data to and from local storage. Returns true. | TheM.fxrates.doSave(); |
doLoad | [] |
Loads fxrates data from local storage and returns a boolean value to indicate success. Normally, there is no need to use this method as the framework knows automatically when to save and when to load the data to and from local storage. | TheM.fxrates.doLoad(); |
doUpdate | [ |
Causes framework to pull fresh fxrates data from the server. If the data is fresh enough, meaning an update has happened recently, the framework will ignore the suggestion. However, you can force the framework to update the data by sending true as an argument. On success, a(n) 'modelBank fxrates refreshed' event will occur. |
TheM.fxrates.doUpdate(true); |
isKnownCurrency | [ |
Gets (returns) true if the given currency code is present in the fxrates array. | TheM.fxrates.isKnownCurrency("USD"); |
doConvertCurrency | [ |
Gets (returns) the amount of givenCur1 needed to buy givenAmount of givenCur2. -1 is returned if an error occurs. 0 is returned if the fxrates array is empty. | TheM.fxrates.doConvertCurrency("USD",10,"EUR","connectFiBOIS"); |
doConvertCurrencyCross | [ |
Gets (returns) an object describing the best known conversion of givenAmount in curTrn from the source account to the destination account. For example, TheM.fxrates.doConvertCurrencyCross('EUR', 'connectFiBOIS', 10, 'JPY', 'GBP', 'tabapayBOIS') represents a request to determine the conversion if a user would like to transfer 10 JPY from a EUR account in the connectFiBOIS back-office to a GBP account in the tabapayBOIS back-office. -1 is returned if an error occurs. If successful, the result is an object containing the following properties: Debit - The amount of EUR to debit from the source account, Credit - the amount of GBP to credit to the destination account, Settlement - The USD equivalent of the transfer amount (in this example, how much USD is 10 JPY). | TheM.fxrates.doConvertCurrencyCross("USD","tabapayBOIS",10,"EUR","EUR","connectFiBOIS"); |