Skip to content

Jedrzej1940518/IO2023

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wstepna dokumentacja:

Installation

Prerequsites:

  • php server installed
  • mysql server installed or internet hosted mysql server
  • mod_rewrite enabled

Instruction

  1. Put everything from repo to directory, where php server looks for .php files
  2. Change values inside file DBConnection.php to math mysql connection parameters
  3. Connect to mysql and copy/paste content of sqlScript.txt or execute this script as a query to prepare mysql server
  4. start php server
  5. done

Endpoints

User endpoints

All user endpoints

POST

  • register - register user

    body

     ```
     {
         "email" : "[email protected]",
         "first_name":"user_name",
         "last_name": "user_last_name",
         "age": 25,
         "address": "krakow",
         "password":"yooo"
     }
     ```
    
  • login - login for registered user

    body

     ```
     {
         "email" : "[email protected]",
         "password":"yooo"
     }
     ```
    

GET

  • me - prints all information about current user

Products endpoints

All products endpoints

POST

  • products - inserts new product

    body

     ```
     {
         "name": "vn5",
         "category_id": 31,
         "alcohol_content": 99.5,
         "description": "zz",
         "country_origin_id": 25,
         "price": 100.99,
         "available_amount": 100,
         "rating": 4
     }
     ```
    

GET

  • products - returns list of products, allows also to specify page and limit, or filters field, where available filters are:
    • name - string, search by name
    • price_min - float, minimal price
    • price_max - float, maximum price
    • alcohol_content_min - int, minimal content of an alcohol
    • alcohol_content_max - int, maximal content of an alcohol
    • category_id - int, by category
  • products/{id} - return single product, where product id is {id}, {id} is integer

PUT

  • products/{id} - {id} is int, edits product with given id

    body

     ```
     {
         "name": "UpdatedProduct",
         "price": 9.99,
         "available_amount": 100,
         "rating": 4
     }
     ```
    

DELETE

  • products/{id} - {id} is int, removes product with given id

Category endpoints

All category endpoints

POST

  • categories - inserts new category

    body

     ```
     {
         "name": "wóda",
         "description": "kopie mocno"
     }
     ```
    

GET

  • categories - returns list of categories

DELETE

  • categories/{id} - {id} is int, removes category with given id

Orders endpoints

All orders endpoints

Available order states:

  • 0 - ORDER_STARTED
  • 1 - AWAITING_PAYMENT
  • 2 - PAYMENT_FAILED
  • 3 - ORDER_FINISHED

POST

  • orders - inserts new order

    body

     ```
     {
         "order_date": "2023-06-15 14:25:45",
         "user_id": 36,
         "state_id": 0
     }
     ```
    

GET

  • orders - returns list of user orders
  • orders/{id} - returns order with specified id

PUT

  • orders/{id} - {id} is int, edits order with given id

    body

     ```
     {
         "order_date": "2023-06-15 14:45:45"
     }
     ```
    

DELETE

  • orders/{id} - {id} is int, removes order with given id

Orders entries endpoints

All orders entries endpoints

POST

  • orders_entries/{id} - {id} is int (order id), inserts new order entry for given order id

    body

     ```
     {
         "order_id": 12,
         "amount": 10,
         "product_id": 40,
         "historic_price": 33
     }
     ```
    

GET

  • orders_entries/{id} - {id} as int (order id), returns all entries per order id

PUT

  • orders_entries/{id} - {id} is int, edits order entry with given id

    body

     ```
     {
         "product_id": 40,
         "historic_price": 33
     }
     ```
    

DELETE

  • orders_entries/{id} - {id} is int, removes order entry with given id

Product opinion endpoints

All product opinion endpoints

POST

  • product_opinions - inserts new product opinion

    body

     ```
     {
         "product_id": 40,
         "user_id": 36,
         "rate": 4,
         "description": "niestety, walory smakowe pozostawiają wiele do życzenia",
         "opinion_date":"2023-06-15 14:25:45"
     }
     ```
    

GET

  • product_opinions/{id} - {id} as int (product id), returns all opinions per product id

PUT

  • product_opinions/{id} - {id} is int, edits opinion with given id

    body

     ```
     {
         "description": "tani trunek na imprezy"
     }
     ```
    

DELETE

  • product_opinions/{id} - {id} is int, removes opinion with given id

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages