Skip to content

API Routes

Isaiah Sinnathamby edited this page Jun 17, 2023 · 5 revisions

API-Routes

The Epic-E-Shop web app uses the following API routes to create a single-page-app-like feel for the user for specific features.

Account creation feature (sign up, log in, demo log in, sign out)

Endpoints needed:

Sign Up a User

  • Method: POST
  • URL: /api/users
  • Body: Request
{ 
  "username": "string", 
  "email": "string",
  "password": "string",
  "vbucks": "int",
  "profileImage": "string"
}

Response:

{
  "id": "int",
  "username": "string",
  "email": "string",
  "vbucks": "int",
  "profileImage": "string"
}

Log In a User

  • Method: POST
  • URL: /api/users/login
  • Body: Request
{
  "username": "string",
  "password": "string"
}

Response:

{
  "id": "int",
  "username": "string",
  "token": "string"
}

Log out a User

- Method: POST
- URL: `/api/users/logout`
- Body: None
Response: None (or HTTP 204 No Content)

Get the Current User

  • Method: GET
  • URL: /api/session
  • Body: None

Response:

{
  "session": { 
    "user": { 
      "id": "int", 
      "username": "string",
      "email": "string",
      "vbucks": "int", 
      "profileImage": "string",
      "cart": {
        "items": [{
          "id": "int",
          "productName": "string",
          "price": "float",
          "quantity": "int"
        }]
      },
      "wishlist": {
        "items": [{
          "id": "int",
          "productName": "string",
          "priority": "int"
        }]
      },
      "reminders": {
        "items": [{
          "id": "int",
          "productName": "string",
          "reminder_time": "datetime",
          "duration": "string"
        }]
      },
      "inventory": {
        "items": [{
          "id": "int",
          "productName": "string"
        }]
      },
      "likes": {
        "items": [{
          "id": "int",
          "productName": "string",
          "value": "boolean"
        }]
      },
      "comments": {
        "items": [{
          "id": "int",
          "productName": "string",
          "content": "text"
        }]
      }
    }
  }
}

Items Management

Get all Items

  • Method: GET
  • URL: /api/items
  • Body: None

Response

{ 
  "items": [
    {
      "id": "string",
      "name": "string",
      "price": "string",
      "images": {
        "icon": "string",
        "png": "string",
        "featured": "string"
      },
      "rarity": "string",
      "type": "string",
      "slug": "string",
      "readableType": "string",
      "description": "string"
    },
  ]
}

Get an Item

- Method: GET
- URL: `/api/items/{itemId}`
- Body: None

Response:

{ 
  "id": "string",
  "name": "string",
  "price": "string",
  "images": {
    "icon": "string",
    "png": "string",
    "featured": "string"
  },
  "rarity": "string",
  "type": "string",
  "slug": "string",
  "readableType": "string",
  "description": "string"
}

Cart Management

Add an Item to Cart

- Method: POST
- URL: `/api/cart`
- Body Request: 
{
  "userId": "int",
  "itemId": "string",
  "quantity": "int"
}

Response:

{
  "id": "int",
  "userId": "int",
  "itemId": "string",
  "quantity": "int"
}

Update an Item in Cart

- Method: PUT
- URL: `/api/cart/{cartId}`
- Body Request:
{
  "quantity": "int"
}

Response:

{
  "id": "int",
  "userId": "int",
  "itemId": "string",
  "quantity": "int"
}

Delete an Item from Cart

- Method: DELETE
- URL: `/api/cart/{cartId}`
- Body: None
Response: None (or HTTP 204 No Content)

Wish-list Management

Add an Item to Wish-list

  • Method: POST
  • URL: /api/wishlist
  • Body: Request
{
  "userId": "int",
  "itemId": "string",
  "priority": "int"
}

Response:

{
  "id": "int",
  "userId": "int",
  "itemId": "string",
  "priority": "int"
}

Update an Item in Wishlist

- Method: PUT
- URL: `/api/wishlist/{wishlistId}`
- Body Request: 
{
  "priority": "int"
}

Response:

{
  "id": "int",
  "userId": "int",
  "itemId": "string",
  "priority": "int"
}

Delete an Item from Wishlist

- Method: DELETE
- URL: `/api/wishlist/{wishlistId}`
- Body: None
Response: None (or HTTP 204 No Content)

Reminders Management

Add a Reminder

  • Method: POST
  • URL: /api/reminders
  • Body: Request
{
  "userId": "int",
  "itemId": "string",
  "reminder_time": "datetime"
}

Response:

{
  "id": "int",
  "userId": "int",
  "itemId": "string",
  "reminder_time": "datetime"
}

Update a Reminder

- Method: PUT
- URL: `/api/reminders/{reminderId}`
- Body Request:
{
  "reminder_time": "datetime"
}

Response:

{
  "id": "int",
  "userId": "int",
  "itemId": "string",
  "reminder_time": "datetime"
}

Delete a Reminder

- Method: DELETE
- URL: `/api/reminders/{reminderId}`
- Body: None
Response: None (or HTTP 204 No Content)

Comments Management

Add a Comment

  • Method: POST
  • URL: /api/comments
  • Body: Request
{
  "userId": "int",
  "itemId": "string",
  "content": "text"
}

Update a Comment

- Method: PUT
- URL: `/api/comments/{commentId}`
- Body Request: 
{
  "content": "text"
}

Response:

{
  "id": "int",
  "userId": "int",
  "itemId": "string",
  "content": "text"
}

Delete a Comment

- Method: DELETE
- URL: `/api/comments/{commentId}`
- Body: None
Response: None (or HTTP 204 No Content)

Likes Management

Add a Like

  • Method: POST
  • URL: /api/likes
  • Body: Request
{
  "userId": "int",
  "itemId": "string",
  "value": "boolean"
}

Response:

{
  "id": "int",
  "userId": "int",
  "itemId": "string",
  "value": "boolean"
}

Update a Like

- Method: PUT
- URL: `/api/likes/{likeId}`
- Body Request:
{
  "value": "boolean"
}

Response:

{
  "id": "int",
  "userId": "int",
  "itemId": "string",
  "value": "boolean"
}

Delete a Like

- Method: DELETE
- URL: `/api/likes/{likeId}`
- Body: None
Response: None (or HTTP 204 No Content)

Shop Sections Management

Get all Shop Sections

  • Method: GET
  • URL: /api/shop_sections
  • Body: None Response
[
  {
    "id": "int",
    "displayName": "string",
    "key": "string",
    "priority": "int"
  },
]

Section Items Management

Get all Items in a Section

- Method: GET
- URL: `/api/section_items/{sectionId}`
- Body: None

Response

[
  {
    "id": "int",
    "shop_section_id": "int",
    "item_id": "string"
  },
]