Class: Code42::Org

Inherits:
Resource show all
Defined in:
lib/code42/org.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(attrs = {}) ⇒ Object



15
16
17
# File 'lib/code42/org.rb', line 15

def self.create(attrs = {})
  client.create_org(attrs)
end

.find_active_by_id(id, attrs = {}) ⇒ Object



23
24
25
# File 'lib/code42/org.rb', line 23

def self.find_active_by_id(id, attrs = {})
  client.org(id, attrs)
end

.find_active_by_name(name, attrs = {}) ⇒ Object



35
36
37
# File 'lib/code42/org.rb', line 35

def self.find_active_by_name(name, attrs = {})
  client.find_org_by_name(name, attrs.merge(active: true))
end

.find_all_active_orgsObject



47
48
49
# File 'lib/code42/org.rb', line 47

def self.find_all_active_orgs
  client.orgs
end

.find_all_inactive_orgsObject



51
52
53
# File 'lib/code42/org.rb', line 51

def self.find_all_inactive_orgs
  client.orgs(active: false)
end

.find_all_orgsObject



43
44
45
# File 'lib/code42/org.rb', line 43

def self.find_all_orgs
  find_all_active_orgs + find_all_inactive_orgs
end

.find_by_id(id, attrs = {}) ⇒ Object



19
20
21
# File 'lib/code42/org.rb', line 19

def self.find_by_id(id, attrs = {})
  find_active_by_id(id, attrs) || find_inactive_by_id(id, attrs)
end

.find_by_name(name, attrs = {}) ⇒ Object



31
32
33
# File 'lib/code42/org.rb', line 31

def self.find_by_name(name, attrs = {})
  find_active_by_name(name, attrs) || find_inactive_by_name(name, attrs)
end

.find_inactive_by_id(id, attrs = {}) ⇒ Object



27
28
29
# File 'lib/code42/org.rb', line 27

def self.find_inactive_by_id(id, attrs = {})
  client.org(id, attrs.merge(active: false))
end

.find_inactive_by_name(name, attrs = {}) ⇒ Object



39
40
41
# File 'lib/code42/org.rb', line 39

def self.find_inactive_by_name(name, attrs = {})
  client.find_inactive_org_by_name name, attrs
end

Instance Method Details

#activateObject



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

def activate
  client.activate_org(id)
  client.org id
end

#blockObject



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

def block
  client.block_org(id)
  client.org id
end

#create_user(attrs = {}) ⇒ Object



83
84
85
86
# File 'lib/code42/org.rb', line 83

def create_user(attrs = {})
  attrs.merge!(org_id: id)
  client.create_user(attrs)
end

#deactivateObject



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

def deactivate
  client.deactivate_org(id)
  client.org(id, active: false)
end

#unblockObject



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

def unblock
  client.unblock_org(id)
  client.org id
end

#update(attrs = {}) ⇒ Object



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

def update(attrs = {})
  client.update_org(id, attrs)
end

#usersObject



55
56
57
# File 'lib/code42/org.rb', line 55

def users
  client.users(org_id: id)
end