Commit fe128267 authored by Mauricio Giacomini Girardello's avatar Mauricio Giacomini Girardello
Browse files

adding item resource

parent 7b3e28c2
......@@ -19,18 +19,6 @@ module Dspace
end
end
action :items, 'GET /rest/collections/:id/items' do
query_keys :expand, :limit, :offset
handler(200) do |response|
Dspace::Builders::ModelBuilder.build_(JSON.parse(response.body))
end
end
action :create_item, 'POST /rest/collections/:id/items' do
body { |object| JSON.generate(object.to_h) }
handler(200, 201) { |response| true }
end
action :update, 'PUT /rest/collections/:id' do
body { |object| JSON.generate(object.to_h) }
handler(200, 201) { |response| true }
......@@ -44,6 +32,18 @@ module Dspace
handler(200, 201, 204) { |response| true }
end
action :items, 'GET /rest/collections/:id/items' do
query_keys :expand, :limit, :offset
handler(200) do |response|
Dspace::Builders::ModelBuilder.build_(JSON.parse(response.body))
end
end
action :create_item, 'POST /rest/collections/:id/items' do
body { |object| JSON.generate(object.to_h) }
handler(200, 201) { |response| true }
end
end
end
end
......
module Dspace
module Resources
class ItemResource < ResourceKit::Resource
resources do
default_handler(401) { raise NotAuthorizedError, 'This request requires authentication' }
action :all, 'GET /rest/items' do
query_keys :expand
handler(200) do |response|
Dspace::Builders::ModelBuilder.build_items(JSON.parse(response.body))
end
end
action :find, 'GET /rest/items/:id' do
query_keys :expand
handler(200) do |response|
Dspace::Item.new(JSON.parse(response.body))
end
end
action :metadata, 'GET /rest/items/:id/metadata' do
handler(200) do |response|
Dspace::Builders::ModelBuilder.build_metadatas(JSON.parse(response.body))
end
end
action :bitstreams, 'GET /rest/items/:id/bitstreams' do
query_keys :expand, :limit, :offset
handler(200) do |response|
Dspace::Builders::ModelBuilder.build_bitstreams(JSON.parse(response.body))
end
end
action :delete, 'DELETE /rest/items/:id' do
handler(200, 201, 204) { |response| true }
end
action :clear_metadata, 'DELETE /rest/items/:id/metadata' do
handler(200, 201, 204) { |response| true }
end
action :delete_bitstream, 'DELETE /rest/items/:id/bitstreams/:bitstream_id' do
handler(200, 201, 204) { |response| true }
end
end
end
end
end
\ No newline at end of file
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