Policy Master
Each property has a default Policy, which is called Policy Master. It exists since the
moment of the property creation, and it should be configured to accomplish
property’s needs.
It is identify by flag ‘master’: as explained in Policy characteristics,
for Policy Master, master=1 (there will be just one policy with this value set to 1). Also, its name is, literally, ‘Policy Master’ (and it can’t be changed).
Handling Policies
Policy characteristics
Each policy will be defined for this fields:
Field |
Meaning |
pid |
The Id of the policy |
name |
The main name of the policy. For Policy Master,
the name is always ‘Policy Master’ |
master |
1 for the Policy Master, 0 for the others |
pshow |
How policy is shown:
0: Clauses too
1: Only Rule (deprecated, use 0 for new)
2: Only clauses (deprecated, use 0 for new)
|
ptype |
Type of penalty:
|
value |
Applying value for the penalty (only if ‘ptype’ is 2 or 3)
A value between 1 and 99 if ptype is 2 or 3, 0 otherwise |
days |
Minimum advance for avoiding the penalty (number of days) |
descr_XX |
Clauses of the Policy, where XX is each language code |
Fetching existing Policies
To retrieve the Policies of one property, the function is:
-
fetch_policies(token, lcode[, ancillary= 0])
It returns a list of Policies, each one being represented by a Key->Value structure. Each structure having the keys explained in Policy characteristics. The clauses (descr_XX),
will be returned just if ‘ancillary=1’.
Here is an example of a fetch Policies request, followed by the response:
+ show/hide code
<methodCall>
<methodName>fetch_policies</methodName>
<params>
<param>
<value><string>1234567890.1234</string></value>
</param>
<param>
<value><int>1234567890</int></value>
</param>
<param>
<value><int>1</int></value>
</param>
</params>
</methodCall>
<---------------response--------------->
<methodResponse>
<params>
<param>
<value><int>0</int></value>
</param>
<param>
<value>
<array><data>
<value><struct>
<member>
<name>pid</name>
<value><int>123</int></value>
</member>
<member>
<name>name</name>
<value><string>Policy Master</string></value>
</member>
<member>
<name>master</name>
<value><int>1</int></value>
</member>
<member>
<name>pshow</name>
<value><int>0</int></value>
</member>
<member>
<name>ptype</name>
<value><int>4</int></value>
</member>
<member>
<name>value</name>
<value><double>0</double></value>
</member>
<member>
<name>days</name>
<value><int>2</int></value>
</member>
<member>
<name>descr_en</name>
<value><string>English description of the clauses</string></value>
</member>
</struct></value>
<value><struct>
<member>
<name>id</name>
<value><int>124</int></value>
</member>
<member>
<name>name</name>
<value><string>Weekend Policy</string></value>
</member>
<member>
<name>master</name>
<value><int>0</int></value>
</member>
<member>
<name>pshow</name>
<value><int>0</int></value>
</member>
<member>
<name>ptype</name>
<value><int>3</int></value>
</member>
<member>
<name>value</name>
<value><double>15</double></value>
</member>
<member>
<name>days</name>
<value><int>5</int></value>
</member>
<member>
<name>descr_en</name>
<value><string>English description of the clauses</string></value>
</member>
</struct></value>
</data></array>
</value>
</param>
</params>
</methodResponse>
Adding a new Policy
The function for adding a new Policy is:
-
new_policy(token, lcode, name, pshow, ptype, value, days[, descrs= {}])
The parameters are explained in Policy characteristics. ‘descrs’ parameter is a
KV structure used to specify clauses in different languages. The function returns,
in case of success, the assigned Id for the new policy.
Let’s see it with an example of request and response:
+ show/hide code
<methodCall>
<methodName>new_policy</methodName>
<params>
<param>
<value><string>1234567890.1234</string></value>
</param>
<param>
<value><int>1234567890</int></value>
</param>
<param>
<value><string>Summer Policy</string></value>
</param>
<param>
<value><int>0</int></value>
</param>
<param>
<value><int>2</int></value>
</param>
<param>
<value><double>10.5</double></value>
</param>
<param>
<value><int>3</int></value>
</param>
<param>
<value><struct>
<member>
<name>descr_en</name>
<value><string>English clauses for the Summer Policy</string></value>
</member>
</struct></value>
</param>
</params>
</methodCall>
<---------------response--------------->
<methodResponse>
<params>
<param>
<value><int>0</int></value>
</param>
<param>
<value><int>125</int></value>
</param>
</params>
</methodResponse>
Modifying an existing Policy
To modify an existing Policy, the function is:
-
mod_policy(token, lcode, pid[, name, pshow, ptype, value, days, descrs= {}])
The parameters are explained in Policy characteristics. ‘descrs’ parameter is a
KV structure used to specify clauses in different languages. If you want to delete a
clause for an specific language, you should specify an empty string for this
own language. The function returns, in case of success, 0; the error code otherwise.
Let’s see it with an example of request and response:
+ show/hide code
<methodCall>
<methodName>mod_policy</methodName>
<params>
<param>
<value><string>1234567890.1234</string></value>
</param>
<param>
<value><int>1234567890</int></value>
</param>
<param>
<value><int>125</int></value>
</param>
<param>
<value><string>Summer Policy Improved</string></value>
</param>
<param>
<value><int>0</int></value>
</param>
<param>
<value><int>2</int></value>
</param>
<param>
<value><double>10.5</double></value>
</param>
<param>
<value><int>4</int></value>
</param>
<param>
<value><struct>
<member>
<name>descr_en</name>
<value><string></string></value>
</member>
<member>
<name>descr_es</name>
<value><string>Cláusulas para la pólitica</string></value>
</member>
</struct></value>
</param>
</params>
</methodCall>
<---------------response--------------->
<methodResponse>
<params>
<param>
<value><int>0</int></value>
</param>
<param>
<value><string>Ok</string></value>
</param>
</params>
</methodResponse>
Deleting an existing Policy
To delete an existing Policy, the function is:
-
del_policy(token, lcode, pid)
Where ‘pid’ is the Policy id, as explained in Policy characteristics. It returns,
in case of success, 0; the error code otherwise.
Note
Policy Master cannot be deleted.
Let’s see an example of request and response:
+ show/hide code
<methodCall>
<methodName>del_policy</methodName>
<params>
<param>
<value><string>1234567890.1234</string></value>
</param>
<param>
<value><int>1234567890</int></value>
</param>
<param>
<value><int>125</int></value>
</param>
</params>
</methodCall>
<---------------response--------------->
<methodResponse>
<params>
<param>
<value><int>0</int></value>
</param>
<param>
<value><string>Ok</string></value>
</param>
</params>
</methodResponse>
Handling Policies Calendar
Fetching Policies Calendar
To fetch the Policies Calendar, the function is:
-
fetch_policy_calendar(token, lcode, dfrom, dto)
Where ‘dfrom’ and ‘dto’ determine the period of time. It’ll return a list of values,
each one representing a day, with a K→V structure like:
{'day': '01/05/2016', 'pid': 11}
If some of the period’ days is not returned, it means that any Policy was set for
this day, so, Policy Master will be applied for it.
Note
Here applies the generic date restrictions of Wired: past dates are not allowed, and the maximum period you can fetch is for two years.
There it is an example of request and response:
+ show/hide code
<methodCall>
<methodName>fetch_policy_calendar</methodName>
<params>
<param>
<value><string>1234567890.1234</string></value>
</param>
<param>
<value><int>1234567890</int></value>
</param>
<param>
<value><string>01/05/2016</string></value>
</param>
<param>
<value><string>07/05/2016</string></value>
</param>
</params>
</methodCall>
<---------------response--------------->
<methodResponse>
<params>
<param>
<value><int>0</int></value>
</param>
<param>
<value>
<array><data>
<value>
<struct>
<member>
<name>pid</name>
<value><int>123</int></value>
</member>
<member>
<name>day</name>
<value><string>01/05/2016</string></value>
</member>
</struct>
</value>
<value>
<struct>
<member>
<name>pid</name>
<value><int>123</int></value>
</member>
<member>
<name>day</name>
<value><string>02/05/2016</string></value>
</member>
</struct>
</value>
<value>
<struct>
<member>
<name>pid</name>
<value><int>123</int></value>
</member>
<member>
<name>day</name>
<value><string>03/05/2016</string></value>
</member>
</struct>
</value>
<value>
<struct>
<member>
<name>pid</name>
<value><int>123</int></value>
</member>
<member>
<name>day</name>
<value><string>04/05/2016</string></value>
</member>
</struct>
</value>
<value>
<struct>
<member>
<name>pid</name>
<value><int>123</int></value>
</member>
<member>
<name>day</name>
<value><string>05/05/2016</string></value>
</member>
</struct>
</value>
<value>
<struct>
<member>
<name>pid</name>
<value><int>124</int></value>
</member>
<member>
<name>day</name>
<value><string>06/05/2016</string></value>
</member>
</struct>
</value>
<value>
<struct>
<member>
<name>pid</name>
<value><int>124</int></value>
</member>
<member>
<name>day</name>
<value><string>07/05/2016</string></value>
</member>
</struct>
</value>
</data></array>
</value>
</param>
</params>
</methodResponse>
Modifying Policies Calendar
To configure the Calendar, the function is:
-
set_policy_calendar(token, lcode, pid, dfrom, dto)
Where ‘dfrom’ and ‘dto’ determine the period of time.
Note
Here applies the generic date restrictions of Wired: past dates are not allowed, and the maximum period you can fetch is for two years.
Here we have an example:
+ show/hide code
<methodCall>
<methodName>set_policy_calendar</methodName>
<params>
<param>
<value><string>1234567890.1234</string></value>
</param>
<param>
<value><int>1234567890</int></value>
</param>
<param>
<value><int>1</int></value>
</param>
<param>
<value><string>08/05/2016</string></value>
</param>
<param>
<value><string>12/05/2016</string></value>
</param>
</params>
</methodCall>
<---------------response--------------->
<methodResponse>
<params>
<param>
<value><int>0</int></value>
</param>
<param>
<value><string>Ok</string></value>
</param>
</params>
</methodResponse>