This app receive a receipt data and calculate its points.
- Install Docker
- Install Make:
sudo apt install makeorbrew install make
- Clone the project repository:
git clone git@github.com:Plus17/receipt-processor.git - Go to project dir:
cd receipt-processor - Execute:
make setupto install dependencies, setup the database, execute migrations, etc. - Execute:
make runto run the server at http://localhost:3000
make run
make ciruns all verifications, including tests
Make a post request to the endpoint: http://localhost:3000/receipts/process. This returns the receipt id
curl --request POST \
--url http://localhost:3000/receipts/process \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"retailer": "Target",
"purchaseDate": "2022-01-01",
"purchaseTime": "13:01",
"items": [
{
"shortDescription": "Mountain Dew 12PK",
"price": "6.49"
},
{
"shortDescription": "Emils Cheese Pizza",
"price": "12.25"
},
{
"shortDescription": "Knorr Creamy Chicken",
"price": "1.26"
},
{
"shortDescription": "Doritos Nacho Cheese",
"price": "3.35"
},
{
"shortDescription": " Klarbrunn 12-PK 12 FL OZ ",
"price": "12.00"
}
],
"total": "35.35"
}' | jq --indent 2
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 542 0 45 100 497 95 1054 --:--:-- --:--:-- --:--:-- 1160
{
"id": "8ebee9bc-0ba3-4a2f-9584-426829835d60"
}The get the receipt points with a GET request to the endpoint: http://localhost:3000/receipts/:id/points
curl --request GET \
--url http://localhost:3000/receipts/8ebee9bc-0ba3-4a2f-9584-426829835d60/points \
--header 'Accept: application/json' | jq --indent 2
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 13 0 13 0 0 106 0 --:--:-- --:--:-- --:--:-- 114
{
"points": 28
}
