Class: Kf5Api::User

Inherits:
Object
  • Object
show all
Extended by:
Base
Defined in:
lib/kf5_api/user.rb

Constant Summary collapse

ACTIONS_HASH =
{
  users: '/apiv2/users',
  users_by_org: '/apiv2/organizations/%{id}/users',
  edit: '/apiv2/users/%{id}',
  search: '/apiv2/users/search'
}

Class Method Summary collapse

Methods included from Base

basic_auth, get, put

Class Method Details

.edit(id, attributes = {}) ⇒ Object

修改用户信息



28
29
30
31
# File 'lib/kf5_api/user.rb', line 28

def edit(id, attributes = {})
  action = format(ACTIONS_HASH[:edit], id: id)
  put(action, attributes).parsed_response
end

.search(keyword, query_fields = nil) ⇒ Object

查询用户信息query为查询参数,模糊搜索(名称,邮箱,手机号,微信openid)



35
36
37
38
39
40
# File 'lib/kf5_api/user.rb', line 35

def search(keyword, query_fields = nil)
  action = format(ACTIONS_HASH[:search])
  query_params = { query: keyword }
  query_params[:query_fields] = query_fields if query_fields.present?
  get(action, query_params).parsed_response
end

.users(query_params = {}) ⇒ Object

获取用户列表



16
17
18
19
# File 'lib/kf5_api/user.rb', line 16

def users(query_params = {})
  action = ACTIONS_HASH[:users]
  get(action, query_params).parsed_response
end

.users_by_organization(org_id, query_params = {}) ⇒ Object

获取某个组织下的所有用户



22
23
24
25
# File 'lib/kf5_api/user.rb', line 22

def users_by_organization(org_id, query_params = {})
  action = format(ACTIONS_HASH[:users_by_org], id: org_id)
  get(action, query_params).parsed_response
end