TheM.restrictions 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.restrictions
Property | Description | Required | Schema |
---|---|---|---|
all | Gets (returns) an array with all the restrictions that may be applicable for the user. | Yes | { "title": "TheM.restrictions.all", "type": "array", "description": "Gets (returns) an array with all the restrictions that may be applicable for the user.", "$comment": "getter", "examples": [ [ { "isAllowed": true, "priority": 0, "restrictionName": "enable wires and ACH", "transactionCurrencies": [ "USD" ], "txnTypes": [ "USA", "USA_wire" ] } ] ], "nullable": false } |
length | Gets (returns) the length of the restrictions array. | Yes | { "title": "TheM.restrictions.length", "type": "number", "description": "Gets (returns) the length of the restrictions array.", "examples": [ 1 ], "default": 0, "nullable": false } |
isReady | Gets (returns) or sets true if TheM.restrictions is fully ready. When setting isReady true for the first time, a(n) 'TheM.restrictions ready' event is also triggered. | Yes | { "title": "TheM.restrictions.isReady", "type": "boolean", "description": "Gets (returns) or sets true if TheM.restrictions is fully ready. When setting isReady true for the first time, a(n) 'TheM.restrictions ready' event is also triggered.", "$comment": "getter setter", "examples": [ true, false ], "default": false, "nullable": false } |
Methods
Method Name | Parameter Descriptions | Description | Example |
---|---|---|---|
doSave | [] |
Saves restrictions 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.restrictions.doSave(); |
doLoad | [] |
Loads restrictions 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.restrictions.doLoad(); |
doUpdate | [ |
Causes framework to pull fresh restrictions 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 restrictions refreshed' event will occur. |
TheM.restrictions.doUpdate(true); |
restriction | [ |
Returns the restriction specified by the givenTxnType, if a matching restriction exists that is applicable to this user. The givenTxnType argument could represent a transactionTypeID, a txnType, or a restrictionId. | TheM.restrictions.restriction("USA"); |
filtered | [ |
This method accepts an object, givenParams , containing filter criteria (key:value pairs where key is a restriction property) and then returns an array of restrictions for this user with properties matching the given criteria. If no givenParams are included, then an unfiltered account list is returned. |
TheM.restrictions.filtered({); |
one | [ |
This method returns the first restriction found that applies to the givenTxnType, which represents a restriction.transactionTypeId or restriction.txnType property. | TheM.restrictions.one("USA"); |
currenciesAllowed | [ |
This method returns a list of the allowed currencies for the givenTxnType, which represents a transactionTypeId or txnType property. | TheM.restrictions.currenciesAllowed("USA"); |
accountsAsDestinationFor | [ |
This method returns an array of accounts which can be a destination account for the givenTxnType, which represents a transactionTypeId or txnType property. | TheM.restrictions.accountsAsDestinationFor("USA"); |
accountsAsSourceFor | [ |
This method returns an array of accounts which can be a source account for the givenTxnType, which represents a transactionTypeId or txnType property. | TheM.restrictions.accountsAsSourceFor("USA"); |
canAccountBeSource | [ |
This method returns true if the givenAccountTypeId (representing an account typeId property) is a valid account type for the givenTxnType, which represents a transactionTypeId or txnType property. | TheM.restrictions.canAccountBeSource("USA","Standard"); |
isAllowed | [ |
Takes an object containing transaction properties and returns a boolean value indicating if the transaction described by the given object is allowed. The given object contains the following properties: sourceAccount, destinationAccount, txnType and/or transactionTypeId, sourceAccountCurrency, destinationAccountCurrency, currency, and amount. Existing restrictions are applied one by one. When a restriction rule applies to the given object, it may result in a change to the isAllowed response. If conflicting restriction rules exist, the last rule applied will overwrite previously applied rules. Returns an object containing the following properties: isAllowed, lastRestrictionName, lastYesRestrictionName, maxAmount, minAmount, isMaxHit, and isMinHit. | TheM.restrictions.isAllowed({); |
isCurrencyAllowed | [ |
This method returns true if the given currency is allowed for the givenTxnType, which represents a transactionTypeId or txnType property. | TheM.restrictions.isCurrencyAllowed("USA","USD"); |
isTransactionAllowed | [ |
This method returns true if the givenTxnType is explicitly allowed, where givenTxnType represents a transactionTypeId or txnType property. | TheM.restrictions.isTransactionAllowed("USA"); |