Availabilities are core Stelace representation of the successives or concurrent states of an asset reachability to your business needs. Any availability impacts search results according to date, place and quantity search parameters.

Availability can be expressed in several ways, using dates and quantity:

  • binary: a car can’t be rented out if it’s ongoing reparations, setting its quantity to 0,
  • absolute stock quantity of items for sale,
  • or relative stock variation denoted by trailing + or - sign, like in "-1", due to an item order.

Setting an asset absolute stock quantity to 3 during two days in the future just take a single call:

  assetId: 'ast_2l7fQps1I3a1gJYz2I3a',
  startDate: '2019-09-13T00:00:00.000Z',
  endDate: '2019-09-15T00:00:00.000Z',
  quantity: 3

Concurrent availabilities with absolute quantity

Should several absolute availabilities overlap, the most recently created availability takes precedence during its full date range.

  assetId: 'ast_2l7fQps1I3a1gJYz2I3a',
  startDate: '2019-09-14T00:00:00.000Z',
  endDate: '2019-09-16T00:00:00.000Z',
  quantity: 0

Given the two previous API calls made in this, ast_2l7fQps1I3a1gJYz2I3a will be unavailable during one day (2019-09-14), surrounded by two single days when its stock quantity is 3.

Default availability

By default, asset availability depends on its quantity attribute when it is created, and on its asset type. You can make an asset unavailable by setting its quantity to 0, and use availability API calls to make it available depending on context. The reverse is also true.

Recurring availability

Depending on your Stelace plan, all these types of availability can also be defined in recurring patterns with cron format to enable powerful business logic.

Here is one API call making an asset unavailable for every Tuesday "0 0 * * 2" of 2019.

  assetId: 'ast_2l7fQps1I3a1gJYz2I3a',
  startDate: '2019-01-01T00:00:00.000Z',
  endDate: '2019-12-31T23:59:59.999Z',
  recurringPattern: '0 0 * * 2',
  recurringDuration: { d: 1 }

recurringDuration is set to one day here using { d: 1 } but you can also use hours h and minutes m.