ArmorsController - xEdziu/RPG-Handy-Helper GitHub Wiki

CpRedArmorsController

This page contains documentation for the CpRedArmorsController class, which handles armors management for Cyberpunk Red.

Basic Information

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

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/armors/all Returns basic info about all available armors
GET /rpgSystems/cpRed/armors/{armorId} Returns detailed information about a specific armor by ID
GET /admin/rpgSystems/cpRed/armors/all Returns a full list of all armors types with administrative data
POST /admin/rpgSystems/cpRed/armors/add Adds a new armor type to the system
PUT /admin/rpgSystems/cpRed/armors/update/{armorId} Update armor data

Field Descriptions

Request Body Fields (ArmorDto)

  • type (String): Type of the armor. Possible values: LEATHER, KEVLAR, LIGHT_ARMORJACK, BODYWEIGHT_SUIT, MEDIUM_ARMORJACK, HEAVY_ARMORJACK, FLAK, METALGEAR, BULLETPROOF_SHIELD.
  • armorPoints (Integer): Number of armor points. Required.
  • penalty (Integer): Penalty to the character's actions when wearing this armor. Required.
  • price (Integer): Price for armor in eurodollars. Required.
  • availability (String): Availability status. Required. Possible values: CHEAP, EVERYDAY, COSTLY, PREMIUM, EXPENSIVE, VERY_EXPENSIVE, LUXURY, SUPER_LUXURY.
  • -description (String): Description of the armor. Required.

Response Fields

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

Endpoint Details

Get All Armors

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

Response

{
  "armors": [
    {
      "type": "KEVLAR",
      "armorPoints": 5,
      "penalty": 1,
      "price": 100,
      "availability": "CHEAP",
      "description": "A lightweight armor made of Kevlar, providing decent protection against small arms fire."
    }
  ],
  "message": "Pobrano pancerze",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 401 Unauthorized: User is not logged in.

Get Armor by ID

Method: GET
Path: /rpgSystems/cpRed/armors/{armorId}

Response

{
  "armor": {
    "type": "KEVLAR",
    "armorPoints": 5,
    "penalty": 1,
    "price": 100,
    "availability": "CHEAP",
    "description": "A lightweight armor made of Kevlar, providing decent protection against small arms fire."
  },
  "message": "Pobrano pancerz",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

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

Get All Armors with Admin Data

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

Response

{
  "armors": [
    {
      "id": 1,
      "type": "KEVLAR",
      "armorPoints": 5,
      "penalty": 1,
      "price": 100,
      "availability": "CHEAP",
      "description": "A lightweight armor made of Kevlar, providing decent protection against small arms fire."
    }
  ],
  "message": "Pobrano pancerze",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

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

Add New Armor

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

Request

{
  "type": "KEVLAR",
  "armorPoints": 5,
  "penalty": 1,
  "price": 100,
  "availability": "CHEAP",
  "description": "A lightweight armor made of Kevlar, providing decent protection against small arms fire."
}

Response

{
  "message": "Pancerz został dodany",
  "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 armor data.

Update Armor

Method: PUT
Path: /admin/rpgSystems/cpRed/armors/update/{armorId}

Request

{
  "type": "KEVLAR",
  "armorPoints": 6,
  "penalty": 1,
  "price": 120,
  "availability": "CHEAP",
  "description": "New armor."
}

Response

{
  "message": "Pancerz został zaktualizowany",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 400 Bad Request: Invalid armor ID or data.
  • 401 Unauthorized: User not logged in.
  • 403 Forbidden: User is not an admin.
  • 404 Not Found: Armor 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** ⚠️