Commit 38730cb5 authored by hellekin's avatar hellekin

Add API controllers

parent 1772e68b
# frozen_string_literal: true
class Api::V0::AddressesController < ApplicationController
def index
@addresses = policy_scope(Address)
render jsonapi: @addresses,
fields: params[:fields],
include: include_from_params
end
def show
@address = policy_scope(Address).find(params[:id])
authorize @address
render jsonapi: @address,
fields: params[:fields],
include: include_from_params
end
private
def model_types
%w(resource_addresses).freeze
end
end
# frozen_string_literal: true
class Api::V0::EmailsController < ApplicationController
def index
@emails = policy_scope(Email)
render jsonapi: @emails,
fields: params[:fields],
include: include_from_params
end
def show
@email = policy_scope(Email).find(params[:id])
authorize @email
render jsonapi: @email,
fields: params[:fields],
include: include_from_params
end
private
def model_types
%w(resource_emails).freeze
end
end
# frozen_string_literal: true
class Api::V0::LinksController < ApplicationController
def index
@links = policy_scope(Link)
render jsonapi: @links,
fields: params[:fields],
include: include_from_params
end
def show
@link = policy_scope(Link).find(params[:id])
authorize @link
render jsonapi: @link,
fields: params[:fields],
include: include_from_params
end
private
def model_types
%w(resource_links).freeze
end
end
# frozen_string_literal: true
class Api::V0::LocationsController < ApplicationController
def index
@locations = policy_scope(Location)
render jsonapi: @locations,
fields: params[:fields],
include: include_from_params
end
def show
@location = policy_scope(Location).find(params[:id])
authorize @location
render jsonapi: @location,
fields: params[:fields],
include: include_from_params
end
private
def model_types
%w(locatables positions)
end
end
# frozen_string_literal: true
class Api::V0::PhonesController < ApplicationController
def index
@phones = policy_scope(Phone)
render jsonapi: @phones,
fields: params[:fields],
include: include_from_params
end
def show
@phone = policy_scope(Phone).find(params[:id])
authorize @phone
render jsonapi: @phone,
fields: params[:fields],
include: include_from_params
end
private
def model_types
%w(resource_phones).freeze
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment