Class: Usergroups
- Inherits:
-
Base
show all
- Defined in:
- lib/zapix/proxies/usergroups.rb
Defined Under Namespace
Classes: NonExistingUsergroup
Instance Attribute Summary
Attributes inherited from Base
#client
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Constructor Details
This class inherits a constructor from Base
Instance Method Details
#create(options) ⇒ Object
4
5
6
|
# File 'lib/zapix/proxies/usergroups.rb', line 4
def create(options)
client.usergroup_create(options) unless exists?(options)
end
|
#delete(*group_ids) ⇒ Object
27
28
29
|
# File 'lib/zapix/proxies/usergroups.rb', line 27
def delete(*group_ids)
client.usergroup_delete(group_ids)
end
|
#exists?(options) ⇒ Boolean
8
9
10
11
12
13
14
15
16
|
# File 'lib/zapix/proxies/usergroups.rb', line 8
def exists?(options)
result = client.usergroup_get('filter' => { 'name' => options['name'] })
if result.empty? || result.nil?
false
else
true
end
end
|
#get_id(options) ⇒ Object
18
19
20
21
22
23
24
25
|
# File 'lib/zapix/proxies/usergroups.rb', line 18
def get_id(options)
if exists?(options)
result = client.usergroup_get('filter' => { 'name' => options['name'] })
result.first['usrgrpid']
else
raise NonExistingUsergroup, "Usergroup #{options['name']} does not exist !"
end
end
|