Class: Api::UsersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/api/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#followObject

put /api/users/:id/follow



13
14
15
16
17
# File 'app/controllers/api/users_controller.rb', line 13

def follow
  link = UserLink.follow(current_user, @entity)
  notify_followee(link)
  render json: { data: { id: link.id } }
end

#grant_privilegeObject

put /api/users/:id/privileges/:privilege_id



26
27
28
29
30
# File 'app/controllers/api/users_controller.rb', line 26

def grant_privilege
  @privilege.grant(@entity, @region)

  render json: { data: { user_privilege_ids: @entity.user_privilege_ids } }
end

#revoke_privilegeObject

delete /api/users/:id/privileges/:privilege_id



33
34
35
36
37
# File 'app/controllers/api/users_controller.rb', line 33

def revoke_privilege
  @privilege.revoke(@entity, @region)

  render json: { data: { user_privilege_ids: @entity.user_privilege_ids } }
end

#toggleObject

post /api/users/:id/toggle



8
9
10
# File 'app/controllers/api/users_controller.rb', line 8

def toggle
  render json: { data: @entity.toggle_parameter(params[:parameter].to_s) }
end

#unfollowObject

delete /api/users/:id/follow



20
21
22
23
# File 'app/controllers/api/users_controller.rb', line 20

def unfollow
  UserLink.unfollow(current_user, @entity)
  head :no_content
end