This Docker container runs a simulation of the "computationally expensive" dynamic pricing model mentioned in the take-home assignment. Your proxy service will act as a client to this API to fetch the dynamic room rates.
To start the service, run the following Docker command. The API will be available on http://localhost:8080.
docker run -p 8080:8080 tripladev/rate-api
The API exposes a single endpoint for fetching room rates in batches.
POST/pricingContent-Type: application/json, token: <your_token>This API has a hard-coded authentication token and a strict rate limit to simulate the constraints of a real-world, costly service.
Token: Only requests with the following token in the token header will be accepted. 04aa6f42aa03f220c2ae9a276cd68c62
Rate Limit: The /pricing endpoint is limited to 1,000 requests per day. During development, you can reset this quota by restarting the Docker container.
The API accepts a JSON object containing an attributes array. Each object in the array represents a unique room for which you want to retrieve a price.
{
"attributes": [
{
"period": "Summer",
"hotel": "FloatingPointResort",
"room": "SingletonRoom"
},
{
"period": "Autumn",
"hotel": "FloatingPointResort",
"room": "SingletonRoom"
},
{
"period": "Winter",
"hotel": "FloatingPointResort",
"room": "SingletonRoom"
},
{
"period": "Spring",
"hotel": "FloatingPointResort",
"room": "SingletonRoom"
}
]
}
The API returns a JSON object containing a rates array, with each object corresponding to a room in the request, now including its calculated rate.
{
"rates": [
{
"period": "Summer",
"hotel": "FloatingPointResort",
"room": "SingletonRoom",
"rate": "12000"
},
{
"period": "Autumn",
"hotel": "FloatingPointResort",
"room": "SingletonRoom",
"rate": "28000"
},
{
"period": "Winter",
"hotel": "FloatingPointResort",
"room": "SingletonRoom",
"rate": "46000"
},
{
"period": "Spring",
"hotel": "FloatingPointResort",
"room": "SingletonRoom",
"rate": "73000"
}
]
}
period: Summer, Autumn, Winter, Springhotel: FloatingPointResort, GitawayHotel, RecursionRetreatroom: SingletonRoom, BooleanTwin, RestfulKingHere is an example curl command to test the running API.
curl -X POST http://localhost:8080/pricing \
-H 'token: 04aa6f42aa03f220c2ae9a276cd68c62' \
-H 'Content-Type: application/json' \
-d '{
"attributes": [
{ "period": "Summer", "hotel": "FloatingPointResort", "room": "SingletonRoom" },
{ "period": "Autumn", "hotel": "GitawayHotel", "room": "RestfulKing" }
]
}'
Content type
Image
Digest
sha256:4539d578b…
Size
22.1 MB
Last updated
10 months ago
docker pull tripladev/rate-api