module FileboundClient::Endpoints::Users

Module for Users resource endpoint

Public Class Methods

included(klass) click to toggle source

This will call macros to create resource methods on the fly

# 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

Public Instance Methods

user(user_id, query_params = nil) click to toggle source

Retrieves a single user by its key @param [int] user_id the user key @param [Hash] query_params additional query params to send in the request @return [User] user object

# 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) click to toggle source

Adds a user. The user.id must be nil or 0. @param [user] user the user to add @param [string] groups a comma-delimited string of group ids to add the user to @return [int] the id of the newly created user @example 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: 'someone@somewhere.com', name: 'username')
# 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) click to toggle source

Retrieves assignments for a user @param [int] user_id the user key @param [Hash] query_params additional query params to send in the request @return [Array] array of assignments

# 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) click to toggle source

Retrieves groups for a user @param [int] user_id the user key @param [Hash] query_params additional query params to send in the request @return [Array] array of groups

# 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) click to toggle source

Retrieves routed items for a user @param [int] user_id the user key @param [Hash] query_params additional query params to send in the request @return [Array] array of routed items

# 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) click to toggle source

Edits a user. The user.Id must be not nil and > 0. @param [Hash] user the user to edit @param [string] groups a comma-delimited string of group ids to add the user to @return [int] the user id updated @example 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: 'someone@somewhere.com', name: 'username')
# 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

Private Instance Methods

get_user_children(user_id, child_name, query_params = nil) click to toggle source
# File lib/filebound_client/endpoints/users.rb, line 75
def get_user_children(user_id, child_name, query_params = nil)
  get("/users/#{user_id}/#{child_name.to_s.split('_')[1]}", query_params)
end