Class: Ribose::FileVersion

Inherits:
Base
  • Object
show all
Includes:
Actions::Fetch
Defined in:
lib/ribose/file_version.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Actions::Fetch

#fetch

Methods included from Actions::Base

#included

Methods inherited from Base

#initialize

Methods included from ResourceHelper

#resource_id, #resource_key, #resources, #resources_path

Constructor Details

This class inherits a constructor from Ribose::Base

Class Method Details

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

Create a new file version

Returns:

  • (Sawyer::Resource)

    Newly updated version



51
52
53
54
55
56
57
# File 'lib/ribose/file_version.rb', line 51

def self.create(space_id, file_id, file:, **attributes)
  upload = VersionUploader.upload(
    space_id, file_id, attributes.merge(file: file)
  )

  upload[:attachment]
end

.download(space_id, file_id, version_id:, **options) ⇒ Object

Download file version

Parameters:

  • space_id (UUID)

    The space Id

  • file_id (Integer)

    The file Id

  • version_id (Hash)

    The file version Id

  • options (Hash)

    Options as key and value pair



34
35
36
37
38
39
40
41
# File 'lib/ribose/file_version.rb', line 34

def self.download(space_id, file_id, version_id:, **options)
  new(
    file_id: file_id,
    space_id: space_id,
    resource_id: version_id,
    **options,
  ).download
end

.fetch(space_id:, file_id:, version_id:, **options) ⇒ Object

Fetch file version



18
19
20
21
22
23
24
25
# File 'lib/ribose/file_version.rb', line 18

def self.fetch(space_id:, file_id:, version_id:, **options)
  new(
    file_id: file_id,
    space_id: space_id,
    resource_id: version_id,
    **options,
  ).fetch
end

Instance Method Details

#downloadObject



7
8
9
# File 'lib/ribose/file_version.rb', line 7

def download
  download_file || raise(Ribose::BadRequest)
end