A simulation of the most significant functions for Customer API customers. See below for running and usage instructions.
Run the simulator as a Docker container, locally or anywhere else. It is standalone and requires no external setup.
docker run -it -p 8080 troperty/customerapi-broker-simulator
This will start the simulator in interactive mode and forward port 8080 to port 8080 of the container. Thus, if you started it locally the simulator API will be available under
http://simulator-IP:8080/...
Both the retrieving operations, long polling and websocket (see below), depends on that your environment can handle their connection requirements. For instance the behavior of long polling will not be the desired if your network terminates the connection before rougly 60 seconds has passed. Similarly for websocket your network must understand and respect the heart beats of such a connection and not treat it as timed out.
As you will notice when reading below the protocols for the simulator are HTTP and WS. In reality, when using the production system, then obviously the protocols are HTTPS and WSS.
Below here we list the different functions and how to use them in the simulator. The simulator Swagger UI can also give you some hints. You reach the Swagger UI by pointing your browser to:
http://simulator-IP:8080/swagger-ui.html
Thus if you installed the simulator locally it should be:
http://localhost:8080/swagger-ui.html
To be able to get anything out you must put something in first! The endpoint for doing so is:
POST
http://simulator-IP:8080/customerapi/channel/id/{channelId}
This is not an endpoint that you as a customer will use in your integration, it's merely here because you need to be able to insert something into the system. You can insert any string but the idea is that you will insert example real time data files and verify that you can handle the format(s) from long polling and websocket respectively (see below).
There are only two valid channels in the simulator; Durable and NonDurable. If you type that in as channelId you will get a 202 ACCEPTED back. If you type in anything else you will get a 404 NOT FOUND accompanied by an error message.
POST
http://simulator-IP:8080/customerapi/authenticate/subscription
The credentials are passed as body payload and the Swagger UI suggested values are the correct values in the simulator:
{
"key": "mykey",
"secret": "mysecret"
}
Pass any other values to test the behavior when authentication fails.
When authentication was successful you'll get a Bearer token back in the response. In reality this token has a validity and is bound to your identity, so you MUST keep it and pass it back to the API when making other request. In the simulator we've made it a bit easier. You'll get it back from the authentication but it's always the same for everyone so you don't have to do the auth step every time if you don't want to. The token is:
Bearer dGVzdHVzZXI=
The durable flow is the "slower" part of the real time data flow. It often has a somewhat longer validity and is made up of such things as startlists, statistics, etc. The endpoint for long polling real time data is:
GET
http://simulator-IP:8080/customerapi/channels/listen
You need to pass your Bearer token or else you'll get 401 UNAUTHORIZED back. The long poll will last for roughly 60 seconds if no message is available.
The non-durable flow is the "faster" part of the real time data flow. Normally the validity of its messages is very short and is made up of such things as countdown to start, late scratchings, etc. The endpoint for connecting to websocket real time data is:
ws://simulator-IP:8080/customerapi/channels/connect
You need to pass your Bearer token or else you'll get 401 UNAUTHORIZED back. Also the Bearer tokens user id is associated with your topic on the server side. The topic to subscribe to from the client perspective will be:
/customerapi/channels/user/topic/publish
The endpoint for inserting horse info is:
POST
http://simulator-IP:8080/customerapi/{organisation}/horseresults
This is not an endpoint that you as a customer will use in your integration, it's merely here cause you need to be able to insert a horse into the system. You can insert any string but the idea is that you will insert example horse search result files and verify that you can handle the format(s) from the GET operation.
The endpoint for searching horse info is:
GET
http://simulator-IP:8080/customerapi/{organisation}/horseresults
You need to pass your Bearer token or else you'll get 401 UNAUTHORIZED back.
On top of this there are lots of query search parameters, the easiest way to see and understand them is to use the Swagger UI. The simulator validates the parameters in terms of which ones you pass in. Either you pass in all except uelnNumber or just uelnNumber. So having said that, the easiest way to get data out is to pass uelnNumber in. If you don't pass the proper combination of query parameters you'll get a 400 BAD REQUEST back.
Once you get it right you should get back the data you posted in the POST operation (see above).
The endpoint for inserting dress image description is:
POST
http://simulator-IP:8080/customerapi/{organisation}/{sourceOfData}/dresses
This endpoint is for the purpose to add dress image description so that it can be retrieved with the GET operation. It's only here cause you need to be able to insert a dress description into the system. The dress description you submit will be connected to dressID, you will later use to retrieve the data.
The endpoint for searching dress description info is:
GET
http://simulator-IP:8080/customerapi/{organisation}/{sourceOfData}/dresses/{dressId}
You need to pass your Bearer token or else you'll get 401 UNAUTHORIZED back.
Here you can send in the dress id and get the dress description you specified in the previous POST operation. If no dress is found, you will get an error message.
The endpoint for inserting dress image is:
POST
http://simulator-IP:8080/customerapi/{organisation}/{sourceOfData}/dresses/image
This endpoint you can insert dress image in these formats; gif, svg or eps. The service will link POST parameters as organisation, formats and dress id as key pairs to the image.
The endpoint for searching dress image info is:
GET
http://simulator-IP:8080/customerapi/{organisation}/{sourceOfData}/dresses/{dressId}/image
You need to pass your Bearer token or else you'll get 401 UNAUTHORIZED back.
Here you can get the dress image by set organisation, format and dress id. Check the swagger UI endpoint documentation for further information.
Content type
Image
Digest
Size
160.8 MB
Last updated
over 6 years ago
docker pull troperty/customerapi-broker-simulator