Sha256: fbf4b890ee8b8be4d4c29dad87106dc7354d0bebdac89f407bcd9cf0836f43d8

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

module GroupDocs
  module Storage
    class Package < Api::Entity

      include Api::Helpers::Path

      # @attr [String] name Package name
      attr_accessor :name
      # @attr [Array] 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

1 entries across 1 versions & 1 rubygems

Version Path
groupdocs-1.4.1 lib/groupdocs/storage/package.rb