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.
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 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 |
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 |
Send POST request to /cp/register with body:
{
"username": "GoodSales",
"password": "8Hds9am33l",
"email": "[email protected]"
}
Expected response:
status: 201 Created
Location: /cp/{id}
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}
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",
}
]
Send POST request to /u/coupons with body:
{
"coupon": {
"id": 1
},
"amount": "3"
}
Expected response:
Status: 200 OK
Location: /coupon/{id}