From 707c0436c56e457b5e16e3904e35546bf558e566 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Mon, 1 Dec 2025 03:23:24 -0800 Subject: [PATCH] api: add update endpoints for characters, weapons, and summons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add PATCH/PUT update actions to all three entity controllers with editor role authorization. Routes updated to include :update action. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/controllers/api/v1/characters_controller.rb | 14 ++++++++++++-- app/controllers/api/v1/summons_controller.rb | 14 ++++++++++++-- app/controllers/api/v1/weapons_controller.rb | 14 ++++++++++++-- config/routes.rb | 6 +++--- 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/app/controllers/api/v1/characters_controller.rb b/app/controllers/api/v1/characters_controller.rb index c18fd44..9b3e590 100644 --- a/app/controllers/api/v1/characters_controller.rb +++ b/app/controllers/api/v1/characters_controller.rb @@ -5,8 +5,8 @@ module Api class CharactersController < Api::V1::ApiController include IdResolvable - before_action :set, only: %i[show related download_images download_status] - before_action :ensure_editor_role, only: %i[create validate download_images] + before_action :set, only: %i[show related download_images download_status update] + before_action :ensure_editor_role, only: %i[create update validate download_images] # GET /characters/:id def show @@ -34,6 +34,16 @@ module Api end end + # PATCH/PUT /characters/:id + # Updates an existing character record + def update + if @character.update(character_params) + render json: CharacterBlueprint.render(@character, view: :full) + else + render_validation_error_response(@character) + end + end + # GET /characters/validate/:granblue_id # Validates that a granblue_id has accessible images on Granblue servers def validate diff --git a/app/controllers/api/v1/summons_controller.rb b/app/controllers/api/v1/summons_controller.rb index 036cc8f..68cdf80 100644 --- a/app/controllers/api/v1/summons_controller.rb +++ b/app/controllers/api/v1/summons_controller.rb @@ -5,8 +5,8 @@ module Api class SummonsController < Api::V1::ApiController include IdResolvable - before_action :set, only: %i[show download_images download_status] - before_action :ensure_editor_role, only: %i[create validate download_images] + before_action :set, only: %i[show download_images download_status update] + before_action :ensure_editor_role, only: %i[create update validate download_images] # GET /summons/:id def show @@ -25,6 +25,16 @@ module Api end end + # PATCH/PUT /summons/:id + # Updates an existing summon record + def update + if @summon.update(summon_params) + render json: SummonBlueprint.render(@summon, view: :full) + else + render_validation_error_response(@summon) + end + end + # GET /summons/validate/:granblue_id # Validates that a granblue_id has accessible images on Granblue servers def validate diff --git a/app/controllers/api/v1/weapons_controller.rb b/app/controllers/api/v1/weapons_controller.rb index edc22ae..cd21914 100644 --- a/app/controllers/api/v1/weapons_controller.rb +++ b/app/controllers/api/v1/weapons_controller.rb @@ -5,8 +5,8 @@ module Api class WeaponsController < Api::V1::ApiController include IdResolvable - before_action :set, only: %i[show download_images download_status] - before_action :ensure_editor_role, only: %i[create validate download_images] + before_action :set, only: %i[show download_images download_status update] + before_action :ensure_editor_role, only: %i[create update validate download_images] # GET /weapons/:id def show @@ -25,6 +25,16 @@ module Api end end + # PATCH/PUT /weapons/:id + # Updates an existing weapon record + def update + if @weapon.update(weapon_params) + render json: WeaponBlueprint.render(@weapon, view: :full) + else + render_validation_error_response(@weapon) + end + end + # GET /weapons/validate/:granblue_id # Validates that a granblue_id has accessible images on Granblue servers def validate diff --git a/config/routes.rb b/config/routes.rb index 27269e4..fadd72e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,7 +12,7 @@ Rails.application.routes.draw do resources :grid_weapons, only: %i[create update destroy] resources :grid_characters, only: %i[create update destroy] resources :grid_summons, only: %i[create update destroy] - resources :weapons, only: %i[show create] do + resources :weapons, only: %i[show create update] do collection do get 'validate/:granblue_id', action: :validate, as: :validate end @@ -21,7 +21,7 @@ Rails.application.routes.draw do get 'download_status' end end - resources :characters, only: %i[show create] do + resources :characters, only: %i[show create update] do collection do get 'validate/:granblue_id', action: :validate, as: :validate end @@ -30,7 +30,7 @@ Rails.application.routes.draw do get 'download_status' end end - resources :summons, only: %i[show create] do + resources :summons, only: %i[show create update] do collection do get 'validate/:granblue_id', action: :validate, as: :validate end