Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rails_dingtalk
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
other
rails_dingtalk
Commits
d4740fad
Commit
d4740fad
authored
Sep 06, 2021
by
mingyuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get infos
parent
ef9cafa8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
app.rb
app/models/dingtalk/model/app.rb
+2
-0
new_app.rb
app/models/dingtalk/model/app/new_app.rb
+13
-4
No files found.
app/models/dingtalk/model/app.rb
View file @
d4740fad
...
...
@@ -14,6 +14,8 @@ module Dingtalk
attribute
:jsapi_ticket
,
:string
attribute
:oauth2_state
,
:string
attribute
:jsapi_ticket_expires_at
,
:datetime
has_many
:dingtalk_users
,
foreign_key: :appid
,
primary_key: :corp_id
end
def
api
...
...
app/models/dingtalk/model/app/new_app.rb
View file @
d4740fad
...
...
@@ -30,11 +30,20 @@ module Dingtalk
r
=
HTTPX
.
post
'https://api.dingtalk.com/v1.0/oauth2/userAccessToken'
,
json:
h
result
=
JSON
.
parse
(
r
.
body
.
to_s
)
logger
.
debug
result
info
=
HTTPX
.
post
'https://api.dingtalk.com/v1.0/contact/users/me'
,
headers:
{
'x-acs-dingtalk-access-token'
:
r
[
'accessToken'
]
}
logger
.
debug
info
#binding.break
# wechat_user = wechat_users.find_or_initialize_by(uid: result['openid'])
# wechat_user.assign_attributes result.slice('access_token', 'refresh_token', 'unionid')
# wechat_user.expires_at = Time.current + result['expires_in'].to_i
# wechat_user
dingtalk_user
=
dingtalk_users
.
find_or_initialize_by
(
uid:
info
[
'openId'
])
dingtalk_user
.
access_token
=
r
[
'accessToken'
]
dingtalk_user
.
expires_at
=
Time
.
current
+
r
[
'expireIn'
].
to_i
dingtalk_user
.
refresh_token
=
r
[
'refreshToken'
]
dingtalk_user
.
unionid
=
info
[
'unionId'
]
dingtalk_user
.
name
=
info
[
'nick'
]
dingtalk_user
.
avatar_url
=
info
[
'avatarUrl'
]
dingtalk_user
.
identity
=
info
[
'mobile'
]
dingtalk_user
.
extra
=
info
.
slice
(
'email'
,
'stateCode'
)
dingtalk_user
end
end
...
...
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