Module: FileboundClient::Endpoints::Users

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

Overview

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

def self.included(klass)
  klass.instance_eval do
    allow_new :user
    allow_all :users
  end
end

Instance Method Details

#user(user_id, query_params = nil) ⇒ User

Retrieves a single user by its key

Parameters:

  • user_id (int)

    the user key

  • query_params (Hash) (defaults to: nil)

    additional query params to send in the request

Returns:

  • (User)

    user object



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

def user(user_id, query_params = nil)
  get("/users/#{user_id}", query_params)
end

#user_add(user, groups) ⇒ int

Adds a user. The user.id must be nil or 0.

Examples:

Add a user

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.user_add(id: nil, displayName: 'Test User', email: '[email protected]', name: 'username')

Parameters:

  • user (user)

    the user to add

  • groups (string)

    a comma-delimited string of group ids to add the user to

Returns:

  • (int)

    the id of the newly created user

Raises:



68
69
70
71
# File 'lib/filebound_client/endpoints/users.rb', line 68

def user_add(user, groups)
  raise Client::FileboundClientException.new('Id is required', 0) if user[:userId].greater_than_zero?
  put('/users', nil, user, user: user, groups: groups)
end

#user_assignments(user_id, query_params = nil) ⇒ Array

Retrieves assignments for a user

Parameters:

  • user_id (int)

    the user key

  • query_params (Hash) (defaults to: nil)

    additional query params to send in the request

Returns:

  • (Array)

    array of assignments



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

def user_assignments(user_id, query_params = nil)
  get_user_children(user_id, __method__, query_params)
end

#user_groups(user_id, query_params = nil) ⇒ Array

Retrieves groups for a user

Parameters:

  • user_id (int)

    the user key

  • query_params (Hash) (defaults to: nil)

    additional query params to send in the request

Returns:

  • (Array)

    array of groups



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

def user_groups(user_id, query_params = nil)
  get_user_children(user_id, __method__, query_params)
end

#user_routeditems(user_id, query_params = nil) ⇒ Array

Retrieves routed items for a user

Parameters:

  • user_id (int)

    the user key

  • query_params (Hash) (defaults to: nil)

    additional query params to send in the request

Returns:

  • (Array)

    array of routed items



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

def user_routeditems(user_id, query_params = nil)
  get_user_children(user_id, __method__, query_params)
end

#user_update(user, groups) ⇒ int

Edits a user. The user.Id must be not nil and > 0.

Examples:

Update an existing user

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.user_update(id: 165, displayName: 'Test User', email: '[email protected]', name: 'username')

Parameters:

  • user (Hash)

    the user to edit

  • groups (string)

    a comma-delimited string of group ids to add the user to

Returns:

  • (int)

    the user id updated

Raises:



54
55
56
57
# File 'lib/filebound_client/endpoints/users.rb', line 54

def user_update(user, groups)
  raise Client::FileboundClientException.new('Id is required', 0) unless user[:dd].greater_than_zero?
  put('/users', nil, user: user, groups: groups)
end