Skip to content

A web service that processes receipts and calculates points based on predefined rules. Built with Go, fully tested, and containerized for easy deployment.

Notifications You must be signed in to change notification settings

meghna-cse/receipt-processor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Receipt Processor

A simple receipt processor that validates receipts, calculates points, and provides an API to retrieve points for processed receipts.

Features

  • Validates receipts based on retailer name, purchase date, purchase time, and items.
  • Calculates points using the provided rules.
  • Exposes two endpoints:
    • POST /receipts/process: Processes a receipt and returns an ID.
    • GET /receipts/{id}/points: Returns points for a receipt ID.

API Specification

The full API specification is available in the api.yml file. See examples directory for reference payloads.

Endpoints

  1. Process Receipt

    • URL: /receipts/process
    • Method: POST
    • Request Body: JSON object representing a receipt.
    • Response: Returns a unique receipt ID.
  2. Get Points

    • URL: /receipts/{id}/points
    • Method: GET
    • Response: Returns the points awarded for the given receipt ID.

Running the application

Prerequisites

Run Locally

1. Clone the Repository

git clone https://github.com/meghna-cse/receipt-processor.git
cd receipt-processor

2. Running the application with Docker

  1. Build the Docker Image
docker build -t receipt_processor .
  1. Run the Docker Container
docker run -p 8080:8080 receipt_processor

The API endpoints can be accessed on http://localhost:8080 or the port you're running the container on.

Testing

Used the Postman collection tests/ReceiptProcessor.postman_collection.json to test API endpoints.

  • Test Scenarios : See tests/TEST_SCENARIOS.md for details on the scenarios tested, including positive, negative, and edge cases.
  • For a detailed description of the test collection and payloads, see the Postman Documentation for the tested scenarios.
  • Tests Report : ReceiptProcessor_TestsReport.json

About

A web service that processes receipts and calculates points based on predefined rules. Built with Go, fully tested, and containerized for easy deployment.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published