Sha256: ded690bd05535944c91318d96b8e2e2d87fae1a143893be100e855880907a0ff

Contents?: true

Size: 1.26 KB

Versions: 19

Compression:

Stored size: 1.26 KB

Contents

module GroupDocs
  module Storage
    class Package < Api::Entity

      include Api::Helpers::Path

      # @attr [String] name Package name
      attr_accessor :name
      # @attr [Array<GroupDocs::Storage::File, GroupDocs::Storage::Folder>] objects Storage entities to be packed
      attr_accessor :objects

      #
      # Appends object to be packed.
      #
      # @param [GroupDocs::Storage::File, GroupDocs::Storage::Folder] object
      #
      def add(object)
        @objects ||= Array.new
        @objects << object
      end
      alias_method :<<, :add

      #
      # Creates package on server.
      #
      # @param [Hash] access Access credentials
      # @option access [String] :client_id
      # @option access [String] :private_key
      # @return [String] URL of package for downloading
      #
      def create!(access = {})
        paths = @objects.map do |object|
          prepare_path("#{object.path}/#{object.name}")
        end

        json = Api::Request.new do |request|
          request[:access] = access
          request[:method] = :POST
          request[:path] = "/storage/{{client_id}}/packages/#{name}.zip"
          request[:request_body] = paths
        end.execute!

        json[:url]
      end

    end # Package
  end # Storage
end # GroupDocs

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
groupdocs-2.2.0 lib/groupdocs/storage/package.rb
groupdocs-2.1.0 lib/groupdocs/storage/package.rb
groupdocs-2.0.0 lib/groupdocs/storage/package.rb
groupdocs-1.9.0 lib/groupdocs/storage/package.rb
groupdocs-1.8.1 lib/groupdocs/storage/package.rb
groupdocs-1.8.0 lib/groupdocs/storage/package.rb
groupdocs-1.7.0 lib/groupdocs/storage/package.rb
groupdocs-1.6.0 lib/groupdocs/storage/package.rb
groupdocs-1.5.9 lib/groupdocs/storage/package.rb
groupdocs-1.5.8 lib/groupdocs/storage/package.rb
groupdocs-1.5.7 lib/groupdocs/storage/package.rb
groupdocs-1.5.6 lib/groupdocs/storage/package.rb
groupdocs-1.5.5 lib/groupdocs/storage/package.rb
groupdocs-1.5.4 lib/groupdocs/storage/package.rb
groupdocs-1.5.3 lib/groupdocs/storage/package.rb
groupdocs-1.5.2 lib/groupdocs/storage/package.rb
groupdocs-1.5.1 lib/groupdocs/storage/package.rb
groupdocs-1.5.0 lib/groupdocs/storage/package.rb
groupdocs-1.4.2 lib/groupdocs/storage/package.rb