Module: Gerry::Api::Groups
- Included in:
- Client
- Defined in:
- lib/gerry/api/groups.rb
Instance Method Summary collapse
-
#add_to_group(group_id, users) ⇒ Hash
Adds one or more users to a group.
-
#create_group(name, description, visible, owner_id = nil) ⇒ Hash
Create a new group.
-
#group_members(group_id, options = []) ⇒ Array
Get all members for a group.
-
#groups ⇒ Hash
Get all groups.
-
#included_groups(group_id) ⇒ Array
Get the directly included groups of a group.
- #remove_from_group(group_id, users) ⇒ Object
Instance Method Details
#add_to_group(group_id, users) ⇒ Hash
Adds one or more users to a group
55 56 57 58 59 60 61 |
# File 'lib/gerry/api/groups.rb', line 55 def add_to_group(group_id, users) url = "/groups/#{group_id}/members" body = { members: users } post(url, body) end |
#create_group(name, description, visible, owner_id = nil) ⇒ Hash
Create a new group
40 41 42 43 44 45 46 47 48 |
# File 'lib/gerry/api/groups.rb', line 40 def create_group(name, description, visible, owner_id=nil) url = "/groups/#{name}" body = { description: description, visible_to_all: visible, } body[:owner_id] = owner_id unless owner_id.nil? || owner_id.empty? put(url, body) end |
#group_members(group_id, options = []) ⇒ Array
Get all members for a group
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gerry/api/groups.rb', line 18 def group_members(group_id, = []) url = "/groups/#{group_id}/members/" if .empty? return get(url) end = () get("#{url}?#{}") end |
#groups ⇒ Hash
Get all groups
9 10 11 12 |
# File 'lib/gerry/api/groups.rb', line 9 def groups url = '/groups/' get(url) end |
#included_groups(group_id) ⇒ Array
Get the directly included groups of a group
32 33 34 35 |
# File 'lib/gerry/api/groups.rb', line 32 def included_groups(group_id) url = "/groups/#{group_id}/groups/" get(url) end |
#remove_from_group(group_id, users) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/gerry/api/groups.rb', line 63 def remove_from_group(group_id, users) url = "/groups/#{group_id}/members.delete" body = { members: users } post(url, body) end |