Skip to content

Commit

Permalink
feat(work): add DepartmentGet api (#718)
Browse files Browse the repository at this point in the history
get single department detail
  • Loading branch information
Lumiaqian committed Sep 24, 2023
1 parent 8bb1451 commit ae40639
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions work/addresslist/department.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const (
departmentSimpleListURL = "https://qyapi.weixin.qq.com/cgi-bin/department/simplelist?access_token=%s&id=%d"
// departmentListURL 获取部门列表
departmentListURL = "https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token=%s"
// departmentGetURL 获取单个部门详情 https://qyapi.weixin.qq.com/cgi-bin/department/get?access_token=ACCESS_TOKEN&id=ID
departmentGetURL = "https://qyapi.weixin.qq.com/cgi-bin/department/get?access_token=%s&id=%d"
)

type (
Expand Down Expand Up @@ -121,3 +123,24 @@ func (r *Client) DepartmentList() ([]*Department, error) {
// 返回数据
return result.Department, err
}

// DepartmentGet 获取单个部门详情
// see https://developer.work.weixin.qq.com/document/path/95351
func (r *Client) DepartmentGet(departmentID int) (*Department, error) {
var (
accessToken string
err error
)
if accessToken, err = r.GetAccessToken(); err != nil {
return nil, err
}
var response []byte
if response, err = util.HTTPGet(fmt.Sprintf(departmentGetURL, accessToken, departmentID)); err != nil {
return nil, err
}
result := &Department{}
if err = util.DecodeWithError(response, result, "DepartmentGet"); err != nil {
return nil, err
}
return result, nil
}

0 comments on commit ae40639

Please sign in to comment.