Method: Boxr::Client#update_file

Defined in:
lib/boxr/files.rb

#update_file(file, name: nil, description: nil, parent: nil, shared_link: nil, tags: nil, lock: nil, if_match: nil) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/boxr/files.rb', line 29

def update_file(file, name: nil, description: nil, parent: nil, shared_link: nil, tags: nil, lock: nil, if_match: nil)
  file_id = ensure_id(file)
  parent_id = ensure_id(parent)
  uri = "#{FILES_URI}/#{file_id}"

  attributes = {}
  attributes[:name] = name unless name.nil?
  attributes[:description] = description unless description.nil?
  attributes[:parent] = {id: parent_id} unless parent_id.nil?
  attributes[:shared_link] = shared_link unless shared_link.nil?
  attributes[:tags] = tags unless tags.nil?
  attributes[:lock] = lock unless lock.nil?

  updated_file, response = put(uri, attributes, if_match: if_match)
  updated_file
end