Class: Ribose::SpaceFile

Inherits:
Base
  • Object
show all
Includes:
Actions::All, Actions::Delete, Actions::Fetch, Actions::Update
Defined in:
lib/ribose/space_file.rb

Class Method Summary collapse

Methods included from Actions::Delete

#delete

Methods included from Actions::Base

#included

Methods included from Actions::Update

#update

Methods included from Actions::Fetch

#fetch

Methods included from Actions::All

#all

Methods inherited from Base

#initialize

Methods included from ResourceHelper

#resource_id, #resource_path, #resources

Constructor Details

This class inherits a constructor from Ribose::Base

Class Method Details

.all(space_id, options = {}) ⇒ Array<Sawyer::Resource>

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 id and it will return the files as ‘Sawyer::Resource`

Parameters:

  • space_id (String)

    The spcific space Id

  • options (Hash) (defaults to: {})

    Query parameters as a Hash

Returns:

  • (Array<Sawyer::Resource>)


20
21
22
# File 'lib/ribose/space_file.rb', line 20

def self.all(space_id, options = {})
  new(space_id: space_id, **options).all
end

.create(space_id, file:, **attributes) ⇒ Sawyer::Resource

Create a new file upload

Parameters:

  • space_id (String)

    The Space UUID

  • file (String)

    The complete path for the file

  • attributes (Hash)

    The file attributes as Hash

Returns:

  • (Sawyer::Resource)

    The file upload response.



44
45
46
47
# File 'lib/ribose/space_file.rb', line 44

def self.create(space_id, file:, **attributes)
  upload = FileUploader.upload(space_id, attributes.merge(file: file))
  upload[:attachment]
end

.delete(space_id, file_id, options = {}) ⇒ Object

Delete a space file

Parameters:

  • space_id (String)

    The Space UUID

  • file_id (String)

    The space file ID



65
66
67
# File 'lib/ribose/space_file.rb', line 65

def self.delete(space_id, file_id, options = {})
  new(space_id: space_id, resource_id: file_id, **options).delete
end

.fetch(space_id, file_id, options = {}) ⇒ Sawyer::Resource

Fetch a space file

This interface retrieve the details for a single file in any given user space. The response is a ‘Sawyer::Resource`.

Parameters:

  • space_id (String)

    The space UUID

  • file_id (String)

    The space file ID

Returns:

  • (Sawyer::Resource)


33
34
35
# File 'lib/ribose/space_file.rb', line 33

def self.fetch(space_id, file_id, options = {})
  new(space_id: space_id, resource_id: file_id, **options).fetch
end

.update(space_id, file_id, attributes) ⇒ Sawyer::Resource

Update a space file

Parameters:

  • space_id (String)

    The Space UUID

  • file_id (String)

    The space file ID

  • attributes (Hash)

    The file attributes

Returns:

  • (Sawyer::Resource)


56
57
58
# File 'lib/ribose/space_file.rb', line 56

def self.update(space_id, file_id, attributes)
  new(space_id: space_id, resource_id: file_id, **attributes).update
end