Use resources to declare API TOS access endpoints (#38416)
This commit is contained in:
1 parent
e81a4e258c
commit
b321d5d377
4 files changed
+83
-37
No files matched your search
@@ -0,0 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::Instances::TermsOfServiceController < Api::V1::Instances::BaseController
|
||||
before_action :cache_even_if_authenticated!
|
||||
|
||||
def index
|
||||
@terms_of_service = TermsOfService.current || raise(ActiveRecord::RecordNotFound)
|
||||
render json: @terms_of_service, serializer: REST::TermsOfServiceSerializer
|
||||
end
|
||||
|
||||
def show
|
||||
@terms_of_service = TermsOfService.published.find_by!(effective_date: params[:date])
|
||||
render json: @terms_of_service, serializer: REST::TermsOfServiceSerializer
|
||||
end
|
||||
end
|
||||
@@ -1,23 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::Instances::TermsOfServicesController < Api::V1::Instances::BaseController
|
||||
before_action :set_terms_of_service
|
||||
|
||||
def show
|
||||
cache_even_if_authenticated!
|
||||
render json: @terms_of_service, serializer: REST::TermsOfServiceSerializer
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_terms_of_service
|
||||
@terms_of_service = begin
|
||||
if params[:date].present?
|
||||
TermsOfService.published.find_by!(effective_date: params[:date])
|
||||
else
|
||||
TermsOfService.current
|
||||
end
|
||||
end
|
||||
not_found if @terms_of_service.nil?
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user