Skip to content

API Documentation

HamzaAlfarrash edited this page Nov 14, 2024 · 31 revisions

API Documentation

Table of Contents

  1. Games
  2. Categories
  3. Reviews
  4. Orders
  5. Customers
  6. Employees
  7. Manager
  8. Store

Game

1. Create Game

  • URI: POST /games/
  • Description: Allows the creation of a new game in the catalog.
  • Associated Requirement(s): FR1.4
  • Parameters: None (All necessary data is provided in the request body.)
  • Request Body:
    {
        "name": "Direct Game Title",
        "description": "Description of the game.",
        "imageUrl": "https://example.com/direct-game-image.jpg",
        "price": 49.99,
        "quantityInStock": 30,
        "isAvailable": true,
        "categoryIds": [2, 4]
    }
  • Response:
    • 200 OK: Game created successfully.
      {
          "gameId": 201,
          "name": "Direct Game Title",
          "description": "Description of the game.",
          "imageUrl": "https://example.com/direct-game-image.jpg",
          "price": 49.99,
          "quantityInStock": 30,
          "isAvailable": true,
          "categoryIds": [2, 4],
          "wishListIds": [],
          "orderIds": [],
          "promotionIds": []
      }

2. Update Game

  • URI: PUT /games/{gameId}
  • Description: Allows the employee (with manager approval) or manager to update the details of an existing game, including price, stock quantity, availability status, and other attributes.
  • Associated Requirement(s): FR1.4, FR7.6
  • Parameters:
    • gameId (integer, path parameter, required): The ID of the game to update.
  • Request Body:
    {
        "price": 39.99,
        "quantityInStock": 20,
        "isAvailable": true,
        "name": "Updated Game Title",
        "description": "Updated description.",
        "imageUrl": "https://example.com/updated-game-image.jpg",
        "categoryIds": [2, 5]
    }
  • Response:
    • 200 OK: Game updated successfully.
      {
          "gameId": 201,
          "name": "Updated Game Title",
          "description": "Updated description.",
          "imageUrl": "https://example.com/updated-game-image.jpg",
          "price": 39.99,
          "quantityInStock": 20,
          "isAvailable": true,
          "categoryIds": [2, 5],
          "wishListIds": [],
          "orderIds": [],
          "promotionIds": []
      }

3. Archive Game

  • URI: PUT /games/archive/{gameId}
  • Description: Allows the archiving of a game by marking it as unavailable in the inventory. Archived games remain in the system but are excluded from active listings and browsing.
  • Associated Requirement(s): FR1.5
  • Parameters:
    • gameId (integer, path parameter, required): The ID of the game to archive.
  • Request Body: None
  • Response:
    • 200 OK: Game archived successfully.
      {
          "gameId": 201,
          "name": "Direct Game Title",
          "description": "Description of the game.",
          "imageUrl": "https://example.com/direct-game-image.jpg",
          "price": 39.99,
          "quantityInStock": 20,
          "isAvailable": false,
          "categoryIds": [2, 4],
          "wishListIds": [],
          "orderIds": [],
          "promotionIds": []
      }

4. View Archived Games

  • URI: GET /games/archive
  • Description: Retrieves a list of all archived (unavailable) games in the catalog. This allows employees to view games that are no longer active but still retained in the system.
  • Associated Requirement(s): FR1.6
  • Parameters: None
  • Request Body: None
  • Response:
    • 200 OK: Archived games retrieved successfully.
      [
          {
              "gameId": 201,
              "name": "Direct Game Title",
              "description": "Description of the game.",
              "imageUrl": "https://example.com/direct-game-image.jpg",
              "price": 39.99,
              "quantityInStock": 20,
              "isAvailable": false,
              "categoryIds": [2, 4],
              "wishListIds": [],
              "orderIds": [],
              "promotionIds": []
          }
      ]

5. Reactivate Archived Game

  • URI: PUT /games/archive/{gameId}/reactivate
  • Description: Allows the manager to reactivate an archived game, making it available again in the inventory and visible in active listings.
  • Associated Requirement(s): FR1.7
  • Parameters:
    • gameId (integer, path parameter, required): The ID of the game to reactivate.
  • Request Body: None
  • Response:
    • 200 OK: Game reactivated successfully.
      {
          "gameId": 201,
          "name": "Direct Game Title",
          "description": "Description of the game.",
          "imageUrl": "https://example.com/direct-game-image.jpg",
          "price": 39.99,
          "quantityInStock": 20,
          "isAvailable": true,
          "categoryIds": [2, 4],
          "wishListIds": [],
          "orderIds": [],
          "promotionIds": []
      }

6. Browse Games

  • URI: GET /games
  • Description: Retrieves a list of all available (non-archived) games in the catalog. Supports optional filtering by category, minimum price, and maximum price.
  • Associated Requirement(s): FR4.1, FR4.2, FR4.3
  • Parameters:
    • category (string, query parameter, optional): Filter games by category name.
    • minPrice (double, query parameter, optional): Minimum price to filter games.
    • maxPrice (double, query parameter, optional): Maximum price to filter games.
  • Request Body: None
  • Response:
    • 200 OK: Games retrieved successfully.
      [
          {
              "gameId": 123,
              "name": "Available Game Title",
              "description": "Description of the game.",
              "imageUrl": "https://example.com/available-game-image.jpg",
              "price": 49.99,
              "quantityInStock": 15,
              "isAvailable": true,
              "categoryIds": [1, 2],
              "wishListIds": [],
              "orderIds": [],
              "promotionIds": []
          }
      ]

7. Search Games

  • URI: GET /games/search
  • Description: Searches for available games based on a search query and optional filtering by category, minimum price, and maximum price. The search considers game names, descriptions, and category names.
  • Associated Requirement(s): FR4.2
  • Parameters:
    • query (string, query parameter, required): The search term to look for in game names, descriptions, or categories.
    • category (string, query parameter, optional): Filter search results by category name.
    • minPrice (double, query parameter, optional): Minimum price to filter games.
    • maxPrice (double, query parameter, optional): Maximum price to filter games.
  • Request Body: None
  • Response:
    • 200 OK: Search results retrieved successfully.
      [
          {
              "gameId": 456,
              "name": "Unique Game Title",
              "description": "Description of the unique game.",
              "imageUrl": "https://example.com/unique-game-image.jpg",
              "price": 29.99,
              "quantityInStock": 10,
              "isAvailable": true,
              "categoryIds": [1, 3],
              "wishListIds": [],
              "orderIds": [],
              "promotionIds": []
          }
      ]

8. Add Game to Category

  • URI: PUT /games/{gameId}/categories/{categoryId}
  • Description: Assigns an existing game to a specified category, enhancing the organization and filtering capabilities within the catalog.
  • Associated Requirement(s): FR2.4
  • Parameters:
    • gameId (integer, path parameter, required): The ID of the game to add to a category.
    • categoryId (integer, path parameter, required): The ID of the category to which the game will be added.
  • Request Body: None
  • Response:
    • 200 OK: Game added to category successfully.
      {
          "gameId": 123,
          "name": "Available Game Title",
          "description": "Description of the game.",
          "imageUrl": "https://example.com/available-game-image.jpg",
          "price": 49.99,
          "quantityInStock": 15,
          "isAvailable": true,
          "categoryIds": [1, 2, 3],
          "wishListIds": [],
          "orderIds": [],
          "promotionIds": []
      }

9. Update Game Stock

  • URI: PUT /games/{gameId}/stock
  • Description: Updates the stock quantity of an existing game in the inventory, allowing the manager to manage inventory levels.
  • Associated Requirement(s): FR7.6
  • Parameters:
    • gameId (integer, path parameter, required): The ID of the game to update.
    • stock (integer, query parameter, required): The new stock quantity for the game.
  • Request Body: None
  • Response:
    • 200 OK: Game stock updated successfully.
      {
          "gameId": 123,
          "name": "Available Game Title",
          "description": "Description of the game.",
          "imageUrl": "https://example.com/available-game-image.jpg",
          "price": 49.99,
          "quantityInStock": 20,
          "isAvailable": true,
          "categoryIds": [1, 2],
          "wishListIds": [],
          "orderIds": [],
          "promotionIds": []
      }

10. Update Game Price

  • URI: PUT /games/{gameId}/price
  • Description: Updates the price of an existing game in the inventory, allowing the manager to adjust pricing as needed.
  • Associated Requirement(s): FR7.6
  • Parameters:
    • gameId (integer, path parameter, required): The ID of the game to update.
    • price (double, query parameter, required): The new price for the game.
  • Request Body: None
  • Response:
    • 200 OK: Game price updated successfully.
      {
          "gameId": 123,
          "name": "Available Game Title",
          "description": "Description of the game.",
          "imageUrl": "https://example.com/available-game-image.jpg",
          "price": 59.99,
          "quantityInStock": 20,
          "isAvailable": true,
          "categoryIds": [1, 2],
          "wishListIds": [],
          "orderIds": [],
          "promotionIds": []
      }

GameRequest

1. Submit Game Request

  • URI: POST /games/request
  • Description: Allows employees to submit a game request for adding a new game or updating an existing game's details. This request requires managerial approval before the game is officially added or updated in the catalog.
  • Associated Requirement(s): FR1.1
  • Parameters: None
  • Request Body:
    {
        "name": "New Game Title",
        "description": "A comprehensive description of the new game.",
        "imageUrl": "https://example.com/new-game-image.jpg",
        "price": 59.99,
        "quantityInStock": 50,
        "categoryIds": [1, 3],
        "isUpdate": false
    }
  • Response:
    • 200 OK: Game request submitted successfully.
      {
          "requestId": 101,
          "name": "New Game Title",
          "description": "A comprehensive description of the new game.",
          "imageUrl": "https://example.com/new-game-image.jpg",
          "price": 59.99,
          "quantityInStock": 50,
          "categoryIds": [1, 3],
          "isApproved": false,
          "isUpdate": false
      }

2. Edit Game Request

  • URI: POST /games/request/{requestId}
  • Description: Allows employees to edit an existing game request before it has been approved or rejected. This enables adjustments to the proposed game details as needed.
  • Associated Requirement(s): FR1.1
  • Parameters:
    • requestId (integer, path parameter, required): The ID of the game request to edit.
  • Request Body:
    {
        "name": "Updated Game Title",
        "description": "Updated description of the game.",
        "imageUrl": "https://example.com/updated-game-image.jpg",
        "price": 49.99,
        "quantityInStock": 40,
        "categoryIds": [2, 4],
        "isUpdate": true
    }
  • Response:
    • 200 OK: Game request updated successfully.
      {
          "requestId": 101,
          "name": "Updated Game Title",
          "description": "Updated description of the game.",
          "imageUrl": "https://example.com/updated-game-image.jpg",
          "price": 49.99,
          "quantityInStock": 40,
          "categoryIds": [2, 4],
          "isApproved": false,
          "isUpdate": true
      }

3. Delete Game Request

  • URI: DELETE /games/request/{requestId}
  • Description: Allows the manager or employee to delete a game request that is no longer needed or was submitted in error. This removes the request from the system.
  • Associated Requirement(s): FR1.1
  • Parameters:
    • requestId (integer, path parameter, required): The ID of the game request to delete.
  • Request Body: None
  • Response:
    • 200 OK: Game request deleted successfully.
      {
          "message": "Game request deleted successfully."
      }

4. Add Note to Game Request

  • URI: POST /games/request/{requestId}/note
  • Description: Allows managers or employees to add notes to a specific game request. Notes can provide additional context, feedback, or instructions related to the request.
  • Associated Requirement(s): FR5.1
  • Parameters:
    • requestId (integer, path parameter, required): The ID of the game request to which the note will be added.
  • Request Body:
    {
        "content": "Please ensure the game meets all quality standards before approval."
    }
  • Response:
    • 200 OK: Note added successfully.
      {
          "noteId": 301,
          "content": "Please ensure the game meets all quality standards before approval.",
          "timestamp": "2024-04-27T10:15:30Z",
          "authorId": 2
      }

5. Delete Note from Game Request

  • URI: DELETE /games/request/{requestId}/note/{noteId}
  • Description: Allows the manager or employee to delete a specific note from a game request. This helps in maintaining relevant and concise information within requests.
  • Associated Requirement(s): FR5.1
  • Parameters:
    • requestId (integer, path parameter, required): The ID of the game request.
    • noteId (integer, path parameter, required): The ID of the note to delete.
  • Request Body: None
  • Response:
    • 200 OK: Note deleted successfully.
      {
          "message": "Note deleted successfully."
      }

6. Process Game Request (Approve/Reject)

  • URI: PUT /games/request/{requestId}/approval
  • Description: Enables the manager to approve or reject a submitted game request. Upon approval, the game is either added as a new entry or updated in the catalog. Upon rejection, the request is marked as rejected with an optional reason.
  • Associated Requirement(s): FR1.2, FR1.3
  • Parameters:
    • requestId (integer, path parameter, required): The ID of the game request to approve or reject.
    • managerId (integer, query parameter, required): The ID of the manager processing the request.
    • approval (boolean, query parameter, required): Indicates approval (true) or rejection (false).
  • Request Body:
    {
        "price": 59.99,
        "quantityInStock": 50,
        "isAvailable": true,
        "categoryIds": [1, 3],
        "rejectionReason": "Insufficient budget."
    }
  • Response:
    • 200 OK: Game request processed successfully.
      {
          "requestId": 101,
          "name": "New Game Title",
          "description": "A comprehensive description of the new game.",
          "imageUrl": "https://example.com/new-game-image.jpg",
          "price": 59.99,
          "quantityInStock": 50,
          "categoryIds": [1, 3],
          "isApproved": true,
          "isUpdate": false,
          "rejectionReason": null
      }

7. Retrieve All Game Requests

  • URI: GET /games/request
  • Description: Retrieves a list of all submitted game requests. This allows managers and employees to view the status and details of each request.
  • Associated Requirement(s): FR1.2
  • Parameters: None
  • Request Body: None
  • Response:
    • 200 OK: Game requests retrieved successfully.
      [
          {
              "requestId": 101,
              "name": "New Game Title",
              "description": "A comprehensive description of the new game.",
              "imageUrl": "https://example.com/new-game-image.jpg",
              "price": 59.99,
              "quantityInStock": 50,
              "categoryIds": [1, 3],
              "isApproved": false,
              "isUpdate": false,
              "notes": [
                  {
                      "noteId": 301,
                      "content": "Initial request submitted.",
                      "timestamp": "2024-04-27T10:15:30Z",
                      "authorId": 2
                  }
              ]
          }
      ]

8. Retrieve Specific Game Request

  • URI: GET /games/request/{requestId}
  • Description: Retrieves the details of a specific game request by its ID. This allows managers and employees to view individual request details.
  • Associated Requirement(s): FR1.2
  • Parameters:
    • requestId (integer, path parameter, required): The ID of the game request to retrieve.
  • Request Body: None
  • Response:
    • 200 OK: Specific game request retrieved successfully.
      {
          "requestId": 101,
          "name": "New Game Title",
          "description": "A comprehensive description of the new game.",
          "imageUrl": "https://example.com/new-game-image.jpg",
          "price": 59.99,
          "quantityInStock": 50,
          "categoryIds": [1, 3],
          "isApproved": false,
          "isUpdate": false,
          "notes": [
              {
                  "noteId": 301,
                  "content": "Initial request submitted.",
                  "timestamp": "2024-04-27T10:15:30Z",
                  "authorId": 2
              }
          ]
      }

Categories

1. View All Game Categories

  • URI: GET /categories/
  • Description: Retrieves a list of all game categories in the system.
  • Associated Requirement(s): FR2, FR4.2
  • Parameters: None
  • Request Body: None
  • Response:
    • 200 OK: List of game categories retrieved successfully.
      {
          "categories": [
              {
                  "categoryId": 1,
                  "name": "Action",
                  "categoryType": "CONSOLE",
                  "available": true
              },
              {
                  "categoryId": 2,
                  "name": "Adventure",
                  "categoryType": "PC",
                  "available": true
              }
          ]
      }

2. Create Game Category

  • URI: POST /categories/
  • Description: Allows the creation of a new game category in the catalog.
  • Associated Requirement(s): FR2.2
  • Parameters: None
  • Request Body:
    {
        "name": "Action",
        "categoryType": "CONSOLE",
        "available": true
    }
  • Response:
    • 200 OK: Game category created successfully.
      {
          "categoryId": 1,
          "name": "Action",
          "categoryType": "CONSOLE",
          "available": true
      }
    • 409 Conflict: Game category already exists.
      {
          "error": "Game category already exists."
      }

3. Update Game Category

  • URI: PUT /categories/{categoryId}
  • Description: Updates an existing game category's details.
  • Associated Requirement(s): FR2.2
  • Parameters:
    • categoryId (integer, path parameter, required): The ID of the category to update.
  • Request Body:
    {
        "name": "Drama",
        "categoryType": "CONSOLE",
        "available": true
    }
  • Response:
    • 200 OK: Game category updated successfully.
      {
          "categoryId": 1,
          "name": "Drama",
          "categoryType": "CONSOLE",
          "available": true
      }
    • 404 Not Found: Game category not found.
      {
          "error": "Game category not found."
      }

4. Delete Game Category

  • URI: DELETE /categories/{categoryId}
  • Description: Deletes an existing game category by its ID.
  • Associated Requirement(s): FR2.3
  • Parameters:
    • categoryId (integer, path parameter, required): The ID of the category to delete.
  • Request Body: None
  • Response:
    • 200 OK: Game category deleted successfully.
    • 404 Not Found: Game category not found.
      {
          "error": "Game category with ID {categoryId} not found."
      }

5. Get Game Categories by Game ID

  • URI: GET /categories/game/{gameId}
  • Description: Retrieves a list of categories associated with a specific game.
  • Associated Requirement(s): FR2, FR2.4
  • Parameters:
    • gameId (integer, path parameter, required): The ID of the game.
  • Request Body: None
  • Response:
    • 200 OK: Categories associated with the game retrieved successfully.
      [
          {
              "categoryId": 1,
              "name": "Action",
              "categoryType": "CONSOLE",
              "available": true
          }
      ]
    • 404 Not Found: Game not found.
      {
          "error": "Game with ID {gameId} not found."
      }

6. Get Game Categories by Promotion ID

  • URI: GET /categories/promotion/{promotionId}
  • Description: Retrieves a list of categories associated with a specific promotion.
  • Associated Requirement(s): FR7.2
  • Parameters:
    • promotionId (integer, path parameter, required): The ID of the promotion.
  • Request Body: None
  • Response:
    • 200 OK: Categories associated with the promotion retrieved successfully.
      [
          {
              "categoryId": 1,
              "name": "Action",
              "categoryType": "CONSOLE",
              "available": true
          }
      ]
    • 404 Not Found: Promotion not found.
      {
          "error": "Promotion with ID {promotionId} not found."
      }

Reviews

1. Submit Review

  • URI: POST /games/{orderGameId}/reviews
  • Description: Allows customers to submit a review for a game they purchased.
  • Associated Requirement(s): FR3, FR3.1
  • Parameters:
    • orderGameId (integer, path parameter, required): The ID of the purchased game order.
  • Request Body:
    {
        "rating": "FIVE_STARS",
        "customerId": 1,
        "comment": "Fantastic game!!!"
    }
  • Response:
    • 200 OK: Review submitted successfully.
      {
          "reviewId": 101,
          "rating": "FIVE_STARS",
          "customerId": 1,
          "comment": "Fantastic game!!!"
      }
    • 404 Not Found: OrderGame not found.
      {
          "error": "OrderGame not found."
      }
    • 403 Forbidden: Customer does not own the order.
      {
          "error": "Customer is not the owner of the order."
      }
    • 400 Bad Request: Validation failed.
      {
          "error": "Validation failed."
      }

2. View Reviews

  • URI: GET /games/{gameId}/reviews
  • Description: Retrieves all reviews for a specific game.
  • Associated Requirement(s): FR3.3
  • Parameters:
    • gameId (integer, path parameter, required): The ID of the game.
  • Request Body: None
  • Response:
    • 200 OK: Reviews retrieved successfully.
      {
          "reviews": [
              {
                  "reviewId": 101,
                  "rating": "FIVE_STARS",
                  "comment": "Fantastic game!!!"
              },
              {
                  "reviewId": 102,
                  "rating": "THREE_STARS",
                  "comment": "Actually, not too bad!"
              }
          ]
      }
    • 404 Not Found: Game not found.
      {
          "error": "Game not found."
      }

3. Reply to Review

  • URI: POST /games/reviews/{reviewId}/reply
  • Description: Allows a manager to reply to a specific review.
  • Associated Requirement(s): FR3.4
  • Parameters:
    • reviewId (integer, path parameter, required): The ID of the review to reply to.
  • Request Body:
    {
        "content": "Thank you for your feedback!",
        "managerId": 1
    }
  • Response:
    • 200 OK: Reply submitted successfully.
      {
          "replyId": 301,
          "content": "Thank you for your feedback!",
          "reviewId": 101
      }
    • 404 Not Found: Review or Manager not found.
      {
          "error": "Review not found."
      }
      {
          "error": "Manager not found."
      }

4. Delete Review

  • URI: DELETE /games/reviews/{reviewId}
  • Description: Deletes a specific review.
  • Associated Requirement(s): FR3.5
  • Parameters:
    • reviewId (integer, path parameter, required): The ID of the review to delete.
  • Request Body: None
  • Response:
    • 200 OK: Review deleted successfully.
    • 404 Not Found: Review not found.
      {
          "error": "Review not found."
      }

5. Delete Reply

  • URI: DELETE /games/reviews/reply/{replyId}
  • Description: Deletes a specific reply to a review.
  • Associated Requirement(s): FR3.4
  • Parameters:
    • replyId (integer, path parameter, required): The ID of the reply to delete.
  • Request Body: None
  • Response:
    • 200 OK: Reply deleted successfully.
    • 404 Not Found: Reply not found.
      {
          "error": "Reply not found."
      }

Orders

1. Create Customer Order

  • URI: POST /orders/
  • Description: Creates a new customer order with the provided details.
  • Associated Requirement(s): FR8
  • Parameters: None
  • Request Body:
    {
        "gameIds": [1, 2],
        "paymentDetailsId": 1001,
        "customerId": 2001
    }
  • Response:
    • 200 OK: Customer order created successfully.
      {
          "orderId": 1,
          "orderDate": "2024-11-13",
          "totalPrice": 99.99,
          "status": "PROCESSING",
          "customerId": 2001,
          "gameIds": [1, 2]
      }
    • 404 Not Found: Game, customer, or payment details not found.
      {
          "error": "Game with ID 1 not found"
      }
    • 400 Bad Request: Insufficient stock or unavailable game.
      {
          "error": "Game with ID 1 is out of stock"
      }

2. Return Customer Order

  • URI: POST /orders/{orderId}/return
  • Description: Marks a customer order as returned if within the allowed return period.
  • Associated Requirement(s): FR8, FR8.4
  • Parameters:
    • orderId (integer, path parameter, required): The ID of the order to be returned.
  • Request Body: None
  • Response:
    • 200 OK: Customer order marked as returned successfully.
      {
          "orderId": 1,
          "orderDate": "2024-11-08",
          "totalPrice": 99.99,
          "status": "RETURNED",
          "customerId": 2001,
          "gameIds": [1, 2]
      }
    • 404 Not Found: Order not found.
      {
          "error": "Order with ID 1 not found"
      }
    • 400 Bad Request: Order outside of the allowed return period.
      {
          "error": "Order with ID 1 was placed more than 7 days ago"
      }

3. Get Customer Order by ID

  • URI: GET /orders/{orderId}
  • Description: Retrieves a customer order by its ID.
  • Associated Requirement(s): FR 7.3, FR9.1
  • Parameters:
    • orderId (integer, path parameter, required): The ID of the order to retrieve.
  • Request Body: None
  • Response:
    • 200 OK: Customer order retrieved successfully.
      {
          "orderId": 1,
          "orderDate": "2024-11-13",
          "totalPrice": 99.99,
          "status": "PROCESSING",
          "customerId": 2001,
          "gameIds": [1, 2]
      }
    • 404 Not Found: Order not found.
      {
          "error": "Order with ID 1 not found"
      }
      
      

Customer

1. Create Customer Account

  • URI: POST /customers/
  • Description: Creates a new customer account with the provided details.
  • Associated Requirement(s): FR5, FR5.2
  • Parameters: None
  • Request Body:
    {
        "email": "customer@example.com",
        "password": "Secure@Pass1",
        "name": "Jane Smith",
        "phoneNumber": "111-222-3333"
    }
  • Response:
    • 200 OK: Customer account created successfully.
      {
          "customerId": 1,
          "email": "customer@example.com",
          "name": "Jane Smith",
          "phoneNumber": "111-222-3333"
      }
    • 409 Conflict: An account with this email already exists.
      {
          "error": "An account with this email already exists."
      }
    • 400 Bad Request: Validation error, e.g., invalid phone number or weak password.
      {
          "error": "Password does not meet security requirements."
      }

2. Update Customer Account

  • URI: PUT /customers/{customerId}
  • Description: Updates the details of an existing customer account.
  • Associated Requirement(s): FR5, FR5.3
  • Parameters:
    • customerId (integer, path parameter, required): The ID of the customer account to update.
  • Request Body:
    {
        "email": "updated@example.com",
        "password": "Secure@Pass2",
        "name": "Jane Doe",
        "phoneNumber": "222-333-4444"
    }
  • Response:
    • 200 OK: Customer account updated successfully.
      {
          "customerId": 1,
          "email": "updated@example.com",
          "name": "Jane Doe",
          "phoneNumber": "222-333-4444"
      }
    • 404 Not Found: Customer account not found.
      {
          "error": "Customer not found."
      }
    • 400 Bad Request: Validation error.
      {
          "error": "Password does not meet security requirements."
      }

3. Get All Customer Accounts

  • URI: GET /customers
  • Description: Retrieves all customer accounts.
  • Associated Requirement(s): FR7
  • Parameters: None
  • Request Body: None
  • Response:
    • 200 OK: List of customer accounts retrieved successfully.
      {
          "customers": [
              {
                  "customerId": 1,
                  "email": "customer@example.com",
                  "name": "Jane Smith",
                  "phoneNumber": "111-222-3333"
              },
              {
                  "customerId": 2,
                  "email": "another@example.com",
                  "name": "John Doe",
                  "phoneNumber": "444-555-6666"
              }
          ]
      }

4. Get Customer Account by ID

  • URI: GET /customers/{customerId}
  • Description: Retrieves a specific customer account by its ID.
  • Associated Requirement(s): FR7
  • Parameters:
    • customerId (integer, path parameter, required): The ID of the customer account to retrieve.
  • Request Body: None
  • Response:
    • 200 OK: Customer account details retrieved successfully.
      {
          "customerId": 1,
          "email": "customer@example.com",
          "name": "Jane Smith",
          "phoneNumber": "111-222-3333"
      }
    • 404 Not Found: Customer account not found.
      {
          "error": "Customer not found."
      }

5. Customer Login

  • URI: POST /customers/login
  • Description: Authenticates a customer with email and password.
  • Associated Requirement(s): FR5.8
  • Parameters: None
  • Request Body:
    {
        "email": "customer@example.com",
        "password": "Secure@Pass1"
    }
  • Response:
    • 200 OK: Customer logged in successfully.
      {
          "customerId": 1,
          "email": "customer@example.com",
          "name": "Jane Smith",
          "phoneNumber": "111-222-3333"
      }
    • 400 Bad Request: Invalid email or password.
      {
          "error": "Invalid email or password."
      }

6. View Order History

  • URI: GET /customers/{customerId}/orders
  • Description: Retrieves the order history of a specific customer.
  • Associated Requirement(s): FR9
  • Parameters:
    • customerId (integer, path parameter, required): The ID of the customer whose order history is being retrieved.
  • Request Body: None
  • Response:
    • 200 OK: Order history retrieved successfully.
      {
          "orders": [
              {
                  "orderId": 101,
                  "date": "2024-10-22",
                  "total": 99.99
              },
              {
                  "orderId": 102,
                  "date": "2024-11-01",
                  "total": 49.99
              }
          ]
      }
    • 404 Not Found: Customer not found.
      {
          "error": "Customer not found."
      }

7. View Wishlist

  • URI: GET /customers/{customerId}/wishlist
  • Description: Retrieves the wishlist of a specific customer.
  • Associated Requirement(s): FR10
  • Parameters:
    • customerId (integer, path parameter, required): The ID of the customer whose wishlist is being retrieved.
  • Request Body: None
  • Response:
    • 200 OK: Wishlist retrieved successfully.
      {
          "games": [
              {
                  "gameId": 1,
                  "name": "Sample Game",
                  "price": 59.99
              },
              {
                  "gameId": 2,
                  "name": "Sample Game 2",
                  "price": 49.99
              }
          ]
      }
    • 404 Not Found: Customer not found.
      {
          "error": "Customer not found."
      }

Employees

1. Create Employee Account

  • URI: POST /employees
  • Description: Creates a new employee account with the provided details.
  • Associated Requirement(s): FR5.8, NFR2
  • Request Body:
{
  "email": "employee@example.com", 
  "password": "password123",     
  "name": "John Doe",        
  "phoneNumber": "123-456-789",  
  "isActive": "true"
}
  • Response Body:
    • 200 OK: Employee account created successfully.
    • 400 Bad Request: TBD...

2. Update Employee Account

  • URI: PUT /employees/{employeeId}
  • Description: Updates an existing employee account with the provided details.
  • Associated Requirement(s): TBD
  • Parameters: employeeId (integer): The ID of the employee to update.
  • Request Body:
{
  "email": "employee@example.com", 
  "password": "password123",     
  "name": "John Doe V2",        
  "phoneNumber": "123-456-789",  
  "isActive": "true"
}
  • Response Body:
    • 200 OK: Employee's details on successful update.
    {
      "staffId": "1",     
      "email": "employee@example.com",      
      "name": "John Doe V2",         
      "phoneNumber": "123-456-789",  
      "isActive": "true"    
    }
    • 400 Bad Request: TBD

3. Deactivate Employee Account

  • URI: PUT /employees/{employeeId}/deactivate
  • Description: Deactivates an existing employee account by the employee ID.
  • Associated Requirement(s): TBD
  • Parameters: employeeId (integer): The ID of the employee to deactivate.
  • Response Body:
    • 200 OK: Employee's account has been deactivated successfully.
    {
      "staffId": "1",  
      "email": "employee@example.com",       
      "name": "John Doe",        
      "phoneNumber": "123-456-789", 
      "isActive": "false"     
    }
    • 400 Bad Request: TBD

4. Employee Login

  • URI: POST /employees/login
  • Description: Authenticates an employee's login attempt with email and password.
  • Associated Requirement(s): TBD
  • Request Body:
{
  "email": "employee@example.com", 
  "password": "password123",     
  "name": "John Doe",        
  "phoneNumber": "123-456-789",  
  "isActive": "true"
}
  • Response Body:
    • 200 OK: Employee's details on successful login.
    {
      "staffId": "1",  
      "email": "employee@example.com",       
      "name": "John Doe",        
      "phoneNumber": "123-456-789", 
      "isActive": "true"     
    }
    • 400 Bad Request: Invalid email or password.

5. Monitor All Employee Activities

  • URI: GET /employees/activities
  • Description: Retrieves a log of all employee activities, including actions taken on the system.
  • Associated Requirement(s): TBD
  • Response Body:
    • 200 OK: Activity logs retrieved successfully.
    [
      {
        "logId": "integer",      
        "content": "string",      
        "employeeId": "integer"    
      },
       ...
    ]
    
    • 400 Bad Request: TBD

6. Monitor Specific Employee Activities

  • URI: GET /employees/{employeeId}/activities
  • Description: Retrieves a log of activities for a specific employee identified by their ID.
  • Associated Requirement(s): TBD
  • Parameters: employeeId (integer): The ID of the employee whose activities are to be retrieved.
  • Response Body:
    • 200 OK: Activity logs retrieved successfully.
    [
      {
       "logId": "integer",    
       "content": "string"   
      },
      ...
    ]
    • 400 Bad Request: TBD

Manager

1. Manager Login

  • URI: POST /manager/login
  • Description: Authenticates a manager by email and password.
  • Associated Requirement(s): FR5.8, NFR2
  • Request Body:
    {
        "email": "manager@example.com",
        "password": "password123"
    }
  • Response:
    • 200 OK: Manager details on successful login.
      {
          "staffId": 1,
          "email": "manager@example.com",
          "name": "John Doe",
          "phoneNumber": "123-456-7890"
      }
    • 400 Bad Request: Invalid email or password.

2. Create Manager

  • URI: POST /manager/
  • Description: Creates a new manager account. Only one manager allowed.
  • Associated Requirement(s): FR5.4, NFR1, NFR3
  • Request Body:
    {
        "email": "manager@example.com",
        "password": "Strong@Pass1",
        "name": "John Doe",
        "phoneNumber": "123-456-7890"
    }
  • Response:
    • 200 OK: Manager created successfully.
    • 409 Conflict: Manager account already exists.
    • 400 Bad Request: Password requirements not met.

3. Update Manager

  • URI: PUT /manager/
  • Description: Updates details for an existing manager.
  • Associated Requirement(s): FR5.5, NFR1
  • Request Body:
    {
        "email": "manager@example.com",
        "password": "New@Pass123",
        "name": "Jane Doe",
        "phoneNumber": "987-654-3210"
    }
  • Response:
    • 200 OK: Manager details updated successfully.
    • 404 Not Found: Manager not found.
    • 400 Bad Request: Password requirements not met.

Store

Store

1. View Store Policies

  • URI: GET /store/policy
  • Description: Retrieves the current store policy. This endpoint allows employees and managers to view the details of the store's policy.
  • Associated Requirement(s): FR7
  • Parameters: None
  • Request Body: None
  • Response:
    • 200 OK: Store policy retrieved successfully.
      {
          "storePolicy": "Return policy: No returns after 30 days."
      }
    • 404 Not Found: No store policy exists.
      {
          "error": "Store policy not found."
      }

2. Manage Store Policies

  • URI: PUT /store/policy
  • Description: Updates the store policy with new details. This endpoint requires valid input to modify the policy.
  • Associated Requirement(s): FR7.1
  • Parameters: None
  • Request Body:
    {
        "storePolicy": "Updated policy: Returns accepted within 15 days."
    }
  • Response:
    • 200 OK: Store policy updated successfully.
      {
          "storePolicy": "Updated policy: Returns accepted within 15 days."
      }
    • 404 Not Found: No existing store policy to update.
      {
          "error": "Store policy not found."
      }

3. Create Store Policy

  • URI: POST /store/policy
  • Description: Creates a new store policy. If a policy already exists, this action is not permitted.
  • Associated Requirement(s): FR7.1
  • Parameters: None
  • Request Body:
    {
        "storePolicy": "Return policy: No returns after 30 days."
    }
  • Response:
    • 200 OK: Store policy created successfully.
      {
          "storePolicy": "Return policy: No returns after 30 days."
      }
    • 409 Conflict: A store policy already exists.
      {
          "error": "Store policy already exists."
      }
    • 400 Bad Request: Invalid input provided (e.g., empty policy).
      {
          "error": "Invalid store policy."
      }

4. View Sales Metrics

  • URI: GET /store/sales/metrics
  • Description: Retrieves the store’s sales metrics, including total orders, total customers, total games sold, and total revenue.
  • Associated Requirement(s): FR7.5
  • Parameters: None
  • Request Body: None
  • Response:
    • 200 OK: Sales metrics retrieved successfully.
      {
          "totalOrders": 0,
          "totalCustomers": 0,
          "totalGamesSold": 0,
          "totalSales": 0.0
      }

5. Delete Store Policy

  • URI: DELETE /store/policy
  • Description: Deletes the current store policy, if one exists. Only managers are authorized to perform this action.
  • Associated Requirement(s): FR7.1
  • Parameters: None
  • Request Body: None
  • Response:
    • 200 OK: Store policy deleted successfully.
      {
          "message": "Store policy deleted successfully."
      }
    • 404 Not Found: No store policy exists to delete.
      {
          "error": "Store policy not found."
      }

6. Add Promotion

  • URI: POST /store/promotions
  • Description: Creates a new promotion for the store. Promotions allow discounts to be applied to games.
  • Associated Requirement(s): FR7.2
  • Parameters: None
  • Request Body:
    {
        "name": "Holiday Sale",
        "discount": 20.0,
        "startDate": "2024-12-01",
        "endDate": "2024-12-31"
    }
  • Response:
    • 200 OK: Promotion created successfully.
      {
          "promotionId": 1,
          "name": "Holiday Sale",
          "discount": 20.0,
          "startDate": "2024-12-01",
          "endDate": "2024-12-31"
      }
    • 400 Bad Request: Invalid promotion details.
      {
          "error": "Invalid promotion details."
      }

7. View Promotions

  • URI: GET /store/promotions
  • Description: Retrieves a list of all current promotions in the store.
  • Associated Requirement(s): FR7.2
  • Parameters: None
  • Request Body: None
  • Response:
    • 200 OK: Promotions retrieved successfully.
      [
          {
              "promotionId": 1,
              "name": "Holiday Sale",
              "discount": 20.0,
              "startDate": "2024-12-01",
              "endDate": "2024-12-31"
          },
          {
              "promotionId": 2,
              "name": "Black Friday Sale",
              "discount": 30.0,
              "startDate": "2024-11-24",
              "endDate": "2024-11-27"
          }
      ]

Clone this wiki locally