Class: Code42::User

Inherits:
Resource show all
Defined in:
lib/code42/user.rb

Instance Attribute Summary

Attributes inherited from Resource

#attributes, #client

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

attribute, collection_from_response, deserialize, deserialize_and_initialize, from_response, #initialize, serialize, #serialize, serializer

Constructor Details

This class inherits a constructor from Code42::Resource

Class Method Details

.create(attributes) ⇒ Object



14
15
16
# File 'lib/code42/user.rb', line 14

def self.create(attributes)
  client.create_user(attributes)
end

.find_all_usersObject



26
27
28
# File 'lib/code42/user.rb', line 26

def self.find_all_users
  client.users + client.users(active: false)
end

.find_by_id(id) ⇒ Object



18
19
20
# File 'lib/code42/user.rb', line 18

def self.find_by_id(id)
  client.find_user_by_id id
end

.find_by_name(user_name) ⇒ Object



22
23
24
# File 'lib/code42/user.rb', line 22

def self.find_by_name(user_name)
  client.user user_name
end

Instance Method Details

#activateObject



68
69
70
71
# File 'lib/code42/user.rb', line 68

def activate
  client.activate_user(id)
  client.user id
end

#assign_role(attrs = {}) ⇒ Code42::Role

Assigns a role to this user

Returns:



48
49
50
51
# File 'lib/code42/user.rb', line 48

def assign_role(attrs = {})
  attrs.merge!(user_id: id)
  client.assign_role(attrs)
end

#blockObject



58
59
60
61
# File 'lib/code42/user.rb', line 58

def block
  client.block_user(id)
  client.user id
end

#deactivateObject



73
74
75
76
# File 'lib/code42/user.rb', line 73

def deactivate
  client.deactivate_user(id)
  client.user(id, active: false)
end

#orgCode42::User

Returns the org associated with this user

Returns:



36
37
38
# File 'lib/code42/user.rb', line 36

def org
  client.org(org_id)
end

#permissionsObject



78
79
80
# File 'lib/code42/user.rb', line 78

def permissions
  client.permissions
end

#rolesCode42::RoleCollection

Returns the roles associated with this user



42
43
44
# File 'lib/code42/user.rb', line 42

def roles
  client.user_roles(id)
end

#unassign_role(role_name) ⇒ Object

Delete a role from this user



54
55
56
# File 'lib/code42/user.rb', line 54

def unassign_role(role_name)
  client.unassign_role(id, role_name)
end

#unblockObject



63
64
65
66
# File 'lib/code42/user.rb', line 63

def unblock
  client.unblock_user(id)
  client.user id
end

#update(attributes) ⇒ Object



30
31
32
# File 'lib/code42/user.rb', line 30

def update(attributes)
  client.update_user(id, attributes)
end