Module: FileboundClient::Endpoints::Files

Defined in:
lib/filebound_client/endpoints/files.rb

Overview

Module for Files resource endpoint

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object

This will call macros to create resource methods on the fly



6
7
8
9
10
11
# File 'lib/filebound_client/endpoints/files.rb', line 6

def self.included(klass)
  klass.instance_eval do
    allow_new :file
    allow_all :files
  end
end

Instance Method Details

#file(file_id, query_params = nil) ⇒ Hash

Retrieves a single file by its key

Parameters:

  • file_id (int)

    the file key

  • query_params (Hash) (defaults to: nil)

    additional query params to send in the request (optional params: filter)

Returns:

  • (Hash)

    the file hash



17
18
19
# File 'lib/filebound_client/endpoints/files.rb', line 17

def file(file_id, query_params = nil)
  get("/files/#{file_id}", query_params)
end

#file_add(file) ⇒ Hash

Adds a file

Parameters:

  • file (Hash)

    the file hash to add

Returns:

  • (Hash)

    the newly added file hash



48
49
50
# File 'lib/filebound_client/endpoints/files.rb', line 48

def file_add(file)
  put('/files', nil, file)
end

#file_add_comment(file_id, comment_data, query_params = nil) ⇒ Hash

Adds a comment to file

Parameters:

  • file_id (int)

    the file key

  • comment_data (Hash)

    the comment to add

Returns:

  • (Hash)

    the newly added file comment hash



79
80
81
# File 'lib/filebound_client/endpoints/files.rb', line 79

def file_add_comment(file_id, comment_data, query_params = nil)
  put("/files/#{file_id}/comments", nil, comment_data)
end

#file_by_key_value(project_id, key_value) ⇒ int

Retrieves file_id by specifying a project id and key value

Parameters:

  • project_id (int)

    the project key

  • key_value (String)

    the key value to search on

Returns:

  • (int)

    the file id



33
34
35
# File 'lib/filebound_client/endpoints/files.rb', line 33

def file_by_key_value(project_id, key_value)
  get("/files/#{project_id}/ByKeyValue", value: key_value)
end

#file_comments(file_id, query_params = nil) ⇒ Object

Returns the file comments for the supplied file key

Parameters:

  • file_id (int)

    the file key

  • query_params (Hash) (defaults to: nil)

    the additional query params to send in the request



71
72
73
# File 'lib/filebound_client/endpoints/files.rb', line 71

def file_comments(file_id, query_params = nil)
  get("/files/#{file_id}/comments", query_params)
end

#file_delete(file_id) ⇒ bool

Deletes a file

Parameters:

  • file_id (int)

    the file key

Returns:

  • (bool)

    true if the file deleted successfully



64
65
66
# File 'lib/filebound_client/endpoints/files.rb', line 64

def file_delete(file_id)
  delete("/files/#{file_id}")
end

#file_documents(file_id, query_params = nil) ⇒ Array

Retrieves all documents for the specified file key

Parameters:

  • file_id (int)

    the file key

  • query_params (Hash) (defaults to: nil)

    additional query params to send in the request (optional params: filter)

Returns:

  • (Array)

    an array of document hashes



25
26
27
# File 'lib/filebound_client/endpoints/files.rb', line 25

def file_documents(file_id, query_params = nil)
  get("/files/#{file_id}/documents", query_params)
end

#file_update(file_id, file) ⇒ Hash

Updates a file

Parameters:

  • file_id (int)

    the file key

  • file (Hash)

    the file hash with updated fields

Returns:

  • (Hash)

    the updated file hash



41
42
43
# File 'lib/filebound_client/endpoints/files.rb', line 41

def file_update(file_id, file)
  post("files/#{file_id}", nil, file)
end

#file_update_by_key_value(project_id, key_value, file) ⇒ Hash

Adds file based on project key value

Parameters:

  • project_id (int)

    the project key value

  • key_value (String)

    the key value

  • file (Hash)

    the file hash with updated fields

Returns:

  • (Hash)

    the updated file hash



57
58
59
# File 'lib/filebound_client/endpoints/files.rb', line 57

def file_update_by_key_value(project_id, key_value, file)
  put("/files/#{project_id}/ByKeyValue", { value: key_value }, file)
end