Module: Gerry::Client::Groups

Included in:
Gerry::Client
Defined in:
lib/gerry/client/groups.rb

Instance Method Summary collapse

Instance Method Details

#add_to_group(group_id, users) ⇒ Hash

Adds one or more users to a group

Parameters:

  • group_id (String)

    the group id

  • users (Enumberable)

    the list of users identified by email address

Returns:

  • (Hash)

    the account info details for each user added


40
41
42
43
44
45
46
# File 'lib/gerry/client/groups.rb', line 40

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

Returns:

  • (Hash)

    the group details


25
26
27
28
29
30
31
32
33
# File 'lib/gerry/client/groups.rb', line 25

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) ⇒ Array

Get all members for a group

Returns:

  • (Array)

    the members


17
18
19
20
# File 'lib/gerry/client/groups.rb', line 17

def group_members(group_id)
  url = "/groups/#{group_id}/members/"
  get(url)
end

#groupsHash

Get all groups

Returns:

  • (Hash)

    the groups


9
10
11
12
# File 'lib/gerry/client/groups.rb', line 9

def groups
  url = '/groups/'
  get(url)
end

#remove_from_group(group_id, users) ⇒ Object


48
49
50
51
52
53
54
# File 'lib/gerry/client/groups.rb', line 48

def remove_from_group(group_id, users)
  url = "/groups/#{group_id}/members.delete"
  body = {
    members: users
  }
  post(url, body)
end