Module: Brivo::API::Groups

Includes:
HTTP
Included in:
Brivo::Application
Defined in:
lib/brivo/api/groups.rb

Constant Summary

Constants included from HTTP

HTTP::API_URL, HTTP::DEFAULT_HTTPS_SETTINGS, HTTP::MAX_RETRIES, HTTP::PAGE_SIZE

Instance Method Summary collapse

Methods included from HTTP

#http_request, #set_access_token

Instance Method Details

#create_group(name) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/brivo/api/groups.rb', line 33

def create_group name
  group_json = http_request(
    'groups',
    params: {
      name: name
    },
    method: :post
  )

  group_class.new(group_json)
end

#delete_group(id) ⇒ Object



45
46
47
# File 'lib/brivo/api/groups.rb', line 45

def delete_group id
  http_request "groups/#{id}", method: :delete
end

#group(id = nil) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/brivo/api/groups.rb', line 16

def group id = nil
  if id
    group_json = http_request("groups/#{id}")
    group_class.new(group_json)
  else
    group_class
  end
end

#group_assign_user(group_id, user_id) ⇒ Object



25
26
27
# File 'lib/brivo/api/groups.rb', line 25

def group_assign_user group_id, user_id
  http_request "groups/#{group_id}/users/#{user_id}", method: :put
end

#group_remove_user(group_id, user_id) ⇒ Object



29
30
31
# File 'lib/brivo/api/groups.rb', line 29

def group_remove_user group_id, user_id
  http_request "groups/#{group_id}/users/#{user_id}", method: :delete
end

#groupsObject



8
9
10
# File 'lib/brivo/api/groups.rb', line 8

def groups
  Brivo::Collection.new(self, 'groups', group_class)
end

#user_groups(user_id) ⇒ Object



12
13
14
# File 'lib/brivo/api/groups.rb', line 12

def user_groups(user_id)
  Brivo::Collection.new(self, "users/#{user_id}/groups", group_class)
end