Class: GroupDocs::Storage::Package

Inherits:
Api::Entity show all
Defined in:
lib/groupdocs/storage/package.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Api::Entity

#initialize, #inspect, #to_hash

Constructor Details

This class inherits a constructor from GroupDocs::Api::Entity

Instance Attribute Details

#nameObject



6
7
8
# File 'lib/groupdocs/storage/package.rb', line 6

def name
  @name
end

#objectsObject



8
9
10
# File 'lib/groupdocs/storage/package.rb', line 8

def objects
  @objects
end

Instance Method Details

#add(object) ⇒ Object Also known as: <<

Appends object to be packed.



15
16
17
18
# File 'lib/groupdocs/storage/package.rb', line 15

def add(object)
  @objects ||= Array.new
  @objects << object
end

#create!(access = {}) ⇒ String

Creates package on server.

Parameters:

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

    Access credentials

Options Hash (access):

  • :client_id (String)
  • :private_key (String)

Returns:

  • (String)

    URL of package for downloading



29
30
31
32
33
34
35
36
37
38
# File 'lib/groupdocs/storage/package.rb', line 29

def create!(access = {})
  json = Api::Request.new do |request|
    request[:access] = access
    request[:method] = :POST
    request[:path] = "/storage/{{client_id}}/packages/#{name}.zip"
    request[:request_body] = @objects.map(&:name)
  end.execute!

  json[:url]
end