Skip to content

A REST web service that enables companies to offer coupons and customers to purchase them.

Notifications You must be signed in to change notification settings

MirYeh/CouponSystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Coupon System

A REST web service that enables companies to offer coupons and customers to purchase them. Built using Maven and Spring Boot. Utilizes Hibernate to manage database calls.

Supported URLs

Company URLs

Company URLs start with /cp

URL HTTP Method Description
/register POST register a company
/login POST log in to existing company account
/logout/{accountId} GET log out of account
/{accountId} GET, PUT, DELETE get, update and remove account
/coupons GET, POST get account's coupons and add coupon to account
/coupons/{couponId} GET, PUT, DELETE get, update and remove specific coupon of account

Customer URLs

Customer URLs start with /u

URL HTTP Method Description
/register POST register a customer
/login POST log in to existing customer account
/logout/{accountId} GET log out of account
/{accountId} GET, PUT, DELETE get, update and remove account
/coupons GET, POST get purchased coupons and purchase coupon
/coupons/{couponId} GET get purchased coupon

General URLs

URL HTTP Method Description
/coupons GET get active coupons (accepts min, max and type parameters)
/coupons/{couponId} GET get specific coupon
/companies GET get all companies
/companies/{companyId} GET get a specific company
/companies/{companyId}/coupons GET get all coupons of a specific company

Examples

Register Company

Send POST request to /cp/register with body:

{
    "username": "GoodSales",
    "password": "8Hds9am33l",
    "email": "[email protected]"
}

Expected response:

status: 201 Created

Location: /cp/{id}

Add Coupon

Send POST request to /cp/coupons with body:

{
  "title": "Some title",
  "startDate": "2018-01-01",
  "endDate": "2019-01-01",
  "amount": 200,
  "type": "Electronics",
  "price": 50,
  "message": "Some message"
}

Expected response:

status: 201 Created

Location: /coupon/{id}

Search Coupons

Send GET request to /coupons?min=5&max=1000&type=electronics

Expected response:

[
    {
        "id": 1,
        "owner": {
            "id": 1,
            "username": "GoodSales",
            "password": "8Hds9am33l",
            "email": "[email protected]",
            "joined": "2018-01-01"
        },
        "title": "Some title",
        "startDate": "2018-01-01",
        "endDate": "2019-01-01",
        "amount": 200,
        "type": {
            "id": 1,
            "name": "Electronics"
        },
        "price": 50,
        "isActive": true,
        "message": "Some message",
    }
]

Purchase Coupon

Send POST request to /u/coupons with body:

{
	"coupon": {
		"id": 1
	},
	"amount": "3"
}

Expected response:

Status: 200 OK

Location: /coupon/{id}

About

A REST web service that enables companies to offer coupons and customers to purchase them.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages