Module: FileboundClient::Endpoints::Projects

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

Overview

Module for Projects 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/projects.rb', line 6

def self.included(klass)
  klass.instance_eval do
    allow_new :project
    allow_all :projects
  end
end

Instance Method Details

#project(project_id, query_params = nil) ⇒ Project

Retrieves a single project by its key

Parameters:

  • project_id (int)

    the project key

  • query_params (Hash) (defaults to: nil)

    additional query params to send in the request

Returns:

  • (Project)

    project object



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

def project(project_id, query_params = nil)
  get("/projects/#{project_id}", query_params)
end

#project_add(project) ⇒ int

Adds a project. The project.ProjectId must be nil or 0.

Examples:

Add a project

c = FileboundClient::Client.connect(host: url, username: 'username', password: 'password', use_ntlm: true,
                                    ntlm_user: 'ntlm_user', ntlm_password: 'ntlm_password',
                                    ntlm_domain: 'ntlm_domain')
c.project_add(ProjectId: nil, Name: 'Test API Project', ProjectType: 'HR')

Parameters:

  • project (Project)

    the project to add

Returns:

  • (int)

    the id of the newly created project

Raises:



96
97
98
99
# File 'lib/filebound_client/endpoints/projects.rb', line 96

def project_add(project)
  raise Client::FileboundClientException.new('Id is required', 0) if project[:projectId].greater_than_zero?
  put('/projects', nil, project)
end

#project_assignments(project_id, query_params = nil) ⇒ Array

Retrieves assignments for a project

Parameters:

  • project_id (int)

    the project key

  • query_params (Hash) (defaults to: nil)

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

Returns:

  • (Array)

    array of assignments



75
76
77
# File 'lib/filebound_client/endpoints/projects.rb', line 75

def project_assignments(project_id, query_params = nil)
  get_project_children(project_id, __method__, query_params)
end

#project_delete(project_id) ⇒ bool

Deletes a project

Parameters:

  • project_id (int)

    the project key of the project to delete

Returns:

  • (bool)

    true if deleting the project was successful



149
150
151
# File 'lib/filebound_client/endpoints/projects.rb', line 149

def project_delete(project_id)
  delete("/projects/#{project_id}")
end

#project_divider_add(project_id, divider) ⇒ int

Adds a divider to a project

Parameters:

  • project_id (int)

    the project key to add the divider to

  • divider (Hash)

    the divider hash to add to the project

Returns:

  • (int)

    the divider id



118
119
120
# File 'lib/filebound_client/endpoints/projects.rb', line 118

def project_divider_add(project_id, divider)
  put("/projects/#{project_id}/dividers", nil, divider)
end

#project_dividers(project_id, query_params = nil) ⇒ Array

Retrieves dividers for a project

Parameters:

  • project_id (int)

    the project key

  • query_params (Hash) (defaults to: nil)

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

Returns:

  • (Array)

    array of dividers



50
51
52
# File 'lib/filebound_client/endpoints/projects.rb', line 50

def project_dividers(project_id, query_params = nil)
  get_project_children(project_id, __method__, query_params)
end

#project_fields(project_id, query_params = nil) ⇒ Array

Retrieves fields for a project

Parameters:

  • project_id (int)

    the project key

  • query_params (Hash) (defaults to: nil)

    additional query params to send in the request (optional params: filter(String), includeProjectLinkOptions(bool))

Returns:

  • (Array)

    array of fields



26
27
28
# File 'lib/filebound_client/endpoints/projects.rb', line 26

def project_fields(project_id, query_params = nil)
  get_project_children(project_id, __method__, query_params)
end

#project_file_add(project_id, file) ⇒ int

Adds a file to a project

Parameters:

  • project_id (int)

    the project key to add the file to

  • file (Hash)

    the file hash to add

Returns:

  • (int)

    the file id created



134
135
136
# File 'lib/filebound_client/endpoints/projects.rb', line 134

def project_file_add(project_id, file)
  put("/projects/#{project_id}/files", nil, file)
end

#project_files(project_id, query_params = nil) ⇒ Array

Retrieves files for a project

Parameters:

  • project_id (int)

    the project key

  • query_params (Hash) (defaults to: nil)

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

Returns:

  • (Array)

    array of files



34
35
36
# File 'lib/filebound_client/endpoints/projects.rb', line 34

def project_files(project_id, query_params = nil)
  get_project_children(project_id, __method__, query_params)
end

#project_files_add(project_id, files) ⇒ Hash

Adds an array of files to a project

Parameters:

  • project_id (int)

    the project key to add the files to

  • files (Array)

    the array of file hashes to add

Returns:

  • (Hash)

    true if adding the files was successful



142
143
144
# File 'lib/filebound_client/endpoints/projects.rb', line 142

def project_files_add(project_id, files)
  put("/projects/#{project_id}/listfiles", nil, files)
end

#project_groups(project_id, query_params = nil) ⇒ Array

Retrieves groups for a project

Parameters:

  • project_id (int)

    the project key

  • query_params (Hash) (defaults to: nil)

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

Returns:

  • (Array)

    array of groups



42
43
44
# File 'lib/filebound_client/endpoints/projects.rb', line 42

def project_groups(project_id, query_params = nil)
  get_project_children(project_id, __method__, query_params)
end

#project_routeditems(project_id, query_params = nil) ⇒ Array

Retrieves routed items for a project

Parameters:

  • project_id (int)

    the project key

  • query_params (Hash) (defaults to: nil)

    additional query params to send in the request (optional params: filter(String), userId(int), type(int))

Returns:

  • (Array)

    array of routed items



59
60
61
# File 'lib/filebound_client/endpoints/projects.rb', line 59

def project_routeditems(project_id, query_params = nil)
  get_project_children(project_id, __method__, query_params)
end

#project_routes(project_id, query_params = nil) ⇒ Array

Retrieves routes for a project

Parameters:

  • project_id (int)

    the project key

  • query_params (Hash) (defaults to: nil)

    additional query params to send in the request (optional params: filter(String), xml(bool), hiddenRoutes(bool))

Returns:

  • (Array)

    array of routes



84
85
86
# File 'lib/filebound_client/endpoints/projects.rb', line 84

def project_routes(project_id, query_params = nil)
  get_project_children(project_id, __method__, query_params)
end

#project_separator_add(project_id, separator) ⇒ int

Adds a separator to a project

Parameters:

  • project_id (int)

    the project key to add the separator to

  • separator (Hash)

    the separator hash to add to the project

Returns:

  • (int)

    the separator id



126
127
128
# File 'lib/filebound_client/endpoints/projects.rb', line 126

def project_separator_add(project_id, separator)
  put("/projects/#{project_id}/separators", nil, separator)
end

#project_separators(project_id, query_params = nil) ⇒ Array

Retrieves separators for a project

Parameters:

  • project_id (int)

    the project key

  • query_params (Hash) (defaults to: nil)

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

Returns:

  • (Array)

    array of separators



67
68
69
# File 'lib/filebound_client/endpoints/projects.rb', line 67

def project_separators(project_id, query_params = nil)
  get_project_children(project_id, __method__, query_params)
end

#project_update(project) ⇒ int

Edits a project. The project.ProjectId must be not nil and > 0.

Examples:

Update an existing project

c = FileboundClient::Client.connect(host: url, username: 'username', password: 'password', use_ntlm: true,
                                    ntlm_user: 'ntlm_user', ntlm_password: 'ntlm_password',
                                    ntlm_domain: 'ntlm_domain')
c.project_update(ProjectId: 165, Name: 'Test API Project', ProjectType: 'HR', EnableMultiKeySearch: true)

Parameters:

  • project (Hash)

    the project to edit

Returns:

  • (int)

    the project id updated

Raises:



109
110
111
112
# File 'lib/filebound_client/endpoints/projects.rb', line 109

def project_update(project)
  raise Client::FileboundClientException.new('Id is required', 0) unless project[:projectId].greater_than_zero?
  put('/projects', nil, project)
end