Sha256: 5f6efca729d293dd5dba753545f960e8d653ba41cc257f845f00cf6d8ad595c4

Contents?: true

Size: 977 Bytes

Versions: 1

Compression:

Stored size: 977 Bytes

Contents

module Egnyte
  class Item

    attr_accessor :session

    def initialize(data, session)
      @data = data
      @session = session
    end

    def method_missing(method, *args, &block)
      @data[method.to_s]
    end

    def update_data(data)
      @data = @data.update(data)
      self
    end

    # mode can be either fs, or fs-content.
    def fs_path(mode='fs')
      Egnyte::Item.fs_path(@session, mode)
    end

    def self.fs_path(session, mode='fs')
      "https://#{session.domain}.#{EGNYTE_DOMAIN}/#{session.api}/v1/#{mode}/"
    end

    def move_or_copy(destination_path, action)
      item_path = "#{fs_path}#{Egnyte::Helper.normalize_path(path)}"
      @session.post(item_path, { action: action, destination: destination_path }.to_json, return_parsed_response=true)
    end

    def move(destination_path)
      move_or_copy(destination_path, 'move')
    end

    def copy(destination_path)
      move_or_copy(destination_path, 'copy')
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-egnyte-0.1.6 lib/egnyte/item.rb