Skip to content

Conditionals

Conditionals allow you to capture business rules in Order Book. You can target Orders based on several attributes or create time-based rules, and apply mutations to this order set enriching for your optimization.

Create a new conditional

Request

This endpoint allows you to create a new conditional. The application will assign a generated ID to the conditional, that can be used for retrieving, updating or deleting the conditional. This generated ID is returned in the Location header and (optional) response body.

Security
clientCredentials
Headers
PreferArray of strings

The RFC7240 Prefer header indicates that a particular server behavior is preferred by the client but is not required for successful completion of the request (see RFC 7240).

The following behavior is supported by this API:

  • return=<minimal|representation> is used to suggest the server to return using status code 204 without a resource in the response body (minimal) or using status codes 200 or 201 with the resource in the response body on success (representation).
Bodyapplication/jsonrequired
namestring

A short name for the Conditional

Example:"a name"
descriptionstring

A description for the conditional, helpful in determining the why or what.

Example:"a description"
conditionsobjectrequired

The rules that will determine whether this conditional is applicable to an order or not.

At least one conditional needs to be provided. The different top-level conditions are combined with AND logic, ie: they all need to match for an order to match this conditional.

effectsobjectrequired

At least one property has to be filled.

curl -i -X POST \
  https://developer.conundra.eu/_mock/apis/order-book/order-book-api/conditionals \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Type: application/json' \
  -H 'Prefer: string' \
  -d '{
    "name": "a name",
    "description": "a description",
    "conditions": {
      "locations": [
        "locationA"
      ],
      "temporals": [
        {
          "start_at": "2021-01-01T10:15:30Z",
          "end_at": "2021-01-01T10:15:30Z"
        }
      ],
      "categories": [
        {
          "entity_type": "LOCATION",
          "categories": [
            "my-category"
          ]
        }
      ],
      "clients": [
        "company-id"
      ]
    },
    "effects": {
      "stop_time": "PT5M",
      "time_windows": [
        {
          "open_time": "14:45",
          "open_day": "MONDAY",
          "close_time": "14:45",
          "close_day": "MONDAY",
          "cost": 0
        }
      ],
      "requirements": {
        "tags": [],
        "forbidden_tags": []
      }
    }
  }'

Responses

OK

Headers
Locationstring

contains the URI, including the ID of the created conditional ex /conditional/{id}

ETagstring

weak Etag (ex W/<etag_value>) which contains the (updated) version of the entity

Preference-Appliedstring

to indicate whether a preference has been applied. (ex Preference-Applied: return=representation)

Bodyapplication/json
idstringread-only

A generated identifier for a conditional. The identifier is returned in both the Location header and (optional) response body when creating the Conditional.

Example:"624ec196-4c5c-4fb4-bb43-9ffd8a6b8844"
namestring

A short name for the Conditional

Example:"a name"
descriptionstring

A description for the conditional, helpful in determining the why or what.

Example:"a description"
conditionsobjectrequired

The rules that will determine whether this conditional is applicable to an order or not.

At least one conditional needs to be provided. The different top-level conditions are combined with AND logic, ie: they all need to match for an order to match this conditional.

effectsobjectrequired

At least one property has to be filled.

Response
{ "id": "624ec196-4c5c-4fb4-bb43-9ffd8a6b8844", "name": "a name", "description": "a description", "conditions": { "locations": [], "temporals": [], "categories": [], "clients": [] }, "effects": { "stop_time": "PT5M", "time_windows": [], "requirements": {} } }