This is a simple checkout system implementation based on a shop that sells Items
(Apples, Oranges, Bananas). Input is a Basket
which can contain several items and output is a Receipt
which lists all your items and the total price.
- Apples: buy one, get one free*
- Bananas: buy one, get one free*
- Oranges: 3 for the price of 2
* You can mix and match items and the cheapest one will be free.
The service will run on http://localhost:5000 (see application.conf). To start the service, type:
$ sbt run
POST
/checkout
withBasket
entity200
with aReceipt
400
if noBasket
is provided400
if theBasket
contained an unrecognised item500
if something unexpected happened
$ curl -X POST -H "Content-Type: application/json" -d '{"items":["Apple","Orange","Orange"]}' 'localhost:5000/checkout'
{"items":["Apple","Orange","Orange"],"total":1.1}
To run all the tests, simply type:
$ sbt test