Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add GetOATemplateDetail ApplyOAEvent GetOAApprovalInfo GetOAApprovalDetail EventSysApprovalChange #57

Merged
merged 1 commit into from Dec 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion README.md
Expand Up @@ -65,6 +65,7 @@ in at least 2 of Qiniu's internal systems.
* [x] 消息发送 (除修改群聊会话外全部支持)
* [x] 消息接收 (**接口尚不稳定,极有可能做出不兼容改动,先不要用**)
* [x] 素材管理 (**支持上传**, 见下)
* [ ] OA
* [ ] 会话内容存档
* [x] 企业微信登录接口 (code2Session)

Expand Down Expand Up @@ -111,7 +112,6 @@ in at least 2 of Qiniu's internal systems.
<details>
<summary>外部联系人管理 API</summary>


* [x] 成员对外信息
* [x] 客户管理
- [x] 获取客户列表
Expand Down Expand Up @@ -190,6 +190,20 @@ in at least 2 of Qiniu's internal systems.

</details>

<details>
<summary>OA API</summary>

* [ ] 审批
- [x] 获取审批模板详情
- [x] 提交审批申请
- [x] 审批申请状态变化回调通知
- [x] 批量获取审批单号
- [x] 获取审批申请详情
- [ ] 获取企业假期管理配置
- [ ] 修改成员假期余额

</details>

<details>
<summary>会话内容存档 API</summary>

Expand Down
56 changes: 56 additions & 0 deletions apis.md.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion docs/apis.md
Expand Up @@ -149,7 +149,10 @@ Name|Request Type|Response Type|Access Token|URL|Doc

Name|Request Type|Response Type|Access Token|URL|Doc
:---|------------|-------------|------------|:--|:--
`execCorpGetOpenApprovalData`|TODO|TODO|+|`POST /cgi-bin/corp/getopenapprovaldata`|[查询自建应用审批单当前状态](https://work.weixin.qq.com/api/doc#90000/90135/90269)
`execOAGetTemplateDetail`|`reqOAGetTemplateDetail`|`respOAGetTemplateDetail`|+|`POST /cgi-bin/oa/gettemplatedetail`|[获取审批模板详情](https://work.weixin.qq.com/api/doc/90000/90135/91982)
`execOAApplyEvent`|`reqOAApplyEvent`|`respOAApplyEvent`|+|`POST /cgi-bin/oa/applyevent`|[提交审批申请](https://work.weixin.qq.com/api/doc/90000/90135/91853)
`execOAGetApprovalInfo`|`reqOAGetApprovalInfo`|`respOAGetApprovalInfo`|+|`POST /cgi-bin/oa/getapprovalinfo`|[批量获取审批单号](https://work.weixin.qq.com/api/doc/90000/90135/91816)
`execOAGetApprovalDetail`|`reqOAGetApprovalDetail`|`respOAGetApprovalDetail`|+|`POST /cgi-bin/oa/getapprovaldetail`|[获取审批申请详情](https://work.weixin.qq.com/api/doc/90000/90135/91983)

# 企业支付

Expand Down
372 changes: 372 additions & 0 deletions docs/oa.md

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions docs/rx_msg.md
Expand Up @@ -48,6 +48,9 @@ const EventTypeChangeExternalContact EventType = "change_external_contact"
// EventTypeChangeExternalChat 客户群变更事件
const EventTypeChangeExternalChat EventType = "change_external_chat"

// EventTypeSysApprovalChange 审批申请状态变化回调通知
const EventTypeSysApprovalChange EventType = "sys_approval_change"

// ChangeType 变更类型
type ChangeType string

Expand Down Expand Up @@ -173,3 +176,9 @@ Name|XML|Type|Doc
`FromUserName`|`FromUserName`|`string`|此事件该值固定为sys,表示该消息由系统生成
`FailReason`|`FailReason`|`string`|接替失败的原因, customer_refused-客户拒绝, customer_limit_exceed-接替成员的客户数达到上限
`ChatID`|`ChatId`|`string`|群ID

### `rxEventSysApprovalChange` 接收的事件消息,审批申请状态变化回调通知

Name|XML|Type|Doc
:---|:--|:---|:--
`ApprovalInfo`|`ApprovalInfo`|`OAApprovalInfo`|审批信息、
1 change: 1 addition & 0 deletions dummy_for_generate.go
Expand Up @@ -5,5 +5,6 @@ package workwx
//go:generate go run --tags sdkcodegen ./internal/sdkcodegen ./docs/dept_info.md ./dept_info.md.go
//go:generate go run --tags sdkcodegen ./internal/sdkcodegen ./docs/external_contact.md ./external_contact.md.go
//go:generate go run --tags sdkcodegen ./internal/sdkcodegen ./docs/user_info.md ./user_info.md.go
//go:generate go run --tags sdkcodegen ./internal/sdkcodegen ./docs/oa.md ./oa.md.go
//go:generate go run --tags sdkcodegen ./internal/sdkcodegen ./docs/rx_msg.md ./rx_msg.md.go
//go:generate go run --tags sdkcodegen ./internal/errcodegen ./errcodes/mod.go
235 changes: 231 additions & 4 deletions example_test.go
Expand Up @@ -2,13 +2,18 @@ package workwx_test

import (
"net/http"
"strconv"
"time"

"github.com/xen0n/go-workwx"
)

const (
corpID = "your_corpid"
corpSecret = "your_corpsecret"
)

func ExampleWorkwx() {
corpID := "your_corpid"
corpSecret := "your_corpsecret"
agentID := int64(1234567)

client := workwx.New(corpID)
Expand All @@ -28,8 +33,6 @@ func ExampleWorkwx() {
}

func ExampleWorkwxApp_SendTextMessage() {
corpID := "your_corpid"
corpSecret := "your_corpsecret"
agentID := int64(1234567)

client := workwx.New(corpID)
Expand Down Expand Up @@ -68,3 +71,227 @@ func ExampleWorkwxApp_SendTextMessage() {
}
_ = app.SendTextMessage(&to5, "send to chatid", false)
}

func ExampleWorkwxApp_ApplyOAEvent() {
agentID := int64(1234567)

client := workwx.New(corpID)

app := client.WithApp(corpSecret, agentID)
app.SpawnAccessTokenRefresher()

appInfo := workwx.OAApplyEvent{
CreatorUserID: "your_userid",
TemplateID: "your_templateid",
UseTemplateApprover: 1,
ApplyData: workwx.OAContents{
Contents: []workwx.OAContent{
{
Control: workwx.OAControlText,
ID: "Text-1608628829793",
Value: workwx.OAContentValue{
Text: "文本",
},
},
{
Control: workwx.OAControlTextarea,
ID: "Textarea-1608628832640",
Value: workwx.OAContentValue{
Text: "多行文本\n可换行",
},
},
{
Control: workwx.OAControlNumber,
ID: "Number-1608632495498",
Value: workwx.OAContentValue{
Number: "123.45",
},
},
{
Control: workwx.OAControlMoney,
ID: "Money-1608632497034",
Value: workwx.OAContentValue{
Money: "678.90",
},
},
{
Control: workwx.OAControlFormula,
ID: "Formula-1608632498148",
Value: workwx.OAContentValue{
Formula: workwx.OAContentFormula{Value: "5.0"},
},
},
{
Control: workwx.OAControlDate,
ID: "Date-1608632499227",
Value: workwx.OAContentValue{
Date: workwx.OAContentDate{Type: "day", Timestamp: strconv.FormatInt(time.Now().Unix(), 10)},
},
},
{
Control: workwx.OAControlDate,
ID: "Date-1608632500394",
Value: workwx.OAContentValue{
Date: workwx.OAContentDate{Type: "hour", Timestamp: strconv.FormatInt(time.Now().Unix(), 10)},
},
},
{
Control: workwx.OAControlDateRange,
ID: "DateRange-1608632502131",
Value: workwx.OAContentValue{
DateRange: workwx.OAContentDateRange{
NewBegin: int(time.Now().Unix()),
NewEnd: int(time.Now().Add(time.Hour * 24).Unix()),
NewDuration: 60 * 60 * 24,
},
},
},
{
Control: workwx.OAControlSelector,
ID: "Selector-1608632503203",
Value: workwx.OAContentValue{
Selector: workwx.OAContentSelector{
Type: "single",
Options: []workwx.OAContentSelectorOption{
{Key: "option-1608632503204"},
},
},
},
},
{
Control: workwx.OAControlSelector,
ID: "Selector-1608632504330",
Value: workwx.OAContentValue{
Selector: workwx.OAContentSelector{
Type: "multi",
Options: []workwx.OAContentSelectorOption{
{Key: "option-1608632504330"},
{Key: "option-1608632504331"},
},
},
},
},
{
Control: workwx.OAControlContact,
ID: "Contact-1608632505579",
Value: workwx.OAContentValue{
Members: []workwx.OAContentMember{{
UserID: "your_userid",
Name: "your_name",
}},
},
},
{
Control: workwx.OAControlContact,
ID: "Contact-1608632506635",
Value: workwx.OAContentValue{
Departments: []workwx.OAContentDepartment{{
OpenAPIID: "39",
Name: "xx部门1",
}, {
OpenAPIID: "40",
Name: "xx部门2",
}},
},
},
{
Control: workwx.OAControlLocation,
ID: "Location-1608632507748",
Value: workwx.OAContentValue{
Location: workwx.OAContentLocation{
Latitude: "30.547239",
Longitude: "104.063291",
Title: "腾讯科技(成都)有限公司(腾讯成都大厦)",
Address: "四川省成都市武侯区天府三街198号腾讯成都大厦A座",
Time: int(time.Now().Unix()),
},
},
},
{
Control: workwx.OAControlRelatedApproval,
ID: "RelatedApproval-1608632509930",
Value: workwx.OAContentValue{
RelatedApproval: []workwx.OAContentRelatedApproval{
{SpNo: "202012220021"},
},
},
},
{
Control: workwx.OAControlTable,
ID: "Table-1608632511066",
Value: workwx.OAContentValue{
Table: []workwx.OAContentTableList{
{
List: []workwx.OAContent{
{
Control: workwx.OAControlText,
ID: "Text-1608632519610",
Value: workwx.OAContentValue{
Text: "第一行第一列",
},
}, {
Control: workwx.OAControlText,
ID: "Text-1608632521106",
Value: workwx.OAContentValue{
Text: "第一行第二列",
},
},
},
},
{
List: []workwx.OAContent{
{
Control: workwx.OAControlText,
ID: "Text-1608632519610",
Value: workwx.OAContentValue{
Text: "第二行第一列",
},
}, {
Control: workwx.OAControlText,
ID: "Text-1608632521106",
Value: workwx.OAContentValue{
Text: "第二行第二列",
},
},
},
},
},
},
},
{
Control: workwx.OAControlVacation,
ID: "Vacation-1608715577151",
Value: workwx.OAContentValue{
Vacation: workwx.OAContentVacation{
Selector: workwx.OAContentSelector{
Type: "single",
Options: []workwx.OAContentSelectorOption{
{
Key: "3",
},
},
},
Attendance: workwx.OAContentVacationAttendance{
DateRange: workwx.OAContentVacationAttendanceDateRange{
Type: "hour",
OAContentDateRange: workwx.OAContentDateRange{
NewBegin: int(time.Now().Unix()),
NewEnd: int(time.Now().Add(time.Hour * 72).Unix()),
NewDuration: 60 * 60 * 72,
},
},
Type: 1,
},
},
},
},
},
},
SummaryList: []workwx.OASummaryList{{SummaryInfo: []workwx.OAText{{
Text: "摘要第1行",
}}}, {SummaryInfo: []workwx.OAText{{
Text: "摘要第2行",
}}}},
}
_, _ = app.ApplyOAEvent(appInfo)
}