Skip to content

Commit

Permalink
[feat] Add New API to CorpApi
Browse files Browse the repository at this point in the history
1. CorpApi#batch_get_by_user
2. CorpApi#follow_user_list
  • Loading branch information
leepood authored and Eric-Guo committed Jan 4, 2024
1 parent 439110f commit e2f6f40
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/wechat/corp_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ def get_externalcontact(external_userid, cursor = nil)
get 'externalcontact/get', params: { external_userid: external_userid, cursor: cursor }
end

def follow_user_list
# https://developer.work.weixin.qq.com/document/path/92576
get 'externalcontact/get_follow_user_list'
end

def batch_get_by_user(userid_list, cursor: nil, limit: nil)
# https://developer.work.weixin.qq.com/document/path/93010
post 'externalcontact/batch/get_by_user', JSON.generate(userid_list:, cursor:, limit:)
end

def agent_list
get 'agent/list'
end
Expand Down
36 changes: 36 additions & 0 deletions spec/lib/wechat/corp_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -595,4 +595,40 @@
end
end

describe '#follow_user_list' do
specify 'should get a list of members configured with the Customer Contact feature.' do
follow_user_data = {
errcode: 0,
errmsg: "ok",
follow_user: []
}

expect(subject.client).to receive(:get)
.with('externalcontact/get_follow_user_list',
hash_including(params: { access_token: 'access_token' }))
.and_return(follow_user_data)
expect(subject.follow_user_list).to eq follow_user_data
end
end

describe '#batch_get_by_user' do
specify "should get a list of external_contact user details" do

expected_data = {
errcode: 0,
errmsg: "ok",
external_contact_list: [],
next_cursor: "",
}

expect(subject.client).to receive(:post)
.with('externalcontact/batch/get_by_user',
JSON.generate({ userid_list: ['user_id'], cursor: '', limit: 100 }),
hash_including(params: { access_token: 'access_token' }))
.and_return(expected_data)
expect(subject.batch_get_by_user(['user_id'], cursor: '', limit: 100)).to eq expected_data
end

end

end

0 comments on commit e2f6f40

Please sign in to comment.