From edf489ce310efe14e939fb1fbb7700b5b9e539dc Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Wed, 23 Feb 2022 19:04:34 -0800 Subject: [PATCH] Add route to get all raids --- app/controllers/api/v1/raids_controller.rb | 6 ++++++ app/views/api/v1/raids/all.json.rabl | 3 +++ app/views/api/v1/raids/base.json.rabl | 10 ++++++++++ config/routes.rb | 2 ++ 4 files changed, 21 insertions(+) create mode 100644 app/controllers/api/v1/raids_controller.rb create mode 100644 app/views/api/v1/raids/all.json.rabl create mode 100644 app/views/api/v1/raids/base.json.rabl diff --git a/app/controllers/api/v1/raids_controller.rb b/app/controllers/api/v1/raids_controller.rb new file mode 100644 index 0000000..cac3b93 --- /dev/null +++ b/app/controllers/api/v1/raids_controller.rb @@ -0,0 +1,6 @@ +class Api::V1::RaidsController < Api::V1::ApiController + def all + @raids = Raid.all() + render :all, status: :ok + end +end \ No newline at end of file diff --git a/app/views/api/v1/raids/all.json.rabl b/app/views/api/v1/raids/all.json.rabl new file mode 100644 index 0000000..b6abde3 --- /dev/null +++ b/app/views/api/v1/raids/all.json.rabl @@ -0,0 +1,3 @@ +collection @raids + +extends 'raids/base' diff --git a/app/views/api/v1/raids/base.json.rabl b/app/views/api/v1/raids/base.json.rabl new file mode 100644 index 0000000..b0909f9 --- /dev/null +++ b/app/views/api/v1/raids/base.json.rabl @@ -0,0 +1,10 @@ +object :raid + +attributes :id, :level, :group + +node :name do |r| + { + :en => r.name_en, + :jp => r.name_jp + } +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index caf5ca9..0134515 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,6 +20,8 @@ Rails.application.routes.draw do get 'search/weapons', to: 'search#weapons' get 'search/summons', to: 'search#summons' + get 'raids', to: 'raids#all' + post 'characters', to: 'grid_characters#create' post 'characters/update_uncap', to: 'grid_characters#update_uncap_level' delete 'characters', to: 'grid_characters#destroy'