2020-12-16 00:31:30 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Api::V1::BookmarkCollectionsController < Api::BaseController
|
|
|
|
before_action :require_user!
|
|
|
|
before_action :set_bookmark_collections, only: :index
|
2020-12-17 06:34:00 +00:00
|
|
|
before_action :set_bookmark_collection, only: [:show, :update, :destroy, :update_status]
|
2020-12-16 00:31:30 +00:00
|
|
|
|
|
|
|
def index
|
2020-12-17 06:34:00 +00:00
|
|
|
render json: @bookmark_collections, each_serializer: REST::StatusBookmarkCollectionSerializer
|
2020-12-16 00:31:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2020-12-17 06:34:00 +00:00
|
|
|
@bookmark_collection = current_account.status_bookmark_collections.create!(resource_params)
|
|
|
|
render json: @bookmark_collection, serializer: REST::StatusBookmarkCollectionSerializer
|
2020-12-16 00:31:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
2020-12-17 06:34:00 +00:00
|
|
|
render json: @bookmark_collection, serializer: REST::StatusBookmarkCollectionSerializer
|
2020-12-16 00:31:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@bookmark_collection.update!(resource_params)
|
2020-12-17 06:34:00 +00:00
|
|
|
render json: @bookmark_collection, serializer: REST::StatusBookmarkCollectionSerializer
|
2020-12-16 00:31:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@bookmark_collection.destroy!
|
|
|
|
render_empty_success
|
|
|
|
end
|
|
|
|
|
2020-12-17 06:34:00 +00:00
|
|
|
def update_status
|
|
|
|
#
|
|
|
|
end
|
|
|
|
|
2020-12-16 00:31:30 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def set_bookmark_collections
|
2020-12-17 06:34:00 +00:00
|
|
|
@bookmark_collections = current_account.status_bookmark_collections
|
2020-12-16 00:31:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def set_bookmark_collection
|
2020-12-17 06:34:00 +00:00
|
|
|
@bookmark_collection = current_account.status_bookmark_collections.find(params[:id])
|
2020-12-16 00:31:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def resource_params
|
|
|
|
params.permit(:title)
|
|
|
|
end
|
|
|
|
end
|