Original question: https://github.com/fetch-rewards/receipt-processor-challenge. Brief summary: Used Python's flask libary to define the required endpoints. Used docker to containerize the requirements. Used postman for testing the input/output correctness.
To run this application, you need the following dependencies:
- Python 3.x
- Flask
- SQLite3 (standard Python library)
- math (standard Python library)
- logging (standard Python library)
- uuid (standard Python library)
Summary: The code has been written in Python and uses Python's flask library. The best way to run this locally is to install and set up these libraries locally.
1 .Install python from this link based on your machine
- Use python's package manager 'pip' to install flask such as
pip3 install flask
- Run the code with
python3 ReceiptProcessor.py
Summary: The provided DockerFile should do most of the heavy lifting in order to get this project up and running succesfully
-
Move to the directory with the required Dockerfile as provided in this Repository
-
If not installed already, install docker on your local machine from here
-
Run
docker build -t receipt-processor .
-
Run
docker run -p 10001:10001 receipt-processor
(Please note to update the port number if any other process is already using this port on your machine)
For testing, it is recommended to use something like Postman to call the POST and GET endpoints
Example input for receipts/process
:
{ "retailer": "M&M Corner Market", "purchaseDate": "2022-03-20", "purchaseTime": "14:33", "items": [ { "shortDescription": "Gatorade", "price": "2.25" },{ "shortDescription": "Gatorade", "price": "2.25" },{ "shortDescription": "Gatorade", "price": "2.25" },{ "shortDescription": "Gatorade", "price": "2.25" } ], "total": "9.00" }
Sample output for the above:
{ "id": "5b9fdd1c-223f-447a-a9d9-2d8f391a1038" }
Screenshot example in Postman: Input receipt: Input ID to get the points