Code Monkey home page Code Monkey logo

rewards's Introduction


Rewards Calculator Service

About the project

Project includes source code for rewards app built by user Naresh

Problem statement

A retailer offers a rewards program to its customers, awarding points based on each recorded purchase. A customer receives 2 points for every dollar spent over $100 in each transaction, plus 1 point for every dollar spent between $50 and $100 in each transaction. (e.g., a $120 purchase = 2x$20 + 1x$50 = 90 points). ย  Given a record of every transaction during a three-month period, calculate the reward points earned for each customer per month and total.

  • Solve using Spring Boot
  • Create a RESTful endpoint
  • Make up a data set to best demonstrate your solution
  • Check solution into GitHub

How to build

git clone [email protected]:naresh8t7/rewards.git
mvn clean install
mvn spring-boot run

Assumptions

  • H2 in memory database with minimum DB fields required.
  • Pagination of results not in scope, rest end points provides all results.
  • Round amount in points calculation.

How to use

All end points

  • Fetch all customers or by id
http://localhost:8080/api/customers
http://localhost:8080/api/customers/1000
  • Fetch all transactions or by customer
http://localhost:8080/api/customers/transactions
http://localhost:8080/api/customers/1000/transactions
  • Fetch rewards for a customer
    • roll_up parameter: either by by_day or by_month.
    • window parameter: duration of aggregation
http://localhost:8080/api/customers/1000/rewards (defaults to by_month, with window as 3)
http://localhost:8080/api/customers/1000/rewards?rollUp=by_day&window=2
http://localhost:8080/api/customers/1000/rewards?roll_up=by_day&window=3
http://localhost:8080/api/customers/1000/rewards?roll_up=by_month&window=3
  • Swagger API Docs
http://localhost:8080/swagger-ui/index.html
  • Actuator/Prometheus endpoints
http://localhost:8080/actuator
http://localhost:8080/actuator/health
http://localhost:8080/actuator/prometheus
http://localhost:8080/swagger-ui/index.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.