Code Monkey home page Code Monkey logo

gophermartbonus's Introduction

Bonus counting service «Gophermart»


Main

Service is HTTP API with next business requirements:

  • registration and user authorization;
  • accepts of order numbers from authorized users;
  • accounting and maintaining of order numbers list from registered user;
  • accounting of a registered user;
  • verification of order numbers using the loyalty counting system;
  • accrual reward to the user's loyalty account for each suitable order number.

Bonus counting service «Gophermart» Service is HTTP API with next business requirements:

  • registration and user authorization;

  • accepts of order numbers from authorized users;

  • accounting and maintaining of order numbers list from registered user;

  • accounting of a registered user;

  • verification of order numbers using the loyalty counting system;

  • accrual reward to the user's loyalty account for each suitable order number.

API

Sing up

POST /api/user/register

POST /api/user/register HTTP/1.1
Content-Type: application/json

{
"login": "<login>",
"password": "<password>"
}
  • 200 — User registered;

  • 400 — Wrong request format;

  • 409 — Login already used;

  • 500 — Internal error.


Login

POST /api/user/login

POST /api/user/login HTTP/1.1
Content-Type: application/json

{
"login": "<login>",
"password": "<password>"
}
  • 200 — User authorized successfully;

  • 400 — Wrong request format;

  • 401 — Wrong login or password;

  • 500 — Internal error.


User upload new order number

POST /api/user/orders

POST /api/user/login HTTP/1.1
Content-Type: application/json

12345678903
  • 200 — Order number already uploaded before;

  • 202 — New order namber accepted;

  • 400 — Wrong request format;

  • 401 — Unathorized;

  • 409 — Order number already uploaded by other user;

  • 422 — Wrong format of order number;

  • 500 — Internal error.


User gets list of orders with status and balance

GET /api/user/orders

GET /api/user/orders HTTP/1.1
Content-Length: 0
  • 200 — List of orders in JSON

200 OK HTTP/1.1 Content-Type: application/json [ { "number": "9278923470", "status": "PROCESSED", "accrual": 500, "uploaded_at": "2020-12-10T15:15:45+03:00" }, { "number": "12345678903", "status": "PROCESSING", "uploaded_at": "2020-12-10T15:12:01+03:00" }, { "number": "346436439", "status": "INVALID", "uploaded_at": "2020-12-09T16:09:53+03:00" } ]

  • 204 — No orders;

  • 401 — Unathorized;

  • 500 — Internal error.


User gets current balance

GET /api/user/balance

GET /api/user/balance HTTP/1.1
Content-Length: 0
  • 200 — Balance

       200 OK HTTP/1.1
       Content-Type: application/json
    
      {
      	"current": 500.5,
      	"withdrawn": 42
      }
    
  • 401 — Unathorized;

  • 500 — Internal error.


User request to pay new order using bonus account

POST /api/user/balance/withdraw

 POST /api/user/balance/withdraw HTTP/1.1
 Content-Type: application/json

 {
	"order": "2377225624",
    "sum": 751
 }
  • 200 — Success;

  • 401 — Unathorized;

  • 402 - Not enough money;

  • 422 - Wrong order number;

  • 500 — Internal error.


User gets list of withdrawals approved

GET /api/user/withdrawals

 GET /api/user/withdrawals HTTP/1.1
 Content-Length: 0
  • 200 — Success

200 OK HTTP/1.1 Content-Type: application/json

[ { "order": "2377225624", "sum": 500, "processed_at": "2020-12-09T16:09:57+03:00" } ]

  • 204 - Not withdrawals yet;

  • 401 — Unathorized;

  • 500 — Internal error.

Order statuses

  • REGISTERED — registeres;

  • INVALID — no bonus for this order number;

  • PROCESSING — calculating in progress;

  • PROCESSED — order accepted, balance updated;

Revards calculation system

Bonus counting service makes order numbers validation using third party service as client. Final stages are INVAID or PROCESSED.

Settings

Database connection link (required): environment variable 'DATABASE_URI' or flag '-d'

Third party service: environment variable 'ACCRUAL_SYSTEM_ADDRESS' or flag '-r'

Service port (default:'localhost:8080'): environment variable 'RUN_ADDRESS' or flag '-a'

gophermartbonus's People

Contributors

kormiltsev avatar

Watchers

 avatar

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.