Fetch Rewards Receipt Processor Challenge
$ git clone https://github.com/vchrombie/receipt-processor-challenge
$ cd receipt-processor-challenge
$ go run main.go
$ docker build -t vchrombie-receipt-processor .
$ docker run -p 8080:8080 vchrombie-receipt-processor
$ curl -X POST http://localhost:8080/receipts/process \
-H "Content-Type: application/json" \
-d @examples/receipt-1.json
{"id":"785a61d2-4da6-4e6d-9572-198086bff003"}
$ curl -X GET http://localhost:8080/receipts/2ee47ba9-ac23-4fdc-96be-d3d8ea968899/points
{"points":28}
You can find the unit tests in the main_test.go
file. You can
run them using the following command:
$ go test
You can find the tests in the tests
directory. You can run them
using the following commands:
$ docker run -p 8080:8080 --name vchrombie_receipt_processor vchrombie-receipt-processor
$ docker exec -it vchrombie_receipt_processor python -m unittest discover -s tests
- POST
/receipts/process
: Accepts a receipt JSON, calculates points, and returns a unique receipt ID. - GET
/receipts/{id}/points
: Retrieves the points for the receipt with the specified ID.
- Retailer Name
- One point for every alphanumeric character in the retailer name.
- Total Amount
- 50 points if the total is a round dollar amount with no cents.
- 25 points if the total is a multiple of
0.25
.
- Item Count
- 5 points for every two items on the receipt.
- Item Description Length
- If the trimmed length of the item description is a multiple of 3, multiply
the price by
0.2
and round up to the nearest integer. The result is the number of points earned.
- If the trimmed length of the item description is a multiple of 3, multiply
the price by
- Purchase Date and Time
- 6 points if the day in the purchase date is odd.
- 10 points if the time of purchase is after 2:00pm and before 4:00pm.