Sha256: bc30b347feca21b8db22e3d3ed26cfc5f8b07dcf501997eb12cc2e0b4264ad2c
Contents?: true
Size: 1.56 KB
Versions: 6
Compression:
Stored size: 1.56 KB
Contents
# frozen_string_literal: true module Mihari module Web module Endpoints # # Tag API endpoint # class Tags < Grape::API namespace :tags do desc "List tags", { is_array: true, success: Entities::TagsWithPagination, summary: "List tags" } params do optional :q, type: String, default: "" optional :page, type: Integer, default: 1 optional :limit, type: Integer, default: 10 end get "/" do value = Services::TagSearcher.call(params.to_h) present( { results: value.results, total: value.total, current_page: value.filter[:page].to_i, page_size: value.filter[:limit].to_i }, with: Entities::TagsWithPagination ) end desc "Delete a tag", { success: {code: 204}, failure: [{code: 404, model: Entities::ErrorMessage}], summary: "Delete a tag" } params do requires :id, type: Integer end delete "/:id" do status 204 id = params[:id].to_i result = Services::TagDestroyer.result(id) return if result.success? case result.failure when ActiveRecord::RecordNotFound error!({message: "ID:#{id} not found"}, 404) end raise result.failure end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems