Skip to content
Reece Edwards edited this page Mar 28, 2024 · 12 revisions

API Endpoint Documentation

Overview

The website contains a variety of files pertaining to the API and how its utilized within the website

Table of Contents

API Endpoints

/api/addAdmin

POST to addAdmin This adds a new admin to the database

Requires

  • adminUsername
    • The username of the admin
  • adminPassword
    • The password of the admin
  • Token
    • Generated Token from the Admin Panel

Responses N/A

/api/addProduct

POST to addProduct This adds a new product to the database

Requires

  • productName
    • The name of the product
  • productPrice
    • The price of the product
  • productStock
    • The amount of stock of the product
  • productDescription
    • The product description
  • productCategory
    • What category is the product in
  • Token
    • Generated Token from the Admin Panel

Response N/A

/api/AddToken

POST to addToken This adds a new token to the database

Requires

  • tokenName
    • the name of the token
  • tokenAdmin
    • Which admin the token is associated with
  • tokenExp
    • The expiry date of the token
  • `Token"
    • Generated Token from the Admin Panel

Responses

  • 418
    • "Invalid Token"
    • "Error parsing token expiry date"
    • "error creating token"

/api/cancelOrder

POST to cancelOrder cancels a current order

Requires

  • orderID
    • The order ID
  • Token
    • Generated Token from the Admin Panel

Responses

  • 418
    • "The Order ID is not specified"
    • "Error cancelling order"

/api/deleteAdmin

POST to deleteAdmin Deletes an admin from the database

Requires

  • adminID
    • The id of the admin to be deleted
  • Token
    • Generated Token from the Admin Panel

Response

  • 400
    • "Admin ID not specified"
    • "echo $message"

/api/deleteCustomer

POST to deleteCustomer Deletes a customer from the database

Requires

  • Token
    • Generated Token from the Admin Panel
  • customerID
    • The ID of the customer

Response

  • 400
    • "Customer ID not specified"
    • "echo $message"

/api/deleteCustomerReviews

POST to deleteCustomerReviews Deletes all reviews of a certain customer

Requires

  • Token
    • Generated Token from the Admin Panel
  • customerID
    • The ID of the customer

Responses

  • 418
    • Customer ID not specified
    • Error deleting reviews

/api/deleteProduct

POST TO deleteProduct Deletes a product from the database

Requires

  • Token
    • Generated Token from the Admin Panel
  • productID
    • The ID of the product

Responses

  • 400
    • Product ID not specified
    • "echo $message"

/api/deleteProductReviews

POST to deleteProductReviews Deletes all reviews from a certain product

Requires

  • Token
    • Generated Token from the Admin Panel
  • productID
    • The ID of the product

Responses

  • 400
    • Product ID not specified
    • Error deleting reviews

/api/deleteReview

POST to deleteReview Deletes a review from a specified product

Requires

  • Token
    • Generated Token from the Admin Panel
  • productID
    • The ID of the product
  • customerID
    • the ID of the customer

Responses

  • 418
    • Customer ID not specified
    • Product ID not specified
    • Database error deleting review

/api/editAdmin

POST to editAdmin Edits an existing admin within the database

Requires

  • Token
    • Generated Token from the Admin Panel
  • adminID
    • the ID of the admin
  • adminUsername
    • the username of the admin
  • adminPassword
    • the password of the admin

Responses N/A

/api/editCustomer

POST to editCustomer

Requires

  • Token
    • Generated Token from the Admin Panel
  • customerID
    • The ID of the customer
  • customerUsername
    • The username of the customer
  • customerEmail
    • The email of the customer
  • customerAddress
    • The address of the customer
  • custommerPassword
    • The password of the customer [misspelt in code]

Responses N/A

/api/editProduct

POST to editProduct Edits an existing product on the database

Requires

  • Token
    • Generated Token from the Admin Panel
  • productID
    • The product ID
  • productName
    • The product name
  • productPrice
    • The product price
  • productStock
    • The current stock of the product
  • ProductDescription
    • The description of the product
  • productCategory
    • The category of the product

Responses N/A

/api/editReview

POST to editReview Edits a specific review for a product

Requires

  • Token
    • Generated Token from the Admin Panel
  • prodID
    • The product ID
  • custID
    • The customer ID
  • rating
    • The rating for the review
  • review
    • The review itself

Responses

  • 418
    • Customer ID not specified [Repeated for all variables]
    • "echo $err"

/api/getAdmin

POST to getAdmin Gets a specific admin from the database

Requires

  • Token
    • Generated Token from the Admin Panel
  • adminID
    • The ID of the admin

Responses

  • 418
    • adminID not specified

/api/getAllReviews

POST to getAllReviews Gets all the reviews

Requires

  • Token
    • Generated Token from the Admin Panel

Responses

  • 418
    • Error retrieving reviews

/api/getCustomer

POST to getCustomer Gets a specific customer

Requires

  • Token
    • Generated Token from the Admin Panel
  • CustomerID
    • the ID of the customer

Responses

  • 418
    • customerID not specified

/api/getCustomerReviews

POST to getCustomerReviews Gets reviews from a specific customer

Requires

  • Token
    • Generated Token from the Admin Panel
  • customerID
    • the ID of the customer

Responses

  • 418
    • Customer ID not specified
    • Error Retrieving reviews

/api/getProduct

POST to getProduct Gets a specific product

Requires

  • Token
    • Generated Token from the Admin Panel
  • productID
    • The Product ID

Responses

  • 418
    • productID not specified

/api/getProductReviews

POST to getProductReviews Gets all reviews from a specific product

Requires

  • Token
    • Generated Token from the Admin Panel
  • productID
    • The Product ID

Responses

  • 418
    • Product ID not specified
    • Error retrieving reviews

/api/refreshToken

POST to refreshToken Refreshes a specific token

Requires

  • Token
    • Generated Token from the Admin Panel

Responses

  • Invalid token specified

/api/returnOrder

POST to returnOrder returns a specific order

Requires

  • Token
    • Generated Token from the Admin Panel
  • OrderID
    • The specific order ID

Responses

  • 418
    • Order ID not specified
    • Error returning order

/api/revokeToken

POST to `revokeToken Revokes a specific token

Requires

  • Token
    • Generated Token from the Admin Panel
  • removalToken
    • The specific token to be revoked

Responses

  • 418
    • removalToken not specified
    • Error revoking token

/api/updateOrderStatus

POST to updateOrderStatus Updates an order status

Requires

  • Token
    • Generated Token from the Admin Panel
  • orderID
    • the order ID
  • newStatusID
    • the new status ID

Responses

  • 418
    • key not specified
  • 404
    • Order not found
  • 500
    • status update failed