Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ gem "bootsnap", require: false
# Used for our import of the card data.
gem "activerecord-import"

gem 'jsonapi-resources'

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri mingw x64_mingw ]
Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ GEM
io-wait (0.2.1)
irb (1.4.1)
reline (>= 0.3.0)
jsonapi-resources (0.10.6)
activerecord (>= 4.1)
concurrent-ruby
railties (>= 4.1)
loofah (2.13.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
Expand Down Expand Up @@ -194,6 +198,7 @@ DEPENDENCIES
debug
factory_bot_rails
faker
jsonapi-resources
pg (~> 1.1)
puma (~> 5.0)
rails (~> 7.0.1)
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/api/v3/public/card_cycles_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module API
module V3
module Public
class Api::V3::Public::CardCyclesController < JSONAPI::ResourceController
end
end
end
end
8 changes: 8 additions & 0 deletions app/controllers/api/v3/public/card_set_types_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module API
module V3
module Public
class Api::V3::Public::CardSetTypesController < JSONAPI::ResourceController
end
end
end
end
8 changes: 8 additions & 0 deletions app/controllers/api/v3/public/card_sets_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module API
module V3
module Public
class Api::V3::Public::CardSetsController < JSONAPI::ResourceController
end
end
end
end
8 changes: 8 additions & 0 deletions app/controllers/api/v3/public/card_types_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module API
module V3
module Public
class Api::V3::Public::CardTypesController < JSONAPI::ResourceController
end
end
end
end
8 changes: 8 additions & 0 deletions app/controllers/api/v3/public/cards_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module API
module V3
module Public
class Api::V3::Public::CardsController < JSONAPI::ResourceController
end
end
end
end
8 changes: 8 additions & 0 deletions app/controllers/api/v3/public/factions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module API
module V3
module Public
class Api::V3::Public::FactionsController < JSONAPI::ResourceController
end
end
end
end
8 changes: 8 additions & 0 deletions app/controllers/api/v3/public/printings_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module API
module V3
module Public
class Api::V3::Public::PrintingsController < JSONAPI::ResourceController
end
end
end
end
8 changes: 8 additions & 0 deletions app/controllers/api/v3/public/sides_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module API
module V3
module Public
class Api::V3::Public::SidesController < JSONAPI::ResourceController
end
end
end
end
8 changes: 8 additions & 0 deletions app/controllers/api/v3/public/subtypes_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module API
module V3
module Public
class Api::V3::Public::SubtypesController < JSONAPI::ResourceController
end
end
end
end
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
class ApplicationController < ActionController::API
include JSONAPI::ActsAsResourceController
end
1 change: 0 additions & 1 deletion app/models/side.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

class Side < ApplicationRecord
# TODO(plural): Add an association for factions.
has_many :cards
end
10 changes: 10 additions & 0 deletions app/resources/api/v3/public/card_cycle_resource.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module API
module V3
module Public
class Api::V3::Public::CardCycleResource < JSONAPI::Resource
attributes :name, :description, :updated_at
key_type :string
end
end
end
end
11 changes: 11 additions & 0 deletions app/resources/api/v3/public/card_resource.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module API
module V3
module Public
class Api::V3::Public::CardResource < JSONAPI::Resource
# TODO(plural): get the relationships in here and possibly replace the keywords field.
attributes :name, :card_type_id, :side_id, :faction_id, :advancement_requirement, :agenda_points, :base_link, :cost, :deck_limit, :influence_cost, :influence_limit, :memory_cost, :minimum_deck_size, :strength, :text, :trash_cost, :uniqueness, :keywords, :updated_at
key_type :string
end
end
end
end
11 changes: 11 additions & 0 deletions app/resources/api/v3/public/card_set_resource.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module API
module V3
module Public
class Api::V3::Public::CardSetResource < JSONAPI::Resource
# TODO(plural): Add relationships in here.
attributes :name, :date_release, :size, :card_cycle_id, :card_set_type_id, :updated_at
key_type :string
end
end
end
end
10 changes: 10 additions & 0 deletions app/resources/api/v3/public/card_set_type_resource.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module API
module V3
module Public
class Api::V3::Public::CardSetTypeResource < JSONAPI::Resource
attributes :name, :description, :updated_at
key_type :string
end
end
end
end
10 changes: 10 additions & 0 deletions app/resources/api/v3/public/card_type_resource.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module API
module V3
module Public
class Api::V3::Public::CardTypeResource < JSONAPI::Resource
attributes :name, :updated_at
key_type :string
end
end
end
end
10 changes: 10 additions & 0 deletions app/resources/api/v3/public/faction_resource.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module API
module V3
module Public
class Api::V3::Public::FactionResource < JSONAPI::Resource
attributes :name, :is_mini, :updated_at
key_type :string
end
end
end
end
11 changes: 11 additions & 0 deletions app/resources/api/v3/public/printing_resource.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module API
module V3
module Public
class Api::V3::Public::PrintingResource < JSONAPI::Resource
# TODO: add relationships in here.
attributes :card_id, :card_set_id, :printed_text, :printed_uniqueness, :flavor, :illustrator, :position, :quantity, :date_release, :updated_at
key_type :string
end
end
end
end
10 changes: 10 additions & 0 deletions app/resources/api/v3/public/side_resource.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module API
module V3
module Public
class Api::V3::Public::SideResource < JSONAPI::Resource
attributes :name, :updated_at
key_type :string
end
end
end
end
12 changes: 12 additions & 0 deletions app/resources/api/v3/public/subtype_resource.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module API
module V3
module Public
class Api::V3::Public::SubtypeResource < JSONAPI::Resource
attributes :name, :updated_at
key_type :string

paginator :offset
end
end
end
end
3 changes: 1 addition & 2 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false

# Do not eager load code on boot.
config.eager_load = false
config.eager_load = true

# Show full error reports.
config.consider_all_requests_local = true
Expand Down
19 changes: 15 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
Rails.application.routes.draw do
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html

# Defines the root path route ("/")
# root "articles#index"
namespace :api do
namespace :v3 do
namespace :public, defaults: { format: :json } do
jsonapi_resources :card_cycles, only: [:index, :show]
jsonapi_resources :card_sets, only: [:index, :show]
jsonapi_resources :card_set_types, only: [:index, :show]
jsonapi_resources :cards, only: [:index, :show]
jsonapi_resources :card_types, only: [:index, :show]
jsonapi_resources :factions, only: [:index, :show]
jsonapi_resources :printings, only: [:index, :show]
jsonapi_resources :sides, only: [:index, :show]
jsonapi_resources :subtypes, only: [:index, :show]
end
end
end
end