Skip to content

Commit

Permalink
get user info via code in Enterprise Account.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Guo committed Dec 17, 2015
1 parent c51f675 commit 9af4eff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/wechat/corp_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def user(userid)
get 'user/get', params: { userid: userid }
end

def getuserinfo(code)
get 'user/getuserinfo', params: { code: code }
end

def convert_to_openid(userid)
post 'user/convert_to_openid', JSON.generate(userid: userid, agentid: agentid)
end
Expand Down
10 changes: 10 additions & 0 deletions spec/lib/wechat/corp_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@
end
end

describe '#getuserinfo' do
specify 'will get user/getuserinfo with access_token and code' do
code = 'code'
getuserinfo_result = { UserId: 'USERID', DeviceId: 'DEVICEID' }
expect(subject.client).to receive(:get)
.with('user/getuserinfo', params: { code: code, access_token: 'access_token' }).and_return(getuserinfo_result)
expect(subject.getuserinfo(code)).to eq getuserinfo_result
end
end

describe '#convert_to_openid' do
specify 'will get invite/send with access_token and json userid' do
userid = 'userid'
Expand Down

0 comments on commit 9af4eff

Please sign in to comment.