From f0c889c67132189372ec5e6fb899933efef27692 Mon Sep 17 00:00:00 2001 From: Tao Huang Date: Sat, 21 Sep 2019 16:09:20 +0800 Subject: [PATCH] Add more user APIs --- lib/dingtalk/api/department.rb | 4 ++-- lib/dingtalk/api/user.rb | 33 +++++++++++++++++++++++++++++++-- lib/dingtalk/corp.rb | 4 ++++ 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/lib/dingtalk/api/department.rb b/lib/dingtalk/api/department.rb index 803479d..355a291 100644 --- a/lib/dingtalk/api/department.rb +++ b/lib/dingtalk/api/department.rb @@ -1,8 +1,8 @@ module Dingtalk module Api class Department < Base - def list - http_get("list?access_token=#{access_token}") + def list(parent_id = 1, fetch_child = false) + http_get("list?id=#{parent_id}&fetch_child=#{fetch_child}&access_token=#{access_token}") end def create(params) diff --git a/lib/dingtalk/api/user.rb b/lib/dingtalk/api/user.rb index cfb4073..789e538 100644 --- a/lib/dingtalk/api/user.rb +++ b/lib/dingtalk/api/user.rb @@ -5,14 +5,43 @@ module Dingtalk http_get("getuserinfo?access_token=#{access_token}&code=#{code}") end - def list(department=1) - http_get("list?access_token=#{access_token}&department_id=#{department}") + def userids(department=1) + http_get("getDeptMember?access_token=#{access_token}&deptId=#{department}") + end + + def simplelist(department=1) + http_get("simplelist?access_token=#{access_token}&department_id=#{department}") + end + + def listbypage(department=1, offset=0, size=20, order='custom') + http_get("list?access_token=#{access_token}&department_id=#{department}&offset=#{offset}&size=#{size}&order=#{order}") end def get(userid) http_get("get?access_token=#{access_token}&userid=#{URI.escape userid}") end + def get_admin + http_get("get_admin?access_token=#{access_token}") + end + + def get_admin_scope + http_get("get_admin_scope?access_token=#{access_token}") + end + + def get_access_microapp(app_id, user_id) + http_get("get_access_microapp?access_token=#{access_token}&appId=#{app_id}&user_id=#{URI.escape userid}") + end + + def get_userid_by_unionid(unionid) + http_get("getUseridByUnionid?access_token=#{access_token}&unionid=#{URI.escape unionid}") + end + + # onlyActive: 0: 包含未激活钉钉的人员数量, 1: 不包含未激活钉钉的人员数量 + def get_org_user_count(onlyActive = 0) + http_get("get_org_user_count?access_token=#{access_token}&onlyActive=#{onlyActive}") + end + def delete(userid) http_get("delete?access_token=#{access_token}&userid=#{URI.escape userid}") end diff --git a/lib/dingtalk/corp.rb b/lib/dingtalk/corp.rb index 0150f06..418374b 100644 --- a/lib/dingtalk/corp.rb +++ b/lib/dingtalk/corp.rb @@ -8,5 +8,9 @@ module Dingtalk @corp_secret = '' @permanent_code = '' end + + def isv_mode? + @isv_mode + end end end \ No newline at end of file -- libgit2 0.21.0