lib/ribose/space_file.rb in ribose-0.2.0 vs lib/ribose/space_file.rb in ribose-0.3.0
- old
+ new
@@ -1,10 +1,13 @@
require "ribose/file_uploader"
module Ribose
class SpaceFile < Ribose::Base
include Ribose::Actions::All
+ include Ribose::Actions::Fetch
+ include Ribose::Actions::Update
+ include Ribose::Actions::Delete
# List Files for Space
#
# This interface retrieves the files for any specific space, and
# the usages is pretty simple all we need to do, provide the space
@@ -16,10 +19,23 @@
#
def self.all(space_id, options = {})
new(space_id: space_id, **options).all
end
+ # Fetch a space file
+ #
+ # This interface retrieve the details for a single file in any
+ # given user space. The response is a `Sawyer::Resource`.
+ #
+ # @param space_id [String] The space UUID
+ # @param file_id [String] The space file ID
+ # @return [Sawyer::Resource]
+ #
+ def self.fetch(space_id, file_id, options = {})
+ new(space_id: space_id, resource_id: file_id, **options).fetch
+ end
+
# Create a new file upload
#
# @param space_id [String] The Space UUID
# @param file [String] The complete path for the file
# @param attributes [Hash] The file attributes as Hash
@@ -28,15 +44,39 @@
def self.create(space_id, file:, **attributes)
upload = FileUploader.upload(space_id, attributes.merge(file: file))
upload[:attachment]
end
+ # Update a space file
+ #
+ # @param space_id [String] The Space UUID
+ # @param file_id [String] The space file ID
+ # @param attributes [Hash] The file attributes
+ # @return [Sawyer::Resource]
+ #
+ def self.update(space_id, file_id, attributes)
+ new(space_id: space_id, resource_id: file_id, **attributes).update
+ end
+
+ # Delete a space file
+ #
+ # @param space_id [String] The Space UUID
+ # @param file_id [String] The space file ID
+ #
+ def self.delete(space_id, file_id, options = {})
+ new(space_id: space_id, resource_id: file_id, **options).delete
+ end
+
private
attr_reader :space_id
def resource
"file"
+ end
+
+ def resource_key
+ "file_info"
end
def resources_path
["spaces", space_id, "file", "files"].join("/")
end