This is a web service built with Go that processes receipts and calculates points based on predefined rules.
Endpoint: /receipts/process
Method: POST
Payload: Receipt JSON
Response: JSON containing an ID for the receipt
This endpoint takes in a JSON receipt and returns a JSON object with an ID generated by the service. The ID can be used to retrieve the number of points awarded to the receipt.
Endpoint: /receipts/{id}/points
Method: GET
Response: JSON object containing the number of points awarded
This endpoint retrieves the number of points awarded to a receipt identified by the ID parameter.
To run the Receipt Processor, follow these steps:
-
Clone the repository: git clone https://github.com/your-username/receipt-processor.git
-
Navigate to the project directory: cd receipt-processor
-
Build the Docker image: docker build -t receipt-processor .
-
Run the Docker container: docker run -p 8080:8080 receipt-processor
By default, the application will run on port 8080. You can access the API endpoints using the following URLs:
- Process Receipts:
http://localhost:8080/receipts/process
- Get Points:
http://localhost:8080/receipts/{id}/points
To run the unit tests for the Receipt Processor, execute the following command: go test
The tests cover different scenarios, including valid inputs, invalid inputs, and edge cases.