Commit 1cb52522 by Francis Zhou

增加获取 userId 和 用户资料接口

parent f9eb1336
......@@ -11,4 +11,5 @@
.rspec_status
.idea
*.iml
Gemfile.lock
......@@ -90,8 +90,10 @@ module Dingtalk
[:body, :query].each do |arg_pos|
h[arg_pos] = {} if builder.send(:"has_#{arg_pos}?")
builder.send(:"#{arg_pos}_args").each do |arg|
h[arg_pos][arg] = method_args[arg]
builder.send(:"#{arg_pos}_args").each do |arg_name|
arg_value = method_args[arg_name]
next if arg_pos == :query && arg_value.nil?
h[arg_pos][arg_name] = arg_value
end
builder.send(:"#{arg_pos}_const").each do |arg_name, arg_value|
......
......@@ -16,5 +16,17 @@ module Dingtalk
# 服务端通过临时授权码获取授权用户的个人信息
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/etaarr
GET_USER_INFO_SNS = "https://oapi.dingtalk.com/sns/getuserinfo_bycode"
# 获取用户详情
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/ege851/AaRQe
GET_USER_PROFILE = "https://oapi.dingtalk.com/user/get"
# 通过 unionId 获取 userId
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/ege851/602f4b15
GET_USERID_FROM_UNIONID = "https://oapi.dingtalk.com/user/getUseridByUnionid"
# 根据手机号获取 userId
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/ege851/soV11
GET_USERID_FROM_MOBILE = "https://oapi.dingtalk.com/user/get_by_mobile"
end
end
\ No newline at end of file
require "dingtalk/core"
require "dingtalk/request_url"
module Dingtalk
module User
extend Dingtalk::Core
# 获取用户详情
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/ege851/AaRQe
add_request :get_user_profile, :get, Dingtalk::RequestUrl::GET_USER_PROFILE do |request|
request.add_arg :userid, required: true, in: :query
request.add_arg :access_token, required: true, in: :query
end
# 根据 unionId 获取 userId
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/ege851/602f4b15
add_request :get_userid_by_unionid, :get, Dingtalk::RequestUrl::GET_USERID_FROM_UNIONID do |request|
request.add_arg :unionid, required: true, in: :query
request.add_arg :access_token, required: true, in: :query
end
# 根据手机号获取 userId
# @url https://ding-doc.dingtalk.com/doc#/serverapi2/ege851/soV11
add_request :get_userid_by_mobile, :get, Dingtalk::RequestUrl::GET_USERID_FROM_MOBILE do |request|
request.add_arg :mobile, required: true, in: :query
request.add_arg :access_token, required: true, in: :query
end
end
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment