ClassesController - xEdziu/RPG-Handy-Helper GitHub Wiki

CpRedClassesController

This page contains documentation for the CpRedClassesController class, which handles classes management for Cyberpunk Red.

Basic Information

Base Path: /api/v1/authorized
Package: dev.goral.rpghandyhelper.rpgSystems.cpRed.manual.classes

Authentication

All requests to this controller require an XSRF token to be included in the headers.
Example:

headers: {
  "X-XSRF-TOKEN": "<csrfToken>"
}

Endpoint Summary

HTTP Method Path Description
GET /rpgSystems/cpRed/classes/all Returns basic info about all available classes
GET /rpgSystems/cpRed/classes/{clasId} Returns detailed information about a specific class by ID
GET /admin/rpgSystems/cpRed/classes/all Returns a full list of all classes types with administrative data
POST /admin/rpgSystems/cpRed/classes/add Adds a new class type to the system
PUT /admin/rpgSystems/cpRed/classes/update/{classId} Update class data

Field Descriptions

Request Body Fields (ClassDto)

  • name (String): Name of the class. Required.
  • description (String): Description of the class. Required.

Response Fields

  • message (String): Describes the result of the operation.
  • error (Integer): HTTP status code.
  • timestamp (String): Time the response was generated.
  • classes (Object): A single class object (if applicable).
  • classesList (Array): List of classes (if applicable).

Endpoint Details

Get All Classes

Method: GET
Path: /rpgSystems/cpRed/classes/all

Response

{
  "classes": [
    {
      "name": "Kowal",
      "description": "Kuje przedmioty"
    }
  ],
  "message": "Pobrano klasy",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 401 Unauthorized: User is not logged in.

Get classes by ID

Method: GET
Path: /rpgSystems/cpRed/classes/{classId}

Response

{
  "message": "Pobrano klasę",
  "error": 200,
  "class": {
    "name": "Kowal",
    "description": "Kuje przedmioty"
  },
  "timestamp": "..."
}

Possible Errors

  • 400 Bad Request: Invalid classes ID.
  • 401 Unauthorized: User is not logged in.
  • 404 Not Found: class with the specified ID does not exist.

Get All classes with Admin Data

Method: GET
Path: admin/rpgSystems/cpRed/classes/all

Response

{
  "classes": [
    {
      "id": 1,
      "name": "Kowal",
      "description": "Kuje przedmioty"
    }
  ],
  "message": "Pobrano klasy",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 401 Unauthorized: User is not logged in.
  • 403 Forbidden: User is not an admin.

Add New class

Method: POST
Path: /admin/rpgSystems/cpRed/classes/add

Request

{
  "name": "Kowal",
  "description": "Kuje przedmioty"
}

Response

{
  "message": "Klasa Kowal została dodana",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 400 Bad Request: User not authenticated.
  • 401 Unauthorized: User not logged in.
  • 403 Forbidden: User is not an admin.
  • 404 Not Found: Invalid class data.

Update classes

Method: PUT
Path: /admin/rpgSystems/cpRed/classes/update/{classId}

Request

{
  "name": "Nowy Kowal",
  "description": "Kuje lepsze przedmioty"
}

Response

{
  "message": "Klasa Nowy Kowal została zaktualizowana",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 400 Bad Request: Invalid classes ID or data.
  • 401 Unauthorized: User not logged in.
  • 403 Forbidden: User is not an admin.
  • 404 Not Found: class with the specified ID does not exist.

Common Troubleshooting Tips

  • Missing XSRF Token: Ensure the X-XSRF-TOKEN header is included in every request.
  • Invalid Fields: Double-check the request body for missing or invalid fields.
  • Permission Issues: Verify that the user has the necessary permissions for the requested operation.
⚠️ **GitHub.com Fallback** ⚠️