Add controller, blueprint and route for JobAccessories

This commit is contained in:
Justin Edmund 2023-01-23 20:52:20 -08:00
parent c474d8030b
commit ea7650a9bb
3 changed files with 33 additions and 0 deletions

View file

@ -0,0 +1,20 @@
# frozen_string_literal: true
module Api
module V1
class JobAccessoryBlueprint < ApiBlueprint
field :name do |skill|
{
en: skill.name_en,
ja: skill.name_jp
}
end
association :job,
name: :job,
blueprint: JobBlueprint
fields :granblue_id, :rarity, :release_date
end
end
end

View file

@ -0,0 +1,12 @@
# frozen_string_literal: true
module Api
module V1
class JobAccessoriesController < Api::V1::ApiController
def job
accessories = JobAccessory.where('job_id = ?', params[:id])
render json: JobAccessoryBlueprint.render(accessories)
end
end
end
end

View file

@ -34,6 +34,7 @@ Rails.application.routes.draw do
get 'jobs/skills', to: 'job_skills#all'
get 'jobs/:id/skills', to: 'job_skills#job'
get 'jobs/:id/accessories', to: 'job_accessories#job'
get 'raids', to: 'raids#all'
get 'weapon_keys', to: 'weapon_keys#all'