RpgSystemsController - xEdziu/RPG-Handy-Helper GitHub Wiki

RpgSystemsController

This page contains documentation for the RpgSystemsController class, which handles RPG system retrieval and creation.

Basic Information

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

Authentication

  • All user endpoints require a valid XSRF token.
  • Admin endpoints require appropriate admin privileges.

Endpoint Summary

HTTP Method Path Description
GET /rpgSystems/{rpgSystemsId} Retrieves a specific RPG system by ID
GET /rpgSystems/all Retrieves all RPG systems
POST /admin/rpgSystems/create Creates a new RPG system (Admin only)

Field Descriptions

Request Body Fields (RpgSystems)

  • name (String): Name of the RPG system. Required, max 255 characters.
  • description (String): Description of the system. Required, max 1000 characters.

Response Fields

  • message (String): Describes the result of the operation.
  • error (Integer): HTTP status code.
  • timestamp (String): Time the response was generated.
  • rpgSystem (Object): A single RPG system object (if applicable).
  • rpgSystems (Array): List of RPG systems (if applicable).

Example RPG System Object

{
  "id": 1,
  "name": "Cyberpunk RED",
  "description": "Futuristic role-playing game set in a dystopian world."
}

Endpoint Details

Get RPG System by ID

Method: GET
Path: /rpgSystems/{rpgSystemsId}

Response

{
  "rpgSystem": { ... },
  "message": "System został pobrany.",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 404 Not Found: System with the given ID does not exist.

Get All RPG Systems

Method: GET
Path: /rpgSystems/all

Response

{
  "rpgSystems": [ { ... } ],
  "message": "Systemy zostały pobrane.",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 401 Unauthorized: User is not authenticated.

Create New RPG System

Method: POST
Path: /admin/rpgSystems/create

Request Body

{
  "name": "Cyberpunk RED",
  "description": "Futuristic role-playing game set in a dystopian world."
}

Response

{
  "message": "System został dodany",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 400 Bad Request: Empty or too long name/description.
  • 409 Conflict: RPG system with the same name already exists.

Common Troubleshooting Tips

  • Missing or invalid fields: Ensure name and description are both non-empty and within length limits.
  • Permission errors: Make sure the request to /admin/... routes is made by an admin user.
  • Duplicate name: Use a unique RPG system name.