2022-05-16 08:29:59 +00:00
|
|
|
class Api::V1::Accounts::PortalsController < Api::V1::Accounts::BaseController
|
2020-09-25 21:02:34 +00:00
|
|
|
before_action :fetch_portal, except: [:index, :create]
|
|
|
|
|
|
|
|
def index
|
2022-05-16 08:29:59 +00:00
|
|
|
@portals = Current.account.portals
|
2020-09-25 21:02:34 +00:00
|
|
|
end
|
|
|
|
|
2022-04-20 10:30:37 +00:00
|
|
|
def show; end
|
|
|
|
|
2020-09-25 21:02:34 +00:00
|
|
|
def create
|
2022-05-16 08:29:59 +00:00
|
|
|
@portal = Current.account.portals.create!(portal_params)
|
2020-09-25 21:02:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@portal.update!(portal_params)
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2022-03-24 07:58:25 +00:00
|
|
|
@portal.destroy!
|
2020-09-25 21:02:34 +00:00
|
|
|
head :ok
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def fetch_portal
|
2022-05-16 08:29:59 +00:00
|
|
|
@portal = Current.account.portals.find_by(slug: permitted_params[:id])
|
2022-04-20 10:30:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def permitted_params
|
|
|
|
params.permit(:id)
|
2020-09-25 21:02:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def portal_params
|
|
|
|
params.require(:portal).permit(
|
2022-05-16 08:29:59 +00:00
|
|
|
:account_id, :color, :custom_domain, :header_text, :homepage_link, :name, :page_title, :slug, :archived
|
2020-09-25 21:02:34 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|