Restrictions

An explanation of the algorithms used to support Set restrictions and Clear restrictions.

What are restrictions?

Restrictions give Mews customers more control over their reservations, by preventing guests from making bookings that meet certain conditions. Restrictions can be applied to rates and space types, to control the way guests can book them. For example:

  • Use restrictions to implement a promotional rate which applies only to weekend bookings during July and August

  • Use restrictions to prevent guests from booking a room in a particular space type category (room type)

Restrictions in the API

To retrieve information about restrictions, use Get all restrictions. To add and remove restrictions, use Set restrictions and Clear restrictions respectively.

'How to' use case

API Operations

How to get service restrictions

How to add service restrictions

How to remove service restrictions

circle-exclamation

Restrictions are independent of user and API restrictions

Restrictions quota limit

Each service can have up to 150,000 active restrictions at any given time. This includes restrictions created both through the API and through the user interface of Mews Operations. In practice, the risk of hitting this quota is low because Set restrictions merges multiple similar restrictions into a single restriction. Its sibling operation Clear restrictions uses a splicing algorithm to work out how to divide up any existing restrictions to meet the specified time interval.

The following sections explain the algorithms used by these operations in more detail.

Merging algorithm

When using Set restrictions, if a specified restriction already exists with the same conditions, or if multiple specified restrictions match in all properties but differ in time interval and follow each other chronologically, a merging algorithm is applied to combine them. This reduces the overall number of restrictions and improves system performance. The merging algorithm is as follows:

  • If the exceptions of the new restriction match the old restriction:

    • If the new interval is longer than the old one, a new restriction is created joining the two intervals.

    • If the new interval is shorter, no changes are made.

  • If the exceptions of the new restriction do not match the old restriction:

    • If the new interval overlaps the old interval, the old restriction will be spliced before and after the new interval. Restrictions matching the old restriction are then added at the appropriate interval along with the new restriction.

    • If the new interval does not overlap the old interval, the new restriction is added as usual.

Matching conditions

The conditions specified in Set restrictions and Clear restrictions must be met exactly. For example:

A bookable service has two restrictions A and B. Restriction A applies to resource category C1 and rate R1. Restriction B applies to resource category C1 and to all rates. If Clear restrictions is called, specifying a restriction condition of resource category C1 but with no rate specified (this defaults to all rates), then only Restriction B is cleared, not Restriction A.

Time interval splicing

The time interval for a specified restriction does not need to correspond to an existing restriction in the system, instead the API uses a splicing algorithm to work out how to divide up any existing restrictions to meet the specified time interval. For example:

An existing restriction in the system A applies from 5th January to 25th January. As usual, time intervals are inclusive, meaning that the time interval includes both the 5th January and the 25th January. If the Clear restrictions operation is called, specifying a restriction time interval of 10th January to 20th January, i.e. within the original restriction A, then the time interval of restriction A is split into three separate intervals. The original restriction A is deleted, and in its place new restriction B is created for the period of time from 5th January to 9th January inclusive, and new restriction C is created for the period of time from 21st January to 25th January. Thus the period 10th January to 20th January has been cleared, but without affecting other time periods.

Scope of restrictions

Only restrictions created through the API are affected by these operations, not restrictions created by the user within Mews Operations. Similarly, if a user creates a restriction in Mews Operations, this will not affect restrictions created through the API. User restrictions and API restrictions are independent.

triangle-exclamation

Single third-party integration per enterprise

Last updated

Was this helpful?