Carpaccio is a price calculating API.
Clone this project and then run the following commands :
npm install
npm start
To run the tests :
npm test
Added a GET request at /id.
Test it using the following command :
curl -i -X GET localhost:3000/id
Added a POST request at /bill.
Test it using the following command :
curl -i -X POST -H 'Content-Type: application/json' -d '{"prices": [10,20], "quantities" : [1,2]}' localhost:3000/bill
Expanded the /bill POST request with a country's corresponding value-added tax.
Test it using the following command :
curl -i -X POST -H 'Content-Type: application/json' -d '{"prices": [10,20], "quantities" : [1,2], "country" : "FR"}' localhost:3000/bill
Within the file /src/tva, a list of all possible countries is referenced.
Adding a country's value-added tax entry should follow the following structure :
{"country" : <country>, "code" : <country_code>, "tva" : <country_values_added_tax_in_decimal_format> }
Expanded the /bill POST request with discounts.
Test it using the following command :
curl -i -X POST -H 'Content-Type: application/json' -d '{"prices": [10,20], "quantities" : [1,2], "country" : "FR", "discount" : "FLAT_DISCOUNT"}' localhost:3000/bill
A variety of different discounts is offered :
NO_DISCOUNT :
0% reduction.
PROGRESSIVE_DISCOUNT :
Total >= 50 000 EUR : 15 % reduction
Total >= 10 000 EUR : 10 % reduction
Total >= 7 000 EUR : 7 % reduction
Total >= 5 000 EUR : 5 % reduction
Total >= 1 000 EUR : 3 % reduction
FLAT_DISCOUNT :
30 % reduction
FIXED_DISCOUNT :
-10 euros if the total spent is over 100 euros but under 400 euros
-50 euros if the total spent is over 400 euros but under 1000 euros
-200 euros if the total spent is over 1000 euros
Expanded the /bill POST request with foreign exchange rates conversion.
Test it using the following command :
curl -i -X POST -H 'Content-Type: application/json' -d '{"prices": [10,20], "quantities" : [1,2], "country" : "FR", "discount" : "FLAT_DISCOUNT", "currency": "USD"}' localhost:3000/bill
An external API is used to determine the current rates. (External API documentation)
Note : prices are still provided in euros.
- JABALLAH Sarra
- SLAMA Amenallah