CustomAmmunitionController - xEdziu/RPG-Handy-Helper GitHub Wiki

CpRedCustomAmmunitionController

This page contains documentation for the CpRedCustomAmmunitionController class, which handles custom ammunition management for Cyberpunk Red.

Basic Information

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

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

Field Descriptions

Request Body Fields (CustomAmmunitionDto)

  • gameId (Long): ID of the game this ammunition belongs to. Required.
  • name (String): Name of the ammunition. Required.
  • description (String): Description of the ammunition. Required.
  • pricePerBullet (Integer): Price per bullet. Required.
  • availability (String): Availability status. Required. Possible values: CHEAP, EVERYDAY, COSTLY, PREMIUM, EXPENSIVE, VERY_EXPENSIVE, LUXURY, SUPER_LUXURY.

Response Fields

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

Endpoint Details

Get All Custom Ammunition

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

Response

{
  "customAmmunition": [
    {
      "gameId": 1,
      "name": "Customowa amunicja",
      "description": "Customowa amunicja do broni palnej.",
      "pricePerBullet": 20,
      "availability": "COSTLY"
    }
  ],
  "message": "Customowa amunicja została pobrana.",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 401 Unauthorized: User is not logged in.

Get Custom Ammunition by ID

Method: GET
Path: /rpgSystems/cpRed/customAmmunition/{ammunitionId}

Response

{
  "customAmmunition": {
    "gameId": 1,
    "name": "Customowa amunicja",
    "description": "Customowa amunicja do broni palnej.",
    "pricePerBullet": 20,
    "availability": "COSTLY"
  },
  "message": "Customowa amunicja została pobrana.",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 400 Bad Request: Invalid custom ammunition ID.
  • 401 Unauthorized: User is not logged in.
  • 404 Not Found:Custom Ammunition with the specified ID does not exist.

Get Custom Ammunition by Game ID

Method: GET
Path: /rpgSystems/cpRed/customAmmunition/game/{gameId}

Response

{
  "customAmmunition": [
    {
      "gameId": 1,
      "name": "Customowa amunicja",
      "description": "Customowa amunicja do broni palnej.",
      "pricePerBullet": 20,
      "availability": "COSTLY"
    },
    {
      "gameId": 1,
      "name": "Customowa amunicja ale lepsza",
      "description": "Może i lata jak zwykła amunicja ale za to jest głośniejsza. Zapytasz więc czemu lepsza? Bo jest droższa.",
      "pricePerBullet": 20,
      "availability": "COSTLY"
    }
  ],
  "message": "Customowa amunicja dla gry została pobrana.",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

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

Get All Custom Ammunition with Admin Data

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

Response

{
  "customAmmunition": [],
  "message": "Customowa amunicja została pobrana dla administratora.",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

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

Add New Custom Ammunition

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

Request

{
  "gameId": 1,
  "name": "Amunicja EMP 2",
  "description": "Amunicja EMP, która wyłącza elektronikę w pojazdach i broniach.",
  "pricePerBullet": 20,
  "availability": "SUPER_LUXURY"
}

Response

{
  "message": "Customowa amunicja została dodana.",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 400 Bad Request: User not authenticated.
  • 401 Unauthorized: User not logged in.
  • 404 Not Found: Invalid custom ammunition data.

Update Custom Ammunition

Method: PUT
Path: /admin/rpgSystems/cpRed/customAmmunition/update/{ammunitionId}

Request

{
  "gameId": 1,
  "name": "Amunicja EMP zmodyfikowany 3",
  "description": "Amunicja EMP, która wyłącza elektronikę w pojazdach i broniach.",
  "pricePerBullet": 2000,
  "availability": "COSTLY"
}

Response

{
  "message": "Customowa amunicja została zmodyfikowana.",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 400 Bad Request: Invalid custom ammunition ID or data.
  • 401 Unauthorized: User not logged in.
  • 404 Not Found:Custom ammunition 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** ⚠️