From 6e837e5d189e543532a5615cc60df758239e043d Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Tue, 31 Jan 2023 21:48:00 -0800 Subject: [PATCH] Add endpoints for getting info about canonical items --- .../api/v1/characters_controller.rb | 19 +++++++++++++++++++ app/controllers/api/v1/summons_controller.rb | 19 +++++++++++++++++++ app/controllers/api/v1/weapons_controller.rb | 19 +++++++++++++++++++ config/routes.rb | 3 +++ db/schema.rb | 1 + 5 files changed, 61 insertions(+) create mode 100644 app/controllers/api/v1/characters_controller.rb create mode 100644 app/controllers/api/v1/summons_controller.rb create mode 100644 app/controllers/api/v1/weapons_controller.rb diff --git a/app/controllers/api/v1/characters_controller.rb b/app/controllers/api/v1/characters_controller.rb new file mode 100644 index 0000000..354f524 --- /dev/null +++ b/app/controllers/api/v1/characters_controller.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Api + module V1 + class CharactersController < Api::V1::ApiController + before_action :set + + def show + render json: CharacterBlueprint.render(@character) + end + + private + + def set + @character = Character.where(granblue_id: params[:id]).first + end + end + end +end diff --git a/app/controllers/api/v1/summons_controller.rb b/app/controllers/api/v1/summons_controller.rb new file mode 100644 index 0000000..f4ba9ea --- /dev/null +++ b/app/controllers/api/v1/summons_controller.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Api + module V1 + class SummonsController < Api::V1::ApiController + before_action :set + + def show + render json: SummonBlueprint.render(@summon) + end + + private + + def set + @summon = Summon.where(granblue_id: params[:id]).first + end + end + end +end diff --git a/app/controllers/api/v1/weapons_controller.rb b/app/controllers/api/v1/weapons_controller.rb new file mode 100644 index 0000000..2f163b4 --- /dev/null +++ b/app/controllers/api/v1/weapons_controller.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Api + module V1 + class WeaponsController < Api::V1::ApiController + before_action :set + + def show + render json: WeaponBlueprint.render(@weapon) + end + + private + + def set + @weapon = Weapon.where(granblue_id: params[:id]).first + end + end + end +end diff --git a/config/routes.rb b/config/routes.rb index 30c3180..fe827c9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,6 +11,9 @@ Rails.application.routes.draw do resources :grid_weapons, only: %i[update destroy] resources :grid_characters, only: %i[update destroy] resources :grid_summons, only: %i[update destroy] + resources :weapons, only: :show + resources :characters, only: :show + resources :summons, only: :show resources :favorites, only: [:create] get 'version', to: 'api#version' diff --git a/db/schema.rb b/db/schema.rb index 96513a7..2e115d4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -16,6 +16,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_31_084343) do enable_extension "pg_trgm" enable_extension "pgcrypto" enable_extension "plpgsql" + enable_extension "timescaledb" create_table "app_updates", primary_key: "updated_at", id: :datetime, force: :cascade do |t| t.string "update_type", null: false