Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dingtalk-sdk
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
dingtalk-sdk
Commits
1cb52522
Commit
1cb52522
authored
Sep 02, 2020
by
Francis Zhou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加获取 userId 和 用户资料接口
parent
f9eb1336
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
2 deletions
+48
-2
.gitignore
.gitignore
+1
-0
core.rb
lib/dingtalk/core.rb
+4
-2
request_url.rb
lib/dingtalk/request_url.rb
+13
-0
user.rb
lib/dingtalk/user.rb
+30
-0
No files found.
.gitignore
View file @
1cb52522
...
...
@@ -11,4 +11,5 @@
.rspec_status
.idea
*.iml
Gemfile.lock
lib/dingtalk/core.rb
View file @
1cb52522
...
...
@@ -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
|
...
...
lib/dingtalk/request_url.rb
View file @
1cb52522
...
...
@@ -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
lib/dingtalk/user.rb
0 → 100644
View file @
1cb52522
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment