Mock Account Properties

Each mock account can have multiple named properties which mimic real account properties.

Properties are defined on the environment level, i.e. two different environments can have different sets of account properties.

Every mock account has the same property names. If we add another mock account property to the environment, this property gets added to every mock account. However, it won’t have a value.

Because the property name must be a valid XML node name for XQuery scripts, only alpha-numeric symbols are permitted in the property names.

Example

Here is a mock account that has properties city, latitude, longitude, officeAddress, officeId, postalCode and province:

These names are used to pass the properties’ values to the scripts. For example, a XQuery script will get the account above as a variable $account with the following structure:

<account>
	<city>GATINEAU</city>
	<latitude>45.5856</latitude>
	<longitude>-75.4132</longitude>
	<officeAddress>563 RUE BELANGER</officeAddress>
	<officeId>102978</officeId>
	<postalCode>J8L1N0</postalCode>
	<province>QC</province>
</account>

And a Javascript will get it as variable account:

{
	"city":"GATINEAU",
	"latitude":"45.5856",
	"longitude":"-75.4132",
	"officeAddress":"563 RUE BELANGER",
	"officeId":"102978",
	"postalCode":"J8L1N0",
	"province":"QC"
}

Note that the values are always encoded as strings. If a numeric or boolean value is required, the using script should perform the necessary type conversion.

Empty Values are Nulls

If any property lacks a value, that property won’t be included into the encoded $account or account variable, i.e. it will be missing altogether and not just have an empty value.

Creating a New Property

To add a new property to environment accounts, navigate to Accounts, then to Account Properties and click Add Property:

Then populate the new property fields:

The only mandatory field is the property name (moneyGram in this case), which is the script-visible element or object property. It must be alpha-numeric. Note that it is case-sensitive.

A human-readable name is used in UI to better describe the property.

Aliases are alternative property names. This field is useful when you copy services from other environments and their scripts use different names for the same property - for example, businessAccount while your environment uses BAN. Then, you can just add businessAccount as an alias for BAN and both your own and imported scripts will work with the same value. You can have multiple aliases listed separated by a comma.

The description is a free-form field to remind you later why did you introduce this property in the first place.

Editing a Property

You can always edit a property from the same Account Properties tab.

However, beware that if you change the property name all the existing values for that property become invisible.

Deleting a Property

A property can be deleted using the Delete button.

Naturally, the property values then become unavailable to the scripts.

Multi-Value Properties

Sometimes, it is convenient to give one account property multiple values. For instance, a property named workHours may have a number of values, one per work day. Each value is placed into its own line in the property input field.

When provided to scripts, the multi-values are represented as an array.

For XML scripts, the property will be repeated multiple times, once per value:

<account>
  ...
  <workHours>0900-1700</workHours>
  <workHours>0900-1700</workHours>
  <workHours>0900-1700</workHours>
  <workHours>0900-1700</workHours>
  <workHours>0900-1400</workHours>
  ...
</account>

For Javascript, the value will be provided as a JSON array:

{
   ...
   "workHours": [ "0900-1700","0900-1700","0900-1700","0900-1700","0900-1400" ],
   ...
}

How to Enter Multi-Values

To enter a multi-value in the spreadsheet, separate the values with a pipe symbol:

To enter a multi-value in the UI, place each value on a separate line:

How to Enter Pipe into Value

What should you do if the property value itself has the pipe symbol?

For example, consider a property named “specialSymbols” which should contain &|><. How would you make sure that the value is not interpreted as an array of & and ><?

When using Excel to enter the value, escape each pipe symbol with another pipe symbol, i.e. repeat the pipe symbol twice: &||><:

When using UI, simply enter the value as &|><. In UI the values are separated by a new string and not the pipe symbol.