Create Opportunity Endpoint
Last updated
Last updated
The Create Opportunity endpoint (POST /test-interface/datasets/:testDatasetIdentifier/opportunities
) is part of the Test Interface (see the full detail in its ). It is called by to create test in your booking system.
This doc contains some guidance for how and what to implement for this endpoint.
The payload for this endpoint includes a field, test:testOpportunityCriteria
, which defines what type of Opportunity should be created. For example, if this is set to https://openactive.io/test-interface#TestOpportunityBookableFree
, then the created opportunity must be both and cost no money to book.
The full list of Opportunity Criteria, and what is expected for each, can be found in the — it's every row with Type = test:TestOpportunityCriteriaEnumeration
.
Your booking system only needs to implement, for this endpoint, those criteria which relate to that it implements. For example, if your booking system doesn't support free bookings, it does not need to support any of the free opportunity criteria.
Use to find out which criteria your booking system needs to implement. Follow these steps:
In your Test Suite instance, , run:
The logs from this script will point to two files that it generated, called:
opportunity-test-data.json
test-interface-actions.json
The opportunity-test-data.json
file will contain a list of Opportunity Criteria that you need to implement for the features that your booking system supports. To see an example of what this looks like, see the .
Use something like a switch
statement for this endpoint.
For example, if your booking system only needs to support the https://openactive.io/test-interface#TestOpportunityBookable
and https://openactive.io/test-interface#TestOpportunityBookableCancellable
criteria — and only supports , your route would look like (using Node.js with Express as an example):
There is an example of this in the code base for , which is an example implementation of a booking system in .NET. That example is .