diff --git a/.github/.version b/.github/.version new file mode 100644 index 00000000..785a9ec0 --- /dev/null +++ b/.github/.version @@ -0,0 +1,2 @@ +v2.0.0 +v2/version.go diff --git a/.github/ISSUE_TEMPLATE/Bug_Report.md b/.github/ISSUE_TEMPLATE/Bug_Report.md new file mode 100644 index 00000000..2d1db6f2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Bug_Report.md @@ -0,0 +1,28 @@ +--- +Name: "Defect Problem Feedback" +About: Submit defect feedback + +--- + + + +* **SDK version**: +* **access API HTTP URL**: +* **How to Reproduce**: + + \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/Bug_Report_zh.md b/.github/ISSUE_TEMPLATE/Bug_Report_zh.md new file mode 100644 index 00000000..b9da5d6d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Bug_Report_zh.md @@ -0,0 +1,24 @@ +--- +name: "缺陷问题反馈" +about: 提交缺陷问题反馈 + +--- + + + +* **SDK 版本**: +* **访问的 API HTTP URL**: +* **最小代码**: +* **报错信息** + + diff --git a/.gitignore b/.gitignore index 5f05c8a2..33b7fc94 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,4 @@ modules.txt *_test.go *.json *.sh -test.go +test*.* diff --git a/FeiShu.md b/FeiShu.md new file mode 100644 index 00000000..0e09d97c --- /dev/null +++ b/FeiShu.md @@ -0,0 +1,578 @@ +# 飞书开放接口SDK + +## 概述 + +- 飞书开放平台,便于企业应用与飞书集成,让协同与管理更加高效 +- 飞书开发接口SDK,便捷 [调用服务端API](https://open.feishu.cn/document/ukTMukTMukTM/uITNz4iM1MjLyUzM) + 与 [订阅服务端事件](https://open.feishu.cn/document/ukTMukTMukTM/uUTNz4SN1MjL1UzM)。 + +## 问题反馈 + +如有任何SDK使用相关问题,请提交 [Github Issues](https://github.com/larksuite/oapi-sdk-go/issues), 我们会在收到 Issues 的第一时间处理,并尽快给您答复。 + +## 运行环境 + +- Golang 1.5及以上 + +## 安装方法 + +```shell +go get -u github.com/larksuite/v2 +``` + +## SDK 包引入与使用规则 + +- lark 包,引入的路径:"github.com/larksuite/oapi-sdk-go/v2" + +- 业务 包,引入的路径:"github.com/larksuite/oapi-sdk-go/v2/service/业务/版本" + + - 例如:im 包,引入的路径:"github.com/larksuite/oapi-sdk-go/v2/service/im/v1" + +- SDK 包如何使用,下面有代码示例可以参考 + +## 术语解释 + +- [开发文档](https://open.feishu.cn/document/) :开放平台的开放接口的参考,**开发者必看,可以使用搜索功能,高效的查询文档** +- [开发者后台](https://open.feishu.cn/app/) :开发者开发应用的管理后台 +- [企业自建应用](https://open.feishu.cn/document/home/introduction-to-custom-app-development/self-built-application-development-process) + :应用仅仅可在本企业内发布使用 +- [应用商店应用](https://open.feishu.cn/document/uMzNwEjLzcDMx4yM3ATM/uYzNwEjL2cDMx4iN3ATM?lang=zh-CN) + :应用会在 [应用目录](https://app.feishu.cn/) 展示,各个企业可以选择安装使用 + +![App type](doc/app_type.zh.png) + +## 如何调用服务端API + +- **必看** [如何调用服务端 API](https://open.feishu.cn/document/ukTMukTMukTM/uYTM5UjL2ETO14iNxkTN/guide-to-use-server-api) + ,了解调用服务端API的过程及注意事项。 + - 由于 SDK 已经封装了 app_access_token、tenant_access_token 的获取,所以在调业务 API 的时候,不需要去获取 + app_access_token、tenant_access_token。如果业务接口需要使用 user_access_token,需要进行设置 lark.WithUserAccessToken(" + userAccessToken"),具体请看:[如何发送请求](#如何发送请求) + +### 使用`企业自建应用`访问 [发送消息 API](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/create) 示例 + +- 在 [v2/service](./v2/service) 下的业务 API,都是可以直接使用业务 SDK +- 更多示例,请看:[v2/sample/api/im.go](./v2/sample/api/im.go)(含:文件的上传与下载) + +```go +package main + +import ( + "context" + "fmt" + "github.com/larksuite/oapi-sdk-go/v2" + "github.com/larksuite/oapi-sdk-go/v2/service/im/v1" + "os" +) + +func main() { + var appID, appSecret = os.Getenv("APP_ID"), os.Getenv("APP_SECRET") + + larkApp := lark.NewApp(lark.DomainFeiShu, appID, appSecret) + + ctx := context.Background() + messageCreate(ctx, larkApp) +} + +// 发送消息 +func messageCreate(ctx context.Context, larkApp *lark.App) { + messageText := &lark.MessageText{Text: "Tom test content"} + content, err := messageText.JSON() + if err != nil { + fmt.Println(err) + return + } + messageCreateResp, err := im.New(larkApp).Messages.Create(ctx, &im.MessageCreateReq{ + ReceiveIdType: lark.StringPtr("user_id"), + Body: &im.MessageCreateReqBody{ + ReceiveId: lark.StringPtr("77bbc392"), + MsgType: lark.StringPtr("text"), + Content: lark.StringPtr(content), + }, + }) + if err != nil { + fmt.Println(err) + return + } + fmt.Printf("request id: %s \n", messageCreateResp.RequestId()) + if messageCreateResp.Code != 0 { + fmt.Println(messageCreateResp.CodeError) + return + } + fmt.Println(lark.Prettify(messageCreateResp.Data)) +} +``` + +### 使用`企业自建应用`访问 [发送文本消息 API](https://open.feishu.cn/document/ukTMukTMukTM/uUjNz4SN2MjL1YzM) 示例 + +- 有些老版接口,没有直接可以使用的业务 SDK,可以使用`原生`模式,具体请看:[如何发送请求](#如何发送请求) + +- 更多示例,请看:[v2/sample/api/api.go](./v2/sample/api/api.go)(含:文件的上传与下载) + +```go +package main + +import ( + "context" + "fmt" + "github.com/larksuite/oapi-sdk-go/v2" + "net/http" + "os" +) + +func main() { + var appID, appSecret = os.Getenv("APP_ID"), os.Getenv("APP_SECRET") + + larkApp := lark.NewApp(lark.DomainFeiShu, appID, appSecret) + + ctx := context.Background() + sendMessage(ctx, larkApp) +} + +// 发送消息 +func sendMessage(ctx context.Context, larkApp *lark.App) { + resp, err := larkApp.SendRequest(ctx, http.MethodGet, "/open-apis/message/v4/send", + lark.AccessTokenTypeTenant, map[string]interface{}{ + "user_id": "77bbc392", + "msg_type": "text", + "content": &lark.MessageText{Text: "test"}, + }) + if err != nil { + fmt.Println(err) + return + } + fmt.Printf("request id: %s \n", resp.RequestId()) + fmt.Println(resp) + fmt.Println() +} + +``` + +## 如何订阅服务端事件 + +- **必看** [订阅事件概述](https://open.feishu.cn/document/ukTMukTMukTM/uUTNz4SN1MjL1UzM) ,了解订阅事件的过程及注意事项 + +### 使用`企业自建应用`订阅 [接收消息事件](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/events/receive) 示例 + +- 在 [v2/service](./v2/service) 下的业务 Event,都是可以直接使用业务 SDK + +- 更多使用示例,请看:[v2/sample/event/im.go](./v2/sample/event/im.go) + +```go +package main + +import ( + "context" + "fmt" + "github.com/larksuite/oapi-sdk-go/v2" + "github.com/larksuite/oapi-sdk-go/v2/service/im/v1" + "net/http" + "os" +) + +func main() { + appID, appSecret, verificationToken, encryptKey := os.Getenv("APP_ID"), os.Getenv("APP_SECRET"), + os.Getenv("VERIFICATION_TOKEN"), os.Getenv("ENCRYPT_KEY") + + larkApp := lark.NewApp(lark.DomainFeiShu, appID, appSecret, + lark.WithAppEventVerify(verificationToken, encryptKey)) + + // @应用机器人的消息处理 + im.New(larkApp).Messages.ReceiveEventHandler(func(ctx context.Context, req *lark.RawRequest, event *im.MessageReceiveEvent) error { + fmt.Println(req) + fmt.Println(lark.Prettify(event)) + return nil + }) + + // http server handle func + http.HandleFunc("/webhook/event", func(writer http.ResponseWriter, request *http.Request) { + // 如果开发者使用是其他Web框架,需要将Web框架的Request转成lark.RawRequest + // 经过larkApp.Webhook.EventCommandHandle(...) 的处理,返回lark.RawResponse + // 再将lark.RawResponse转成Web框架的Response + rawRequest, err := lark.NewRawRequest(request) + if err != nil { + writer.WriteHeader(http.StatusInternalServerError) + writer.Write([]byte(err.Error())) + return + } + rawResp := larkApp.Webhook.EventCommandHandle(context.Background(), rawRequest) + rawResp.Write(writer) + }) + // 设置 "开发者后台" -> "事件订阅" 请求网址 URL:https://domain/webhook/event + // startup event http server, port: 8089 + err := http.ListenAndServe(":8089", nil) + if err != nil { + panic(err) + } +} +``` + +### 使用`企业自建应用`订阅 [接收消息事件](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/events/receive) 示例 + +- 有些老的事件,没有直接可以使用的业务 SDK,可以使用`原生`模式,具体请看:[如何订阅事件](#如何订阅事件) + +- 更多使用示例,请看:[v2/sample/event/event.go](./v2/sample/event/event.go) + +```go +package main + +import ( + "context" + "fmt" + "github.com/larksuite/oapi-sdk-go/v2" + "net/http" + "os" +) + +func main() { + appID, appSecret, verificationToken, encryptKey := os.Getenv("APP_ID"), os.Getenv("APP_SECRET"), + os.Getenv("VERIFICATION_TOKEN"), os.Getenv("ENCRYPT_KEY") + + larkApp := lark.NewApp(lark.DomainFeiShu, appID, appSecret, + lark.WithAppEventVerify(verificationToken, encryptKey)) + + // @应用机器人的消息处理 + // "im.message.receive_v1":事件类型 + larkApp.Webhook.EventHandleFunc("im.message.receive_v1", func(ctx context.Context, req *lark.RawRequest) error { + fmt.Println(req.RequestId()) + fmt.Println(req) + return nil + }) + + // http server handle func + http.HandleFunc("/webhook/event", func(writer http.ResponseWriter, request *http.Request) { + // 如果开发者使用是其他Web框架,需要将Web框架的Request转成lark.RawRequest + // 经过larkApp.Webhook.EventCommandHandle(...) 的处理,返回lark.RawResponse + // 再将lark.RawResponse转成Web框架的Response + rawRequest, err := lark.NewRawRequest(request) + if err != nil { + writer.WriteHeader(http.StatusInternalServerError) + writer.Write([]byte(err.Error())) + return + } + rawResp := larkApp.Webhook.EventCommandHandle(context.Background(), rawRequest) + rawResp.Write(writer) + }) + // 设置 "开发者后台" -> "事件订阅" 请求网址 URL:https://domain/webhook/event + // startup event http server, port: 8089 + err := http.ListenAndServe(":8089", nil) + if err != nil { + panic(err) + } +} +``` + +## 如何处理消息卡片 Action + +- **必看** [消息卡片开发流程](https://open.feishu.cn/document/ukTMukTMukTM/uAzMxEjLwMTMx4CMzETM) ,了解订阅事件的过程及注意事项 +- 更多使用示例,请看:[v2/sample/card/card.go](./v2/sample/card/card.go) + +#### 使用`企业自建应用`处理消息卡片回调示例 + +```go +package main + +import ( + "context" + "fmt" + "github.com/larksuite/oapi-sdk-go/v2" + "net/http" + "os" +) + +func main() { + appID, appSecret, verificationToken, encryptKey := os.Getenv("APP_ID"), os.Getenv("APP_SECRET"), + os.Getenv("VERIFICATION_TOKEN"), os.Getenv("ENCRYPT_KEY") + + larkApp := lark.NewApp(lark.DomainFeiShu, appID, appSecret, + lark.WithAppEventVerify(verificationToken, encryptKey)) + + // card action handler + // return new card + larkApp.Webhook.CardActionHandler(func(ctx context.Context, request *lark.RawRequest, + action *lark.CardAction) (interface{}, error) { + fmt.Println(request) + fmt.Println(lark.Prettify(action)) + + card := &lark.MessageCard{ + Config: &lark.MessageCardConfig{WideScreenMode: lark.BoolPtr(true)}, + Elements: []lark.MessageCardElement{&lark.MessageCardMarkdown{ + Content: "**test**", + }}, + } + return card, nil + }) + // http server handle func + http.HandleFunc("/webhook/card", func(writer http.ResponseWriter, request *http.Request) { + // 如果开发者使用是其他Web框架,需要将Web框架的Request转成lark.RawRequest + // 经过larkApp.Webhook.CardActionHandle(...) 的处理,返回lark.RawResponse + // 再将lark.RawResponse转成Web框架的Response + rawRequest, err := lark.NewRawRequest(request) + if err != nil { + writer.WriteHeader(http.StatusInternalServerError) + writer.Write([]byte(err.Error())) + return + } + larkApp.Webhook.CardActionHandle(context.Background(), rawRequest).Write(writer) + }) + // 设置 "开发者后台" -> "应用功能" -> "机器人" 消息卡片请求网址:https://domain/webhook/card + // startup event http server, port: 8089 + err := http.ListenAndServe(":8089", nil) + if err != nil { + panic(err) + } +} +``` + +## 使用`应用商店应用`调用 服务端API 示例 + +- [如何获取 app_access_token](https://open.feishu.cn/document/ukTMukTMukTM/uEjNz4SM2MjLxYzM) (应用商店应用) + - 与企业自建应用相比,应用商店应用的获取 app_access_token 的流程复杂一些。 + - 需要开放平台下发的 app_ticket,通过订阅事件接收。SDK 已经封装了 app_ticket 事件的处理,只需要启动事件订阅服务。 + - 使用SDK调用服务端 API 时,如果当前还没有收到开发平台下发的 app_ticket ,会报错且向开放平台申请下发 app_ticket ,可以尽快的收到开发平台下发的 app_ticket,保证再次调用服务端 + API 的正常。 + - 使用SDK调用服务端 API 时,需要使用 tenant_access_token 访问凭证时,需要 tenant_key ,来表示当前是哪个租户使用这个应用调用服务端 API。 + - tenant_key,租户安装启用了这个应用,开放平台发送的服务端事件,事件内容中都含有 tenant_key。 +- 示例代码:[v2/sample/api/marketplace_app.go](./v2/sample/api/marketplace_app.go) + +## 如何构建应用 + +```go + +import ( +"github.com/larksuite/oapi-sdk-go/v2" +) + +// 防止应用信息泄漏,配置环境变量中,变量说明: +// APP_ID:"开发者后台" -> "凭证与基础信息" -> 应用凭证 App ID +// APP_SECRET:"开发者后台" -> "凭证与基础信息" -> 应用凭证 App Secret +// VERIFICATION_TOKEN:"开发者后台" -> "事件订阅" -> 事件订阅 Verification Token (事件订阅、处理消息卡片Action 必需) +// ENCRYPT_KEY:"开发者后台" -> "事件订阅" -> 事件订阅 Encrypt Key(事件订阅 必需) +// HELP_DESK_ID: 服务台设置中心 -> ID +// HELP_DESK_TOKEN: 服务台设置中心 -> 令牌 + +appID, appSecret, verificationToken, encryptKey, helpDeskID, helpDeskToken := os.Getenv("APP_ID"), os.Getenv("APP_SECRET"), +os.Getenv("VERIFICATION_TOKEN"), os.Getenv("ENCRYPT_KEY"), os.Getenv("HELP_DESK_ID"), os.Getenv("HELP_DESK_TOKEN") + +// 企业自建应用的配置 +larkApp := lark.NewApp(lark.DomainFeiShu, appID, appSecret, +lark.WithAppEventVerify(verificationToken, encryptKey), // 非必需,事件订阅、处理消息卡片Action时必需 +lark.WithAppHelpdeskCredential(helpDeskID, helpDeskToken), // 非必需,访问服务台API时必需 +) + +// 应用商店应用的配置 +larkApp := lark.NewApp(lark.DomainFeiShu, appID, appSecret, +lark.WithAppType(lark.AppTypeMarketplace), // 标识应用类型为:应用商店应用 +lark.WithAppEventVerify(verificationToken, encryptKey), // 非必需,事件订阅、处理消息卡片Action时必需 +lark.WithAppHelpdeskCredential(helpDeskID, helpDeskToken), // 非必需,访问服务台API时必需 +) + +// 配置日志接口的实现 +// 例如:使用logrus实现,请看示例代码:v2/sample/logrus.go +// 例如:日志(lark.NewDefaultLogger():日志控制台输出),日志级别(lark.LogLevelDebug:debug级别,可以打印更好的日志,利于排查问题) +larkApp := lark.NewApp(lark.DomainFeiShu, appID, appSecret, +lark.WithLogger(lark.NewDefaultLogger(), lark.LogLevelDebug), // 非必需 +) +// 更多示例:v2/sample/api/marketplace_app.go的"sample.Logrus{}" +larkApp := lark.NewApp(lark.DomainFeiShu, appID, appSecret, +lark.WithLogger(sample.Logrus{}, lark.LogLevelDebug), +) + +// 配置存储接口,用于存放:app_access_token、tenant_access_token、app_ticket +// 默认是sync.map内存实现的 +// 例如:使用redis实现,请看示例代码:v2/sample/redis_store.go +// 对于应用商品应用,接收开放平台下发的app_ticket,会保存到存储中,所以存储接口的实现的实现需要支持分布式存储 +// 更多示例:v2/sample/api/marketplace_app.go的"sample.NewRedisStore()" +larkApp := lark.NewApp(lark.DomainFeiShu, appID, appSecret, +lark.WithStore(sample.NewRedisStore()) // use redis store +) + +``` + +## 如何发送请求 + +- 有些老版接口,没有直接可以使用的业务 SDK,可以使用原生模式 +- 更多示例,请看:[v2/sample/api/api.go](./v2/sample/api/api.go)(含:文件的上传与下载) + +```go + +import ( +"context" +"net/http" +"github.com/larksuite/oapi-sdk-go/v2" +) + +app := lark.NewApp(lark.DomainFeiShu, appID, appSecret) + +// 参数说明: +// ctx: context.Context + +// httpMethod: HTTP method(http.MethodGet/http.MethodPost/http.MethodPut/http.MethodPatch/http.MethodDelete) + +// httpPath:API路径 +// 支持:域名之后的路径,则 httpPath:"/open-apis/contact/v3/users/:user_id"(推荐) +// 支持:全路径,则 httpPath:"https://domain/open-apis/contact/v3/users/:user_id" + +// accessTokenType:API使用哪种访问凭证(lark.AccessTokenTypeApp/lark.AccessTokenTypeTenant/lark.AccessTokenTypeUser) + +// input:请求体(可以是lark.NewFormdata(),表示:文件上传), 如果不需要请求体(例如:GET请求),则传:nil + +// options:扩展函数,如下: +// lark.WithTenantKey("tenantKey"),以`应用商店应用`身份,表示使用`tenant_access_token`访问API,需要设置 +// lark.WithUserAccessToken("userAccessToken"),表示使用`user_access_token`访问API,需要设置 +// lark.WithNeedHelpDeskAuth(),表示是服务台API,需要HelpDesk的Auth验证,需要设置 lark app 的 HelpDesk 信息 +// lark.WithHTTPHeader(header http.Header),设置 HTTP header +// lark.WithFileDownload(),表示下载文件 +func (app *App) SendRequest(ctx context.Context, httpMethod string, httpPath string, +accessTokenType AccessTokenType, input interface{}, options ...RequestOptionFunc) (*RawResponse, error) {} + + +// 发送请求的响应(lark.RawResponse) +type RawResponse struct { +StatusCode int `json:"-"` +Header http.Header `json:"-"` +RawBody []byte `json:"-"` +} + +// 获取请求的ID,反馈问题的时候,提供RequestId(HTTP.header["X-Tt-Logid"]),排查问题更方便 +func (resp RawResponse) RequestId() string {} + +// 响应的Body,反序列化一个实例上 +func (resp RawResponse) JSONUnmarshalBody(val interface{}) error {} + +``` + +## 如何订阅事件 + +- 有些老版接口,没有直接可以使用的业务 SDK,可以使用原生模式 +- 更多示例,请看:[v2/sample/event/event.go](./v2/sample/event/event.go) + +```go + +import ( +"context" +"net/http" +"github.com/larksuite/oapi-sdk-go/v2" +) + +app := lark.NewApp(lark.DomainFeiShu, appID, appSecret, lark.WithAppEventVerify(verificationToken, encryptKey)) + +// app.Webhook.EventHandleFunc +// 参数说明: +// eventType: 事件类型 + +// handler: 事件处理函数 +// ctx:context.Context +// req:事件的回调请求 +func (wh *webhook) EventHandleFunc(eventType string, handler func (ctx context.Context, req *RawRequest) error) {} + + +// 事件的回调请求(lark.RawRequest) +type RawRequest struct { +Header http.Header +RawBody []byte +} + +// 获取请求的ID,反馈问题的时候,提供RequestId,排查问题更方便 +func (req RawRequest) RequestId() string {} + +// 请求的Body,反序列化一个实例上 +func (req RawRequest) JSONUnmarshalBody(val interface{}) error {} + +``` + +## 自定义机器人 + +- 开发文档:[自定义机器人指南](https://open.feishu.cn/document/ukTMukTMukTM/ucTM5YjL3ETO24yNxkjN) +- 示例代码:[v2/sample/customer_bot/customer_bot.go](./v2/sample/customer_bot/customer_bot.go) + +```go + +// 创建一个 CustomerBot +// 参数说明: +// webhook:Webhook 地址 +// secret:安全设置 -> 签名校验,如果没有开启,则值为空字符串 +func NewCustomerBot(webhook string, secret string) *CustomerBot {} + +// 发送消息 +// 参数说明: +// ctx:context.Context +// msgType:消息类型 +// content:消息内容,类型:interface{} ,可以使用消息内容Model +func (c *CustomerBot) SendMessage(ctx context.Context, msgType string, content interface{}) (*CustomerBotSendMessageResp, error) + +``` + +## 消息内容 Model + +- 文档:[发送消息 content 说明](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/im-v1/message/create_json) + +- 消息内容 Model 代码:[v2/message_model.go](./v2/message_model.go) + +- 消息内容 Model 使用示例:[v2/sample/api/message_model.go](./v2/sample/api/message_model.go) + +|消息类型| Model | +|----|----| +|文本 text|lark.MessageText| +|富文本 post|lark.MessagePost| +|图片 image|lark.MessageImage| +|消息卡片 interactive|lark.MessageCard| +|分享个人名片 share_user|lark.MessageShareUser| +|分享群组名片 share_chat|lark.MessageShareChat| +|语音 audio|lark.MessageAudio| +|视频 media|lark.MessageVideo| +|文件 file|lark.MessageFile| +|表情包 sticker|lark.MessageFile| + +```go + +// 消息内容Model都有JSON方法,返回JSON字符串 +func (m *Message***) JSON() (string, error) {} + +``` + +## 基本类型与指针类型的转换 + +### 基本类型转指针类型 + +|方法名| 描述 | +|----|----| +|lark.StringPtr(v string)|string 转 *string| +|lark.BoolPtr(v bool)|bool 转 *bool| +|lark.IntPtr(v int)|int 转 *int| +|lark.Int8Ptr(v int8)|int8 转 *int8| +|lark.Int16Ptr(v int16)|int16 转 *int16| +|lark.Int32Ptr(v int32)|int32 转 *int32| +|lark.Int64Ptr(v int64)|int64 转 *int64| +|lark.Float32Ptr(v float32)|float32 转 *float32| +|lark.Float64Ptr(v float64)|float64 转 *float64| +|lark.TimePtr(v time.Time)|time.Time 转 *time.Time| + +### 指针类型转基本类型 + +|方法名| 描述 | +|----|----| +|lark.StringValue(v *string)|*string 转 string| +|lark.BoolValue(v *bool)|*bool 转 bool| +|lark.IntValue(v *int)|*int 转 int| +|lark.Int8Value(v *int8)|*int8 转 int8| +|lark.Int16Value(v *int16)|*int16 转 int16| +|lark.Int32Value(v *int32)|*int32 转 int32| +|lark.Int64Value(v *int64)|*int64 转 int64| +|lark.Float32Value(v *float32)|*float32 转 float32| +|lark.Float64Value(v *float64)|*float64 转 float64| +|lark.TimeValue(v *time.Time)|*time.Time 转 time.Time| + +## 下载文件工具 + +- 通过网络请求下载文件 +- 更多使用示例,请看:[v2/sample/utils/file_download.go](./v2/sample/utils/file_download.go) + +## License + +--- + +- MIT + + + diff --git a/LarkSuite.md b/LarkSuite.md new file mode 100644 index 00000000..e69de29b diff --git a/README.md b/README.md index 33cf1ec3..1a342d00 100644 --- a/README.md +++ b/README.md @@ -1,423 +1,34 @@ -[**飞书,点这里**](README.zh.md) | Larksuite(Overseas) - -- 如果使用的是飞书,请看 [**飞书,点这里**](README.zh.md) ,飞书与Larksuite使用的域名不一样,引用的文档地址也是不同的。(If you are using FeiShu, please see [**飞书,点这里**](README.zh.md) , Feishu and larksuite use different domain names and reference different document addresses.) - - -# LarkSuite open api SDK - -## Overview - ---- - -- Larksuite open platform facilitates the integration of enterprise applications and larksuite, making collaboration and - management more efficient. - -- Larksuite development interface SDK, convenient call server API and subscribe server events, such as: Message & group, - address book, calendar, docs and others can - visit [larksuite open platform document](https://open.larksuite.cn/document) ,Take a look at [REFERENCE]. - -## Problem feedback - ---- - -If you encounter any problems during usage, please let us know by submitting [Github Issues](https://github.com/larksuite/oapi-sdk-go/issues). We will deal with these Issues and get back to you as soon as possible. - -- Upgrade the package first, if you still have problems, please submit Issues - -## Run environment - ---- - -- Golang 1.5+ - -## Install - ---- - -- The latest release candidate provides more [open services API](/service) and bug repair. -```shell -go get github.com/larksuite/oapi-sdk-go@v1.1.40-rc9 -``` - -## Explanation of terms - -- Larksuite: the overseas name of lark, which mainly provides services for overseas enterprises and has an - independent [domain name address](https://www.larksuite.com/) . -- Development documents: reference to the open interface of the open platform **developers must see, and can use search - to query documents efficiently** . [more information](https://open.feishu.cn/document/) . -- Developer background: the management background for developers to develop - applications, [more introduction](https://open.larksuite.cn/app/) . -- Cutome APP: the application can only be installed and used in the - enterprise,[more introduction](https://open.larksuite.com/document/ukzMxEjL5MTMx4SOzETM/uEjNwYjLxYDM24SM2AjN) . -- Marketplace App:The app will be displayed in [App Directory](https://app.larksuite.com/) Display, each enterprise can - choose to install. - -![App type](doc/app_type.en.png) - -## Quick use - ---- - -### Call API - -#### Example of using "Custom App" to access [send text message](https://open.larksuite.com/document/uMzMyEjLzMjMx4yMzITM/ugDN0EjL4QDNx4CO0QTM) API -- Since the SDK has encapsulated the app_access_token、tenant_access_token So when calling the business API, you don't need to get the app_access_token、tenant_access_token. If the business interface needs to use user_access_token, which needs to be set(request.SetUserAccessToken("user_access_token")), Please refer to README.md -> How to build a request(Request) -- Some of the old API do not have a direct SDK to use. They can use the `native` mode. - -```go -package main - -import ( - "context" - "fmt" - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" -) - -func main() { - // Configuration of "Custom App", parameter description: - // AppID、AppSecret: "Developer Console" -> "Credentials"(App ID、App Secret) - // EncryptKey、VerificationToken:"Developer Console" -> "Event Subscriptions"(Encrypt Key、Verification Token) - appSettings := core.NewInternalAppSettings( - core.SetAppCredentials("AppID", "AppSecret"), // Required - core.SetAppEventKey("VerificationToken", "EncryptKey"), // Not required. Required for event、card subscription - ) - - // Currently, you are visiting larksuite, which uses default storage and default log (error level). More optional configurations are as follows: core.NewConfig() - conf := core.NewConfig(core.DomainLarkSuite, appSettings, core.SetLoggerLevel(core.LoggerLevelError)) - - // The content of the sent message - body := map[string]interface{}{ - "open_id": "user open id", - "msg_type": "text", - "content": map[string]interface{}{ - "text": "test send message", - }, - } - // The result of the request to send a message - ret := make(map[string]interface{}) - // Build request - req := request.NewRequestWithNative("/open-apis/message/v4/send", "POST", request.AccessTokenTypeTenant, body, &ret) - // The context of the request - coreCtx := core.WrapContext(context.Background()) - // Send request - err := api.Send(coreCtx, conf, req) - // Print the requestId of the request - fmt.Println(coreCtx.GetRequestID()) - // Print the response status of the request - fmt.Println(coreCtx.GetHTTPStatusCode()) - // Error handling of request - if err != nil { - e := err.(*response.Error) - fmt.Println(e.Code) - fmt.Println(e.Msg) - fmt.Println(tools.Prettify(err)) - return - } - // Print the result of the request - fmt.Println(tools.Prettify(ret)) -} - -``` - -### Subscribe to events - -- [Subscribe to events](https://open.larksuite.com/document/uMzMyEjLzMjMx4yMzITM/uETM4QjLxEDO04SMxgDN) , to understand - the process and precautions of subscribing to events. -- For more use examples, please refer to [sample/event](sample/event)(including: use in combination with gin) - -#### Example of using "Custom App" to subscribe [App First Enabled](https://open.larksuite.com/document/uMzMyEjLzMjMx4yMzITM/uYjMyYjL2IjM24iNyIjN) event. - -- For some old events, there is no SDK that can be used directly. You can use the `native` mode - -```go -package main - -import ( - "fmt" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - "github.com/larksuite/oapi-sdk-go/event" - eventhttpserver "github.com/larksuite/oapi-sdk-go/event/http/native" - "net/http" -) - -func main() { - - // Configuration of "Custom App", parameter description: - // AppID、AppSecret: "Developer Console" -> "Credentials"(App ID、App Secret) - // EncryptKey、VerificationToken:"Developer Console" -> "Event Subscriptions"(Encrypt Key、Verification Token) - appSettings := core.NewInternalAppSettings( - core.SetAppCredentials("AppID", "AppSecret"), // Required - core.SetAppEventKey("VerificationToken", "EncryptKey"), // Not required. Required for event、card subscription - ) - - // Currently, you are visiting larksuite, which uses default storage and default log (error level). More optional configurations are as follows: core.NewConfig() - conf := core.NewConfig(core.DomainLarkSuite, appSettings, core.SetLoggerLevel(core.LoggerLevelError)) - - // Set the application event callback to be enabled for the first time - event.SetTypeCallback(conf, "app_open", func(ctx *core.Context, e map[string]interface{}) error { - // Print the request ID of the request - fmt.Println(ctx.GetRequestID()) - // Print event - fmt.Println(tools.Prettify(e)) - return nil - }) - - // Start the httpserver, "Developer Console" -> "Event Subscriptions", setting Request URL: https://domain/webhook/event - eventhttpserver.Register("/webhook/event", conf) - err := http.ListenAndServe(":8089", nil) - if err != nil { - panic(err) - } -} - -``` - -### Processing message card callbacks - -- [Message Card Development Process](https://open.larksuite.com/document/uMzMyEjLzMjMx4yMzITM/ukzM3QjL5MzN04SOzcDN) , to - understand the process and precautions of processing message cards -- For more use examples, please refer to [sample/card](sample/card)(including: use in combination with gin) - -#### Example of using "Custom App" to handling message card callback. - -```go -package main - -import ( - "fmt" - "github.com/larksuite/oapi-sdk-go/card" - cardhttpserver "github.com/larksuite/oapi-sdk-go/card/http/native" - "github.com/larksuite/oapi-sdk-go/card/model" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - "net/http" -) - -func main() { - - // Configuration of "Custom App", parameter description: - // AppID、AppSecret: "Developer Console" -> "Credentials"(App ID、App Secret) - // EncryptKey、VerificationToken:"Developer Console" -> "Event Subscriptions"(Encrypt Key、Verification Token) - appSettings := core.NewInternalAppSettings( - core.SetAppCredentials("AppID", "AppSecret"), // Required - core.SetAppEventKey("VerificationToken", "EncryptKey"), // Not required. Required for event、card subscription - ) - - // Currently, you are visiting larksuite, which uses default storage and default log (error level). More optional configurations are as follows: core.NewConfig() - conf := core.NewConfig(core.DomainLarkSuite, appSettings, core.SetLoggerLevel(core.LoggerLevelError)) - - // Set the handler of the message card - // Return value: can be nil, JSON string of new message card - card.SetHandler(conf, func(ctx *core.Context, c *model.Card) (interface{}, error) { - // Print message card - fmt.Println(tools.Prettify(c)) - return "{\"config\":{\"wide_screen_mode\":true},\"i18n_elements\":{\"zh_cn\":[{\"tag\":\"div\",\"text\":{\"tag\":\"lark_md\",\"content\":\"[Larksuitegolang](https://www.larksuite.cn)Integrate instant communication, calendar, audio and video conference, cloud document, cloud disk, workbench and other functions into one to make organizations and individuals more efficient and enjoyable.\"}}]}}", nil - }) - - // Start the httpserver, "Developer Console" -> "Features" -> "Bot", setting Message Card Request URL: https://domain/webhook/card - cardhttpserver.Register("/webhook/card", conf) - err := http.ListenAndServe(":8089", nil) - if err != nil { - panic(err) - } -} - -``` - -## How to build app settings(AppSettings) - -```go - -import ( - "github.com/larksuite/oapi-sdk-go/core" -) - -// To prevent application information leakage, in the configuration environment variables, the variables (4) are described as follows: -// APP_ID: "Developer Console" -> "Credentials"(App ID) -// APP_Secret: "Developer Console" -> "Credentials"(App Secret) -// VERIFICATION_Token: VerificationToken、EncryptKey:"Developer Console" -> "Event Subscriptions"(Verification Token) -// ENCRYPT_Key: VerificationToken、EncryptKey:"Developer Console" -> "Event Subscriptions"(Encrypt Key) -// HELP_DESK_ID: Help desk setting -> ID -// HELP_DESK_TOKEN: Help desk setting -> Token -// The configuration of "Custom App" is obtained through environment variables -appSettings := core.GetInternalAppSettingsByEnv() -// The configuration of "Marketplace App" is obtained through environment variables -appSettings := core.GetISVAppSettingsByEnv() - -// Parameter Description: -// AppID、AppSecret: "Developer Console" -> "Credentials"(App ID、App Secret) -// VerificationToken、EncryptKey:"Developer Console" -> "Event Subscriptions"(Verification Token、Encrypt Key) -// HelpDeskID、HelpDeskToken:Help desk setting -> ID、Token -// The configuration of "Custom App" -appSettings := core.NewInternalAppSettings( -core.SetAppCredentials("AppID", "AppSecret"), // Required -core.SetAppEventKey("VerificationToken", "EncryptKey"), // Not required. Required for event、card subscription -core.SetHelpDeskCredentials("HelpDeskID", "HelpDeskToken"), // Not required. Required to access the service desk API -) -// The configuration of "Marketplace App" -appSettings := core.NewISVAppSettings( -core.SetAppCredentials("AppID", "AppSecret"), // Required -core.SetAppEventKey("VerificationToken", "EncryptKey"), // Not required. Required for event、card subscription -core.SetHelpDeskCredentials("HelpDeskID", "HelpDeskToken"), // Not required. Required to access the service desk API -) -``` - -## How to build overall configuration(Config) - -- Visit Larksuite, Feishu or others -- App settings -- The implementation of logger is used to output the logs generated in the process of SDK processing, which is - convenient for troubleshooting. - - You can use the log implementation of the business system, see the sample - code: [sample/config/logrus.go](sample/config/logrus.go) -- The implementation of store is used to save the access credentials (app/tenant_access_token), temporary voucher ( - app_ticket) - - Redis is recommended. Please see the example code: [sample/config/redis_store.go](sample/config/redis_store.go) - - It can reduce the times of obtaining access credentials and prevent the frequency limit of calling access - credentials interface. - - "Marketplace App", accept open platform distributed `app_ticket` will be saved to the storage, so the - implementation of the storage interface (store) needs to support distributed storage. - -```go -import ( - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" - "github.com/larksuite/oapi-sdk-go/core/log" - "github.com/larksuite/oapi-sdk-go/core/store" -) - -// Parameter Description: -// domain:URL domain address, value range: core.DomainFeiShu / core.DomainLarkSuite / 其他URL域名地址 -// appSettings:App settings -// opts:Option parameters - // core.SetLogger(logger log.Logger), Set logger. The default is console output - // core.SetLoggerLevel(core.LoggerLevelDebug), Set the logger log level, and the default is: core.LoggerLevelError - // core.SetStore(store store.Store), Set Store([Store interface](core/store/store.go), used to store app_ticket/access_token),it is recommended to use redis to implement the store interface, so as to reduce the times of accessing the accesstoken interface. The default is: memory (sync.Map) storage -conf = core.NewConfig(domain Domain, appSettings *config.AppSettings, opts ...ConfigOpt) -``` - -## How to build a request(Request) - -- Some of the old interfaces do not have an SDK that can be used directly. They can use `native` mode. At this time, - they need to build requests. -- For more examples, see [sample/api/api.go](sample/api/api.go) (including: file upload and download) - -```go -import ( - "github.com/larksuite/oapi-sdk-go/api/core/request" -) - -// Parameter Description: -// httpPath: API path - // such as: https://domain/open-apis/contact/v3/users/:user_id - // support: the path of the domain name after, httpPath: "/open apis/contact/v3/users/:user_id" (recommended) - // support: the full path, httpPath: "https://domain/open-apis/contact/v3/users/:user_id" - // support: httpPath: "contact/v3/users/:user_id" -// httpMethod: GET/POST/PUT/BATCH/DELETE -// accessTokenType:What kind of access certificate does the API use and the value range:request.AccessTokenTypeApp/request.AccessTokenTypeTenant/request.AccessTokenTypeUser, for example: request.AccessTokenTypeTenant -// input:Request body (possibly request.NewFormData () (e.g. file upload)), if the request body (e.g. some get requests) is not needed, it will be transferred to: nil -// output:Response body (output: = response ["data"]) -// optFns:Extension function, some rarely used parameter encapsulation, as follows: - // request.SetPathParams(map[string]interface{}{"user_id": 4}): set the URL Path parameter(with: prefix) value, When httpPath="contact/v3/users/:user_id", the requested URL="https://{domain}/open-apis/contact/v3/users/4" - // request.SetQueryParams(map[string]interface{}{"age":4,"types":[1,2]}): Set the URL query, will append to the url?age=4&types=1&types=2 - // request.setResponseStream(), set whether the response is a stream, such as downloading a file, At this point: the type of output needs to be implemented io.Writer Interface - // request.SetNotDataField(), set whether the response does not have a `data` field, business interfaces all have `data `Field, so you don’t need to set - // request.SetTenantKey("TenantKey"), as an `app store application`, it means using `tenant_access_token` to access the API, you need to set - // request.SetUserAccessToken("UserAccessToken"), which means using` user_access_token` To access the API, you need to set - // request.NeedHelpDeskAuth(), Indicates that the help desk API needs to set help desk information of config.AppSettings -req := request.NewRequestWithNative(httpPath, httpMethod string, accessTokenType AccessTokenType, -input interface{}, output interface{}, optFns ...OptFn) -``` - -## How to build request context(core.Context) And common methods - -```go -import( - "github.com/larksuite/oapi-sdk-go/core" -) - -// Parameter Description: -// c:Golang的context.Context -// Return value Description: -// ctx: Implementation of golang's context.Context To save some variables in the request -ctx := core.WrapContext(c context.Context) - -// Get the request ID of the request for troubleshooting -requestId := ctx.GetRequestID() - -// Get the response status code of the request -httpStatusCode := ctx.GetHTTPStatusCode() - -// In the handler of event subscription and message card callback, you can core.Context Get config from -conf := config.ByCtx(ctx *core.Context) - -``` - -## How to send a request - -- Since the SDK has encapsulated the app_access_token、tenant_access_token So when calling the business API, you don't need to get the app_access_token、tenant_access_token. If the business interface needs to use user_access_token, which needs to be set(request.SetUserAccessToken("user_access_token")), Please refer to README.md -> How to build a request(Request) -- For more use examples, please see: [sample/api/api.go](sample/api/api.go) - -```go -import( - "fmt" - "context" - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/test" - "github.com/larksuite/oapi-sdk-go/core/tools" -) - -// Parameter Description: -// ctx:The context of the request -// conf:Overall configuration(Config) -// req:Request(Request) -// Return value Description: -// err:Send request, happen error and response error code(response.body["code"]) is not equal to 0 -err := api.Send(ctx *core.Context, conf *config.Config, req *request.Request) - -``` - -### Download File Tool - -- Download files via network request -- For more use examples, please see: [sample/tools/file_download.go](sample/tools/file_download.go) - -```go -import( - "context" - "github.com/larksuite/oapi-sdk-go/core/tools" -) - -// Get the file content -// Parameter Description: -// ctx:context.Context -// url:The HTTP address of the file -// Return value Description: -// bytes:Binary array of file contents -// err:Error -bytes, err := tools.DownloadFile(ctx context.Context, url string) - -// Get the file content stream. After reading the file content, you need to close the stream -// Parameter Description: -// ctx:context.Context -// url:The HTTP address of the file -// Return value Description: -// readCloser:Binary read stream of file content -// err:Error -readCloser, err := tools.DownloadFileToStream(ctx context.Context, url string) - -``` - -## License - ---- - -- MIT +# OAPI-SDK-GO + +## New SDK version v2 (SDK v2 新版本) + +> ### 使用飞书([feishu.cn](http://open.feishu.cn)),请看文档:[FeiShu.md](FeiShu.md) +> ### SDK v2 advantage(SDK v2 优势) +> - SDK V2 introduces fewer packages, avoiding the problem of package name conflict between SDK and developer`s business system +> (SDK v2 引入的包更少,避免 SDK 包名与开发者的业务系统出现包名冲突的问题) +> +> +> - SDK V2 request API need parameters are encapsulated into a structure (including HTTP request path, Query, and body parameters) to avoid the omission caused by scattered Settings of parameters required by the request +> (SDK v2 请求 API 需要的参数,封装成一个结构体(含:HTTP request path、query、body 参数),避免请求需要的参数分散设置出现遗漏) +> +> +> - The SDK V2 adds models for various messages to facilitate building message content +> (SDK v2 增加了各种消息内容 Model,方便构建消息内容) +> +> - The SDK V2 adds sending messages via custom bots +> (SDK v2 增加了通过自定义机器人发送消息) + + +## Older SDK version v1 (SDK v1 老版本) + +> SDK V1 source code is not in the main branch, please cut to the specific tag branch to see(SDK v1 的源代码不在 main + 分支,可以切到具体的 tag 版本上看) +> +> +> - 使用飞书([feishu.cn](http://open.feishu.cn)),请看:[doc/FeiShu.old.md](doc/FeiShu.old.md) +> (SDK v1 与 v2 可以在 Go module 项目中同时使用,也可以使用 v2 版本进行重构) +> +> +> - Use Lark([larksuite.com](http://open.larksuite.com)), see: [doc/LarkSuite.old.md](doc/LarkSuite.old.md) +> (SDK V1 and V2 can be used in Go Module project at the same time, or v2 version can be used for reconstruction) +> diff --git a/api/api.go b/api/api.go deleted file mode 100644 index 01ee17b2..00000000 --- a/api/api.go +++ /dev/null @@ -1,19 +0,0 @@ -package api - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/handlers" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -func Send(ctx *core.Context, conf *config.Config, req *request.Request) error { - ctx.Set(config.CtxKeyConfig, conf) - req.WithContext(ctx) - handlers.Handle(ctx, req) - if req.Err == nil { - return nil - } - return response.ToError(req.Err) -} diff --git a/api/core/constants/constants.go b/api/core/constants/constants.go deleted file mode 100644 index cc052dc9..00000000 --- a/api/core/constants/constants.go +++ /dev/null @@ -1,19 +0,0 @@ -package constants - -const OAPIRootPath = "open-apis" - -const ( - AppAccessTokenInternalUrlPath string = "auth/v3/app_access_token/internal" - AppAccessTokenIsvUrlPath string = "auth/v3/app_access_token" - TenantAccessTokenInternalUrlPath string = "auth/v3/tenant_access_token/internal" - TenantAccessTokenIsvUrlPath string = "auth/v3/tenant_access_token" - ApplyAppTicketPath string = "auth/v3/app_ticket/resend" -) - -type UserIDType string - -const ( - UserIDTypeOpen UserIDType = "OpenID" - UserIDTypeUnion UserIDType = "UnionID" - UserIDTypeUser UserIDType = "UserID" -) diff --git a/api/core/errors/errors.go b/api/core/errors/errors.go deleted file mode 100644 index b2667940..00000000 --- a/api/core/errors/errors.go +++ /dev/null @@ -1,10 +0,0 @@ -package errors - -import "errors" - -var ( - ErrAccessTokenTypeInvalid = errors.New("access token type is invalid") - ErrTenantKeyIsEmpty = errors.New("tenant key is empty") - ErrUserAccessTokenKeyIsEmpty = errors.New("user access token is empty") - ErrAppTicketIsEmpty = errors.New("app ticket is empty") -) diff --git a/api/core/handlers/access_token.go b/api/core/handlers/access_token.go deleted file mode 100644 index 38fdb624..00000000 --- a/api/core/handlers/access_token.go +++ /dev/null @@ -1,210 +0,0 @@ -package handlers - -import ( - "context" - "fmt" - "github.com/larksuite/oapi-sdk-go/api/core/constants" - coreerrors "github.com/larksuite/oapi-sdk-go/api/core/errors" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/token" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" - commonconst "github.com/larksuite/oapi-sdk-go/core/constants" - "github.com/larksuite/oapi-sdk-go/core/store" - "net/http" - "time" -) - -const expiryDelta = 3 * time.Minute - -// get internal app access token -func getInternalAppAccessToken(ctx *core.Context) (*token.AppAccessToken, error) { - accessToken := &token.AppAccessToken{} - conf := config.ByCtx(ctx) - req := request.NewRequestByAuth(constants.AppAccessTokenInternalUrlPath, http.MethodPost, - &token.InternalAccessTokenReq{ - AppID: conf.GetAppSettings().AppID, - AppSecret: conf.GetAppSettings().AppSecret, - }, accessToken) - err := send(ctx, req) - if err != nil { - return nil, err - } - return accessToken, nil -} - -// get internal tenant access token -func getInternalTenantAccessToken(ctx *core.Context) (*token.TenantAccessToken, error) { - accessToken := &token.TenantAccessToken{} - conf := config.ByCtx(ctx) - req := request.NewRequestByAuth(constants.TenantAccessTokenInternalUrlPath, http.MethodPost, - &token.InternalAccessTokenReq{ - AppID: conf.GetAppSettings().AppID, - AppSecret: conf.GetAppSettings().AppSecret, - }, accessToken) - err := send(ctx, req) - if err != nil { - return nil, err - } - return accessToken, nil -} - -// get isv app access token -func getIsvAppAccessToken(ctx *core.Context) (*token.AppAccessToken, error) { - appTicket, err := getAppTicket(ctx) - if err != nil { - return nil, err - } - if appTicket == "" { - return nil, coreerrors.ErrAppTicketIsEmpty - } - conf := config.ByCtx(ctx) - appAccessToken := &token.AppAccessToken{} - req := request.NewRequestByAuth(constants.AppAccessTokenIsvUrlPath, http.MethodPost, - &token.ISVAppAccessTokenReq{ - AppID: conf.GetAppSettings().AppID, - AppSecret: conf.GetAppSettings().AppSecret, - AppTicket: appTicket, - }, appAccessToken) - err = send(ctx, req) - if err != nil { - return nil, err - } - return appAccessToken, nil -} - -func setAppAccessTokenToStore(ctx context.Context, appAccessToken *token.AppAccessToken) { - conf := config.ByCtx(ctx) - expire := time.Duration(appAccessToken.Expire)*time.Second - expiryDelta - err := conf.GetStore().Put(ctx, store.AppAccessTokenKey(conf.GetAppSettings().AppID), appAccessToken.AppAccessToken, expire) - if err != nil { - conf.GetLogger().Warn(ctx, err) - } -} - -// get isv tenant access token -func getIsvTenantAccessToken(ctx *core.Context) (*token.AppAccessToken, *token.TenantAccessToken, error) { - appAccessToken, err := getIsvAppAccessToken(ctx) - if err != nil { - return nil, nil, err - } - info := request.GetInfoByCtx(ctx) - tenantAccessToken := &token.TenantAccessToken{} - req := request.NewRequestByAuth(constants.TenantAccessTokenIsvUrlPath, http.MethodPost, - &token.ISVTenantAccessTokenReq{ - AppAccessToken: appAccessToken.AppAccessToken, - TenantKey: info.TenantKey, - }, tenantAccessToken) - err = send(ctx, req) - if err != nil { - return appAccessToken, nil, err - } - return appAccessToken, tenantAccessToken, nil -} - -func setTenantAccessTokenToStore(ctx context.Context, tenantAccessToken *token.TenantAccessToken) { - info := request.GetInfoByCtx(ctx) - conf := config.ByCtx(ctx) - expire := time.Duration(tenantAccessToken.Expire)*time.Second - expiryDelta - err := conf.GetStore().Put(ctx, store.TenantAccessTokenKey(conf.GetAppSettings().AppID, info.TenantKey), tenantAccessToken.TenantAccessToken, expire) - if err != nil { - conf.GetLogger().Warn(ctx, err) - } -} - -func setAuthorizationToHeader(req *http.Request, token string) { - req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token)) -} - -func cloneHTTPRequest(req *http.Request) *http.Request { - convertedRequest := new(http.Request) - *convertedRequest = *req - convertedRequest.Header = make(http.Header, len(req.Header)) - for k, s := range req.Header { - convertedRequest.Header[k] = append([]string(nil), s...) - } - return convertedRequest -} - -func send(ctx *core.Context, req *request.Request) error { - Handle(ctx, req) - return req.Err -} - -func getAppTicket(ctx *core.Context) (string, error) { - conf := config.ByCtx(ctx) - return conf.GetStore().Get(ctx, store.AppTicketKey(conf.GetAppSettings().AppID)) -} - -func setAppAccessToken(ctx *core.Context, req *http.Request) (*http.Request, error) { - convertedRequest := cloneHTTPRequest(req) - info := request.GetInfoByCtx(ctx) - conf := config.ByCtx(ctx) - // from store get app access token - if !info.Retryable { - tok, err := conf.GetStore().Get(ctx, store.AppAccessTokenKey(conf.GetAppSettings().AppID)) - if err != nil { - return nil, err - } - if tok != "" { - setAuthorizationToHeader(convertedRequest, tok) - return convertedRequest, nil - } - } - // from api get app access token - var appAccessToken *token.AppAccessToken - var err error - if conf.GetAppSettings().AppType == commonconst.AppTypeInternal { - appAccessToken, err = getInternalAppAccessToken(ctx) - } else { - appAccessToken, err = getIsvAppAccessToken(ctx) - } - if err != nil { - return nil, err - } - setAppAccessTokenToStore(ctx, appAccessToken) - setAuthorizationToHeader(convertedRequest, appAccessToken.AppAccessToken) - return convertedRequest, nil -} - -func setTenantAccessToken(ctx *core.Context, req *http.Request) (*http.Request, error) { - convertedRequest := cloneHTTPRequest(req) - info := request.GetInfoByCtx(ctx) - conf := config.ByCtx(ctx) - // from store get tenant access token - if !info.Retryable { - tok, err := conf.GetStore().Get(ctx, store.TenantAccessTokenKey(conf.GetAppSettings().AppID, info.TenantKey)) - if err != nil { - return nil, err - } - if tok != "" { - setAuthorizationToHeader(convertedRequest, tok) - return convertedRequest, nil - } - } - // from api get tenant access token - var tenantAccessToken *token.TenantAccessToken - var appAccessToken *token.AppAccessToken - var err error - if conf.GetAppSettings().AppType == commonconst.AppTypeInternal { - tenantAccessToken, err = getInternalTenantAccessToken(ctx) - } else { - appAccessToken, tenantAccessToken, err = getIsvTenantAccessToken(ctx) - if appAccessToken != nil { - setAppAccessTokenToStore(ctx, appAccessToken) - } - } - if err != nil { - return nil, err - } - setTenantAccessTokenToStore(ctx, tenantAccessToken) - setAuthorizationToHeader(convertedRequest, tenantAccessToken.TenantAccessToken) - return convertedRequest, nil -} - -func setUserAccessToken(ctx *core.Context, req *http.Request) (*http.Request, error) { - convertedRequest := cloneHTTPRequest(req) - info := request.GetInfoByCtx(ctx) - setAuthorizationToHeader(convertedRequest, info.UserAccessToken) - return convertedRequest, nil -} diff --git a/api/core/handlers/handlers.go b/api/core/handlers/handlers.go deleted file mode 100644 index 3ced55f5..00000000 --- a/api/core/handlers/handlers.go +++ /dev/null @@ -1,432 +0,0 @@ -package handlers - -import ( - "bytes" - "encoding/json" - "errors" - "fmt" - "github.com/larksuite/oapi-sdk-go/api/core/constants" - coreerrors "github.com/larksuite/oapi-sdk-go/api/core/errors" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/api/core/token" - "github.com/larksuite/oapi-sdk-go/api/core/transport" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" - coreconst "github.com/larksuite/oapi-sdk-go/core/constants" - "io" - "io/ioutil" - "mime/multipart" - "net/http" - "os" - "reflect" - "strings" -) - -const defaultMaxRetryCount = 1 - -var defaultHTTPRequestHeader = map[string]string{} -var defaultHTTPRequestHeaderKeysWithContext = []string{coreconst.HTTPHeaderKeyRequestID} -var Default = &Handlers{} - -func init() { - defaultHTTPRequestHeader["User-Agent"] = fmt.Sprintf("oapi-sdk-go/%s", core.SdkVersion) - Default.init = initFunc - Default.validate = validateFunc - Default.build = buildFunc - Default.sign = signFunc - Default.unmarshalResponse = unmarshalResponseFunc - Default.validateResponse = validateResponseFunc - Default.retry = retryFunc - Default.complement = complementFunc -} - -type Handler func(*core.Context, *request.Request) - -type Handlers struct { - init Handler - validate Handler - build Handler // build http request - sign Handler // sign token to header - validateResponse Handler - unmarshalResponse Handler - retry Handler // when token invalid, retry - complement Handler -} - -func Handle(ctx *core.Context, req *request.Request) { - defer Default.complement(ctx, req) - Default.init(ctx, req) - if req.Err != nil { - return - } - Default.validate(ctx, req) - if req.Err != nil { - return - } - i := 0 - for { - i++ - Default.send(ctx, req) - if !req.Retryable || i > defaultMaxRetryCount { - return - } - config.ByCtx(ctx).GetLogger().Debug(ctx, fmt.Sprintf("[retry] request:%v, err: %v", req, req.Err)) - req.Err = nil - } -} - -func (hs *Handlers) send(ctx *core.Context, req *request.Request) { - hs.build(ctx, req) - if req.Err != nil { - return - } - hs.sign(ctx, req) - if req.Err != nil { - return - } - resp, err := transport.DefaultClient.Do(req.HTTPRequest) - if err != nil { - req.Err = err - return - } - ctx.Set(coreconst.HTTPHeader, core.NewOapiHeader(resp.Header)) - ctx.Set(coreconst.HTTPKeyStatusCode, resp.StatusCode) - req.HTTPResponse = resp - defer hs.retry(ctx, req) - hs.validateResponse(ctx, req) - if req.Err != nil { - return - } - hs.unmarshalResponse(ctx, req) -} - -func initFunc(ctx *core.Context, req *request.Request) { - conf := config.ByCtx(ctx) - req.Err = req.Init(conf.GetDomain()) -} - -func validateFunc(ctx *core.Context, req *request.Request) { - if req.AccessTokenType == request.AccessTokenTypeNone { - return - } - if _, ok := req.AccessibleTokenTypeSet[req.AccessTokenType]; !ok { - req.Err = coreerrors.ErrAccessTokenTypeInvalid - } - if config.ByCtx(ctx).GetAppSettings().AppType == coreconst.AppTypeISV { - if req.AccessTokenType == request.AccessTokenTypeTenant && req.TenantKey == "" { - req.Err = coreerrors.ErrTenantKeyIsEmpty - return - } - } - if req.AccessTokenType == request.AccessTokenTypeUser && req.UserAccessToken == "" { - req.Err = coreerrors.ErrUserAccessTokenKeyIsEmpty - return - } -} - -func buildFunc(ctx *core.Context, req *request.Request) { - conf := config.ByCtx(ctx) - if !req.Retryable { - if req.Input != nil { - switch req.Input.(type) { - case *request.FormData: - reqBodyFromFormData(ctx, req) - conf.GetLogger().Debug(ctx, fmt.Sprintf("[build]request:%v, body:formdata:%s", req, req.RequestBodyFilePath)) - default: - reqBodyFromInput(ctx, req) - conf.GetLogger().Debug(ctx, fmt.Sprintf("[build]request:%v, body:%s", req, string(req.RequestBody))) - } - } else { - conf.GetLogger().Debug(ctx, fmt.Sprintf("[build]request:%v", req)) - } - if req.Err != nil { - return - } - } - if req.RequestBody != nil { - req.RequestBodyStream = bytes.NewBuffer(req.RequestBody) - } else if req.RequestBodyFilePath != "" { - req.RequestBodyStream, req.Err = os.Open(req.RequestBodyFilePath) - if req.Err != nil { - return - } - } - r, err := http.NewRequestWithContext(ctx, req.HttpMethod, req.Url(), req.RequestBodyStream) - if err != nil { - req.Err = err - return - } - for k, v := range defaultHTTPRequestHeader { - r.Header.Set(k, v) - } - for _, k := range defaultHTTPRequestHeaderKeysWithContext { - if v, ok := ctx.Get(k); ok { - r.Header.Set(k, fmt.Sprint(v)) - } - } - if req.ContentType != "" { - r.Header.Set(coreconst.ContentType, req.ContentType) - } - req.HTTPRequest = r -} - -func signFunc(ctx *core.Context, req *request.Request) { - var httpRequest *http.Request - var err error - switch req.AccessTokenType { - case request.AccessTokenTypeApp: - httpRequest, err = setAppAccessToken(ctx, req.HTTPRequest) - case request.AccessTokenTypeTenant: - httpRequest, err = setTenantAccessToken(ctx, req.HTTPRequest) - case request.AccessTokenTypeUser: - httpRequest, err = setUserAccessToken(ctx, req.HTTPRequest) - default: - httpRequest, err = req.HTTPRequest, req.Err - } - if req.NeedHelpDeskAuth { - conf := config.ByCtx(ctx) - if conf.GetHelpDeskAuthorization() == "" { - err = errors.New("help desk API, please set the helpdesk information of config.AppSettings") - } else if httpRequest != nil { - httpRequest.Header.Set("X-Lark-Helpdesk-Authorization", conf.GetHelpDeskAuthorization()) - } - } - req.HTTPRequest = httpRequest - req.Err = err -} - -func validateResponseFunc(_ *core.Context, req *request.Request) { - resp := req.HTTPResponse - contentType := resp.Header.Get(coreconst.ContentType) - if req.IsResponseStream { - if resp.StatusCode == http.StatusOK { - req.IsResponseStreamReal = true - return - } - if strings.Contains(contentType, coreconst.ContentTypeJson) { - req.IsResponseStreamReal = false - return - } - if resp.StatusCode != http.StatusOK { - req.Err = fmt.Errorf("response is stream, but status code:%d, contentType:%s", resp.StatusCode, contentType) - } - return - } - if !strings.Contains(contentType, coreconst.ContentTypeJson) { - respBody, err := readResponse(resp) - if err != nil { - req.Err = err - return - } - req.Err = response.NewErrorOfInvalidResp(fmt.Sprintf("content-type: %s, is not: %s, body:%s", contentType, coreconst.ContentTypeJson, string(respBody))) - } -} - -func unmarshalResponseFunc(ctx *core.Context, req *request.Request) { - resp := req.HTTPResponse - if req.IsResponseStreamReal { - defer resp.Body.Close() - switch output := req.Output.(type) { - case io.Writer: - _, err := io.Copy(output, resp.Body) - if err != nil { - req.Err = err - return - } - default: - req.Err = fmt.Errorf("request`s Output type must implement `io.Writer` interface") - return - } - return - } - respBody, err := readResponse(resp) - if err != nil { - req.Err = err - return - } - config.ByCtx(ctx).GetLogger().Debug(ctx, fmt.Sprintf("[unmarshalResponse] request:%v, response:body:%s", - req, string(respBody))) - if req.DataFilled() { - err := unmarshalJSON(req.Output, req.IsNotDataField, respBody) - if err != nil { - req.Err = err - return - } - } else { - req.Err = fmt.Errorf("request out do not write") - return - } -} - -func readResponse(resp *http.Response) ([]byte, error) { - defer resp.Body.Close() - respBody, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, err - } - return respBody, nil -} - -func retryFunc(_ *core.Context, req *request.Request) { - if req.Err != nil { - if err, ok := req.Err.(*response.Error); ok { - req.Info.Retryable = err.Retryable() - return - } - } - req.Info.Retryable = false -} - -func complementFunc(ctx *core.Context, req *request.Request) { - if req.RequestBodyFilePath != "" { - if err := os.Remove(req.RequestBodyFilePath); err != nil { - config.ByCtx(ctx).GetLogger().Debug(ctx, fmt.Sprintf("[complement] request:%v, "+ - "delete tmp file(%s) err: %v", req, req.RequestBodyFilePath, err)) - } - } - switch err := req.Err.(type) { - case *response.Error: - switch err.Code { - case response.ErrCodeAppTicketInvalid: - applyAppTicket(ctx) - } - default: - if req.Err == coreerrors.ErrAppTicketIsEmpty { - applyAppTicket(ctx) - } - } -} - -// apply app ticket -func applyAppTicket(ctx *core.Context) { - conf := config.ByCtx(ctx) - req := request.NewRequestByAuth(constants.ApplyAppTicketPath, http.MethodPost, - &token.ApplyAppTicketReq{ - AppID: conf.GetAppSettings().AppID, - AppSecret: conf.GetAppSettings().AppSecret, - }, &response.NoData{}) - Handle(ctx, req) - if req.Err != nil { - conf.GetLogger().Error(ctx, req.Err) - } -} - -func unmarshalJSON(v interface{}, isNotDataField bool, data []byte) error { - var e response.Error - if isNotDataField { - if ret, ok := v.(*map[string]interface{}); ok { - e = response.Error{} - err := json.Unmarshal(data, &e) - if err != nil { - return err - } - err = json.Unmarshal(data, ret) - if err != nil { - return err - } - delete(*ret, "code") - delete(*ret, "msg") - } else { - typ := reflect.TypeOf(v) - name := typ.Elem().Name() - responseTyp := reflect.StructOf([]reflect.StructField{ - { - Name: "Error", - Anonymous: true, - Type: reflect.TypeOf(response.Error{}), - }, - { - Name: name, - Anonymous: true, - Type: typ, - }, - }) - responseV := reflect.New(responseTyp).Elem() - responseV.Field(1).Set(reflect.ValueOf(v)) - s := responseV.Addr().Interface() - err := json.Unmarshal(data, s) - if err != nil { - return err - } - e = responseV.Field(0).Interface().(response.Error) - } - } else { - out := &response.Response{ - Data: v, - } - err := json.Unmarshal(data, out) - if err != nil { - return err - } - e = out.Error - } - if e.Code == response.ErrCodeOk { - return nil - } - return &e -} - -func reqBodyFromFormData(_ *core.Context, req *request.Request) { - var reqBody io.ReadWriter - fd := req.Input.(*request.FormData) - hasStream := fd.HasStream() - if hasStream { - var reqBodyFile *os.File - reqBodyFile, req.Err = ioutil.TempFile("", ".larksuiteoapisdk") - if req.Err != nil { - return - } - defer reqBodyFile.Close() - req.RequestBodyFilePath = reqBodyFile.Name() - reqBody = reqBodyFile - } else { - reqBody = &bytes.Buffer{} - } - writer := multipart.NewWriter(reqBody) - for key, val := range fd.Params() { - err := writer.WriteField(key, fmt.Sprint(val)) - if err != nil { - req.Err = err - return - } - } - for _, file := range fd.Files() { - part, err := writer.CreatePart(file.MIMEHeader()) - if err != nil { - req.Err = err - return - } - _, err = io.Copy(part, file) - if err != nil { - req.Err = err - return - } - } - req.ContentType = writer.FormDataContentType() - err := writer.Close() - if err != nil { - req.Err = err - return - } - if !hasStream { - req.RequestBody, req.Err = ioutil.ReadAll(reqBody) - } -} - -func reqBodyFromInput(_ *core.Context, req *request.Request) { - var bs []byte - if input, ok := req.Input.(string); ok { - bs = []byte(input) - } else { - reqBody := new(bytes.Buffer) - err := json.NewEncoder(reqBody).Encode(req.Input) - if err != nil { - req.Err = err - return - } - bs = reqBody.Bytes() - } - req.ContentType = coreconst.DefaultContentType - req.RequestBody = bs -} diff --git a/api/core/request/formdata.go b/api/core/request/formdata.go deleted file mode 100644 index 667688b6..00000000 --- a/api/core/request/formdata.go +++ /dev/null @@ -1,137 +0,0 @@ -package request - -import ( - "bytes" - "fmt" - "io" - "net/textproto" - "strings" -) - -type FormData struct { - params map[string]interface{} - files []*File -} - -func (fd *FormData) Params() map[string]interface{} { - return fd.params -} - -func (fd *FormData) Files() []*File { - return fd.files -} - -func NewFormData() *FormData { - return &FormData{ - params: map[string]interface{}{}, - } -} - -func (fd *FormData) AddParam(field string, val interface{}) *FormData { - fd.params[field] = val - return fd -} - -func (fd *FormData) AddFile(field string, file *File) *FormData { - file.fieldName = field - fd.files = append(fd.files, file) - return fd -} - -func (fd *FormData) HasStream() bool { - for _, file := range fd.files { - isStream := file.IsStream() - if isStream { - return isStream - } - } - return false -} - -type File struct { - fieldName string - name string - typ string - content *bytes.Buffer - contentStream io.Reader - isStream bool -} - -func NewFile() *File { - return &File{} -} - -func (f *File) ContentStream() io.Reader { - return f.contentStream -} - -func (f *File) SetContentStream(reader io.Reader) *File { - f.contentStream = reader - f.isStream = true - switch f.contentStream.(type) { - case *bytes.Buffer: - f.isStream = false - } - return f -} - -func (f *File) SetContent(content []byte) *File { - f.content = bytes.NewBuffer(content) - return f -} - -func (f *File) Type() string { - return f.typ -} - -func (f *File) SetType(typ string) *File { - f.typ = typ - return f -} - -func (f *File) Name() string { - return f.name -} - -func (f *File) IsStream() bool { - return f.isStream -} - -func (f *File) SetName(name string) *File { - f.name = name - return f -} - -func (f *File) Read(p []byte) (n int, err error) { - if f.contentStream != nil { - return f.contentStream.Read(p) - } - return f.content.Read(p) -} - -func (f *File) MIMEHeader() textproto.MIMEHeader { - fieldName := "file" - if f.fieldName != "" { - fieldName = f.fieldName - } - name := "unknown" - if f.name != "" { - name = f.name - } - typ := "application/octet-stream" - if f.typ != "" { - typ = f.typ - } - h := make(textproto.MIMEHeader) - h.Set("Content-Disposition", - fmt.Sprintf(`form-data; name="%s"; filename="%s"`, - escapeQuotes(fieldName), escapeQuotes(name))) - h.Set("Content-Type", typ) - return h -} - -var quoteEscaper = strings.NewReplacer("\\", "\\\\", `"`, "\\\"") - -func escapeQuotes(s string) string { - return quoteEscaper.Replace(s) -} diff --git a/api/core/request/request.go b/api/core/request/request.go deleted file mode 100644 index b29acefe..00000000 --- a/api/core/request/request.go +++ /dev/null @@ -1,275 +0,0 @@ -package request - -import ( - "context" - "fmt" - "github.com/larksuite/oapi-sdk-go/api/core/constants" - "github.com/larksuite/oapi-sdk-go/core" - "io" - "net/http" - "net/url" - "reflect" - "strings" -) - -var ctxKeyRequestInfo = "------ctxKeyRequestInfo" - -type AccessTokenType string - -const ( - AccessTokenTypeNone AccessTokenType = "none_access_token" - AccessTokenTypeApp AccessTokenType = "app_access_token" - AccessTokenTypeTenant AccessTokenType = "tenant_access_token" - AccessTokenTypeUser AccessTokenType = "user_access_token" -) - -type Opt struct { - isNotDataField bool - pathParams map[string]interface{} - queryParams map[string]interface{} - userAccessToken string - tenantKey string - isResponseStream bool - needHelpDeskAuth bool -} - -type Info struct { - Domain string - HttpPath string // request http path - HttpMethod string // request http method - QueryParams string // request query - Input interface{} // request body - AccessibleTokenTypeSet map[AccessTokenType]struct{} // request accessible token type - AccessTokenType AccessTokenType // request access token type - TenantKey string - UserAccessToken string // user access token - IsNotDataField bool // response body is not data field - Output interface{} // response body data - Retryable bool - optFns []OptFn - IsResponseStream bool - IsResponseStreamReal bool - NeedHelpDeskAuth bool -} - -func (i *Info) WithContext(ctx *core.Context) { - ctx.Set(ctxKeyRequestInfo, i) -} - -type OptFn func(*Opt) - -func SetUserAccessToken(userAccessToken string) OptFn { - return func(opt *Opt) { - opt.userAccessToken = userAccessToken - } -} - -func SetTenantKey(tenantKey string) OptFn { - return func(opt *Opt) { - opt.tenantKey = tenantKey - } -} - -func SetQueryParams(queryParams map[string]interface{}) OptFn { - return func(opt *Opt) { - opt.queryParams = queryParams - } -} - -func SetPathParams(pathParams map[string]interface{}) OptFn { - return func(opt *Opt) { - opt.pathParams = pathParams - } -} - -func SetNotDataField() OptFn { - return func(opt *Opt) { - opt.isNotDataField = true - } -} - -func SetResponseStream() OptFn { - return func(opt *Opt) { - opt.isResponseStream = true - } -} - -func NeedHelpDeskAuth() OptFn { - return func(opt *Opt) { - opt.needHelpDeskAuth = true - } -} - -type Request struct { - *Info - HTTPRequest *http.Request - HTTPResponse *http.Response - RequestBody []byte - RequestBodyStream io.Reader - RequestBodyFilePath string - ContentType string - Err error -} - -func (r *Request) String() string { - return fmt.Sprintf("%s %s %s", r.HttpMethod, r.Url(), r.AccessTokenType) -} - -func NewRequestByAuth(httpPath, httpMethod string, input, output interface{}) *Request { - return &Request{ - Info: &Info{ - HttpPath: httpPath, - HttpMethod: httpMethod, - AccessTokenType: AccessTokenTypeNone, - Input: input, - Output: output, - optFns: []OptFn{SetNotDataField()}, - }, - } -} - -// Deprecated, please use `NewRequestWithNative` -func NewRequest2(httpPath, httpMethod string, accessTokenType AccessTokenType, - input interface{}, output interface{}, optFns ...OptFn) *Request { - return NewRequest(httpPath, httpMethod, []AccessTokenType{accessTokenType}, input, output, optFns...) -} - -func NewRequestWithNative(httpPath, httpMethod string, accessTokenType AccessTokenType, - input interface{}, output interface{}, optFns ...OptFn) *Request { - return NewRequest(httpPath, httpMethod, []AccessTokenType{accessTokenType}, input, output, optFns...) -} - -func NewRequest(httpPath, httpMethod string, accessTokenTypes []AccessTokenType, - input interface{}, output interface{}, optFns ...OptFn) *Request { - accessibleTokenTypeSet := make(map[AccessTokenType]struct{}) - accessTokenType := accessTokenTypes[0] - for _, t := range accessTokenTypes { - if t == AccessTokenTypeTenant { - accessTokenType = t - } - accessibleTokenTypeSet[t] = struct{}{} - } - req := &Request{ - Info: &Info{ - HttpPath: httpPath, - HttpMethod: httpMethod, - AccessTokenType: accessTokenType, - AccessibleTokenTypeSet: accessibleTokenTypeSet, - Input: input, - Output: output, - optFns: optFns, - }, - } - return req -} - -func (r *Request) Init(domain string) error { - r.Domain = domain - opt := &Opt{} - for _, optFn := range r.optFns { - optFn(opt) - } - r.IsNotDataField = opt.isNotDataField - r.IsResponseStream = opt.isResponseStream - r.NeedHelpDeskAuth = opt.needHelpDeskAuth - if opt.tenantKey != "" { - if _, ok := r.AccessibleTokenTypeSet[AccessTokenTypeTenant]; ok { - r.AccessTokenType = AccessTokenTypeTenant - r.TenantKey = opt.tenantKey - } - } - if opt.userAccessToken != "" { - if _, ok := r.AccessibleTokenTypeSet[AccessTokenTypeUser]; ok { - r.AccessTokenType = AccessTokenTypeUser - r.UserAccessToken = opt.userAccessToken - } - } - if opt.queryParams != nil { - r.QueryParams = toUrlValues(opt.queryParams).Encode() - } - if opt.pathParams != nil { - httpPath, err := resolvePath(r.HttpPath, opt.pathParams) - if err != nil { - return err - } - r.HttpPath = httpPath - } - return nil -} - -func toUrlValues(params map[string]interface{}) url.Values { - vs := make(url.Values) - for k, v := range params { - sv := reflect.ValueOf(v) - if sv.Kind() == reflect.Slice || sv.Kind() == reflect.Array { - for i := 0; i < sv.Len(); i++ { - vs.Add(k, fmt.Sprint(sv.Index(i))) - } - } else { - vs.Set(k, fmt.Sprint(v)) - } - } - return vs -} - -func resolvePath(path string, pathVar map[string]interface{}) (string, error) { - tmpPath := path - newPath := "" - for { - i := strings.Index(tmpPath, ":") - if i == -1 { - newPath += tmpPath - break - } - newPath += tmpPath[:i] - subPath := tmpPath[i:] - j := strings.Index(subPath, "/") - if j == -1 { - j = len(subPath) - } - varName := subPath[1:j] - if varName == "" { - newPath += fmt.Sprint(subPath[:j]) - } else { - v, ok := pathVar[varName] - if !ok { - return "", fmt.Errorf("path:%s, var name:%s not find value", path, varName) - } - newPath += fmt.Sprint(v) - } - if j == len(subPath) { - break - } - tmpPath = subPath[j:] - } - return newPath, nil -} - -func (r *Request) Url() string { - path := r.HttpPath - if strings.Index(r.HttpPath, "http") != 0 { - if strings.Index(r.HttpPath, "/open-apis") == 0 { - path = fmt.Sprintf("%s%s", r.Domain, r.HttpPath) - } else { - path = fmt.Sprintf("%s/%s/%s", r.Domain, constants.OAPIRootPath, r.HttpPath) - } - } - - if r.QueryParams != "" { - path = fmt.Sprintf("%s?%s", path, r.QueryParams) - } - return path -} - -func (r *Request) DataFilled() bool { - return r.Output != nil && reflect.ValueOf(r.Output).Elem().IsValid() -} - -func GetInfoByCtx(ctx context.Context) *Info { - return ctx.Value(ctxKeyRequestInfo).(*Info) -} - -type UserID struct { - Type constants.UserIDType - ID string -} diff --git a/api/core/response/error.go b/api/core/response/error.go deleted file mode 100644 index 87e43303..00000000 --- a/api/core/response/error.go +++ /dev/null @@ -1,89 +0,0 @@ -package response - -import ( - "github.com/larksuite/oapi-sdk-go/core/tools" -) - -const ( - ErrCodeNative = -1 - ErrCodeOk = 0 - ErrCodeAppTicketInvalid = 10012 - ErrCodeAccessTokenInvalid = 99991671 - ErrCodeAppAccessTokenInvalid = 99991664 - ErrCodeTenantAccessTokenInvalid = 99991663 - ErrCodeUserAccessTokenInvalid = 99991668 - ErrCodeUserRefreshTokenInvalid = 99991669 -) - -type Detail struct { - Key string `json:"key,omitempty"` - Value string `json:"value,omitempty"` -} - -type PermissionViolation struct { - Type string `json:"type,omitempty"` - Subject string `json:"subject,omitempty"` - Description string `json:"description,omitempty"` -} - -type FieldViolation struct { - Field string `json:"field,omitempty"` - Value string `json:"value,omitempty"` - Description string `json:"description,omitempty"` -} - -type Help struct { - Url string `json:"url,omitempty"` - Description string `json:"description,omitempty"` -} - -type Err struct { - Details []*Detail `json:"details,omitempty"` - PermissionViolations []*PermissionViolation `json:"permission_violations,omitempty"` - FieldViolations []*FieldViolation `json:"field_violations,omitempty"` - Helps []*Help `json:"helps,omitempty"` -} - -type Error struct { - Code int `json:"code"` - Msg string `json:"msg"` - Err *Err `json:"error"` -} - -func NewErrorOfInvalidResp(msg string) *Error { - return &Error{ - Code: ErrCodeNative, - Msg: msg, - } -} - -func NewError(err error) *Error { - return &Error{ - Code: ErrCodeNative, - Msg: err.Error(), - } -} - -func (e Error) Retryable() bool { - switch e.Code { - case ErrCodeAccessTokenInvalid, - ErrCodeAppAccessTokenInvalid, - ErrCodeTenantAccessTokenInvalid: - return true - default: - return false - } -} - -func ToError(err error) *Error { - switch realErr := err.(type) { - case *Error: - return realErr - default: - return NewError(err) - } -} - -func (e Error) Error() string { - return tools.Prettify(e) -} diff --git a/api/core/response/no_data.go b/api/core/response/no_data.go deleted file mode 100644 index 0c70afd8..00000000 --- a/api/core/response/no_data.go +++ /dev/null @@ -1,4 +0,0 @@ -package response - -type NoData struct { -} diff --git a/api/core/response/response.go b/api/core/response/response.go deleted file mode 100644 index acc06bcf..00000000 --- a/api/core/response/response.go +++ /dev/null @@ -1,6 +0,0 @@ -package response - -type Response struct { - Error - Data interface{} `json:"data"` -} diff --git a/api/core/token/token.go b/api/core/token/token.go deleted file mode 100644 index bb737acb..00000000 --- a/api/core/token/token.go +++ /dev/null @@ -1,32 +0,0 @@ -package token - -type ISVTenantAccessTokenReq struct { - AppAccessToken string `json:"app_access_token"` - TenantKey string `json:"tenant_key"` -} - -type TenantAccessToken struct { - Expire int `json:"expire"` - TenantAccessToken string `json:"tenant_access_token"` -} - -type InternalAccessTokenReq struct { - AppID string `json:"app_id"` - AppSecret string `json:"app_secret"` -} - -type ISVAppAccessTokenReq struct { - AppID string `json:"app_id"` - AppSecret string `json:"app_secret"` - AppTicket string `json:"app_ticket"` -} - -type AppAccessToken struct { - Expire int `json:"expire"` - AppAccessToken string `json:"app_access_token"` -} - -type ApplyAppTicketReq struct { - AppID string `json:"app_id"` - AppSecret string `json:"app_secret"` -} diff --git a/api/core/tools/file.go b/api/core/tools/file.go deleted file mode 100644 index 8740e6f8..00000000 --- a/api/core/tools/file.go +++ /dev/null @@ -1,36 +0,0 @@ -package tools - -import ( - "context" - "fmt" - "io" - "io/ioutil" - "net/http" -) - -// download file return ReadCloser -// defer r.Close() -// -func DownloadFileToStream(ctx context.Context, url string) (io.ReadCloser, error) { - request, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) - if err != nil { - return nil, err - } - resp, err := http.DefaultClient.Do(request) - if err != nil { - return nil, err - } - if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("response status code:%d", resp.StatusCode) - } - return resp.Body, nil -} - -func DownloadFile(ctx context.Context, url string) ([]byte, error) { - r, err := DownloadFileToStream(ctx, url) - if err != nil { - return nil, err - } - defer r.Close() - return ioutil.ReadAll(r) -} diff --git a/api/core/tools/json.go b/api/core/tools/json.go deleted file mode 100644 index 7eb0d4c2..00000000 --- a/api/core/tools/json.go +++ /dev/null @@ -1,127 +0,0 @@ -package tools - -import ( - "encoding/json" - "fmt" - "reflect" - "strings" -) - -func MarshalJSON(value interface{}, forceSendFields []string) ([]byte, error) { - if len(forceSendFields) == 0 { - return json.Marshal(value) - } - mustInclude := make(map[string]bool) - for _, f := range forceSendFields { - mustInclude[f] = true - } - dataMap, err := structToMap(value, mustInclude) - if err != nil { - return nil, err - } - return json.Marshal(dataMap) -} - -func structToMap(schema interface{}, mustInclude map[string]bool) (map[string]interface{}, error) { - m := make(map[string]interface{}) - s := reflect.ValueOf(schema) - st := s.Type() - - for i := 0; i < s.NumField(); i++ { - jsonTag := st.Field(i).Tag.Get("json") - if jsonTag == "" { - continue - } - tag, err := parseJSONTag(jsonTag) - if err != nil { - return nil, err - } - if tag.ignore { - continue - } - v := s.Field(i) - f := st.Field(i) - if !includeField(v, f, mustInclude) { - continue - } - - // nil maps are treated as empty maps. - if f.Type.Kind() == reflect.Map && v.IsNil() { - m[tag.apiName] = map[string]string{} - continue - } - if f.Type.Kind() == reflect.Slice && v.IsNil() { - m[tag.apiName] = []string{} - continue - } - if tag.stringFormat { - m[tag.apiName] = formatAsString(v, f.Type.Kind()) - } else { - m[tag.apiName] = v.Interface() - } - } - return m, nil -} - -func formatAsString(v reflect.Value, kind reflect.Kind) string { - if kind == reflect.Ptr && !v.IsNil() { - v = v.Elem() - } - return fmt.Sprintf("%v", v.Interface()) -} - -type jsonTag struct { - apiName string - stringFormat bool - ignore bool -} - -func parseJSONTag(val string) (jsonTag, error) { - if val == "-" { - return jsonTag{ignore: true}, nil - } - var tag jsonTag - i := strings.Index(val, ",") - if i == -1 || val[:i] == "" { - return tag, fmt.Errorf("malformed json tag: %s", val) - } - tag = jsonTag{ - apiName: val[:i], - } - switch val[i+1:] { - case "omitempty": - case "omitempty,string": - tag.stringFormat = true - default: - return tag, fmt.Errorf("malformed json tag: %s", val) - } - return tag, nil -} - -func includeField(v reflect.Value, f reflect.StructField, mustInclude map[string]bool) bool { - if f.Type.Kind() == reflect.Ptr && v.IsNil() { - return false - } - if f.Type.Kind() == reflect.Interface && v.IsNil() { - return false - } - return mustInclude[f.Name] || !isEmptyValue(v) -} - -func isEmptyValue(v reflect.Value) bool { - switch v.Kind() { - case reflect.Array, reflect.Map, reflect.Slice, reflect.String: - return v.Len() == 0 - case reflect.Bool: - return !v.Bool() - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return v.Int() == 0 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - return v.Uint() == 0 - case reflect.Float32, reflect.Float64: - return v.Float() == 0 - case reflect.Interface, reflect.Ptr: - return v.IsNil() - } - return false -} diff --git a/api/core/transport/transport.go b/api/core/transport/transport.go deleted file mode 100644 index ef45986a..00000000 --- a/api/core/transport/transport.go +++ /dev/null @@ -1,27 +0,0 @@ -package transport - -import ( - "net/http" -) - -var DefaultClient *http.Client - -func init() { - transport := &Transport{} - DefaultClient = transport.Client() -} - -type Transport struct { -} - -func (t *Transport) Client() *http.Client { - return &http.Client{Transport: t} -} - -func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) { - return t.transport().RoundTrip(req) -} - -func (t *Transport) transport() http.RoundTripper { - return http.DefaultTransport -} diff --git a/api_process.jpg b/api_process.jpg deleted file mode 100644 index 0c2a8fa9..00000000 Binary files a/api_process.jpg and /dev/null differ diff --git a/api_process_en.jpg b/api_process_en.jpg deleted file mode 100644 index 0707b40f..00000000 Binary files a/api_process_en.jpg and /dev/null differ diff --git a/card/card.go b/card/card.go deleted file mode 100644 index aece9850..00000000 --- a/card/card.go +++ /dev/null @@ -1,23 +0,0 @@ -package card - -import ( - "github.com/larksuite/oapi-sdk-go/card/handlers" - "github.com/larksuite/oapi-sdk-go/card/model" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -func SetHandler(conf *config.Config, handler handlers.Handler) { - handlers.AppID2Handler[conf.GetAppSettings().AppID] = handler -} - -func Handle(conf *config.Config, request *core.OapiRequest) *core.OapiResponse { - coreCtx := core.WrapContext(request.Ctx) - coreCtx.Set(config.CtxKeyConfig, conf) - httpCard := &model.HTTPCard{ - Request: request, - Response: &core.OapiResponse{}, - } - handlers.Handle(coreCtx, httpCard) - return httpCard.Response -} diff --git a/card/handlers/err.go b/card/handlers/err.go deleted file mode 100644 index a87e624d..00000000 --- a/card/handlers/err.go +++ /dev/null @@ -1,23 +0,0 @@ -package handlers - -type NotFoundHandlerErr struct { -} - -func newNotHandlerErr() *NotFoundHandlerErr { - return &NotFoundHandlerErr{} -} - -func (e NotFoundHandlerErr) Error() string { - return "card, not found handler" -} - -type SignatureErr struct { -} - -func newSignatureErr() *SignatureErr { - return &SignatureErr{} -} - -func (e SignatureErr) Error() string { - return "card, signature error" -} diff --git a/card/handlers/handler.go b/card/handlers/handler.go deleted file mode 100644 index 0084c987..00000000 --- a/card/handlers/handler.go +++ /dev/null @@ -1,16 +0,0 @@ -package handlers - -import ( - "github.com/larksuite/oapi-sdk-go/card/model" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Handler func(*core.Context, *model.Card) (interface{}, error) - -var AppID2Handler = make(map[string]Handler) - -func getHandler(conf *config.Config) (Handler, bool) { - h, ok := AppID2Handler[conf.GetAppSettings().AppID] - return h, ok -} diff --git a/card/handlers/handlers.go b/card/handlers/handlers.go deleted file mode 100644 index 8faed36b..00000000 --- a/card/handlers/handlers.go +++ /dev/null @@ -1,171 +0,0 @@ -package handlers - -import ( - "bytes" - "crypto/sha1" - "encoding/json" - "fmt" - "github.com/larksuite/oapi-sdk-go/card/model" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" - "github.com/larksuite/oapi-sdk-go/core/constants" - "github.com/larksuite/oapi-sdk-go/core/errors" - "net/http" - "strings" -) - -var defaultHandlers = &Handlers{ - init: initFunc, - validate: validateFunc, - unmarshal: unmarshalFunc, - handler: handlerFunc, - complement: complementFunc, -} - -type handler func(*core.Context, *model.HTTPCard) - -type Handlers struct { - init handler - validate handler - unmarshal handler - handler handler - complement handler -} - -func initFunc(ctx *core.Context, httpCard *model.HTTPCard) { - request := httpCard.Request - ctx.Set(constants.HTTPHeader, request.Header) - header := &model.Header{ - Timestamp: request.Header.GetFirstValue(model.LarkRequestTimestamp), - Nonce: request.Header.GetFirstValue(model.LarkRequestRequestNonce), - Signature: request.Header.GetFirstValue(model.LarkSignature), - RefreshToken: request.Header.GetFirstValue(model.LarkRefreshToken), - } - httpCard.Header = header - config.ByCtx(ctx).GetLogger().Debug(ctx, fmt.Sprintf("[init] card: %s", request.Body)) - httpCard.Input = []byte(request.Body) -} - -func validateFunc(ctx *core.Context, httpCard *model.HTTPCard) { - if httpCard.Header.Signature == "" { - return - } - appSettings := config.ByCtx(ctx).GetAppSettings() - err := verify(appSettings.VerificationToken, httpCard.Header, httpCard.Input) - if err != nil { - httpCard.Err = err - return - } -} - -func unmarshalFunc(ctx *core.Context, httpCard *model.HTTPCard) { - out := &model.Challenge{} - err := json.NewDecoder(bytes.NewBuffer(httpCard.Input)).Decode(&out) - if err != nil { - httpCard.Err = err - return - } - httpCard.Type = constants.CallbackType(out.Type) - httpCard.Challenge = out.Challenge - if httpCard.Type == constants.CallbackTypeChallenge { - appSettings := config.ByCtx(ctx).GetAppSettings() - if appSettings.VerificationToken != out.Token { - httpCard.Err = errors.NewTokenInvalidErr(out.Token) - return - } - } -} - -func verify(verifyToken string, header *model.Header, body []byte) error { - targetSig := signature(header.Nonce, header.Timestamp, string(body), verifyToken) - if header.Signature == targetSig { - return nil - } - return newSignatureErr() -} - -func signature(nonce string, timestamp string, body string, token string) string { - var b strings.Builder - b.WriteString(timestamp) - b.WriteString(nonce) - b.WriteString(token) - b.WriteString(body) - bs := []byte(b.String()) - h := sha1.New() - _, _ = h.Write(bs) - bs = h.Sum(nil) - return fmt.Sprintf("%x", bs) -} - -func Handle(ctx *core.Context, httpCard *model.HTTPCard) { - defer defaultHandlers.complement(ctx, httpCard) - defaultHandlers.init(ctx, httpCard) - if httpCard.Err != nil { - return - } - defaultHandlers.validate(ctx, httpCard) - if httpCard.Err != nil { - return - } - defaultHandlers.unmarshal(ctx, httpCard) - if httpCard.Err != nil { - return - } - defaultHandlers.handler(ctx, httpCard) -} - -func handlerFunc(ctx *core.Context, httpCard *model.HTTPCard) { - if httpCard.Type == constants.CallbackTypeChallenge { - return - } - conf := config.ByCtx(ctx) - h, ok := getHandler(conf) - if !ok { - httpCard.Err = newNotHandlerErr() - return - } - out := &model.Card{} - err := json.NewDecoder(bytes.NewBuffer(httpCard.Input)).Decode(&out) - if err != nil { - httpCard.Err = err - return - } - httpCard.Output, httpCard.Err = h(ctx, out) -} - -func complementFunc(ctx *core.Context, httpCard *model.HTTPCard) { - err := httpCard.Err - conf := config.ByCtx(ctx) - if err != nil { - switch e := err.(type) { - case *NotFoundHandlerErr: - conf.GetLogger().Info(ctx, e.Error()) - httpCard.Response.Write(http.StatusOK, constants.DefaultContentType, fmt.Sprintf(core.ResponseFormat, err.Error())) - return - } - conf.GetLogger().Error(ctx, err.Error()) - httpCard.Response.Write(http.StatusInternalServerError, constants.DefaultContentType, fmt.Sprintf(core.ResponseFormat, err.Error())) - return - } - if httpCard.Type == constants.CallbackTypeChallenge { - httpCard.Response.Write(http.StatusOK, constants.DefaultContentType, fmt.Sprintf(core.ChallengeResponseFormat, httpCard.Challenge)) - return - } - if httpCard.Output != nil { - var bs []byte - switch output := httpCard.Output.(type) { - case string: - bs = []byte(output) - default: - bs, err = json.Marshal(httpCard.Output) - if err != nil { - conf.GetLogger().Error(ctx, err.Error()) - httpCard.Response.Write(http.StatusInternalServerError, constants.DefaultContentType, fmt.Sprintf(core.ResponseFormat, err.Error())) - return - } - } - httpCard.Response.Write(http.StatusOK, constants.DefaultContentType, string(bs)) - return - } - httpCard.Response.Write(http.StatusOK, constants.DefaultContentType, fmt.Sprintf(core.ResponseFormat, "successed")) -} diff --git a/card/http/handler.go b/card/http/handler.go deleted file mode 100644 index 4b26f1a6..00000000 --- a/card/http/handler.go +++ /dev/null @@ -1,23 +0,0 @@ -package http - -import ( - "github.com/larksuite/oapi-sdk-go/card" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" - "net/http" -) - -func Handle(conf *config.Config, request *http.Request, response http.ResponseWriter) { - req, err := core.ToOapiRequest(request) - if err != nil { - err = core.NewOapiResponseOfErr(err).WriteTo(response) - if err != nil { - conf.GetLogger().Error(req.Ctx, err) - } - return - } - err = card.Handle(conf, req).WriteTo(response) - if err != nil { - conf.GetLogger().Error(req.Ctx, err) - } -} diff --git a/card/http/native/handler.go b/card/http/native/handler.go deleted file mode 100644 index 7f7d4c80..00000000 --- a/card/http/native/handler.go +++ /dev/null @@ -1,13 +0,0 @@ -package native - -import ( - . "github.com/larksuite/oapi-sdk-go/card/http" - "github.com/larksuite/oapi-sdk-go/core/config" - "net/http" -) - -func Register(path string, conf *config.Config) { - http.HandleFunc(path, func(writer http.ResponseWriter, request *http.Request) { - Handle(conf, request, writer) - }) -} diff --git a/card/model/card.go b/card/model/card.go deleted file mode 100644 index af5d1035..00000000 --- a/card/model/card.go +++ /dev/null @@ -1,58 +0,0 @@ -package model - -import ( - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/constants" -) - -const ( - LarkRequestTimestamp = "X-Lark-Request-Timestamp" - LarkRequestRequestNonce = "X-Lark-Request-Nonce" - LarkSignature = "X-Lark-Signature" - LarkRefreshToken = "X-Refresh-Token" -) - -type Header struct { - Timestamp string - Nonce string - Signature string - RefreshToken string -} - -type HTTPCard struct { - Header *Header - Request *core.OapiRequest - Input []byte - Response *core.OapiResponse - Type constants.CallbackType - Output interface{} - Challenge string - Err error -} - -type Challenge struct { - Challenge string `json:"challenge"` - Token string `json:"token"` - Type string `json:"type"` -} - -type Base struct { - OpenID string `json:"open_id"` - UserID string `json:"user_id"` - OpenMessageID string `json:"open_message_id"` - TenantKey string `json:"tenant_key"` - Token string `json:"token"` - Timezone string `json:"timezone"` -} - -type Card struct { - *Base - Action *Action `json:"action"` -} - -type Action struct { - Value map[string]interface{} `json:"value"` - Tag string `json:"tag"` - Option string `json:"option"` - Timezone string `json:"timezone"` -} diff --git a/core/config/app_settings.go b/core/config/app_settings.go deleted file mode 100644 index f0867eac..00000000 --- a/core/config/app_settings.go +++ /dev/null @@ -1,97 +0,0 @@ -package config - -import ( - "encoding/base64" - "fmt" - "github.com/larksuite/oapi-sdk-go/core/constants" - "os" -) - -type AppSettingsOpt func(*AppSettings) - -type AppSettings struct { - AppType constants.AppType - - AppID string - AppSecret string - - VerificationToken string - EncryptKey string - - HelpDeskID string - HelpDeskToken string -} - -func (s *AppSettings) helpDeskAuthorization() string { - if s.HelpDeskID != "" && s.HelpDeskToken != "" { - helpdeskAuthToken := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", s.HelpDeskID, s.HelpDeskToken))) - return helpdeskAuthToken - } - return "" -} - -func GetISVAppSettingsByEnv() *AppSettings { - return NewISVAppSettingsByOpts(getAppSettingsOptsByEnv()...) -} - -func GetInternalAppSettingsByEnv() *AppSettings { - return NewInternalAppSettingsByOpts(getAppSettingsOptsByEnv()...) -} - -func NewISVAppSettings(appID, appSecret, verificationToken, encryptKey string) *AppSettings { - return NewISVAppSettingsByOpts(SetAppCredentials(appID, appSecret), SetAppEventKey(verificationToken, encryptKey)) -} - -func NewInternalAppSettings(appID, appSecret, verificationToken, encryptKey string) *AppSettings { - return NewInternalAppSettingsByOpts(SetAppCredentials(appID, appSecret), SetAppEventKey(verificationToken, encryptKey)) -} - -func NewISVAppSettingsByOpts(opts ...AppSettingsOpt) *AppSettings { - return newAppSettingsByOpts(constants.AppTypeISV, opts...) -} - -func NewInternalAppSettingsByOpts(opts ...AppSettingsOpt) *AppSettings { - return newAppSettingsByOpts(constants.AppTypeInternal, opts...) -} - -func newAppSettingsByOpts(appType constants.AppType, optFns ...AppSettingsOpt) *AppSettings { - settings := &AppSettings{AppType: appType} - for _, opt := range optFns { - opt(settings) - } - if settings.AppID == "" || settings.AppSecret == "" { - panic("appID or appSecret is empty") - } - return settings -} - -func getAppSettingsOptsByEnv() []AppSettingsOpt { - var opts []AppSettingsOpt - appID, appSecret, verificationToken, encryptKey, helpDeskID, helpDeskToken := os.Getenv("APP_ID"), os.Getenv("APP_SECRET"), - os.Getenv("VERIFICATION_TOKEN"), os.Getenv("ENCRYPT_KEY"), os.Getenv("HELP_DESK_ID"), os.Getenv("HELP_DESK_TOKEN") - opts = append(opts, SetAppCredentials(appID, appSecret)) - opts = append(opts, SetAppEventKey(verificationToken, encryptKey)) - opts = append(opts, SetHelpDeskCredentials(helpDeskID, helpDeskToken)) - return opts -} - -func SetAppCredentials(appID, appSecret string) AppSettingsOpt { - return func(settings *AppSettings) { - settings.AppID = appID - settings.AppSecret = appSecret - } -} - -func SetAppEventKey(verificationToken, encryptKey string) AppSettingsOpt { - return func(settings *AppSettings) { - settings.VerificationToken = verificationToken - settings.EncryptKey = encryptKey - } -} - -func SetHelpDeskCredentials(helpDeskID, helpDeskToken string) AppSettingsOpt { - return func(settings *AppSettings) { - settings.HelpDeskID = helpDeskID - settings.HelpDeskToken = helpDeskToken - } -} diff --git a/core/config/config.go b/core/config/config.go deleted file mode 100644 index 549f2791..00000000 --- a/core/config/config.go +++ /dev/null @@ -1,71 +0,0 @@ -package config - -import ( - "context" - "github.com/larksuite/oapi-sdk-go/core/constants" - "github.com/larksuite/oapi-sdk-go/core/log" - "github.com/larksuite/oapi-sdk-go/core/store" -) - -var CtxKeyConfig = "-----CtxKeyConfig" - -type Config struct { - domain constants.Domain - appSettings *AppSettings - store store.Store // store - logger log.Logger // logger - helpDeskAuthorization string -} - -func NewTestConfig(domain constants.Domain, appSettings *AppSettings) *Config { - return NewConfigWithDefaultStore(domain, appSettings, log.NewDefaultLogger(), log.LevelDebug) -} - -func NewConfigWithDefaultStore(domain constants.Domain, appSettings *AppSettings, logger log.Logger, logLevel log.Level) *Config { - loggerProxy := log.NewLoggerProxy(logLevel, logger) - conf := &Config{ - domain: domain, - appSettings: appSettings, - store: store.NewDefaultStoreWithLog(loggerProxy), - logger: loggerProxy, - helpDeskAuthorization: appSettings.helpDeskAuthorization(), - } - return conf -} - -func NewConfig(domain constants.Domain, appSettings *AppSettings, logger log.Logger, logLevel log.Level, store store.Store) *Config { - loggerProxy := log.NewLoggerProxy(logLevel, logger) - conf := &Config{ - domain: domain, - appSettings: appSettings, - store: store, - logger: loggerProxy, - helpDeskAuthorization: appSettings.helpDeskAuthorization(), - } - return conf -} - -func (c *Config) GetDomain() string { - return string(c.domain) -} - -func (c *Config) GetAppSettings() *AppSettings { - return c.appSettings -} - -func (c *Config) GetLogger() log.Logger { - return c.logger -} - -func (c *Config) GetStore() store.Store { - return c.store -} - -func (c *Config) GetHelpDeskAuthorization() string { - return c.helpDeskAuthorization -} - -func ByCtx(ctx context.Context) *Config { - c := ctx.Value(CtxKeyConfig) - return c.(*Config) -} diff --git a/core/constants/constants.go b/core/constants/constants.go deleted file mode 100644 index a6ac70cd..00000000 --- a/core/constants/constants.go +++ /dev/null @@ -1,33 +0,0 @@ -package constants - -const ContentType = "Content-Type" -const ContentTypeJson = "application/json" -const DefaultContentType = ContentTypeJson + "; charset=utf-8" - -const ( - HTTPHeader = "HTTP-Header" - HTTPHeaderKeyRequestID = "X-Request-Id" - HTTPHeaderKeyLogID = "X-Tt-Logid" - HTTPKeyStatusCode = "http_status_code" -) - -type AppType string - -const ( - AppTypeISV AppType = "isv" // isv app - AppTypeInternal AppType = "internal" // internal app -) - -type Domain string - -const ( - DomainFeiShu Domain = "https://open.feishu.cn" - DomainLarkSuite Domain = "https://open.larksuite.com" -) - -type CallbackType string - -const ( - CallbackTypeEvent CallbackType = "event_callback" - CallbackTypeChallenge CallbackType = "url_verification" -) diff --git a/core/context.go b/core/context.go deleted file mode 100644 index 0ba26f6c..00000000 --- a/core/context.go +++ /dev/null @@ -1,88 +0,0 @@ -package core - -import ( - "context" - "github.com/larksuite/oapi-sdk-go/core/constants" - "sync" - "time" -) - -type Context struct { - c context.Context - mu sync.RWMutex - m map[string]interface{} -} - -// Deprecated, please use `WrapContext` -func WarpContext(c context.Context) *Context { - return &Context{ - c: c, - } -} - -func WrapContext(c context.Context) *Context { - return &Context{ - c: c, - } -} - -func (c *Context) Set(key string, value interface{}) { - c.mu.Lock() - if c.m == nil { - c.m = make(map[string]interface{}) - } - c.m[key] = value - c.mu.Unlock() -} - -// Get returns the value for the given key, ie: (value, true). -// If the value does not exists it returns (nil, false) -func (c *Context) Get(key string) (value interface{}, exists bool) { - c.mu.RLock() - value, exists = c.m[key] - c.mu.RUnlock() - return -} - -func (c *Context) GetHeader() *OapiHeader { - if header, ok := c.Get(constants.HTTPHeader); ok { - return header.(*OapiHeader) - } - return NewOapiHeader(map[string][]string{}) -} - -func (c *Context) GetRequestID() string { - header := c.GetHeader() - logID := header.GetFirstValue(constants.HTTPHeaderKeyLogID) - if logID != "" { - return logID - } - return header.GetFirstValue(constants.HTTPHeaderKeyRequestID) -} - -func (c *Context) GetHTTPStatusCode() int { - if statusCode, ok := c.Get(constants.HTTPKeyStatusCode); ok { - return statusCode.(int) - } - return 0 -} - -func (c *Context) Deadline() (deadline time.Time, ok bool) { - return c.c.Deadline() -} - -func (c *Context) Done() <-chan struct{} { - return c.c.Done() -} - -func (c *Context) Err() error { - return c.c.Err() -} - -func (c *Context) Value(key interface{}) interface{} { - if keyAsString, ok := key.(string); ok { - val, _ := c.Get(keyAsString) - return val - } - return c.c.Value(key) -} diff --git a/core/core.go b/core/core.go deleted file mode 100644 index 887e6fc6..00000000 --- a/core/core.go +++ /dev/null @@ -1,74 +0,0 @@ -package core - -import ( - "github.com/larksuite/oapi-sdk-go/core/config" - "github.com/larksuite/oapi-sdk-go/core/constants" - "github.com/larksuite/oapi-sdk-go/core/log" - "github.com/larksuite/oapi-sdk-go/core/store" -) - -var ( - GetISVAppSettingsByEnv = config.GetISVAppSettingsByEnv - GetInternalAppSettingsByEnv = config.GetInternalAppSettingsByEnv - NewISVAppSettings = config.NewISVAppSettingsByOpts - NewInternalAppSettings = config.NewInternalAppSettingsByOpts - SetAppCredentials = config.SetAppCredentials - SetAppEventKey = config.SetAppEventKey - SetHelpDeskCredentials = config.SetHelpDeskCredentials -) - -type LoggerLevel int - -const ( - LoggerLevelDebug LoggerLevel = LoggerLevel(log.LevelDebug) - LoggerLevelInfo LoggerLevel = LoggerLevel(log.LevelInfo) - LoggerLevelWarn LoggerLevel = LoggerLevel(log.LevelWarn) - LoggerLevelError LoggerLevel = LoggerLevel(log.LevelError) -) - -type configOpt struct { - logger log.Logger - logLevel log.Level - store store.Store -} - -type Domain string - -const ( - DomainFeiShu Domain = Domain(constants.DomainFeiShu) - DomainLarkSuite Domain = Domain(constants.DomainLarkSuite) -) - -func NewConfig(domain Domain, appSettings *config.AppSettings, opts ...ConfigOpt) *config.Config { - configOpt := &configOpt{ - logLevel: log.LevelError, - logger: log.NewDefaultLogger(), - } - for _, opt := range opts { - opt(configOpt) - } - if configOpt.store == nil { - return config.NewConfigWithDefaultStore(constants.Domain(domain), appSettings, configOpt.logger, configOpt.logLevel) - } - return config.NewConfig(constants.Domain(domain), appSettings, configOpt.logger, configOpt.logLevel, configOpt.store) -} - -type ConfigOpt func(o *configOpt) - -func SetLogger(logger log.Logger) func(o *configOpt) { - return func(o *configOpt) { - o.logger = logger - } -} - -func SetLoggerLevel(logLevel LoggerLevel) func(o *configOpt) { - return func(o *configOpt) { - o.logLevel = log.Level(logLevel) - } -} - -func SetStore(store store.Store) func(o *configOpt) { - return func(o *configOpt) { - o.store = store - } -} diff --git a/core/errors/errors.go b/core/errors/errors.go deleted file mode 100644 index dfe75e15..00000000 --- a/core/errors/errors.go +++ /dev/null @@ -1,15 +0,0 @@ -package errors - -import "fmt" - -type TokenInvalidErr struct { - token string -} - -func NewTokenInvalidErr(token string) *TokenInvalidErr { - return &TokenInvalidErr{token: token} -} - -func (e TokenInvalidErr) Error() string { - return fmt.Sprintf("AppSettings.verificationToken not equal token(%s)", e.token) -} diff --git a/core/oapi_header.go b/core/oapi_header.go deleted file mode 100644 index 8794c10c..00000000 --- a/core/oapi_header.go +++ /dev/null @@ -1,39 +0,0 @@ -package core - -import "strings" - -type OapiHeader struct { - header map[string][]string -} - -func NewOapiHeader(m map[string][]string) *OapiHeader { - header := make(map[string][]string, len(m)) - for k, v := range m { - header[normalizeKey(k)] = v - } - return &OapiHeader{header: header} -} - -func (h OapiHeader) GetNames() []string { - var names = make([]string, 0, len(h.header)) - for k := range h.header { - names = append(names, k) - } - return names -} - -func (h OapiHeader) GetFirstValue(name string) string { - values := h.header[normalizeKey(name)] - if len(values) > 0 { - return values[0] - } - return "" -} - -func (h OapiHeader) GetMultiValues(name string) []string { - return h.header[normalizeKey(name)] -} - -func normalizeKey(name string) string { - return strings.ToLower(name) -} diff --git a/core/oapi_request.go b/core/oapi_request.go deleted file mode 100644 index 0d3400e7..00000000 --- a/core/oapi_request.go +++ /dev/null @@ -1,27 +0,0 @@ -package core - -import ( - "context" - "io/ioutil" - "net/http" -) - -type OapiRequest struct { - Ctx context.Context - Uri string - Header *OapiHeader - Body string -} - -func ToOapiRequest(request *http.Request) (*OapiRequest, error) { - body, err := ioutil.ReadAll(request.Body) - if err != nil { - return nil, err - } - return &OapiRequest{ - Ctx: request.Context(), - Uri: request.RequestURI, - Header: NewOapiHeader(request.Header), - Body: string(body), - }, nil -} diff --git a/core/oapi_response.go b/core/oapi_response.go deleted file mode 100644 index 337f8eb1..00000000 --- a/core/oapi_response.go +++ /dev/null @@ -1,44 +0,0 @@ -package core - -import ( - "fmt" - "github.com/larksuite/oapi-sdk-go/core/constants" - "net/http" -) - -const ResponseFormat = `{"codemsg":"%s"}` -const ChallengeResponseFormat = `{"challenge":"%s"}` - -type OapiResponse struct { - StatusCode int - ContentType string - Header map[string][]string - Body string -} - -func NewOapiResponseOfErr(err error) *OapiResponse { - return &OapiResponse{ - StatusCode: http.StatusInternalServerError, - ContentType: constants.DefaultContentType, - Header: nil, - Body: fmt.Sprintf(ResponseFormat, err.Error()), - } -} - -func (r *OapiResponse) Write(statusCode int, contentType string, body string) { - r.StatusCode = statusCode - r.ContentType = contentType - r.Body = body -} - -func (r OapiResponse) WriteTo(response http.ResponseWriter) error { - for k, vs := range r.Header { - for _, v := range vs { - response.Header().Set(k, v) - } - } - response.Header().Set(constants.ContentType, r.ContentType) - response.WriteHeader(r.StatusCode) - _, err := fmt.Fprint(response, r.Body) - return err -} diff --git a/core/store/keys.go b/core/store/keys.go deleted file mode 100644 index 8f9bc560..00000000 --- a/core/store/keys.go +++ /dev/null @@ -1,21 +0,0 @@ -package store - -import "fmt" - -const ( - appTicketKeyPrefix = "app_ticket" - appAccessTokenKeyPrefix = "app_access_token" - tenantAccessTokenKeyPrefix = "tenant_access_token" -) - -func AppTicketKey(appID string) string { - return fmt.Sprintf("%s-%s", appTicketKeyPrefix, appID) -} - -func AppAccessTokenKey(appID string) string { - return fmt.Sprintf("%s-%s", appAccessTokenKeyPrefix, appID) -} - -func TenantAccessTokenKey(appID, tenantKey string) string { - return fmt.Sprintf("%s-%s-%s", tenantAccessTokenKeyPrefix, appID, tenantKey) -} diff --git a/core/store/store.go b/core/store/store.go deleted file mode 100644 index 49736b88..00000000 --- a/core/store/store.go +++ /dev/null @@ -1,50 +0,0 @@ -package store - -import ( - "context" - "fmt" - "github.com/larksuite/oapi-sdk-go/core/log" - "sync" - "time" -) - -type Store interface { - Get(context.Context, string) (string, error) - Put(context.Context, string, string, time.Duration) error -} - -func NewDefaultStoreWithLog(logger *log.LoggerProxy) *DefaultStore { - return &DefaultStore{log: logger} -} - -type DefaultStore struct { - m sync.Map - log *log.LoggerProxy -} - -type Value struct { - value string - expireTime time.Time -} - -func (s *DefaultStore) Get(ctx context.Context, key string) (string, error) { - if val, ok := s.m.Load(key); ok { - ev := val.(*Value) - if ev.expireTime.After(time.Now()) { - s.log.Debug(ctx, fmt.Sprintf("default store Get key %s, value is %s", key, ev.value)) - return ev.value, nil - } - } - s.log.Debug(ctx, fmt.Sprintf("default store Get key %s, value is empty", key)) - return "", nil -} - -func (s *DefaultStore) Put(ctx context.Context, key, value string, ttl time.Duration) error { - expireTime := time.Now().Add(ttl) - s.m.Store(key, &Value{ - value: value, - expireTime: expireTime, - }) - s.log.Debug(ctx, fmt.Sprintf("default store put key %s, value is %s, expire time is %s", key, value, expireTime)) - return nil -} diff --git a/core/test/config.go b/core/test/config.go deleted file mode 100644 index 5561fe82..00000000 --- a/core/test/config.go +++ /dev/null @@ -1,44 +0,0 @@ -package test - -import ( - "github.com/larksuite/oapi-sdk-go/core/config" - "github.com/larksuite/oapi-sdk-go/core/constants" - "os" - "strings" -) - -func domainFeiShu(env string) string { - return os.Getenv(env + "_FEISHU_DOMAIN") -} - -func getISVAppSettings(env string) *config.AppSettings { - appID, appSecret, verificationToken, encryptKey := os.Getenv(env+"_ISV_APP_ID"), - os.Getenv(env+"_ISV_APP_SECRET"), os.Getenv(env+"_ISV_VERIFICATION_TOKEN"), os.Getenv(env+"_ISV_ENCRYPT_KEY") - return config.NewISVAppSettings(appID, appSecret, verificationToken, encryptKey) -} - -func getInternalAppSettings(env string) *config.AppSettings { - appID, appSecret, verificationToken, encryptKey := os.Getenv(env+"_INTERNAL_APP_ID"), - os.Getenv(env+"_INTERNAL_APP_SECRET"), os.Getenv(env+"_INTERNAL_VERIFICATION_TOKEN"), os.Getenv(env+"_INTERNAL_ENCRYPT_KEY") - return config.NewInternalAppSettings(appID, appSecret, verificationToken, encryptKey) -} - -func GetISVConf(env string) *config.Config { - env = strings.ToUpper(env) - return config.NewTestConfig(getDomain(env), getISVAppSettings(env)) -} - -func GetInternalConf(env string) *config.Config { - env = strings.ToUpper(env) - return config.NewTestConfig(getDomain(env), getInternalAppSettings(env)) -} - -func getDomain(env string) constants.Domain { - if env != "BOE" && env != "PRE" && env != "ONLINE" { - panic("env must in [boe, pre, online]") - } - if env == "ONLINE" { - return constants.DomainFeiShu - } - return constants.Domain(domainFeiShu(env)) -} diff --git a/core/tools/decrypt.go b/core/tools/decrypt.go deleted file mode 100644 index babe4405..00000000 --- a/core/tools/decrypt.go +++ /dev/null @@ -1,63 +0,0 @@ -package tools - -import ( - "crypto/aes" - "crypto/cipher" - "crypto/sha256" - "encoding/base64" - "encoding/json" - "fmt" - "strings" -) - -type DecryptErr struct { - Message string -} - -func newDecryptErr(message string) *DecryptErr { - return &DecryptErr{Message: message} -} - -func (e DecryptErr) Error() string { - return e.Message -} - -func Decrypt(encryptBs []byte, keyStr string) ([]byte, error) { - type AESMsg struct { - Encrypt string `json:"encrypt"` - } - var encrypt AESMsg - err := json.Unmarshal(encryptBs, &encrypt) - if err != nil { - return nil, newDecryptErr(fmt.Sprintf("dataDecrypter jsonUnmarshalError[%v]", err)) - } - buf, err := base64.StdEncoding.DecodeString(encrypt.Encrypt) - if err != nil { - return nil, newDecryptErr(fmt.Sprintf("base64StdEncode Error[%v]", err)) - } - if len(buf) < aes.BlockSize { - return nil, newDecryptErr("cipher too short") - } - key := sha256.Sum256([]byte(keyStr)) - block, err := aes.NewCipher(key[:sha256.Size]) - if err != nil { - return nil, newDecryptErr(fmt.Sprintf("AESNewCipher Error[%v]", err)) - } - iv := buf[:aes.BlockSize] - buf = buf[aes.BlockSize:] - // CBC mode always works in whole blocks. - if len(buf)%aes.BlockSize != 0 { - return nil, newDecryptErr("ciphertext is not a multiple of the block size") - } - mode := cipher.NewCBCDecrypter(block, iv) - mode.CryptBlocks(buf, buf) - n := strings.Index(string(buf), "{") - if n == -1 { - n = 0 - } - m := strings.LastIndex(string(buf), "}") - if m == -1 { - m = len(buf) - 1 - } - return buf[n : m+1], nil -} diff --git a/core/tools/file.go b/core/tools/file.go deleted file mode 100644 index 8740e6f8..00000000 --- a/core/tools/file.go +++ /dev/null @@ -1,36 +0,0 @@ -package tools - -import ( - "context" - "fmt" - "io" - "io/ioutil" - "net/http" -) - -// download file return ReadCloser -// defer r.Close() -// -func DownloadFileToStream(ctx context.Context, url string) (io.ReadCloser, error) { - request, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) - if err != nil { - return nil, err - } - resp, err := http.DefaultClient.Do(request) - if err != nil { - return nil, err - } - if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("response status code:%d", resp.StatusCode) - } - return resp.Body, nil -} - -func DownloadFile(ctx context.Context, url string) ([]byte, error) { - r, err := DownloadFileToStream(ctx, url) - if err != nil { - return nil, err - } - defer r.Close() - return ioutil.ReadAll(r) -} diff --git a/core/tools/prettify.go b/core/tools/prettify.go deleted file mode 100644 index ee7cd548..00000000 --- a/core/tools/prettify.go +++ /dev/null @@ -1,112 +0,0 @@ -package tools - -import ( - "bytes" - "fmt" - "io" - "reflect" - "strings" -) - -// Prettify returns the string representation of a value. -func Prettify(i interface{}) string { - var buf bytes.Buffer - prettify(reflect.ValueOf(i), 0, &buf) - return buf.String() -} - -// prettify will recursively walk value v to build a textual -// representation of the value. -func prettify(v reflect.Value, indent int, buf *bytes.Buffer) { - for v.Kind() == reflect.Ptr { - v = v.Elem() - } - switch v.Kind() { - case reflect.Struct: - strType := v.Type().String() - if strType == "time.Time" { - fmt.Fprintf(buf, "%s", v.Interface()) - break - } else if strings.HasPrefix(strType, "io.") { - buf.WriteString("") - break - } - - buf.WriteString("{\n") - - var names []string - for i := 0; i < v.Type().NumField(); i++ { - name := v.Type().Field(i).Name - f := v.Field(i) - if name[0:1] == strings.ToLower(name[0:1]) { - continue // ignore unexported fields - } - if (f.Kind() == reflect.Ptr || f.Kind() == reflect.Slice || f.Kind() == reflect.Map) && f.IsNil() { - continue // ignore unset fields - } - names = append(names, name) - } - - for i, n := range names { - val := v.FieldByName(n) - buf.WriteString(strings.Repeat(" ", indent+2)) - buf.WriteString(n + ": ") - prettify(val, indent+2, buf) - - if i < len(names)-1 { - buf.WriteString(",\n") - } - } - - buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") - case reflect.Slice: - strType := v.Type().String() - if strType == "[]uint8" { - fmt.Fprintf(buf, " len %d", v.Len()) - break - } - - nl, id, id2 := "", "", "" - if v.Len() > 3 { - nl, id, id2 = "\n", strings.Repeat(" ", indent), strings.Repeat(" ", indent+2) - } - buf.WriteString("[" + nl) - for i := 0; i < v.Len(); i++ { - buf.WriteString(id2) - prettify(v.Index(i), indent+2, buf) - - if i < v.Len()-1 { - buf.WriteString("," + nl) - } - } - - buf.WriteString(nl + id + "]") - case reflect.Map: - buf.WriteString("{\n") - - for i, k := range v.MapKeys() { - buf.WriteString(strings.Repeat(" ", indent+2)) - buf.WriteString(k.String() + ": ") - prettify(v.MapIndex(k), indent+2, buf) - - if i < v.Len()-1 { - buf.WriteString(",\n") - } - } - - buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") - default: - if !v.IsValid() { - fmt.Fprint(buf, "") - return - } - format := "%v" - switch v.Interface().(type) { - case string: - format = "%q" - case io.ReadSeeker, io.Reader: - format = "buffer(%p)" - } - fmt.Fprintf(buf, format, v.Interface()) - } -} diff --git a/core/tools/time.go b/core/tools/time.go deleted file mode 100644 index 77163d1d..00000000 --- a/core/tools/time.go +++ /dev/null @@ -1,15 +0,0 @@ -package tools - -import ( - "strconv" - "time" -) - -func TsToTime(ts string) (time.Time, error) { - _ts, err := strconv.ParseFloat(ts, 64) - if err != nil { - return time.Time{}, err - } - ns := int64(_ts * float64(time.Second)) - return time.Unix(0, ns), nil -} diff --git a/core/version.go b/core/version.go deleted file mode 100644 index eaa24f7c..00000000 --- a/core/version.go +++ /dev/null @@ -1,3 +0,0 @@ -package core - -const SdkVersion = "v1.1.40-rc9" diff --git a/README.zh.md b/doc/FeiShu.old.md similarity index 97% rename from README.zh.md rename to doc/FeiShu.old.md index 76a6cee9..927ffd22 100644 --- a/README.zh.md +++ b/doc/FeiShu.old.md @@ -1,5 +1,3 @@ -[**README of Larksuite(Overseas)**](README.md) | 飞书 - # 飞书开放接口SDK ## 概述 @@ -40,8 +38,8 @@ go get github.com/larksuite/oapi-sdk-go@v1.1.40-rc9 - 开发者后台:开发者开发应用的管理后台,[更多介绍说明](https://open.feishu.cn/app/) 。 - 企业自建应用:应用仅仅可在本企业内安装使用,[更多介绍说明](https://open.feishu.cn/document/uQjL04CN/ukzM04SOzQjL5MDN) 。 - 应用商店应用:应用会在 [应用目录](https://app.feishu.cn/?lang=zh-CN) 展示,各个企业可以选择安装,[更多介绍说明](https://open.feishu.cn/document/uQjL04CN/ugTO5UjL4kTO14CO5kTN) 。 - -![App type](doc/app_type.zh.png) + +![App type](app_type.zh.png) ## 快速使用 @@ -51,10 +49,10 @@ go get github.com/larksuite/oapi-sdk-go@v1.1.40-rc9 - **必看** [如何调用服务端API](https://open.feishu.cn/document/ukTMukTMukTM/uYTM5UjL2ETO14iNxkTN/guide-to-use-server-api) ,了解调用服务端API的过程及注意事项。 - - 由于SDK已经封装了 app_access_token、tenant_access_token 的获取,所以在调业务API的时候,不需要去获取 app_access_token、tenant_access_token。如果业务接口需要使用 user_access_token,需要进行设置(request.SetUserAccessToken("UserAccessToken")),具体请看 README.zh.md -> 如何构建请求(Request) + - 由于SDK已经封装了 app_access_token、tenant_access_token 的获取,所以在调业务API的时候,不需要去获取 app_access_token、tenant_access_token。如果业务接口需要使用 user_access_token,需要进行设置(request.SetUserAccessToken("UserAccessToken")),具体请看 README.zh.md -> 如何构建请求(Request) - 更多示例,请看:[sample/api/api.go](sample/api/api.go)(含:文件的上传与下载) -#### [使用`应用商店应用`调用 服务端API 示例](doc/ISV.APP.README.zh.md) +#### [使用`应用商店应用`调用 服务端API 示例](ISV.APP.README.zh.md) #### 使用`企业自建应用`访问 [发送消息API](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/create) 示例 diff --git a/doc/LarkSuite.old.md b/doc/LarkSuite.old.md new file mode 100644 index 00000000..5159c6af --- /dev/null +++ b/doc/LarkSuite.old.md @@ -0,0 +1,418 @@ +# LarkSuite open api SDK + +## Overview + +--- + +- Larksuite open platform facilitates the integration of enterprise applications and larksuite, making collaboration and + management more efficient. + +- Larksuite development interface SDK, convenient call server API and subscribe server events, such as: Message & group, + address book, calendar, docs and others can + visit [larksuite open platform document](https://open.larksuite.cn/document) ,Take a look at [REFERENCE]. + +## Problem feedback + +--- + +If you encounter any problems during usage, please let us know by submitting [Github Issues](https://github.com/larksuite/oapi-sdk-go/issues). We will deal with these Issues and get back to you as soon as possible. + +- Upgrade the package first, if you still have problems, please submit Issues + +## Run environment + +--- + +- Golang 1.5+ + +## Install + +--- + +- The latest release candidate provides more [open services API](/service) and bug repair. +```shell +go get github.com/larksuite/oapi-sdk-go@v1.1.40-rc9 +``` + +## Explanation of terms + +- Larksuite: the overseas name of lark, which mainly provides services for overseas enterprises and has an + independent [domain name address](https://www.larksuite.com/) . +- Development documents: reference to the open interface of the open platform **developers must see, and can use search + to query documents efficiently** . [more information](https://open.feishu.cn/document/) . +- Developer background: the management background for developers to develop + applications, [more introduction](https://open.larksuite.cn/app/) . +- Cutome APP: the application can only be installed and used in the + enterprise,[more introduction](https://open.larksuite.com/document/ukzMxEjL5MTMx4SOzETM/uEjNwYjLxYDM24SM2AjN) . +- Marketplace App:The app will be displayed in [App Directory](https://app.larksuite.com/) Display, each enterprise can + choose to install. + +![App type](doc/app_type.en.png) + +## Quick use + +--- + +### Call API + +#### Example of using "Custom App" to access [send text message](https://open.larksuite.com/document/uMzMyEjLzMjMx4yMzITM/ugDN0EjL4QDNx4CO0QTM) API +- Since the SDK has encapsulated the app_access_token、tenant_access_token So when calling the business API, you don't need to get the app_access_token、tenant_access_token. If the business interface needs to use user_access_token, which needs to be set(request.SetUserAccessToken("user_access_token")), Please refer to README.md -> How to build a request(Request) +- Some of the old API do not have a direct SDK to use. They can use the `native` mode. + +```go +package main + +import ( + "context" + "fmt" + "github.com/larksuite/oapi-sdk-go/api" + "github.com/larksuite/oapi-sdk-go/api/core/request" + "github.com/larksuite/oapi-sdk-go/api/core/response" + "github.com/larksuite/oapi-sdk-go/core" + "github.com/larksuite/oapi-sdk-go/core/tools" +) + +func main() { + // Configuration of "Custom App", parameter description: + // AppID、AppSecret: "Developer Console" -> "Credentials"(App ID、App Secret) + // EncryptKey、VerificationToken:"Developer Console" -> "Event Subscriptions"(Encrypt Key、Verification Token) + appSettings := core.NewInternalAppSettings( + core.SetAppCredentials("AppID", "AppSecret"), // Required + core.SetAppEventKey("VerificationToken", "EncryptKey"), // Not required. Required for event、card subscription + ) + + // Currently, you are visiting larksuite, which uses default storage and default log (error level). More optional configurations are as follows: core.NewConfig() + conf := core.NewConfig(core.DomainLarkSuite, appSettings, core.SetLoggerLevel(core.LoggerLevelError)) + + // The content of the sent message + body := map[string]interface{}{ + "open_id": "user open id", + "msg_type": "text", + "content": map[string]interface{}{ + "text": "test send message", + }, + } + // The result of the request to send a message + ret := make(map[string]interface{}) + // Build request + req := request.NewRequestWithNative("/open-apis/message/v4/send", "POST", request.AccessTokenTypeTenant, body, &ret) + // The context of the request + coreCtx := core.WrapContext(context.Background()) + // Send request + err := api.Send(coreCtx, conf, req) + // Print the requestId of the request + fmt.Println(coreCtx.GetRequestID()) + // Print the response status of the request + fmt.Println(coreCtx.GetHTTPStatusCode()) + // Error handling of request + if err != nil { + e := err.(*response.Error) + fmt.Println(e.Code) + fmt.Println(e.Msg) + fmt.Println(tools.Prettify(err)) + return + } + // Print the result of the request + fmt.Println(tools.Prettify(ret)) +} + +``` + +### Subscribe to events + +- [Subscribe to events](https://open.larksuite.com/document/uMzMyEjLzMjMx4yMzITM/uETM4QjLxEDO04SMxgDN) , to understand + the process and precautions of subscribing to events. +- For more use examples, please refer to [sample/event](sample/event)(including: use in combination with gin) + +#### Example of using "Custom App" to subscribe [App First Enabled](https://open.larksuite.com/document/uMzMyEjLzMjMx4yMzITM/uYjMyYjL2IjM24iNyIjN) event. + +- For some old events, there is no SDK that can be used directly. You can use the `native` mode + +```go +package main + +import ( + "fmt" + "github.com/larksuite/oapi-sdk-go/core" + "github.com/larksuite/oapi-sdk-go/core/tools" + "github.com/larksuite/oapi-sdk-go/event" + eventhttpserver "github.com/larksuite/oapi-sdk-go/event/http/native" + "net/http" +) + +func main() { + + // Configuration of "Custom App", parameter description: + // AppID、AppSecret: "Developer Console" -> "Credentials"(App ID、App Secret) + // EncryptKey、VerificationToken:"Developer Console" -> "Event Subscriptions"(Encrypt Key、Verification Token) + appSettings := core.NewInternalAppSettings( + core.SetAppCredentials("AppID", "AppSecret"), // Required + core.SetAppEventKey("VerificationToken", "EncryptKey"), // Not required. Required for event、card subscription + ) + + // Currently, you are visiting larksuite, which uses default storage and default log (error level). More optional configurations are as follows: core.NewConfig() + conf := core.NewConfig(core.DomainLarkSuite, appSettings, core.SetLoggerLevel(core.LoggerLevelError)) + + // Set the application event callback to be enabled for the first time + event.SetTypeCallback(conf, "app_open", func(ctx *core.Context, e map[string]interface{}) error { + // Print the request ID of the request + fmt.Println(ctx.GetRequestID()) + // Print event + fmt.Println(tools.Prettify(e)) + return nil + }) + + // Start the httpserver, "Developer Console" -> "Event Subscriptions", setting Request URL: https://domain/webhook/event + eventhttpserver.Register("/webhook/event", conf) + err := http.ListenAndServe(":8089", nil) + if err != nil { + panic(err) + } +} + +``` + +### Processing message card callbacks + +- [Message Card Development Process](https://open.larksuite.com/document/uMzMyEjLzMjMx4yMzITM/ukzM3QjL5MzN04SOzcDN) , to + understand the process and precautions of processing message cards +- For more use examples, please refer to [sample/card](sample/card)(including: use in combination with gin) + +#### Example of using "Custom App" to handling message card callback. + +```go +package main + +import ( + "fmt" + "github.com/larksuite/oapi-sdk-go/card" + cardhttpserver "github.com/larksuite/oapi-sdk-go/card/http/native" + "github.com/larksuite/oapi-sdk-go/card/model" + "github.com/larksuite/oapi-sdk-go/core" + "github.com/larksuite/oapi-sdk-go/core/tools" + "net/http" +) + +func main() { + + // Configuration of "Custom App", parameter description: + // AppID、AppSecret: "Developer Console" -> "Credentials"(App ID、App Secret) + // EncryptKey、VerificationToken:"Developer Console" -> "Event Subscriptions"(Encrypt Key、Verification Token) + appSettings := core.NewInternalAppSettings( + core.SetAppCredentials("AppID", "AppSecret"), // Required + core.SetAppEventKey("VerificationToken", "EncryptKey"), // Not required. Required for event、card subscription + ) + + // Currently, you are visiting larksuite, which uses default storage and default log (error level). More optional configurations are as follows: core.NewConfig() + conf := core.NewConfig(core.DomainLarkSuite, appSettings, core.SetLoggerLevel(core.LoggerLevelError)) + + // Set the handler of the message card + // Return value: can be nil, JSON string of new message card + card.SetHandler(conf, func(ctx *core.Context, c *model.Card) (interface{}, error) { + // Print message card + fmt.Println(tools.Prettify(c)) + return "{\"config\":{\"wide_screen_mode\":true},\"i18n_elements\":{\"zh_cn\":[{\"tag\":\"div\",\"text\":{\"tag\":\"lark_md\",\"content\":\"[Larksuitegolang](https://www.larksuite.cn)Integrate instant communication, calendar, audio and video conference, cloud document, cloud disk, workbench and other functions into one to make organizations and individuals more efficient and enjoyable.\"}}]}}", nil + }) + + // Start the httpserver, "Developer Console" -> "Features" -> "Bot", setting Message Card Request URL: https://domain/webhook/card + cardhttpserver.Register("/webhook/card", conf) + err := http.ListenAndServe(":8089", nil) + if err != nil { + panic(err) + } +} + +``` + +## How to build app settings(AppSettings) + +```go + +import ( + "github.com/larksuite/oapi-sdk-go/core" +) + +// To prevent application information leakage, in the configuration environment variables, the variables (4) are described as follows: +// APP_ID: "Developer Console" -> "Credentials"(App ID) +// APP_Secret: "Developer Console" -> "Credentials"(App Secret) +// VERIFICATION_Token: VerificationToken、EncryptKey:"Developer Console" -> "Event Subscriptions"(Verification Token) +// ENCRYPT_Key: VerificationToken、EncryptKey:"Developer Console" -> "Event Subscriptions"(Encrypt Key) +// HELP_DESK_ID: Help desk setting -> ID +// HELP_DESK_TOKEN: Help desk setting -> Token +// The configuration of "Custom App" is obtained through environment variables +appSettings := core.GetInternalAppSettingsByEnv() +// The configuration of "Marketplace App" is obtained through environment variables +appSettings := core.GetISVAppSettingsByEnv() + +// Parameter Description: +// AppID、AppSecret: "Developer Console" -> "Credentials"(App ID、App Secret) +// VerificationToken、EncryptKey:"Developer Console" -> "Event Subscriptions"(Verification Token、Encrypt Key) +// HelpDeskID、HelpDeskToken:Help desk setting -> ID、Token +// The configuration of "Custom App" +appSettings := core.NewInternalAppSettings( +core.SetAppCredentials("AppID", "AppSecret"), // Required +core.SetAppEventKey("VerificationToken", "EncryptKey"), // Not required. Required for event、card subscription +core.SetHelpDeskCredentials("HelpDeskID", "HelpDeskToken"), // Not required. Required to access the service desk API +) +// The configuration of "Marketplace App" +appSettings := core.NewISVAppSettings( +core.SetAppCredentials("AppID", "AppSecret"), // Required +core.SetAppEventKey("VerificationToken", "EncryptKey"), // Not required. Required for event、card subscription +core.SetHelpDeskCredentials("HelpDeskID", "HelpDeskToken"), // Not required. Required to access the service desk API +) +``` + +## How to build overall configuration(Config) + +- Visit Larksuite, Feishu or others +- App settings +- The implementation of logger is used to output the logs generated in the process of SDK processing, which is + convenient for troubleshooting. + - You can use the log implementation of the business system, see the sample + code: [sample/config/logrus.go](sample/config/logrus.go) +- The implementation of store is used to save the access credentials (app/tenant_access_token), temporary voucher ( + app_ticket) + - Redis is recommended. Please see the example code: [sample/config/redis_store.go](sample/config/redis_store.go) + - It can reduce the times of obtaining access credentials and prevent the frequency limit of calling access + credentials interface. + - "Marketplace App", accept open platform distributed `app_ticket` will be saved to the storage, so the + implementation of the storage interface (store) needs to support distributed storage. + +```go +import ( + "github.com/larksuite/oapi-sdk-go/core" + "github.com/larksuite/oapi-sdk-go/core/config" + "github.com/larksuite/oapi-sdk-go/core/log" + "github.com/larksuite/oapi-sdk-go/core/store" +) + +// Parameter Description: +// domain:URL domain address, value range: core.DomainFeiShu / core.DomainLarkSuite / 其他URL域名地址 +// appSettings:App settings +// opts:Option parameters + // core.SetLogger(logger log.Logger), Set logger. The default is console output + // core.SetLoggerLevel(core.LoggerLevelDebug), Set the logger log level, and the default is: core.LoggerLevelError + // core.SetStore(store store.Store), Set Store([Store interface](core/store/store.go), used to store app_ticket/access_token),it is recommended to use redis to implement the store interface, so as to reduce the times of accessing the accesstoken interface. The default is: memory (sync.Map) storage +conf = core.NewConfig(domain Domain, appSettings *config.AppSettings, opts ...ConfigOpt) +``` + +## How to build a request(Request) + +- Some of the old interfaces do not have an SDK that can be used directly. They can use `native` mode. At this time, + they need to build requests. +- For more examples, see [sample/api/api.go](sample/api/api.go) (including: file upload and download) + +```go +import ( + "github.com/larksuite/oapi-sdk-go/api/core/request" +) + +// Parameter Description: +// httpPath: API path + // such as: https://domain/open-apis/contact/v3/users/:user_id + // support: the path of the domain name after, httpPath: "/open apis/contact/v3/users/:user_id" (recommended) + // support: the full path, httpPath: "https://domain/open-apis/contact/v3/users/:user_id" + // support: httpPath: "contact/v3/users/:user_id" +// httpMethod: GET/POST/PUT/BATCH/DELETE +// accessTokenType:What kind of access certificate does the API use and the value range:request.AccessTokenTypeApp/request.AccessTokenTypeTenant/request.AccessTokenTypeUser, for example: request.AccessTokenTypeTenant +// input:Request body (possibly request.NewFormData () (e.g. file upload)), if the request body (e.g. some get requests) is not needed, it will be transferred to: nil +// output:Response body (output: = response ["data"]) +// optFns:Extension function, some rarely used parameter encapsulation, as follows: + // request.SetPathParams(map[string]interface{}{"user_id": 4}): set the URL Path parameter(with: prefix) value, When httpPath="contact/v3/users/:user_id", the requested URL="https://{domain}/open-apis/contact/v3/users/4" + // request.SetQueryParams(map[string]interface{}{"age":4,"types":[1,2]}): Set the URL query, will append to the url?age=4&types=1&types=2 + // request.setResponseStream(), set whether the response is a stream, such as downloading a file, At this point: the type of output needs to be implemented io.Writer Interface + // request.SetNotDataField(), set whether the response does not have a `data` field, business interfaces all have `data `Field, so you don’t need to set + // request.SetTenantKey("TenantKey"), as an `app store application`, it means using `tenant_access_token` to access the API, you need to set + // request.SetUserAccessToken("UserAccessToken"), which means using` user_access_token` To access the API, you need to set + // request.NeedHelpDeskAuth(), Indicates that the help desk API needs to set help desk information of config.AppSettings +req := request.NewRequestWithNative(httpPath, httpMethod string, accessTokenType AccessTokenType, +input interface{}, output interface{}, optFns ...OptFn) +``` + +## How to build request context(core.Context) And common methods + +```go +import( + "github.com/larksuite/oapi-sdk-go/core" +) + +// Parameter Description: +// c:Golang的context.Context +// Return value Description: +// ctx: Implementation of golang's context.Context To save some variables in the request +ctx := core.WrapContext(c context.Context) + +// Get the request ID of the request for troubleshooting +requestId := ctx.GetRequestID() + +// Get the response status code of the request +httpStatusCode := ctx.GetHTTPStatusCode() + +// In the handler of event subscription and message card callback, you can core.Context Get config from +conf := config.ByCtx(ctx *core.Context) + +``` + +## How to send a request + +- Since the SDK has encapsulated the app_access_token、tenant_access_token So when calling the business API, you don't need to get the app_access_token、tenant_access_token. If the business interface needs to use user_access_token, which needs to be set(request.SetUserAccessToken("user_access_token")), Please refer to README.md -> How to build a request(Request) +- For more use examples, please see: [sample/api/api.go](sample/api/api.go) + +```go +import( + "fmt" + "context" + "github.com/larksuite/oapi-sdk-go/api" + "github.com/larksuite/oapi-sdk-go/api/core/request" + "github.com/larksuite/oapi-sdk-go/api/core/response" + "github.com/larksuite/oapi-sdk-go/core" + "github.com/larksuite/oapi-sdk-go/core/test" + "github.com/larksuite/oapi-sdk-go/core/tools" +) + +// Parameter Description: +// ctx:The context of the request +// conf:Overall configuration(Config) +// req:Request(Request) +// Return value Description: +// err:Send request, happen error and response error code(response.body["code"]) is not equal to 0 +err := api.Send(ctx *core.Context, conf *config.Config, req *request.Request) + +``` + +### Download File Tool + +- Download files via network request +- For more use examples, please see: [sample/tools/file_download.go](sample/tools/file_download.go) + +```go +import( + "context" + "github.com/larksuite/oapi-sdk-go/core/tools" +) + +// Get the file content +// Parameter Description: +// ctx:context.Context +// url:The HTTP address of the file +// Return value Description: +// bytes:Binary array of file contents +// err:Error +bytes, err := tools.DownloadFile(ctx context.Context, url string) + +// Get the file content stream. After reading the file content, you need to close the stream +// Parameter Description: +// ctx:context.Context +// url:The HTTP address of the file +// Return value Description: +// readCloser:Binary read stream of file content +// err:Error +readCloser, err := tools.DownloadFileToStream(ctx context.Context, url string) + +``` + +## License + +--- + +- MIT diff --git a/doc/app_type.zh.png b/doc/app_type.zh.png index 91e25ba6..9a3a022e 100644 Binary files a/doc/app_type.zh.png and b/doc/app_type.zh.png differ diff --git a/event/app/v1/app_ticket.go b/event/app/v1/app_ticket.go deleted file mode 100644 index 84f30a30..00000000 --- a/event/app/v1/app_ticket.go +++ /dev/null @@ -1,44 +0,0 @@ -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" - "github.com/larksuite/oapi-sdk-go/core/constants" - "github.com/larksuite/oapi-sdk-go/core/store" - "github.com/larksuite/oapi-sdk-go/event/core/handlers" - "github.com/larksuite/oapi-sdk-go/event/core/model" - - "time" -) - -type AppTicketEventData struct { - *model.BaseEventData - AppTicket string `json:"app_ticket"` -} - -type AppTicketEvent struct { - *model.BaseEvent - Event *AppTicketEventData `json:"event"` -} - -type AppTicketEventHandler struct { - event *AppTicketEvent -} - -func (h *AppTicketEventHandler) GetEvent() interface{} { - h.event = &AppTicketEvent{} - return h.event -} - -func (h *AppTicketEventHandler) Handle(ctx *core.Context, event interface{}) error { - appTicketEvent := event.(*AppTicketEvent) - conf := config.ByCtx(ctx) - return conf.GetStore().Put(ctx, store.AppTicketKey(appTicketEvent.Event.AppID), appTicketEvent.Event.AppTicket, time.Hour*12) -} - -func SetAppTicketEventHandler(conf *config.Config) { - if conf.GetAppSettings().AppType == constants.AppTypeInternal { - return - } - handlers.SetTypeHandler(conf, "app_ticket", &AppTicketEventHandler{}) -} diff --git a/event/core/handlers/err.go b/event/core/handlers/err.go deleted file mode 100644 index 576d2ebe..00000000 --- a/event/core/handlers/err.go +++ /dev/null @@ -1,15 +0,0 @@ -package handlers - -import "fmt" - -type NotFoundHandlerErr struct { - EventType string -} - -func newNotHandlerErr(eventType string) *NotFoundHandlerErr { - return &NotFoundHandlerErr{EventType: eventType} -} - -func (e NotFoundHandlerErr) Error() string { - return fmt.Sprintf("event type:%s, not found handler", e.EventType) -} diff --git a/event/core/handlers/handlers.go b/event/core/handlers/handlers.go deleted file mode 100644 index 2bb705fb..00000000 --- a/event/core/handlers/handlers.go +++ /dev/null @@ -1,131 +0,0 @@ -package handlers - -import ( - "bytes" - "encoding/json" - "fmt" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" - "github.com/larksuite/oapi-sdk-go/core/constants" - "github.com/larksuite/oapi-sdk-go/core/errors" - "github.com/larksuite/oapi-sdk-go/core/tools" - "github.com/larksuite/oapi-sdk-go/event/core/model" - - "net/http" -) - -var defaultHandlers = &Handlers{ - unmarshal: unmarshalFunc, - handler: handlerFunc, - complement: complementFunc, -} - -type handler func(*core.Context, *model.HTTPEvent) - -type Handlers struct { - unmarshal handler - handler handler - complement handler -} - -func Handle(ctx *core.Context, httpEvent *model.HTTPEvent) { - defer defaultHandlers.complement(ctx, httpEvent) - if httpEvent.Err != nil { - return - } - defaultHandlers.unmarshal(ctx, httpEvent) - if httpEvent.Err != nil { - return - } - defaultHandlers.handler(ctx, httpEvent) -} - -func unmarshalFunc(ctx *core.Context, httpEvent *model.HTTPEvent) { - request := httpEvent.Request - ctx.Set(constants.HTTPHeader, request.Header) - conf := config.ByCtx(ctx) - conf.GetLogger().Debug(ctx, fmt.Sprintf("[unmarshal] event: %s", request.Body)) - body := []byte(request.Body) - var err error - if conf.GetAppSettings().EncryptKey != "" { - body, err = tools.Decrypt(body, conf.GetAppSettings().EncryptKey) - if err != nil { - httpEvent.Err = err - return - } - conf.GetLogger().Debug(ctx, fmt.Sprintf("[unmarshal] decrypt event: %s", string(body))) - } - httpEvent.Input = body - fuzzy := &model.Fuzzy{} - err = json.NewDecoder(bytes.NewBuffer(body)).Decode(&fuzzy) - if err != nil { - httpEvent.Err = err - return - } - schema := model.Version1 - token := fuzzy.Token - if fuzzy.Schema != "" { - schema = fuzzy.Schema - } - var eventType string - if fuzzy.Event != nil { - eventType = fuzzy.Event.Type - } - if fuzzy.Header != nil { - token = fuzzy.Header.Token - eventType = fuzzy.Header.EventType - } - httpEvent.Schema = schema - httpEvent.EventType = eventType - httpEvent.Type = fuzzy.Type - httpEvent.Challenge = fuzzy.Challenge - if token != conf.GetAppSettings().VerificationToken { - httpEvent.Err = errors.NewTokenInvalidErr(token) - return - } -} - -func handlerFunc(ctx *core.Context, httpEvent *model.HTTPEvent) { - if constants.CallbackType(httpEvent.Type) == constants.CallbackTypeChallenge { - return - } - conf := config.ByCtx(ctx) - var handler Handler - if type2EventHandler, ok := getType2EventHandler(conf); ok { - h, ok := type2EventHandler[httpEvent.EventType] - if ok { - handler = h - } - } - if handler == nil { - httpEvent.Err = newNotHandlerErr(httpEvent.EventType) - return - } - e := handler.GetEvent() - err := json.NewDecoder(bytes.NewBuffer(httpEvent.Input)).Decode(e) - if err != nil { - httpEvent.Err = err - return - } - err = handler.Handle(ctx, e) - httpEvent.Err = err -} - -func complementFunc(ctx *core.Context, httpEvent *model.HTTPEvent) { - conf := config.ByCtx(ctx) - err := httpEvent.Err - if err != nil { - if _, ok := err.(*NotFoundHandlerErr); ok { - httpEvent.Response.Write(http.StatusOK, constants.DefaultContentType, fmt.Sprintf(core.ResponseFormat, err.Error())) - return - } - httpEvent.Response.Write(http.StatusInternalServerError, constants.DefaultContentType, fmt.Sprintf(core.ResponseFormat, err.Error())) - conf.GetLogger().Error(ctx, err.Error()) - return - } - if constants.CallbackType(httpEvent.Type) == constants.CallbackTypeChallenge { - httpEvent.Response.Write(http.StatusOK, constants.DefaultContentType, fmt.Sprintf(core.ChallengeResponseFormat, httpEvent.Challenge)) - return - } - httpEvent.Response.Write(http.StatusOK, constants.DefaultContentType, fmt.Sprintf(core.ResponseFormat, "successed")) -} diff --git a/event/core/handlers/header.go b/event/core/handlers/header.go deleted file mode 100644 index 0a2c952f..00000000 --- a/event/core/handlers/header.go +++ /dev/null @@ -1,28 +0,0 @@ -package handlers - -import ( - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Handler interface { - GetEvent() interface{} - Handle(*core.Context, interface{}) error -} - -var appID2Type2EventHandler = map[string]map[string]Handler{} - -func getType2EventHandler(conf *config.Config) (map[string]Handler, bool) { - type2EventHandler, ok := appID2Type2EventHandler[conf.GetAppSettings().AppID] - return type2EventHandler, ok -} - -func SetTypeHandler(conf *config.Config, eventType string, handler Handler) { - appID := conf.GetAppSettings().AppID - type2EventHandler, ok := appID2Type2EventHandler[appID] - if !ok { - type2EventHandler = map[string]Handler{} - appID2Type2EventHandler[appID] = type2EventHandler - } - type2EventHandler[eventType] = handler -} diff --git a/event/core/model/event.go b/event/core/model/event.go deleted file mode 100644 index 4954d54c..00000000 --- a/event/core/model/event.go +++ /dev/null @@ -1,57 +0,0 @@ -package model - -import ( - "github.com/larksuite/oapi-sdk-go/core" -) - -const Version1 = "1.0" -const Version2 = "2.0" - -type HTTPEvent struct { - Request *core.OapiRequest - Input []byte - Response *core.OapiResponse - Schema string - Type string - EventType string - Challenge string - Err error -} - -type BaseEvent struct { - Ts string `json:"ts"` - UUID string `json:"uuid"` - Token string `json:"token"` - Type string `json:"type"` -} - -type BaseEventData struct { - AppID string `json:"app_id"` - Type string `json:"type"` - TenantKey string `json:"tenant_key"` -} - -type Fuzzy struct { - Schema string `json:"schema"` - Token string `json:"token"` - Type string `json:"type"` - Challenge string `json:"challenge"` - Header *Header `json:"header"` - Event *struct { - Type string `json:"type"` - } `json:"event"` -} - -type Header struct { - EventID string `json:"event_id"` - EventType string `json:"event_type"` - AppID string `json:"app_id"` - TenantKey string `json:"tenant_key"` - CreateTime string `json:"create_time"` - Token string `json:"token"` -} - -type BaseEventV2 struct { - Schema string `json:"schema"` - Header *Header `json:"header"` -} diff --git a/event/event.go b/event/event.go deleted file mode 100644 index 2bc42506..00000000 --- a/event/event.go +++ /dev/null @@ -1,54 +0,0 @@ -package event - -import ( - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" - app "github.com/larksuite/oapi-sdk-go/event/app/v1" - "github.com/larksuite/oapi-sdk-go/event/core/handlers" - "github.com/larksuite/oapi-sdk-go/event/core/model" - - "sync" -) - -var once sync.Once - -func SetTypeHandler(conf *config.Config, eventType string, handler handlers.Handler) { - handlers.SetTypeHandler(conf, eventType, handler) -} - -// Deprecated, please use `SetTypeCallback` -func SetTypeHandler2(conf *config.Config, eventType string, callback func(ctx *core.Context, event map[string]interface{}) error) { - SetTypeHandler(conf, eventType, &defaultHandler{callback: callback}) -} - -func SetTypeCallback(conf *config.Config, eventType string, callback func(ctx *core.Context, event map[string]interface{}) error) { - SetTypeHandler(conf, eventType, &defaultHandler{callback: callback}) -} - -type defaultHandler struct { - callback func(ctx *core.Context, event map[string]interface{}) error -} - -func (h *defaultHandler) GetEvent() interface{} { - e := make(map[string]interface{}) - return &e -} - -func (h *defaultHandler) Handle(ctx *core.Context, event interface{}) error { - e := event.(*map[string]interface{}) - return h.callback(ctx, *e) -} - -func Handle(conf *config.Config, request *core.OapiRequest) *core.OapiResponse { - once.Do(func() { - app.SetAppTicketEventHandler(conf) - }) - coreCtx := core.WrapContext(request.Ctx) - coreCtx.Set(config.CtxKeyConfig, conf) - httpEvent := &model.HTTPEvent{ - Request: request, - Response: &core.OapiResponse{}, - } - handlers.Handle(coreCtx, httpEvent) - return httpEvent.Response -} diff --git a/event/http/handler.go b/event/http/handler.go deleted file mode 100644 index 757f3437..00000000 --- a/event/http/handler.go +++ /dev/null @@ -1,23 +0,0 @@ -package http - -import ( - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" - "github.com/larksuite/oapi-sdk-go/event" - "net/http" -) - -func Handle(conf *config.Config, request *http.Request, response http.ResponseWriter) { - req, err := core.ToOapiRequest(request) - if err != nil { - err = core.NewOapiResponseOfErr(err).WriteTo(response) - if err != nil { - conf.GetLogger().Error(req.Ctx, err) - } - return - } - err = event.Handle(conf, req).WriteTo(response) - if err != nil { - conf.GetLogger().Error(req.Ctx, err) - } -} diff --git a/event/http/native/handler.go b/event/http/native/handler.go deleted file mode 100644 index e75d7bd5..00000000 --- a/event/http/native/handler.go +++ /dev/null @@ -1,13 +0,0 @@ -package native - -import ( - "github.com/larksuite/oapi-sdk-go/core/config" - . "github.com/larksuite/oapi-sdk-go/event/http" - "net/http" -) - -func Register(path string, conf *config.Config) { - http.HandleFunc(path, func(writer http.ResponseWriter, request *http.Request) { - Handle(conf, request, writer) - }) -} diff --git a/go.mod b/go.mod deleted file mode 100644 index 2ee3a101..00000000 --- a/go.mod +++ /dev/null @@ -1,9 +0,0 @@ -module github.com/larksuite/oapi-sdk-go - -go 1.13 - -require ( - github.com/gin-gonic/gin v1.6.3 - github.com/go-redis/redis/v8 v8.2.2 - github.com/sirupsen/logrus v1.7.0 -) diff --git a/sample/api/api.go b/sample/api/api.go deleted file mode 100644 index e9978578..00000000 --- a/sample/api/api.go +++ /dev/null @@ -1,161 +0,0 @@ -package main - -import ( - "bytes" - "context" - "encoding/json" - "fmt" - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - "github.com/larksuite/oapi-sdk-go/sample/configs" - "io/ioutil" - "os" -) - -// for redis store and logrus -var conf = configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) - -// var conf = configs.TestConfig("https://open.feishu.cn") -// var conf = configs.TestConfig(core.DomainFeiShu) - -func main() { - //testSendMessage() - //testSendCardMessage() - //testUploadFile() - testDownloadFile() -} - -// send card message -func testSendCardMessage() { - coreCtx := core.WrapContext(context.Background()) - cardContent := "{\"config\":{\"wide_screen_mode\":true},\"i18n_elements\":{\"zh_cn\":[{\"tag\":\"div\",\"text\":{\"tag\":\"lark_md\",\"content\":\"[飞书](https://www.feishu.cn)整合即时沟通、日历、音视频会议、云文档、云盘、工作台等功能于一体,成就组织和个人,更高效、更愉悦。\"}},{\"tag\":\"action\",\"actions\":[{\"tag\":\"button\",\"text\":{\"tag\":\"plain_text\",\"content\":\"主按钮\"},\"type\":\"primary\",\"value\":{\"key\":\"primary\"}},{\"tag\":\"button\",\"text\":{\"tag\":\"plain_text\",\"content\":\"次按钮\"},\"type\":\"default\",\"value\":{\"key\":\"default\"}}]}]}}" - card := map[string]interface{}{} - err := json.Unmarshal([]byte(cardContent), &card) - if err != nil { - panic(err) - } - body := map[string]interface{}{ - "user_id": "77bbc392", - "msg_type": "interactive", - "card": card, - } - ret := make(map[string]interface{}) - req := request.NewRequestWithNative("/open-apis/message/v4/send", "POST", - request.AccessTokenTypeTenant, body, &ret, - //应用市场应用 request.SetTenantKey("TenantKey"), - ) - err = api.Send(coreCtx, conf, req) - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(coreCtx.GetHTTPStatusCode()) - if err != nil { - fmt.Println(tools.Prettify(err)) - e := err.(*response.Error) - fmt.Println(e.Code) - fmt.Println(e.Msg) - return - } - fmt.Println(tools.Prettify(ret)) -} - -// send message -func testSendMessage() { - coreCtx := core.WrapContext(context.Background()) - body := map[string]interface{}{ - "open_id": "[open_id]", - "msg_type": "text", - "content": map[string]interface{}{ - "text": "test", - }, - } - ret := make(map[string]interface{}) - req := request.NewRequestWithNative("/open-apis/message/v4/send", "POST", - request.AccessTokenTypeTenant, body, &ret, - //应用市场应用 request.SetTenantKey("TenantKey"), - ) - err := api.Send(coreCtx, conf, req) - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(coreCtx.GetHTTPStatusCode()) - if err != nil { - fmt.Println(tools.Prettify(err)) - e := err.(*response.Error) - fmt.Println(e.Code) - fmt.Println(e.Msg) - return - } - fmt.Println(tools.Prettify(ret)) -} - -type UploadImage struct { - ImageKey string `json:"image_key"` -} - -// upload image -func testUploadFile() { - coreCtx := core.WrapContext(context.Background()) - // coreCtx.Set(constants.HTTPHeaderKeyRequestID, "2020122212081301001702714534518-xxxxx") - var formData = request.NewFormData() - formData.AddParam("image_type", "message") - bs, err := ioutil.ReadFile("test.png") - if err != nil { - fmt.Println(err) - return - } - formData.AddFile("image", request.NewFile().SetContent(bs)) - /* - // stream upload, file implement io.Reader - file, err := os.Open("test.png") - if err != nil { - fmt.Println(err) - return - } - formData.AddFile("image", request.NewFile().SetContentStream(file)) - */ - ret := &UploadImage{} - err = api.Send(coreCtx, conf, request.NewRequestWithNative("/open-apis/image/v4/put", "POST", - request.AccessTokenTypeTenant, formData, ret)) - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(coreCtx.GetHTTPStatusCode()) - if err != nil { - fmt.Println(tools.Prettify(err)) - e := err.(*response.Error) - fmt.Println(e.Code) - fmt.Println(e.Msg) - return - } - fmt.Println(tools.Prettify(ret)) -} - -// download image -func testDownloadFile() { - coreCtx := core.WrapContext(context.Background()) - ret := &bytes.Buffer{} - /* - // stream download: ret implement io.Writer - ret, err := os.Create("[file path]") - if err != nil { - fmt.Println(err) - return - } - */ - req := request.NewRequestWithNative("/open-apis/image/v4/get", "GET", - request.AccessTokenTypeTenant, nil, ret, - request.SetQueryParams(map[string]interface{}{"image_key": "img_v2_f6203671-41d6-46ed-adc9-c50aa840330g"}), request.SetResponseStream()) - err := api.Send(coreCtx, conf, req) - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(coreCtx.GetHTTPStatusCode()) - if err != nil { - fmt.Println(tools.Prettify(err)) - e := err.(*response.Error) - fmt.Println(e.Code) - fmt.Println(e.Msg) - return - } - err = ioutil.WriteFile("test_download.png", ret.Bytes(), os.ModePerm) - if err != nil { - fmt.Println(err) - return - } -} diff --git a/sample/api/authen.go b/sample/api/authen.go deleted file mode 100644 index ae008ff3..00000000 --- a/sample/api/authen.go +++ /dev/null @@ -1,85 +0,0 @@ -package main - -import ( - "context" - "fmt" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - "github.com/larksuite/oapi-sdk-go/sample/configs" - authen "github.com/larksuite/oapi-sdk-go/service/authen/v1" -) - -// for redis store and logrus -// configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) -// configs.TestConfig("https://open.feishu.cn") -var authenService = authen.NewService(configs.TestConfig(core.DomainFeiShu)) - -func main() { - testAccessToken() - //testFlushAccessToken() - //testUserInfo() -} - -func testAccessToken() { - ctx := context.Background() - coreCtx := core.WrapContext(ctx) - body := &authen.AuthenAccessTokenReqBody{ - GrantType: "authorization_code", - Code: "476Bsaz9mCDIAOmjIOjD4a", - } - reqCall := authenService.Authens.AccessToken(coreCtx, body) - - result, err := reqCall.Do() - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(coreCtx.GetHTTPStatusCode()) - if err != nil { - fmt.Println(tools.Prettify(err)) - e := err.(*response.Error) - fmt.Println(e.Code) - fmt.Println(e.Msg) - return - } - fmt.Println(tools.Prettify(result)) -} - -func testFlushAccessToken() { - ctx := context.Background() - coreCtx := core.WrapContext(ctx) - body := &authen.AuthenRefreshAccessTokenReqBody{ - GrantType: "refresh_token", - RefreshToken: "[refresh_token]", - } - reqCall := authenService.Authens.RefreshAccessToken(coreCtx, body) - - result, err := reqCall.Do() - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(coreCtx.GetHTTPStatusCode()) - if err != nil { - fmt.Println(tools.Prettify(err)) - e := err.(*response.Error) - fmt.Println(e.Code) - fmt.Println(e.Msg) - return - } - fmt.Println(tools.Prettify(result)) -} - -func testUserInfo() { - ctx := context.Background() - coreCtx := core.WrapContext(ctx) - reqCall := authenService.Authens.UserInfo(coreCtx, request.SetUserAccessToken("[user_access_token]")) - - result, err := reqCall.Do() - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(coreCtx.GetHTTPStatusCode()) - if err != nil { - fmt.Println(tools.Prettify(err)) - e := err.(*response.Error) - fmt.Println(e.Code) - fmt.Println(e.Msg) - return - } - fmt.Println(tools.Prettify(result)) -} diff --git a/sample/api/bot.go b/sample/api/bot.go deleted file mode 100644 index 78ba59e9..00000000 --- a/sample/api/bot.go +++ /dev/null @@ -1,36 +0,0 @@ -package main - -import ( - "context" - "fmt" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - "github.com/larksuite/oapi-sdk-go/sample/configs" - bot "github.com/larksuite/oapi-sdk-go/service/bot/v3" -) - -// for redis store and logrus -// configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) -// configs.TestConfig("https://open.feishu.cn") -var botService = bot.NewService(configs.TestConfig(core.DomainFeiShu)) - -func main() { - testBotGet() -} - -func testBotGet() { - coreCtx := core.WrapContext(context.Background()) - reqCall := botService.Bots.Get(coreCtx) - result, err := reqCall.Do() - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(coreCtx.GetHTTPStatusCode()) - if err != nil { - fmt.Println(tools.Prettify(err)) - e := err.(*response.Error) - fmt.Println(e.Code) - fmt.Println(e.Msg) - return - } - fmt.Println(tools.Prettify(result.Bot)) -} diff --git a/sample/api/calendar.go b/sample/api/calendar.go deleted file mode 100644 index cd0e416d..00000000 --- a/sample/api/calendar.go +++ /dev/null @@ -1,53 +0,0 @@ -package main - -import ( - "context" - "fmt" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - "github.com/larksuite/oapi-sdk-go/sample/configs" - calendar "github.com/larksuite/oapi-sdk-go/service/calendar/v4" -) - -// for redis store and logrus -// configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) -// configs.TestConfig("https://open.feishu.cn") -var calendarService = calendar.NewService(configs.TestConfig(core.DomainFeiShu)) - -func main() { - testCalendarList() -} - -func testCalendarList() { - ctx := context.Background() - coreCtx := core.WrapContext(ctx) - pageToken := "" - syncToken := "" - hasMore := true - count := 0 - for hasMore { - reqCall := calendarService.Calendars.List(coreCtx, - request.SetUserAccessToken("u-xxxxxxxxx")) - reqCall.SetPageSize(50) - reqCall.SetPageToken("") - reqCall.SetSyncToken("") - result, err := reqCall.Do() - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(coreCtx.GetHTTPStatusCode()) - if err != nil { - fmt.Println(tools.Prettify(err)) - e := err.(*response.Error) - fmt.Println(e.Code) - fmt.Println(e.Msg) - return - } - pageToken = result.PageToken - syncToken = result.SyncToken - hasMore = result.HasMore - fmt.Printf("calendar list finish, count = %d, calendars len = %d, pageToken = %s, syncToken = %s \n", - count, len(result.CalendarList), pageToken, syncToken) - } - fmt.Printf("calendar list finish\n") -} diff --git a/sample/api/contact.go b/sample/api/contact.go deleted file mode 100644 index f48c0868..00000000 --- a/sample/api/contact.go +++ /dev/null @@ -1,55 +0,0 @@ -package main - -import ( - "context" - "fmt" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - "github.com/larksuite/oapi-sdk-go/sample/configs" - contact "github.com/larksuite/oapi-sdk-go/service/contact/v3" -) - -// for redis store and logrus -// configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) -// configs.TestConfig("https://open.feishu.cn") -var contactService = contact.NewService(configs.TestConfig(core.DomainFeiShu)) - -func main() { - testUserServiceList() - //testDepartmentServiceList() -} -func testUserServiceList() { - coreCtx := core.WrapContext(context.Background()) - reqCall := contactService.Users.List(coreCtx) - reqCall.SetDepartmentIdType("open_id") - reqCall.SetPageSize(20) - reqCall.SetDepartmentIdType("open_department_id") - reqCall.SetDepartmentId("0") - reqCall.SetUserIdType("open_id") - result, err := reqCall.Do() - fmt.Printf("request_id:%s", coreCtx.GetRequestID()) - fmt.Printf("http status code:%d", coreCtx.GetHTTPStatusCode()) - if err != nil { - e := err.(*response.Error) - fmt.Printf(tools.Prettify(e)) - return - } - fmt.Printf("reault:%s", tools.Prettify(result)) -} - -func testDepartmentServiceList() { - coreCtx := core.WrapContext(context.Background()) - reqCall := contactService.Departments.List(coreCtx) - reqCall.SetDepartmentIdType("open_department_id") - reqCall.SetUserIdType("open_id") - result, err := reqCall.Do() - fmt.Printf("request_id:%s\n", coreCtx.GetRequestID()) - fmt.Printf("http status code:%d", coreCtx.GetHTTPStatusCode()) - if err != nil { - e := err.(*response.Error) - fmt.Printf(tools.Prettify(e)) - return - } - fmt.Printf("reault:%s", tools.Prettify(result)) -} diff --git a/sample/api/drive.go b/sample/api/drive.go deleted file mode 100644 index 9e40a455..00000000 --- a/sample/api/drive.go +++ /dev/null @@ -1,107 +0,0 @@ -package main - -import ( - "bytes" - "context" - "crypto/rand" - "fmt" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - "github.com/larksuite/oapi-sdk-go/sample/configs" - drivev1 "github.com/larksuite/oapi-sdk-go/service/drive/v1" - "hash/adler32" - "io" -) - -// for redis store and logrus -// configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) -// configs.TestConfig("https://open.feishu.cn") -var driveService = drivev1.NewService(configs.TestConfig(core.DomainFeiShu)) - -func main() { - testFileUploadAll() - testMediaBatchGetTmpDownloadURLs() - testFileDownload() -} -func createRandomFileData(size int64) []byte { - randomData := make([]byte, size) - io.ReadFull(rand.Reader, randomData) - return randomData -} - -func testFileUploadAll() { - coreCtx := core.WrapContext(context.Background()) - reqCall := driveService.Files.UploadAll(coreCtx, request.SetUserAccessToken("[user_access_token]")) - - reqCall.SetParentType("explorer") - reqCall.SetParentNode("[folder_token]") - reqCall.SetFileName(fmt.Sprintf("[file_name]")) - reqCall.SetSize(1024) - - fileContent := createRandomFileData(1024) - reqCall.SetChecksum(fmt.Sprintf("%d", adler32.Checksum(fileContent))) - file := request.NewFile() - file.SetContent(fileContent) - reqCall.SetFile(file) - - result, err := reqCall.Do() - fmt.Printf("request_id:%s", coreCtx.GetRequestID()) - fmt.Printf("http status code:%d", coreCtx.GetHTTPStatusCode()) - if err != nil { - e := err.(*response.Error) - fmt.Println(tools.Prettify(e)) - return - } - fmt.Printf("reault:%s", tools.Prettify(result)) - - if len(result.FileToken) == 0 { - fmt.Printf("file token is empty") - return - } - -} - -func testMediaBatchGetTmpDownloadURLs() { - - coreCtx := core.WrapContext(context.Background()) - userAccessTokenOptFn := request.SetUserAccessToken("[user_access_token]") - - reqCall := driveService.Medias.BatchGetTmpDownloadUrl(coreCtx, userAccessTokenOptFn) - reqCall.SetFileTokens([]string{"[file_token]"}...) - - result, err := reqCall.Do() - fmt.Printf("request_id:%s", coreCtx.GetRequestID()) - fmt.Printf("http status code:%d", coreCtx.GetHTTPStatusCode()) - if err != nil { - e := err.(*response.Error) - fmt.Println(tools.Prettify(e)) - return - } - fmt.Printf("reault:%s", tools.Prettify(result)) - - if len(result.TmpDownloadUrls) == 0 { - fmt.Printf("TmpDownloadUrls len invalid") - return - } -} - -func testFileDownload() { - coreCtx := core.WrapContext(context.Background()) - - reqCall := driveService.Files.Download(coreCtx, request.SetUserAccessToken("[user_access_token]")) - - reqCall.SetFileToken("[file_token]") - - fileContent := bytes.NewBuffer(nil) - reqCall.SetResponseStream(fileContent) - _, err := reqCall.Do() - fmt.Printf("request_id:%s", coreCtx.GetRequestID()) - fmt.Printf("http status code:%d", coreCtx.GetHTTPStatusCode()) - if err != nil { - e := err.(*response.Error) - fmt.Printf(tools.Prettify(e)) - return - } -} diff --git a/sample/api/helpdesk.go b/sample/api/helpdesk.go deleted file mode 100644 index e63d3b9f..00000000 --- a/sample/api/helpdesk.go +++ /dev/null @@ -1,52 +0,0 @@ -package main - -import ( - "context" - "fmt" - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" -) - -func main() { - // 应用商店应用的配置 - // AppID、AppSecret: "开发者后台" -> "凭证与基础信息" -> 应用凭证(App ID、App Secret) - // EncryptKey、VerificationToken:"开发者后台" -> "事件订阅" -> 事件订阅(Encrypt Key、Verification Token) - // HelpDeskID、HelpDeskToken:https://open.feishu.cn/document/ukTMukTMukTM/ugDOyYjL4gjM24CO4IjN - // 更多介绍请看:Github->README.zh.md->如何构建应用配置(AppSettings) - appSettings := core.NewInternalAppSettings( - core.SetAppCredentials("AppID", "AppSecret"), // 必需 - core.SetAppEventKey("VerificationToken", "EncryptKey"), // 非必需,订阅事件、消息卡片时必需 - core.SetHelpDeskCredentials("HelpDeskID", "HelpDeskToken")) // 非必需,使用服务台API时必需 - - // 当前访问的是飞书,使用默认的内存存储(app/tenant access token)、默认日志(Error级别) - // 更多介绍请看:Github->README.zh.md->如何构建整体配置(Config) - conf := core.NewConfig(core.DomainFeiShu, appSettings, core.SetLoggerLevel(core.LoggerLevelError)) - // 请求发送消息的结果 - ret := make(map[string]interface{}) - // 构建请求 - req := request.NewRequestWithNative("/open-apis/helpdesk/v1/tickets/6971250929135779860", "GET", - request.AccessTokenTypeTenant, nil, &ret, - request.NeedHelpDeskAuth(), // 服务台 API,需要 HelpDeskAuth - ) - // 请求的上下文 - coreCtx := core.WrapContext(context.Background()) - // 发送请求 - err := api.Send(coreCtx, conf, req) - // 打印请求的RequestID - fmt.Println(coreCtx.GetRequestID()) - // 打印请求的响应状态吗 - fmt.Println(coreCtx.GetHTTPStatusCode()) - // 请求的error处理 - if err != nil { - e := err.(*response.Error) - fmt.Println(e.Code) - fmt.Println(e.Msg) - fmt.Println(tools.Prettify(err)) - return - } - // 打印请求的结果 - fmt.Println(tools.Prettify(ret)) -} diff --git a/sample/api/im.go b/sample/api/im.go deleted file mode 100644 index b0a79b9e..00000000 --- a/sample/api/im.go +++ /dev/null @@ -1,98 +0,0 @@ -package main - -import ( - "bytes" - "context" - "fmt" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - "github.com/larksuite/oapi-sdk-go/sample/configs" - im "github.com/larksuite/oapi-sdk-go/service/im/v1" - "io/ioutil" - "os" -) - -// for redis store and logrus -// configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) -// configs.TestConfig("https://open.feishu.cn") -var imService = im.NewService(configs.TestConfig(core.DomainFeiShu)) - -func main() { - testMessageCreate() - //testFileCreate() - testFileRead() -} - -func testMessageCreate() { - coreCtx := core.WrapContext(context.Background()) - reqCall := imService.Messages.Create(coreCtx, &im.MessageCreateReqBody{ - // ReceiveId: "b1g6b445", - ReceiveId: "ou_a11d2bcc7d852afbcaf37e5b3ad01f7e", - Content: "{\"text\":\"Tom test content\"}", - MsgType: "text", - }) - reqCall.SetReceiveIdType("open_id") - message, err := reqCall.Do() - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(coreCtx.GetHTTPStatusCode()) - if err != nil { - fmt.Println(tools.Prettify(err)) - e := err.(*response.Error) - fmt.Println(e.Code) - fmt.Println(e.Msg) - return - } - fmt.Println(tools.Prettify(message)) -} - -func testFileRead() { - coreCtx := core.WrapContext(context.Background()) - reqCall := imService.Files.Get(coreCtx) - buf := &bytes.Buffer{} - reqCall.SetResponseStream(buf) - reqCall.SetFileKey("file_ec24f8ad-89ea-4bb5-a7e4-c5db35d2925g") - _, err := reqCall.Do() - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(coreCtx.GetHTTPStatusCode()) - fmt.Println(coreCtx.GetHeader()) - if err != nil { - fmt.Println(tools.Prettify(err)) - e := err.(*response.Error) - fmt.Println(e.Code) - fmt.Println(e.Msg) - return - } - err = ioutil.WriteFile("test_download.pdf", buf.Bytes(), os.ModePerm) - if err != nil { - fmt.Println(err) - return - } -} - -func testFileCreate() { - coreCtx := core.WrapContext(context.Background()) - reqCall := imService.Files.Create(coreCtx) - f, err := os.Open("test.pdf") - if err != nil { - fmt.Println(err) - return - } - file := request.NewFile().SetContentStream(f) - // request.NewFile().SetContent([]byte) - reqCall.SetFile(file) - reqCall.SetFileName("test-测试.pdf") - reqCall.SetFileType("pdf") - message, err := reqCall.Do() - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(coreCtx.GetHTTPStatusCode()) - if err != nil { - fmt.Println(tools.Prettify(err)) - e := err.(*response.Error) - fmt.Println(e.Code) - fmt.Println(e.Msg) - return - } - fmt.Println(tools.Prettify(message)) -} diff --git a/sample/api/image.go b/sample/api/image.go deleted file mode 100644 index 7ed9607f..00000000 --- a/sample/api/image.go +++ /dev/null @@ -1,73 +0,0 @@ -package main - -import ( - "context" - "fmt" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - "github.com/larksuite/oapi-sdk-go/sample/configs" - image "github.com/larksuite/oapi-sdk-go/service/image/v4" - "os" -) - -// for redis store and logrus -// configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) -// configs.TestConfig("https://open.feishu.cn") -var imageService = image.NewService(configs.TestConfig(core.DomainFeiShu)) - -func main() { - testUpload() - testDownload() -} - -func testUpload() { - ctx := context.Background() - coreCtx := core.WrapContext(ctx) - reqCall := imageService.Images.Put(coreCtx) - reqCall.SetImageType("message") - f, err := os.Open("test.png") - if err != nil { - fmt.Println(err) - return - } - file := request.NewFile().SetContentStream(f) - // request.NewFile().SetContent([]byte) - reqCall.SetImage(file) - result, err := reqCall.Do() - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(coreCtx.GetHTTPStatusCode()) - if err != nil { - fmt.Println(tools.Prettify(err)) - e := err.(*response.Error) - fmt.Println(e.Code) - fmt.Println(e.Msg) - return - } - fmt.Println(tools.Prettify(result)) -} - -func testDownload() { - f, err := os.Create("test_download.png") - if err != nil { - fmt.Println(err) - return - } - defer f.Close() - ctx := context.Background() - coreCtx := core.WrapContext(ctx) - reqCall := imageService.Images.Get(coreCtx) - reqCall.SetImageKey("img_800c6035-7db8-4844-bc85-01a74d6e5cag") - reqCall.SetResponseStream(f) - _, err = reqCall.Do() - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(coreCtx.GetHTTPStatusCode()) - if err != nil { - fmt.Println(tools.Prettify(err)) - e := err.(*response.Error) - fmt.Println(e.Code) - fmt.Println(e.Msg) - return - } -} diff --git a/sample/api/optical_char_recognition.go b/sample/api/optical_char_recognition.go deleted file mode 100644 index f1899dae..00000000 --- a/sample/api/optical_char_recognition.go +++ /dev/null @@ -1,36 +0,0 @@ -package main - -import ( - "context" - "fmt" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - "github.com/larksuite/oapi-sdk-go/sample/configs" - optical_char_recognition "github.com/larksuite/oapi-sdk-go/service/optical_char_recognition/v1" -) - -// for redis store and logrus -// configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) -// configs.TestConfig("https://open.feishu.cn") -var opticalCharRecognitionService = optical_char_recognition.NewService(configs.TestConfig(core.DomainFeiShu)) - -func main() { - testImageBasicRecognize() -} - -func testImageBasicRecognize() { - coreCtx := core.WrapContext(context.Background()) - reqCall := opticalCharRecognitionService.Images.BasicRecognize(coreCtx, &optical_char_recognition.ImageBasicRecognizeReqBody{ - Image: "base64 image", - }) - result, err := reqCall.Do() - fmt.Printf("request_id:%s\n", coreCtx.GetRequestID()) - fmt.Printf("http status code:%d", coreCtx.GetHTTPStatusCode()) - if err != nil { - e := err.(*response.Error) - fmt.Printf(tools.Prettify(e)) - return - } - fmt.Printf("reault:%s", tools.Prettify(result)) -} diff --git a/sample/api/speech_to_text.go b/sample/api/speech_to_text.go deleted file mode 100644 index 7a6ad0ad..00000000 --- a/sample/api/speech_to_text.go +++ /dev/null @@ -1,44 +0,0 @@ -package main - -import ( - "context" - "fmt" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - "github.com/larksuite/oapi-sdk-go/sample/configs" - speech_to_text "github.com/larksuite/oapi-sdk-go/service/speech_to_text/v1" -) - -// for redis store and logrus -// configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) -// configs.TestConfig("https://open.feishu.cn") -var speechToTextService = speech_to_text.NewService(configs.TestConfig(core.DomainFeiShu)) - -func main() { - testSpeechFileRecognize() -} - -func testSpeechFileRecognize() { - coreCtx := core.WrapContext(context.Background()) - reqCall := speechToTextService.Speechs.FileRecognize(coreCtx, &speech_to_text.SpeechFileRecognizeReqBody{ - Speech: &speech_to_text.Speech{ - Speech: "base64 后的音频内容", - }, - Config: &speech_to_text.FileConfig{ - FileId: "qwe12dd34567890w", - Format: "pcm", - EngineType: "16k_auto", - }, - }) - result, err := reqCall.Do() - fmt.Printf("header:%s\n", coreCtx.GetHeader()) - fmt.Printf("request_id:%s\n", coreCtx.GetRequestID()) - fmt.Printf("http status code:%d", coreCtx.GetHTTPStatusCode()) - if err != nil { - e := err.(*response.Error) - fmt.Printf(tools.Prettify(e)) - return - } - fmt.Printf("reault:%s", tools.Prettify(result)) -} diff --git a/sample/api/translation.go b/sample/api/translation.go deleted file mode 100644 index eb637bb5..00000000 --- a/sample/api/translation.go +++ /dev/null @@ -1,44 +0,0 @@ -package main - -import ( - "context" - "fmt" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - "github.com/larksuite/oapi-sdk-go/sample/configs" - translation "github.com/larksuite/oapi-sdk-go/service/translation/v1" -) - -// for redis store and logrus -// configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) -// configs.TestConfig("https://open.feishu.cn") -var translationService = translation.NewService(configs.TestConfig(core.DomainFeiShu)) - -func main() { - testTextDetect() -} - -func testTextDetect() { - coreCtx := core.WrapContext(context.Background()) - reqCall := translationService.Texts.Translate(coreCtx, &translation.TextTranslateReqBody{ - SourceLanguage: "zh", - Text: "测试", - TargetLanguage: "en", - Glossary: []*translation.Term{ - { - From: "测", - To: "test", - }, - }, - }) - result, err := reqCall.Do() - fmt.Printf("request_id:%s\n", coreCtx.GetRequestID()) - fmt.Printf("http status code:%d", coreCtx.GetHTTPStatusCode()) - if err != nil { - e := err.(*response.Error) - fmt.Printf(tools.Prettify(e)) - return - } - fmt.Printf("reault:%s", tools.Prettify(result)) -} diff --git a/sample/api/vc.go b/sample/api/vc.go deleted file mode 100644 index e0bcbac9..00000000 --- a/sample/api/vc.go +++ /dev/null @@ -1,55 +0,0 @@ -package main - -import ( - "context" - "fmt" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - "github.com/larksuite/oapi-sdk-go/sample/configs" - vc "github.com/larksuite/oapi-sdk-go/service/vc/v1" -) - -// for redis store and logrus -// configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) -// configs.TestConfig("https://open.feishu.cn") -var VCService = vc.NewService(configs.TestConfig(core.DomainFeiShu)) - -func main() { - testReserveApply() -} - -func testReserveApply() { - ctx := context.Background() - coreCtx := core.WrapContext(ctx) - body := &vc.ReserveApplyReqBody{ - EndTime: 1617161325, - MeetingSettings: &vc.ReserveMeetingSetting{ - Topic: "Test VC", - ActionPermissions: []*vc.ReserveActionPermission{{ - Permission: 1, - PermissionCheckers: []*vc.ReservePermissionChecker{{ - CheckField: 1, - CheckMode: 1, - CheckList: []string{"77bbc392"}, - }, - }, - }, - }, - }, - } - reqCall := VCService.Reserves.Apply(coreCtx, body, request.SetUserAccessToken("User access token")) - reqCall.SetUserIdType("user_id") - result, err := reqCall.Do() - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(coreCtx.GetHTTPStatusCode()) - if err != nil { - fmt.Println(tools.Prettify(err)) - e := err.(*response.Error) - fmt.Println(e.Code) - fmt.Println(e.Msg) - return - } - fmt.Println(tools.Prettify(result)) -} diff --git a/sample/card/gin.go b/sample/card/gin.go deleted file mode 100644 index f3ff7a40..00000000 --- a/sample/card/gin.go +++ /dev/null @@ -1,35 +0,0 @@ -package main - -import ( - "fmt" - "github.com/gin-gonic/gin" - "github.com/larksuite/oapi-sdk-go/card" - cardhttp "github.com/larksuite/oapi-sdk-go/card/http" - "github.com/larksuite/oapi-sdk-go/card/model" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - "github.com/larksuite/oapi-sdk-go/sample/configs" -) - -func main() { - - // for redis store and logrus - // var conf = configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) - // var conf = configs.TestConfig("https://open.feishu.cn") - var conf = configs.TestConfig(core.DomainFeiShu) - - card.SetHandler(conf, func(coreCtx *core.Context, card *model.Card) (interface{}, error) { - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(tools.Prettify(card.Action)) - return nil, nil - }) - - g := gin.Default() - g.POST("/webhook/card", func(context *gin.Context) { - cardhttp.Handle(conf, context.Request, context.Writer) - }) - err := g.Run(":8089") - if err != nil { - panic(err) - } -} diff --git a/sample/card/go.go b/sample/card/go.go deleted file mode 100644 index df81b5b8..00000000 --- a/sample/card/go.go +++ /dev/null @@ -1,42 +0,0 @@ -package main - -import ( - "context" - "fmt" - "github.com/larksuite/oapi-sdk-go/card" - "github.com/larksuite/oapi-sdk-go/card/model" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - "github.com/larksuite/oapi-sdk-go/sample/configs" -) - -func main() { - // for redis store and logrus - // var conf = configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) - // var conf = configs.TestConfig("https://open.feishu.cn") - var conf = configs.TestConfig(core.DomainFeiShu) - - card.SetHandler(conf, func(coreCtx *core.Context, card *model.Card) (interface{}, error) { - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(tools.Prettify(card.Action)) - return nil, nil - }) - - header := make(map[string][]string) - // from http request header - // and "X-Lark-Request-Timestamp"/"X-Lark-Request-Nonce"/"X-Lark-Signature" validate request, Required! - - // header["X-Request-Id"] = []string{"63278309j-yuewuyeu-7828389"} - // header["X-Lark-Request-Timestamp"] = []string{"Monday, 09-Nov-20 23:33:53 CST"} - // header["X-Lark-Request-Nonce"] = []string{"0404f57f-102e-4c91-bb32-a501ad0b7600"} - // header["X-Lark-Signature"] = []string{"26cb59f4f5a91c4147d0xxxxxxxxxc4a36fb2c"} - // header["X-Refresh-Token"] = []string{"acc4d5f2-4bc6-4394-a9d4-45e168fcde97"} - - req := &core.OapiRequest{ - Ctx: context.Background(), - Header: core.NewOapiHeader(header), - Body: "", // from http request body - } - resp := card.Handle(conf, req) - fmt.Println(tools.Prettify(resp)) -} diff --git a/sample/card/http_server.go b/sample/card/http_server.go deleted file mode 100644 index cb8e080f..00000000 --- a/sample/card/http_server.go +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "fmt" - "github.com/larksuite/oapi-sdk-go/card" - cardhttpserver "github.com/larksuite/oapi-sdk-go/card/http/native" - "github.com/larksuite/oapi-sdk-go/card/model" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - "github.com/larksuite/oapi-sdk-go/sample/configs" - "net/http" -) - -func main() { - - // for redis store and logrus - // var conf = configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) - // var conf = configs.TestConfig("https://open.feishu.cn") - var conf = configs.TestConfig(core.DomainFeiShu) - - card.SetHandler(conf, func(ctx *core.Context, card *model.Card) (interface{}, error) { - fmt.Println(ctx.GetRequestID()) - fmt.Println(tools.Prettify(card)) - return "{\"config\":{\"wide_screen_mode\":true},\"i18n_elements\":{\"zh_cn\":[{\"tag\":\"div\",\"text\":{\"tag\":\"lark_md\",\"content\":\"[飞书golang](https://www.feishu.cn)整合即时沟通、日历、音视频会议、云文档、云盘、工作台等功能于一体,成就组织和个人,更高效、更愉悦。\"}}]}}", nil - }) - - cardhttpserver.Register("/webhook/card", conf) - err := http.ListenAndServe(":8089", nil) - if err != nil { - panic(err) - } - -} diff --git a/sample/configs/config.go b/sample/configs/config.go deleted file mode 100644 index ddcdb5c3..00000000 --- a/sample/configs/config.go +++ /dev/null @@ -1,19 +0,0 @@ -package configs - -import ( - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -// for Cutome APP(企业自建应用) -var appSettings = core.GetInternalAppSettingsByEnv() - -func TestConfigWithLogrusAndRedisStore(domain core.Domain) *config.Config { - logger := Logrus{} - store := NewRedisStore() - return core.NewConfig(domain, appSettings, core.SetLogger(logger), core.SetLoggerLevel(core.LoggerLevelDebug), core.SetStore(store)) -} - -func TestConfig(domain core.Domain) *config.Config { - return core.NewConfig(domain, appSettings, core.SetLoggerLevel(core.LoggerLevelDebug)) -} diff --git a/sample/event/application.go b/sample/event/application.go deleted file mode 100644 index 68147b47..00000000 --- a/sample/event/application.go +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import ( - "fmt" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - eventhttpserver "github.com/larksuite/oapi-sdk-go/event/http/native" - "github.com/larksuite/oapi-sdk-go/sample/configs" - application "github.com/larksuite/oapi-sdk-go/service/application/v1" - "net/http" -) - -func main() { - - // for redis store and logrus - // var conf = configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) - // var conf = configs.TestConfig("https://open.feishu.cn") - var conf = configs.TestConfig(core.DomainFeiShu) - - application.SetAppOpenEventHandler(conf, func(coreCtx *core.Context, appOpenEvent *application.AppOpenEvent) error { - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(appOpenEvent) - fmt.Println(tools.Prettify(appOpenEvent)) - return nil - }) - - application.SetAppStatusChangeEventHandler(conf, func(coreCtx *core.Context, appStatusChangeEvent *application.AppStatusChangeEvent) error { - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(appStatusChangeEvent.Event.AppId) - fmt.Println(appStatusChangeEvent.Event.Status) - fmt.Println(tools.Prettify(appStatusChangeEvent)) - return nil - }) - - eventhttpserver.Register("/webhook/event", conf) - err := http.ListenAndServe(":8089", nil) - if err != nil { - panic(err) - } - -} diff --git a/sample/event/contact.go b/sample/event/contact.go deleted file mode 100644 index 80652f3d..00000000 --- a/sample/event/contact.go +++ /dev/null @@ -1,47 +0,0 @@ -package main - -import ( - "fmt" - "github.com/gin-gonic/gin" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - eventhttp "github.com/larksuite/oapi-sdk-go/event/http" - "github.com/larksuite/oapi-sdk-go/sample/configs" - contact "github.com/larksuite/oapi-sdk-go/service/contact/v3" -) - -func main() { - - // for redis store and logrus - // var conf = configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) - // var conf = configs.TestConfig("https://open.feishu.cn") - var conf = configs.TestConfig(core.DomainFeiShu) - - contact.SetDepartmentCreatedEventHandler(conf, func(ctx *core.Context, event *contact.DepartmentCreatedEvent) error { - fmt.Println(ctx.GetRequestID()) - fmt.Println(tools.Prettify(event)) - return nil - }) - - contact.SetUserCreatedEventHandler(conf, func(ctx *core.Context, event *contact.UserCreatedEvent) error { - fmt.Println(ctx.GetRequestID()) - fmt.Println(tools.Prettify(event)) - return nil - }) - - contact.SetUserUpdatedEventHandler(conf, func(ctx *core.Context, event *contact.UserUpdatedEvent) error { - fmt.Println(ctx.GetRequestID()) - fmt.Println(tools.Prettify(event)) - return nil - }) - - g := gin.Default() - g.POST("/webhook/event", func(context *gin.Context) { - eventhttp.Handle(conf, context.Request, context.Writer) - }) - err := g.Run(":8089") - if err != nil { - fmt.Println(err) - } - -} diff --git a/sample/event/gin.go b/sample/event/gin.go deleted file mode 100644 index 8caad683..00000000 --- a/sample/event/gin.go +++ /dev/null @@ -1,60 +0,0 @@ -package main - -import ( - "fmt" - "github.com/gin-gonic/gin" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - "github.com/larksuite/oapi-sdk-go/event" - eventhttp "github.com/larksuite/oapi-sdk-go/event/http" - "github.com/larksuite/oapi-sdk-go/sample/configs" - application "github.com/larksuite/oapi-sdk-go/service/application/v1" -) - -// for redis store and logrus -// var conf = configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) -// var conf = configs.TestConfig("https://open.feishu.cn") -var conf = configs.TestConfig(core.DomainFeiShu) - -func main() { - - application.SetAppOpenEventHandler(conf, func(ctx *core.Context, appOpenEvent *application.AppOpenEvent) error { - fmt.Println(ctx.GetRequestID()) - fmt.Println(appOpenEvent) - fmt.Println(tools.Prettify(appOpenEvent)) - return nil - }) - - /* - application.SetAppStatusChangeEventHandler(conf, func(ctx *core.Context, appStatusChangeEvent *application.AppStatusChangeEvent) error { - fmt.Println(ctx.GetRequestID()) - fmt.Println(appStatusChangeEvent.Event.AppId) - fmt.Println(appStatusChangeEvent.Event.Status) - fmt.Println(tools.Prettify(appStatusChangeEvent)) - return nil - }) - */ - event.SetTypeCallback(conf, "app_status_change", func(ctx *core.Context, event map[string]interface{}) error { - fmt.Println(ctx.GetRequestID()) - fmt.Println(tools.Prettify(event)) - data := event["event"].(map[string]interface{}) - fmt.Println(tools.Prettify(data)) - return nil - }) - - application.SetAppUninstalledEventHandler(conf, func(ctx *core.Context, appUninstalledEvent *application.AppUninstalledEvent) error { - fmt.Println(ctx.GetRequestID()) - fmt.Println(tools.Prettify(appUninstalledEvent)) - return nil - }) - - g := gin.Default() - - g.POST("/webhook/event", func(context *gin.Context) { - eventhttp.Handle(conf, context.Request, context.Writer) - }) - err := g.Run(":8089") - if err != nil { - panic(err) - } -} diff --git a/sample/event/go.go b/sample/event/go.go deleted file mode 100644 index 0947c9f0..00000000 --- a/sample/event/go.go +++ /dev/null @@ -1,43 +0,0 @@ -package main - -import ( - "context" - "fmt" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - "github.com/larksuite/oapi-sdk-go/event" - "github.com/larksuite/oapi-sdk-go/sample/configs" - application "github.com/larksuite/oapi-sdk-go/service/application/v1" -) - -func main() { - // for redis store and logrus - // var conf = configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) - // var conf = configs.TestConfig("https://open.feishu.cn") - var conf = configs.TestConfig(core.DomainFeiShu) - - application.SetAppOpenEventHandler(conf, func(coreCtx *core.Context, appOpenEvent *application.AppOpenEvent) error { - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(appOpenEvent) - fmt.Println(tools.Prettify(appOpenEvent)) - return nil - }) - - application.SetAppStatusChangeEventHandler(conf, func(coreCtx *core.Context, appStatusChangeEvent *application.AppStatusChangeEvent) error { - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(appStatusChangeEvent.Event.AppId) - fmt.Println(appStatusChangeEvent.Event.Status) - fmt.Println(tools.Prettify(appStatusChangeEvent)) - return nil - }) - - header := make(map[string][]string) - // from http request header - req := &core.OapiRequest{ - Ctx: context.Background(), - Header: core.NewOapiHeader(header), - Body: "", // from http request body - } - resp := event.Handle(conf, req) - fmt.Println(tools.Prettify(resp)) -} diff --git a/sample/event/http_server.go b/sample/event/http_server.go deleted file mode 100644 index 3d9eb098..00000000 --- a/sample/event/http_server.go +++ /dev/null @@ -1,47 +0,0 @@ -package main - -import ( - "fmt" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - "github.com/larksuite/oapi-sdk-go/event" - eventhttpserver "github.com/larksuite/oapi-sdk-go/event/http/native" - "github.com/larksuite/oapi-sdk-go/sample/configs" - application "github.com/larksuite/oapi-sdk-go/service/application/v1" - "net/http" -) - -func main() { - - // for redis store and logrus - // var conf = configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) - // var conf = configs.TestConfig("https://open.feishu.cn") - var conf = configs.TestConfig(core.DomainFeiShu) - - application.SetAppOpenEventHandler(conf, func(coreCtx *core.Context, appOpenEvent *application.AppOpenEvent) error { - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(appOpenEvent) - fmt.Println(tools.Prettify(appOpenEvent)) - return nil - }) - - application.SetAppStatusChangeEventHandler(conf, func(coreCtx *core.Context, appStatusChangeEvent *application.AppStatusChangeEvent) error { - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(appStatusChangeEvent.Event.AppId) - fmt.Println(appStatusChangeEvent.Event.Status) - fmt.Println(tools.Prettify(appStatusChangeEvent)) - return nil - }) - - event.SetTypeCallback(conf, "user.created_v2", func(coreCtx *core.Context, event map[string]interface{}) error { - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(tools.Prettify(event)) - return nil - }) - eventhttpserver.Register("/webhook/event", conf) - err := http.ListenAndServe(":8089", nil) - if err != nil { - panic(err) - } - -} diff --git a/sample/event/im.go b/sample/event/im.go deleted file mode 100644 index f9dcdc25..00000000 --- a/sample/event/im.go +++ /dev/null @@ -1,35 +0,0 @@ -package main - -import ( - "fmt" - "github.com/gin-gonic/gin" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/tools" - eventhttp "github.com/larksuite/oapi-sdk-go/event/http" - "github.com/larksuite/oapi-sdk-go/sample/configs" - im "github.com/larksuite/oapi-sdk-go/service/im/v1" -) - -func main() { - - // for redis store and logrus - // var conf = configs.TestConfigWithLogrusAndRedisStore(core.DomainFeiShu) - // var conf = configs.TestConfig("https://open.feishu.cn") - var conf = configs.TestConfig(core.DomainFeiShu) - - im.SetMessageReceiveEventHandler(conf, func(ctx *core.Context, event *im.MessageReceiveEvent) error { - fmt.Println(ctx.GetRequestID()) - fmt.Println(tools.Prettify(event)) - return nil - }) - - g := gin.Default() - g.POST("/webhook/event", func(context *gin.Context) { - eventhttp.Handle(conf, context.Request, context.Writer) - }) - err := g.Run(":8089") - if err != nil { - fmt.Println(err) - } - -} diff --git a/sample/tools/file_download.go b/sample/tools/file_download.go deleted file mode 100644 index 6e051803..00000000 --- a/sample/tools/file_download.go +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "context" - "fmt" - "github.com/larksuite/oapi-sdk-go/core/tools" - "io" - "os" -) - -func main() { - f, err := os.Create("test_file_download.png") - if err != nil { - fmt.Println(err) - return - } - readCloser, err := tools.DownloadFileToStream(context.Background(), "https://sf1-ttcdn-tos.pstatp.com/obj/open-platform-opendoc/b7f456f542e8811e82657e577f126bce_WfFUj8sO1i.png") - if err != nil { - fmt.Println(err) - return - } - defer readCloser.Close() - _, err = io.Copy(f, readCloser) - if err != nil { - fmt.Println(err) - return - } -} diff --git a/service/admin/v1/api.go b/service/admin/v1/api.go deleted file mode 100644 index 01a7454f..00000000 --- a/service/admin/v1/api.go +++ /dev/null @@ -1,141 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - AdminDeptStats *AdminDeptStatService - AdminUserStats *AdminUserStatService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.AdminDeptStats = newAdminDeptStatService(s) - s.AdminUserStats = newAdminUserStatService(s) - return s -} - -type AdminDeptStatService struct { - service *Service -} - -func newAdminDeptStatService(service *Service) *AdminDeptStatService { - return &AdminDeptStatService{ - service: service, - } -} - -type AdminUserStatService struct { - service *Service -} - -func newAdminUserStatService(service *Service) *AdminUserStatService { - return &AdminUserStatService{ - service: service, - } -} - -type AdminUserStatListReqCall struct { - ctx *core.Context - adminUserStats *AdminUserStatService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AdminUserStatListReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *AdminUserStatListReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} -func (rc *AdminUserStatListReqCall) SetStartDate(startDate string) { - rc.queryParams["start_date"] = startDate -} -func (rc *AdminUserStatListReqCall) SetEndDate(endDate string) { - rc.queryParams["end_date"] = endDate -} -func (rc *AdminUserStatListReqCall) SetDepartmentId(departmentId string) { - rc.queryParams["department_id"] = departmentId -} -func (rc *AdminUserStatListReqCall) SetUserId(userId string) { - rc.queryParams["user_id"] = userId -} -func (rc *AdminUserStatListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} -func (rc *AdminUserStatListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} - -func (rc *AdminUserStatListReqCall) Do() (*AdminUserStatListResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &AdminUserStatListResult{} - req := request.NewRequest("/open-apis/admin/v1/admin_user_stats", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.adminUserStats.service.conf, req) - return result, err -} - -func (adminUserStats *AdminUserStatService) List(ctx *core.Context, optFns ...request.OptFn) *AdminUserStatListReqCall { - return &AdminUserStatListReqCall{ - ctx: ctx, - adminUserStats: adminUserStats, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AdminDeptStatListReqCall struct { - ctx *core.Context - adminDeptStats *AdminDeptStatService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AdminDeptStatListReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} -func (rc *AdminDeptStatListReqCall) SetStartDate(startDate string) { - rc.queryParams["start_date"] = startDate -} -func (rc *AdminDeptStatListReqCall) SetEndDate(endDate string) { - rc.queryParams["end_date"] = endDate -} -func (rc *AdminDeptStatListReqCall) SetDepartmentId(departmentId string) { - rc.queryParams["department_id"] = departmentId -} -func (rc *AdminDeptStatListReqCall) SetContainsChildDept(containsChildDept bool) { - rc.queryParams["contains_child_dept"] = containsChildDept -} -func (rc *AdminDeptStatListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} -func (rc *AdminDeptStatListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} - -func (rc *AdminDeptStatListReqCall) Do() (*AdminDeptStatListResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &AdminDeptStatListResult{} - req := request.NewRequest("/open-apis/admin/v1/admin_dept_stats", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.adminDeptStats.service.conf, req) - return result, err -} - -func (adminDeptStats *AdminDeptStatService) List(ctx *core.Context, optFns ...request.OptFn) *AdminDeptStatListReqCall { - return &AdminDeptStatListReqCall{ - ctx: ctx, - adminDeptStats: adminDeptStats, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} diff --git a/service/admin/v1/model.go b/service/admin/v1/model.go deleted file mode 100644 index c7aa1a21..00000000 --- a/service/admin/v1/model.go +++ /dev/null @@ -1,305 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" -) - -type AdminDeptStat struct { - Date string `json:"date,omitempty"` - DepartmentId string `json:"department_id,omitempty"` - DepartmentName string `json:"department_name,omitempty"` - DepartmentPath string `json:"department_path,omitempty"` - TotalUserNum int `json:"total_user_num,omitempty"` - ActiveUserNum int `json:"active_user_num,omitempty"` - ActiveUserRate string `json:"active_user_rate,omitempty"` - SuiteDau int `json:"suite_dau,omitempty"` - SuiteActiveRate string `json:"suite_active_rate,omitempty"` - NewUserNum int `json:"new_user_num,omitempty"` - NewActiveNum int `json:"new_active_num,omitempty"` - ResignUserNum int `json:"resign_user_num,omitempty"` - ImDau int `json:"im_dau,omitempty"` - SendMessengerUserNum int `json:"send_messenger_user_num,omitempty"` - SendMessengerNum int `json:"send_messenger_num,omitempty"` - AvgSendMessengerNum string `json:"avg_send_messenger_num,omitempty"` - DocsDau int `json:"docs_dau,omitempty"` - CreateDocsUserNum int `json:"create_docs_user_num,omitempty"` - CreateDocsNum int `json:"create_docs_num,omitempty"` - AvgCreateDocsNum string `json:"avg_create_docs_num,omitempty"` - CalDau int `json:"cal_dau,omitempty"` - CreateCalUserNum int `json:"create_cal_user_num,omitempty"` - CreateCalNum int `json:"create_cal_num,omitempty"` - AvgCreateCalNum string `json:"avg_create_cal_num,omitempty"` - VcDau int `json:"vc_dau,omitempty"` - VcDuration int `json:"vc_duration,omitempty"` - AvgVcDuration string `json:"avg_vc_duration,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AdminDeptStat) MarshalJSON() ([]byte, error) { - type cp AdminDeptStat - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AdminUserStat struct { - Date string `json:"date,omitempty"` - UserId string `json:"user_id,omitempty"` - UserName string `json:"user_name,omitempty"` - DepartmentName string `json:"department_name,omitempty"` - DepartmentPath string `json:"department_path,omitempty"` - CreateTime string `json:"create_time,omitempty"` - UserActiveFlag int `json:"user_active_flag,omitempty"` - RegisterTime string `json:"register_time,omitempty"` - SuiteActiveFlag int `json:"suite_active_flag,omitempty"` - LastActiveTime string `json:"last_active_time,omitempty"` - ImActiveFlag int `json:"im_active_flag,omitempty"` - SendMessengerNum int `json:"send_messenger_num,omitempty"` - DocsActiveFlag int `json:"docs_active_flag,omitempty"` - CreateDocsNum int `json:"create_docs_num,omitempty"` - CalActiveFlag int `json:"cal_active_flag,omitempty"` - CreateCalNum int `json:"create_cal_num,omitempty"` - VcActiveFlag int `json:"vc_active_flag,omitempty"` - VcDuration int `json:"vc_duration,omitempty"` - ActiveOs string `json:"active_os,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AdminUserStat) MarshalJSON() ([]byte, error) { - type cp AdminUserStat - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AuditAndroidContext struct { - Udid string `json:"udid,omitempty"` - Did string `json:"did,omitempty"` - AppVer string `json:"app_ver,omitempty"` - Ver string `json:"ver,omitempty"` - Region string `json:"region,omitempty"` - IdI string `json:"id_i,omitempty"` - IdR string `json:"id_r,omitempty"` - HwBrand string `json:"hw_brand,omitempty"` - HwManuf string `json:"hw_manuf,omitempty"` - Wifip string `json:"wifip,omitempty"` - RouteIip string `json:"route_iip,omitempty"` - RouteGip string `json:"route_gip,omitempty"` - EnvSu string `json:"env_su,omitempty"` - EnvTz string `json:"env_tz,omitempty"` - EnvMl string `json:"env_ml,omitempty"` - Location string `json:"location,omitempty"` - ActiveIp string `json:"active_ip,omitempty"` - ActiveIpDetail string `json:"active_ip_detail,omitempty"` - CellBaseStation string `json:"cell_base_station,omitempty"` - IP string `json:"IP,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AuditAndroidContext) MarshalJSON() ([]byte, error) { - type cp AuditAndroidContext - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AuditContext struct { - TerminalType int `json:"terminal_type,omitempty"` - IosContext *AuditIosContext `json:"ios_context,omitempty"` - PcContext *AuditPcContext `json:"pc_context,omitempty"` - WebContext *AuditWebContext `json:"web_context,omitempty"` - AndroidContext *AuditAndroidContext `json:"android_context,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AuditContext) MarshalJSON() ([]byte, error) { - type cp AuditContext - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AuditEventExtend struct { - CommentType string `json:"comment_type,omitempty"` - AppDetail string `json:"app_detail,omitempty"` - TwoStepValidation bool `json:"two_step_validation,omitempty"` - LoginMethod string `json:"login_method,omitempty"` - NewPeopleNumInVideo int `json:"new_people_num_in_video,omitempty"` - ExternalPeopleNumInVideo int `json:"external_people_num_in_video,omitempty"` - ExternalPeopleNumInChat int `json:"external_people_num_in_chat,omitempty"` - JoinGroup int `json:"join_group,omitempty"` - QuitGroup int `json:"quit_group,omitempty"` - ExternalPeopleNumInDocShare int `json:"external_people_num_in_doc_share,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AuditEventExtend) MarshalJSON() ([]byte, error) { - type cp AuditEventExtend - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AuditInfo struct { - EventId string `json:"event_id,omitempty"` - EventName string `json:"event_name,omitempty"` - DepartmentIds []string `json:"department_ids,omitempty"` - EventModule int `json:"event_module,omitempty"` - OperatorType int `json:"operator_type,omitempty"` - OperatorValue string `json:"operator_value,omitempty"` - Objects []*AuditObjectEntity `json:"objects,omitempty"` - Recipients []*AuditRecipientEntity `json:"recipients,omitempty"` - EventTime int `json:"event_time,omitempty"` - Ip string `json:"ip,omitempty"` - OperatorApp string `json:"operator_app,omitempty"` - AuditContext *AuditContext `json:"audit_context,omitempty"` - Extend *AuditEventExtend `json:"extend,omitempty"` - OperatorAppName string `json:"operator_app_name,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AuditInfo) MarshalJSON() ([]byte, error) { - type cp AuditInfo - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AuditIosContext struct { - Udid string `json:"udid,omitempty"` - Did string `json:"did,omitempty"` - AppVer string `json:"app_ver,omitempty"` - Ver string `json:"ver,omitempty"` - Os string `json:"os,omitempty"` - STZone string `json:"STZone,omitempty"` - ML string `json:"ML,omitempty"` - Sjd string `json:"sjd,omitempty"` - Proxyip string `json:"proxyip,omitempty"` - Wifip string `json:"wifip,omitempty"` - Location string `json:"location,omitempty"` - ActiveIp string `json:"active_ip,omitempty"` - ActiveIpDetail string `json:"active_ip_detail,omitempty"` - CellBaseStation string `json:"cell_base_station,omitempty"` - IP string `json:"IP,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AuditIosContext) MarshalJSON() ([]byte, error) { - type cp AuditIosContext - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AuditObjectDetail struct { - CloneSource string `json:"clone_source,omitempty"` - TextDetail string `json:"text_detail,omitempty"` - FileName string `json:"file_name,omitempty"` - ThirdPartyAppID string `json:"third_party_appID,omitempty"` - ContainFileNum int `json:"contain_file_num,omitempty"` - PermissionSettingType string `json:"permission_setting_type,omitempty"` - PermissionExternalAccessType bool `json:"permission_external_access_Type,omitempty"` - PermissionShareType string `json:"permission_share_type,omitempty"` - FileServiceSource string `json:"file_service_source,omitempty"` - OkrDownloadContent string `json:"okr_download_content,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AuditObjectDetail) MarshalJSON() ([]byte, error) { - type cp AuditObjectDetail - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AuditObjectEntity struct { - ObjectType string `json:"object_type,omitempty"` - ObjectValue string `json:"object_value,omitempty"` - ObjectName string `json:"object_name,omitempty"` - ObjectOwner string `json:"object_owner,omitempty"` - ObjectDetail *AuditObjectDetail `json:"object_detail,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AuditObjectEntity) MarshalJSON() ([]byte, error) { - type cp AuditObjectEntity - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AuditPcContext struct { - Udid string `json:"udid,omitempty"` - Did string `json:"did,omitempty"` - AppVer string `json:"app_ver,omitempty"` - Ver string `json:"ver,omitempty"` - Os string `json:"os,omitempty"` - Wifip string `json:"wifip,omitempty"` - Region string `json:"region,omitempty"` - IP string `json:"IP,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AuditPcContext) MarshalJSON() ([]byte, error) { - type cp AuditPcContext - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AuditRecipientDetail struct { - PermissionActionType string `json:"permission_action_type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AuditRecipientDetail) MarshalJSON() ([]byte, error) { - type cp AuditRecipientDetail - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AuditRecipientEntity struct { - RecipientType string `json:"recipient_type,omitempty"` - RecipientValue string `json:"recipient_value,omitempty"` - RecipientDetail *AuditRecipientDetail `json:"recipient_detail,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AuditRecipientEntity) MarshalJSON() ([]byte, error) { - type cp AuditRecipientEntity - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AuditWebContext struct { - UserAgent string `json:"user_agent,omitempty"` - IP string `json:"IP,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AuditWebContext) MarshalJSON() ([]byte, error) { - type cp AuditWebContext - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SplashPageStat struct { - Date string `json:"date,omitempty"` - SplashId string `json:"splash_id,omitempty"` - ImpressionCount int `json:"impression_count,omitempty"` - ClickCount int `json:"click_count,omitempty"` - SkipCount int `json:"skip_count,omitempty"` - ImpressionCountAccumulate int `json:"impression_count_accumulate,omitempty"` - ClickCountAccumulate int `json:"click_count_accumulate,omitempty"` - SkipCountAccumulate int `json:"skip_count_accumulate,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SplashPageStat) MarshalJSON() ([]byte, error) { - type cp SplashPageStat - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AdminUserStatListResult struct { - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` - Items []*AdminUserStat `json:"items,omitempty"` -} - -type AdminDeptStatListResult struct { - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` - Items []*AdminDeptStat `json:"items,omitempty"` -} diff --git a/service/application/v1/event.go b/service/application/v1/event.go deleted file mode 100644 index 23c562b5..00000000 --- a/service/application/v1/event.go +++ /dev/null @@ -1,72 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" - "github.com/larksuite/oapi-sdk-go/event" -) - -type AppOpenEventHandler struct { - Fn func(*core.Context, *AppOpenEvent) error -} - -func (h *AppOpenEventHandler) GetEvent() interface{} { - return &AppOpenEvent{} -} - -func (h *AppOpenEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*AppOpenEvent)) -} - -func SetAppOpenEventHandler(conf *config.Config, fn func(ctx *core.Context, event *AppOpenEvent) error) { - event.SetTypeHandler(conf, "app_open", &AppOpenEventHandler{Fn: fn}) -} - -type AppStatusChangeEventHandler struct { - Fn func(*core.Context, *AppStatusChangeEvent) error -} - -func (h *AppStatusChangeEventHandler) GetEvent() interface{} { - return &AppStatusChangeEvent{} -} - -func (h *AppStatusChangeEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*AppStatusChangeEvent)) -} - -func SetAppStatusChangeEventHandler(conf *config.Config, fn func(ctx *core.Context, event *AppStatusChangeEvent) error) { - event.SetTypeHandler(conf, "app_status_change", &AppStatusChangeEventHandler{Fn: fn}) -} - -type AppUninstalledEventHandler struct { - Fn func(*core.Context, *AppUninstalledEvent) error -} - -func (h *AppUninstalledEventHandler) GetEvent() interface{} { - return &AppUninstalledEvent{} -} - -func (h *AppUninstalledEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*AppUninstalledEvent)) -} - -func SetAppUninstalledEventHandler(conf *config.Config, fn func(ctx *core.Context, event *AppUninstalledEvent) error) { - event.SetTypeHandler(conf, "app_uninstalled", &AppUninstalledEventHandler{Fn: fn}) -} - -type OrderPaidEventHandler struct { - Fn func(*core.Context, *OrderPaidEvent) error -} - -func (h *OrderPaidEventHandler) GetEvent() interface{} { - return &OrderPaidEvent{} -} - -func (h *OrderPaidEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*OrderPaidEvent)) -} - -func SetOrderPaidEventHandler(conf *config.Config, fn func(ctx *core.Context, event *OrderPaidEvent) error) { - event.SetTypeHandler(conf, "order_paid", &OrderPaidEventHandler{Fn: fn}) -} diff --git a/service/application/v1/model.go b/service/application/v1/model.go deleted file mode 100644 index be447171..00000000 --- a/service/application/v1/model.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/event/core/model" -) - -type UserId struct { - OpenId string `json:"open_id,omitempty"` - UserId string `json:"user_id,omitempty"` -} - -type AppOpenEventData struct { - AppId string `json:"app_id,omitempty"` - TenantKey string `json:"tenant_key,omitempty"` - Type string `json:"type,omitempty"` - Applicants []*UserId `json:"applicants,omitempty"` - Installer *UserId `json:"installer,omitempty"` -} - -type AppOpenEvent struct { - *model.BaseEvent - Event *AppOpenEventData `json:"event"` -} - -type AppStatusChangeEventData struct { - AppId string `json:"app_id,omitempty"` - TenantKey string `json:"tenant_key,omitempty"` - Type string `json:"type,omitempty"` - Status string `json:"status,omitempty"` -} - -type AppStatusChangeEvent struct { - *model.BaseEvent - Event *AppStatusChangeEventData `json:"event"` -} - -type AppUninstalledEventData struct { - AppId string `json:"app_id,omitempty"` - TenantKey string `json:"tenant_key,omitempty"` - Type string `json:"type,omitempty"` -} - -type AppUninstalledEvent struct { - *model.BaseEvent - Event *AppUninstalledEventData `json:"event"` -} - -type OrderPaidEventData struct { - AppId string `json:"app_id,omitempty"` - TenantKey string `json:"tenant_key,omitempty"` - Type string `json:"type,omitempty"` - OrderId string `json:"order_id,omitempty"` - PricePlanId string `json:"price_plan_id,omitempty"` - PricePlanType string `json:"price_plan_type,omitempty"` - Seats int `json:"seats,omitempty"` - BuyCount int `json:"buy_count,omitempty"` - CreateTime string `json:"create_time,omitempty"` - PayTime string `json:"pay_time,omitempty"` - BuyType string `json:"buy_type,omitempty"` - SrcOrderId string `json:"src_order_id,omitempty"` - OrderPayPrice int `json:"order_pay_price,omitempty"` -} - -type OrderPaidEvent struct { - *model.BaseEvent - Event *OrderPaidEventData `json:"event"` -} diff --git a/service/authen/v1/api.go b/service/authen/v1/api.go deleted file mode 100644 index b3711ff9..00000000 --- a/service/authen/v1/api.go +++ /dev/null @@ -1,102 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - Authens *AuthenService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Authens = newAuthenService(s) - return s -} - -type AuthenService struct { - service *Service -} - -func newAuthenService(service *Service) *AuthenService { - return &AuthenService{ - service: service, - } -} - -type AuthenAccessTokenReqCall struct { - ctx *core.Context - authens *AuthenService - body *AuthenAccessTokenReqBody - optFns []request.OptFn -} - -func (rc *AuthenAccessTokenReqCall) Do() (*UserAccessTokenInfo, error) { - var result = &UserAccessTokenInfo{} - req := request.NewRequest("/open-apis/authen/v1/access_token", "POST", - []request.AccessTokenType{request.AccessTokenTypeApp}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.authens.service.conf, req) - return result, err -} - -func (authens *AuthenService) AccessToken(ctx *core.Context, body *AuthenAccessTokenReqBody, optFns ...request.OptFn) *AuthenAccessTokenReqCall { - return &AuthenAccessTokenReqCall{ - ctx: ctx, - authens: authens, - body: body, - optFns: optFns, - } -} - -type AuthenRefreshAccessTokenReqCall struct { - ctx *core.Context - authens *AuthenService - body *AuthenRefreshAccessTokenReqBody - optFns []request.OptFn -} - -func (rc *AuthenRefreshAccessTokenReqCall) Do() (*UserAccessTokenInfo, error) { - var result = &UserAccessTokenInfo{} - req := request.NewRequest("/open-apis/authen/v1/refresh_access_token", "POST", - []request.AccessTokenType{request.AccessTokenTypeApp}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.authens.service.conf, req) - return result, err -} - -func (authens *AuthenService) RefreshAccessToken(ctx *core.Context, body *AuthenRefreshAccessTokenReqBody, optFns ...request.OptFn) *AuthenRefreshAccessTokenReqCall { - return &AuthenRefreshAccessTokenReqCall{ - ctx: ctx, - authens: authens, - body: body, - optFns: optFns, - } -} - -type AuthenUserInfoReqCall struct { - ctx *core.Context - authens *AuthenService - optFns []request.OptFn -} - -func (rc *AuthenUserInfoReqCall) Do() (*UserInfo, error) { - var result = &UserInfo{} - req := request.NewRequest("/open-apis/authen/v1/user_info", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.authens.service.conf, req) - return result, err -} - -func (authens *AuthenService) UserInfo(ctx *core.Context, optFns ...request.OptFn) *AuthenUserInfoReqCall { - return &AuthenUserInfoReqCall{ - ctx: ctx, - authens: authens, - optFns: optFns, - } -} diff --git a/service/authen/v1/model.go b/service/authen/v1/model.go deleted file mode 100644 index 6d49ab03..00000000 --- a/service/authen/v1/model.go +++ /dev/null @@ -1,82 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" -) - -type Authen struct { -} - -type UserAccessTokenInfo struct { - AccessToken string `json:"access_token,omitempty"` - TokenType string `json:"token_type,omitempty"` - ExpiresIn int `json:"expires_in,omitempty"` - Name string `json:"name,omitempty"` - EnName string `json:"en_name,omitempty"` - AvatarUrl string `json:"avatar_url,omitempty"` - AvatarThumb string `json:"avatar_thumb,omitempty"` - AvatarMiddle string `json:"avatar_middle,omitempty"` - AvatarBig string `json:"avatar_big,omitempty"` - OpenId string `json:"open_id,omitempty"` - UnionId string `json:"union_id,omitempty"` - Email string `json:"email,omitempty"` - UserId string `json:"user_id,omitempty"` - Mobile string `json:"mobile,omitempty"` - TenantKey string `json:"tenant_key,omitempty"` - RefreshExpiresIn int `json:"refresh_expires_in,omitempty"` - RefreshToken string `json:"refresh_token,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *UserAccessTokenInfo) MarshalJSON() ([]byte, error) { - type cp UserAccessTokenInfo - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type UserInfo struct { - Name string `json:"name,omitempty"` - EnName string `json:"en_name,omitempty"` - AvatarUrl string `json:"avatar_url,omitempty"` - AvatarThumb string `json:"avatar_thumb,omitempty"` - AvatarMiddle string `json:"avatar_middle,omitempty"` - AvatarBig string `json:"avatar_big,omitempty"` - OpenId string `json:"open_id,omitempty"` - UnionId string `json:"union_id,omitempty"` - Email string `json:"email,omitempty"` - UserId string `json:"user_id,omitempty"` - Mobile string `json:"mobile,omitempty"` - TenantKey string `json:"tenant_key,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *UserInfo) MarshalJSON() ([]byte, error) { - type cp UserInfo - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AuthenAccessTokenReqBody struct { - GrantType string `json:"grant_type,omitempty"` - Code string `json:"code,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AuthenAccessTokenReqBody) MarshalJSON() ([]byte, error) { - type cp AuthenAccessTokenReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AuthenRefreshAccessTokenReqBody struct { - GrantType string `json:"grant_type,omitempty"` - RefreshToken string `json:"refresh_token,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AuthenRefreshAccessTokenReqBody) MarshalJSON() ([]byte, error) { - type cp AuthenRefreshAccessTokenReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} diff --git a/service/bitable/v1/api.go b/service/bitable/v1/api.go deleted file mode 100644 index 03a521f2..00000000 --- a/service/bitable/v1/api.go +++ /dev/null @@ -1,880 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - Apps *AppService - AppTables *AppTableService - AppTableFields *AppTableFieldService - AppTableRecords *AppTableRecordService - AppTableViews *AppTableViewService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Apps = newAppService(s) - s.AppTables = newAppTableService(s) - s.AppTableFields = newAppTableFieldService(s) - s.AppTableRecords = newAppTableRecordService(s) - s.AppTableViews = newAppTableViewService(s) - return s -} - -type AppService struct { - service *Service -} - -func newAppService(service *Service) *AppService { - return &AppService{ - service: service, - } -} - -type AppTableService struct { - service *Service -} - -func newAppTableService(service *Service) *AppTableService { - return &AppTableService{ - service: service, - } -} - -type AppTableFieldService struct { - service *Service -} - -func newAppTableFieldService(service *Service) *AppTableFieldService { - return &AppTableFieldService{ - service: service, - } -} - -type AppTableRecordService struct { - service *Service -} - -func newAppTableRecordService(service *Service) *AppTableRecordService { - return &AppTableRecordService{ - service: service, - } -} - -type AppTableViewService struct { - service *Service -} - -func newAppTableViewService(service *Service) *AppTableViewService { - return &AppTableViewService{ - service: service, - } -} - -type AppTableBatchCreateReqCall struct { - ctx *core.Context - appTables *AppTableService - body *AppTableBatchCreateReqBody - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppTableBatchCreateReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} -func (rc *AppTableBatchCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *AppTableBatchCreateReqCall) Do() (*AppTableBatchCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &AppTableBatchCreateResult{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token/tables/batch_create", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.appTables.service.conf, req) - return result, err -} - -func (appTables *AppTableService) BatchCreate(ctx *core.Context, body *AppTableBatchCreateReqBody, optFns ...request.OptFn) *AppTableBatchCreateReqCall { - return &AppTableBatchCreateReqCall{ - ctx: ctx, - appTables: appTables, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AppTableRecordBatchDeleteReqCall struct { - ctx *core.Context - appTableRecords *AppTableRecordService - body *AppTableRecordBatchDeleteReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppTableRecordBatchDeleteReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} -func (rc *AppTableRecordBatchDeleteReqCall) SetTableId(tableId string) { - rc.pathParams["table_id"] = tableId -} - -func (rc *AppTableRecordBatchDeleteReqCall) Do() (*AppTableRecordBatchDeleteResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &AppTableRecordBatchDeleteResult{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records/batch_delete", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.appTableRecords.service.conf, req) - return result, err -} - -func (appTableRecords *AppTableRecordService) BatchDelete(ctx *core.Context, body *AppTableRecordBatchDeleteReqBody, optFns ...request.OptFn) *AppTableRecordBatchDeleteReqCall { - return &AppTableRecordBatchDeleteReqCall{ - ctx: ctx, - appTableRecords: appTableRecords, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AppTableBatchDeleteReqCall struct { - ctx *core.Context - appTables *AppTableService - body *AppTableBatchDeleteReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppTableBatchDeleteReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} - -func (rc *AppTableBatchDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token/tables/batch_delete", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.appTables.service.conf, req) - return result, err -} - -func (appTables *AppTableService) BatchDelete(ctx *core.Context, body *AppTableBatchDeleteReqBody, optFns ...request.OptFn) *AppTableBatchDeleteReqCall { - return &AppTableBatchDeleteReqCall{ - ctx: ctx, - appTables: appTables, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AppTableRecordBatchUpdateReqCall struct { - ctx *core.Context - appTableRecords *AppTableRecordService - body *AppTableRecordBatchUpdateReqBody - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppTableRecordBatchUpdateReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} -func (rc *AppTableRecordBatchUpdateReqCall) SetTableId(tableId string) { - rc.pathParams["table_id"] = tableId -} -func (rc *AppTableRecordBatchUpdateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *AppTableRecordBatchUpdateReqCall) Do() (*AppTableRecordBatchUpdateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &AppTableRecordBatchUpdateResult{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records/batch_update", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.appTableRecords.service.conf, req) - return result, err -} - -func (appTableRecords *AppTableRecordService) BatchUpdate(ctx *core.Context, body *AppTableRecordBatchUpdateReqBody, optFns ...request.OptFn) *AppTableRecordBatchUpdateReqCall { - return &AppTableRecordBatchUpdateReqCall{ - ctx: ctx, - appTableRecords: appTableRecords, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AppTableFieldCreateReqCall struct { - ctx *core.Context - appTableFields *AppTableFieldService - body *AppTableField - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppTableFieldCreateReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} -func (rc *AppTableFieldCreateReqCall) SetTableId(tableId string) { - rc.pathParams["table_id"] = tableId -} -func (rc *AppTableFieldCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *AppTableFieldCreateReqCall) Do() (*AppTableFieldCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &AppTableFieldCreateResult{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token/tables/:table_id/fields", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.appTableFields.service.conf, req) - return result, err -} - -func (appTableFields *AppTableFieldService) Create(ctx *core.Context, body *AppTableField, optFns ...request.OptFn) *AppTableFieldCreateReqCall { - return &AppTableFieldCreateReqCall{ - ctx: ctx, - appTableFields: appTableFields, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AppTableRecordBatchCreateReqCall struct { - ctx *core.Context - appTableRecords *AppTableRecordService - body *AppTableRecordBatchCreateReqBody - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppTableRecordBatchCreateReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} -func (rc *AppTableRecordBatchCreateReqCall) SetTableId(tableId string) { - rc.pathParams["table_id"] = tableId -} -func (rc *AppTableRecordBatchCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *AppTableRecordBatchCreateReqCall) Do() (*AppTableRecordBatchCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &AppTableRecordBatchCreateResult{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records/batch_create", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.appTableRecords.service.conf, req) - return result, err -} - -func (appTableRecords *AppTableRecordService) BatchCreate(ctx *core.Context, body *AppTableRecordBatchCreateReqBody, optFns ...request.OptFn) *AppTableRecordBatchCreateReqCall { - return &AppTableRecordBatchCreateReqCall{ - ctx: ctx, - appTableRecords: appTableRecords, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AppTableRecordCreateReqCall struct { - ctx *core.Context - appTableRecords *AppTableRecordService - body *AppTableRecord - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppTableRecordCreateReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} -func (rc *AppTableRecordCreateReqCall) SetTableId(tableId string) { - rc.pathParams["table_id"] = tableId -} -func (rc *AppTableRecordCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *AppTableRecordCreateReqCall) Do() (*AppTableRecordCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &AppTableRecordCreateResult{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.appTableRecords.service.conf, req) - return result, err -} - -func (appTableRecords *AppTableRecordService) Create(ctx *core.Context, body *AppTableRecord, optFns ...request.OptFn) *AppTableRecordCreateReqCall { - return &AppTableRecordCreateReqCall{ - ctx: ctx, - appTableRecords: appTableRecords, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AppTableCreateReqCall struct { - ctx *core.Context - appTables *AppTableService - body *AppTableCreateReqBody - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppTableCreateReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} -func (rc *AppTableCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *AppTableCreateReqCall) Do() (*AppTableCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &AppTableCreateResult{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token/tables", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.appTables.service.conf, req) - return result, err -} - -func (appTables *AppTableService) Create(ctx *core.Context, body *AppTableCreateReqBody, optFns ...request.OptFn) *AppTableCreateReqCall { - return &AppTableCreateReqCall{ - ctx: ctx, - appTables: appTables, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AppTableDeleteReqCall struct { - ctx *core.Context - appTables *AppTableService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppTableDeleteReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} -func (rc *AppTableDeleteReqCall) SetTableId(tableId string) { - rc.pathParams["table_id"] = tableId -} - -func (rc *AppTableDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token/tables/:table_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.appTables.service.conf, req) - return result, err -} - -func (appTables *AppTableService) Delete(ctx *core.Context, optFns ...request.OptFn) *AppTableDeleteReqCall { - return &AppTableDeleteReqCall{ - ctx: ctx, - appTables: appTables, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AppTableFieldDeleteReqCall struct { - ctx *core.Context - appTableFields *AppTableFieldService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppTableFieldDeleteReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} -func (rc *AppTableFieldDeleteReqCall) SetTableId(tableId string) { - rc.pathParams["table_id"] = tableId -} -func (rc *AppTableFieldDeleteReqCall) SetFieldId(fieldId string) { - rc.pathParams["field_id"] = fieldId -} - -func (rc *AppTableFieldDeleteReqCall) Do() (*AppTableFieldDeleteResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &AppTableFieldDeleteResult{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token/tables/:table_id/fields/:field_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.appTableFields.service.conf, req) - return result, err -} - -func (appTableFields *AppTableFieldService) Delete(ctx *core.Context, optFns ...request.OptFn) *AppTableFieldDeleteReqCall { - return &AppTableFieldDeleteReqCall{ - ctx: ctx, - appTableFields: appTableFields, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AppTableRecordDeleteReqCall struct { - ctx *core.Context - appTableRecords *AppTableRecordService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppTableRecordDeleteReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} -func (rc *AppTableRecordDeleteReqCall) SetTableId(tableId string) { - rc.pathParams["table_id"] = tableId -} -func (rc *AppTableRecordDeleteReqCall) SetRecordId(recordId string) { - rc.pathParams["record_id"] = recordId -} - -func (rc *AppTableRecordDeleteReqCall) Do() (*DeleteRecord, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &DeleteRecord{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records/:record_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.appTableRecords.service.conf, req) - return result, err -} - -func (appTableRecords *AppTableRecordService) Delete(ctx *core.Context, optFns ...request.OptFn) *AppTableRecordDeleteReqCall { - return &AppTableRecordDeleteReqCall{ - ctx: ctx, - appTableRecords: appTableRecords, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AppTableRecordGetReqCall struct { - ctx *core.Context - appTableRecords *AppTableRecordService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppTableRecordGetReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} -func (rc *AppTableRecordGetReqCall) SetTableId(tableId string) { - rc.pathParams["table_id"] = tableId -} -func (rc *AppTableRecordGetReqCall) SetRecordId(recordId string) { - rc.pathParams["record_id"] = recordId -} -func (rc *AppTableRecordGetReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *AppTableRecordGetReqCall) Do() (*AppTableRecordGetResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &AppTableRecordGetResult{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records/:record_id", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.appTableRecords.service.conf, req) - return result, err -} - -func (appTableRecords *AppTableRecordService) Get(ctx *core.Context, optFns ...request.OptFn) *AppTableRecordGetReqCall { - return &AppTableRecordGetReqCall{ - ctx: ctx, - appTableRecords: appTableRecords, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AppTableFieldListReqCall struct { - ctx *core.Context - appTableFields *AppTableFieldService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppTableFieldListReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} -func (rc *AppTableFieldListReqCall) SetTableId(tableId string) { - rc.pathParams["table_id"] = tableId -} -func (rc *AppTableFieldListReqCall) SetViewId(viewId string) { - rc.queryParams["view_id"] = viewId -} -func (rc *AppTableFieldListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *AppTableFieldListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *AppTableFieldListReqCall) Do() (*AppTableFieldListResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &AppTableFieldListResult{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token/tables/:table_id/fields", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.appTableFields.service.conf, req) - return result, err -} - -func (appTableFields *AppTableFieldService) List(ctx *core.Context, optFns ...request.OptFn) *AppTableFieldListReqCall { - return &AppTableFieldListReqCall{ - ctx: ctx, - appTableFields: appTableFields, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AppTableRecordListReqCall struct { - ctx *core.Context - appTableRecords *AppTableRecordService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppTableRecordListReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} -func (rc *AppTableRecordListReqCall) SetTableId(tableId string) { - rc.pathParams["table_id"] = tableId -} -func (rc *AppTableRecordListReqCall) SetViewId(viewId string) { - rc.queryParams["view_id"] = viewId -} -func (rc *AppTableRecordListReqCall) SetFilter(filter string) { - rc.queryParams["filter"] = filter -} -func (rc *AppTableRecordListReqCall) SetSort(sort string) { - rc.queryParams["sort"] = sort -} -func (rc *AppTableRecordListReqCall) SetFieldNames(fieldNames string) { - rc.queryParams["field_names"] = fieldNames -} -func (rc *AppTableRecordListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *AppTableRecordListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} -func (rc *AppTableRecordListReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *AppTableRecordListReqCall) Do() (*AppTableRecordListResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &AppTableRecordListResult{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.appTableRecords.service.conf, req) - return result, err -} - -func (appTableRecords *AppTableRecordService) List(ctx *core.Context, optFns ...request.OptFn) *AppTableRecordListReqCall { - return &AppTableRecordListReqCall{ - ctx: ctx, - appTableRecords: appTableRecords, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AppTableListReqCall struct { - ctx *core.Context - appTables *AppTableService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppTableListReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} -func (rc *AppTableListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *AppTableListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *AppTableListReqCall) Do() (*AppTableListResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &AppTableListResult{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token/tables", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.appTables.service.conf, req) - return result, err -} - -func (appTables *AppTableService) List(ctx *core.Context, optFns ...request.OptFn) *AppTableListReqCall { - return &AppTableListReqCall{ - ctx: ctx, - appTables: appTables, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AppTableRecordUpdateReqCall struct { - ctx *core.Context - appTableRecords *AppTableRecordService - body *AppTableRecord - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppTableRecordUpdateReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} -func (rc *AppTableRecordUpdateReqCall) SetTableId(tableId string) { - rc.pathParams["table_id"] = tableId -} -func (rc *AppTableRecordUpdateReqCall) SetRecordId(recordId string) { - rc.pathParams["record_id"] = recordId -} -func (rc *AppTableRecordUpdateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *AppTableRecordUpdateReqCall) Do() (*AppTableRecordUpdateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &AppTableRecordUpdateResult{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records/:record_id", "PUT", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.appTableRecords.service.conf, req) - return result, err -} - -func (appTableRecords *AppTableRecordService) Update(ctx *core.Context, body *AppTableRecord, optFns ...request.OptFn) *AppTableRecordUpdateReqCall { - return &AppTableRecordUpdateReqCall{ - ctx: ctx, - appTableRecords: appTableRecords, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AppTableFieldUpdateReqCall struct { - ctx *core.Context - appTableFields *AppTableFieldService - body *AppTableField - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppTableFieldUpdateReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} -func (rc *AppTableFieldUpdateReqCall) SetTableId(tableId string) { - rc.pathParams["table_id"] = tableId -} -func (rc *AppTableFieldUpdateReqCall) SetFieldId(fieldId string) { - rc.pathParams["field_id"] = fieldId -} - -func (rc *AppTableFieldUpdateReqCall) Do() (*AppTableFieldUpdateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &AppTableFieldUpdateResult{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token/tables/:table_id/fields/:field_id", "PUT", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.appTableFields.service.conf, req) - return result, err -} - -func (appTableFields *AppTableFieldService) Update(ctx *core.Context, body *AppTableField, optFns ...request.OptFn) *AppTableFieldUpdateReqCall { - return &AppTableFieldUpdateReqCall{ - ctx: ctx, - appTableFields: appTableFields, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AppGetReqCall struct { - ctx *core.Context - apps *AppService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppGetReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} - -func (rc *AppGetReqCall) Do() (*AppGetResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &AppGetResult{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.apps.service.conf, req) - return result, err -} - -func (apps *AppService) Get(ctx *core.Context, optFns ...request.OptFn) *AppGetReqCall { - return &AppGetReqCall{ - ctx: ctx, - apps: apps, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AppTableViewCreateReqCall struct { - ctx *core.Context - appTableViews *AppTableViewService - body *AppTableView - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppTableViewCreateReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} -func (rc *AppTableViewCreateReqCall) SetTableId(tableId string) { - rc.pathParams["table_id"] = tableId -} - -func (rc *AppTableViewCreateReqCall) Do() (*AppTableViewCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &AppTableViewCreateResult{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token/tables/:table_id/views", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.appTableViews.service.conf, req) - return result, err -} - -func (appTableViews *AppTableViewService) Create(ctx *core.Context, body *AppTableView, optFns ...request.OptFn) *AppTableViewCreateReqCall { - return &AppTableViewCreateReqCall{ - ctx: ctx, - appTableViews: appTableViews, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AppTableViewDeleteReqCall struct { - ctx *core.Context - appTableViews *AppTableViewService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppTableViewDeleteReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} -func (rc *AppTableViewDeleteReqCall) SetTableId(tableId string) { - rc.pathParams["table_id"] = tableId -} -func (rc *AppTableViewDeleteReqCall) SetViewId(viewId string) { - rc.pathParams["view_id"] = viewId -} - -func (rc *AppTableViewDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token/tables/:table_id/views/:view_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.appTableViews.service.conf, req) - return result, err -} - -func (appTableViews *AppTableViewService) Delete(ctx *core.Context, optFns ...request.OptFn) *AppTableViewDeleteReqCall { - return &AppTableViewDeleteReqCall{ - ctx: ctx, - appTableViews: appTableViews, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type AppTableViewListReqCall struct { - ctx *core.Context - appTableViews *AppTableViewService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *AppTableViewListReqCall) SetAppToken(appToken string) { - rc.pathParams["app_token"] = appToken -} -func (rc *AppTableViewListReqCall) SetTableId(tableId string) { - rc.pathParams["table_id"] = tableId -} -func (rc *AppTableViewListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} -func (rc *AppTableViewListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} - -func (rc *AppTableViewListReqCall) Do() (*AppTableViewListResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &AppTableViewListResult{} - req := request.NewRequest("/open-apis/bitable/v1/apps/:app_token/tables/:table_id/views", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.appTableViews.service.conf, req) - return result, err -} - -func (appTableViews *AppTableViewService) List(ctx *core.Context, optFns ...request.OptFn) *AppTableViewListReqCall { - return &AppTableViewListReqCall{ - ctx: ctx, - appTableViews: appTableViews, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} diff --git a/service/bitable/v1/model.go b/service/bitable/v1/model.go deleted file mode 100644 index 36b316d9..00000000 --- a/service/bitable/v1/model.go +++ /dev/null @@ -1,313 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" -) - -type App struct { - AppToken string `json:"app_token,omitempty"` - Revision int `json:"revision,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *App) MarshalJSON() ([]byte, error) { - type cp App - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AppTable struct { - TableId string `json:"table_id,omitempty"` - Revision int `json:"revision,omitempty"` - Name string `json:"name,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AppTable) MarshalJSON() ([]byte, error) { - type cp AppTable - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DeleteRecord struct { - Deleted bool `json:"deleted,omitempty"` - RecordId string `json:"record_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DeleteRecord) MarshalJSON() ([]byte, error) { - type cp DeleteRecord - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Person struct { - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - EnName string `json:"en_name,omitempty"` - Email string `json:"email,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Person) MarshalJSON() ([]byte, error) { - type cp Person - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ReqTable struct { - Name string `json:"name,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ReqTable) MarshalJSON() ([]byte, error) { - type cp ReqTable - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AppTableField struct { - FieldId string `json:"field_id,omitempty"` - FieldName string `json:"field_name,omitempty"` - Type int `json:"type,omitempty"` - Property *AppTableFieldProperty `json:"property,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AppTableField) MarshalJSON() ([]byte, error) { - type cp AppTableField - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AppTableFieldProperty struct { - Options []*AppTableFieldPropertyOption `json:"options,omitempty"` - Formatter string `json:"formatter,omitempty"` - DateFormat string `json:"date_format,omitempty"` - TimeFormat string `json:"time_format,omitempty"` - AutoFill bool `json:"auto_fill,omitempty"` - Multiple bool `json:"multiple,omitempty"` - TableId string `json:"table_id,omitempty"` - ViewId string `json:"view_id,omitempty"` - Fields []string `json:"fields,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AppTableFieldProperty) MarshalJSON() ([]byte, error) { - type cp AppTableFieldProperty - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AppTableFieldPropertyOption struct { - Name string `json:"name,omitempty"` - Id string `json:"id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AppTableFieldPropertyOption) MarshalJSON() ([]byte, error) { - type cp AppTableFieldPropertyOption - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AppTableRecord struct { - RecordId string `json:"record_id,omitempty"` - Fields map[string]interface{} `json:"fields,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AppTableRecord) MarshalJSON() ([]byte, error) { - type cp AppTableRecord - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AppTableView struct { - ViewId string `json:"view_id,omitempty"` - ViewName string `json:"view_name,omitempty"` - ViewType string `json:"view_type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AppTableView) MarshalJSON() ([]byte, error) { - type cp AppTableView - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Attachment struct { - FileToken string `json:"file_token,omitempty"` - Name string `json:"name,omitempty"` - Type string `json:"type,omitempty"` - Size int `json:"size,omitempty"` - Url string `json:"url,omitempty"` - TmpUrl string `json:"tmp_url,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Attachment) MarshalJSON() ([]byte, error) { - type cp Attachment - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Url struct { - Text string `json:"text,omitempty"` - Link string `json:"link,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Url) MarshalJSON() ([]byte, error) { - type cp Url - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AppTableBatchCreateReqBody struct { - Tables []*ReqTable `json:"tables,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AppTableBatchCreateReqBody) MarshalJSON() ([]byte, error) { - type cp AppTableBatchCreateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AppTableBatchCreateResult struct { - TableIds []string `json:"table_ids,omitempty"` -} - -type AppTableRecordBatchDeleteReqBody struct { - Records []string `json:"records,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AppTableRecordBatchDeleteReqBody) MarshalJSON() ([]byte, error) { - type cp AppTableRecordBatchDeleteReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AppTableRecordBatchDeleteResult struct { - Records []*DeleteRecord `json:"records,omitempty"` -} - -type AppTableBatchDeleteReqBody struct { - TableIds []string `json:"table_ids,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AppTableBatchDeleteReqBody) MarshalJSON() ([]byte, error) { - type cp AppTableBatchDeleteReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AppTableRecordBatchUpdateReqBody struct { - Records []*AppTableRecord `json:"records,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AppTableRecordBatchUpdateReqBody) MarshalJSON() ([]byte, error) { - type cp AppTableRecordBatchUpdateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AppTableRecordBatchUpdateResult struct { - Records []*AppTableRecord `json:"records,omitempty"` -} - -type AppTableFieldCreateResult struct { - Field *AppTableField `json:"field,omitempty"` -} - -type AppTableRecordBatchCreateReqBody struct { - Records []*AppTableRecord `json:"records,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AppTableRecordBatchCreateReqBody) MarshalJSON() ([]byte, error) { - type cp AppTableRecordBatchCreateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AppTableRecordBatchCreateResult struct { - Records []*AppTableRecord `json:"records,omitempty"` -} - -type AppTableRecordCreateResult struct { - Record *AppTableRecord `json:"record,omitempty"` -} - -type AppTableCreateReqBody struct { - Table *ReqTable `json:"table,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AppTableCreateReqBody) MarshalJSON() ([]byte, error) { - type cp AppTableCreateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AppTableCreateResult struct { - TableId string `json:"table_id,omitempty"` -} - -type AppTableFieldDeleteResult struct { - FieldId string `json:"field_id,omitempty"` - Deleted bool `json:"deleted,omitempty"` -} - -type AppTableRecordGetResult struct { - Record *AppTableRecord `json:"record,omitempty"` -} - -type AppTableFieldListResult struct { - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` - Total int `json:"total,omitempty"` - Items []*AppTableField `json:"items,omitempty"` -} - -type AppTableRecordListResult struct { - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` - Total int `json:"total,omitempty"` - Items []*AppTableRecord `json:"items,omitempty"` -} - -type AppTableListResult struct { - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` - Total int `json:"total,omitempty"` - Items []*AppTable `json:"items,omitempty"` -} - -type AppTableRecordUpdateResult struct { - Record *AppTableRecord `json:"record,omitempty"` -} - -type AppTableFieldUpdateResult struct { - Field *AppTableField `json:"field,omitempty"` -} - -type AppGetResult struct { - App *App `json:"app,omitempty"` -} - -type AppTableViewCreateResult struct { - AppTableView *AppTableView `json:"app.table.view,omitempty"` -} - -type AppTableViewListResult struct { - Items []*AppTableView `json:"items,omitempty"` - PageToken string `json:"page_token,omitempty"` - HasMore bool `json:"has_more,omitempty"` - Total int `json:"total,omitempty"` -} diff --git a/service/bot/v3/api.go b/service/bot/v3/api.go deleted file mode 100644 index 0ec30160..00000000 --- a/service/bot/v3/api.go +++ /dev/null @@ -1,55 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v3 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - Bots *BotService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Bots = newBotService(s) - return s -} - -type BotService struct { - service *Service -} - -func newBotService(service *Service) *BotService { - return &BotService{ - service: service, - } -} - -type BotGetReqCall struct { - ctx *core.Context - bots *BotService - optFns []request.OptFn -} - -func (rc *BotGetReqCall) Do() (*BotGetResult, error) { - var result = &BotGetResult{} - rc.optFns = append(rc.optFns, request.SetNotDataField()) - req := request.NewRequest("bot/v3/info", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.bots.service.conf, req) - return result, err -} - -func (bots *BotService) Get(ctx *core.Context, optFns ...request.OptFn) *BotGetReqCall { - return &BotGetReqCall{ - ctx: ctx, - bots: bots, - optFns: optFns, - } -} diff --git a/service/bot/v3/model.go b/service/bot/v3/model.go deleted file mode 100644 index 0ef162d5..00000000 --- a/service/bot/v3/model.go +++ /dev/null @@ -1,28 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v3 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" -) - -type Bot struct { -} - -type BotInfo struct { - ActivateStatus int `json:"activate_status,omitempty"` - AppName string `json:"app_name,omitempty"` - AvatarUrl string `json:"avatar_url,omitempty"` - IpWhiteList []string `json:"ip_white_list,omitempty"` - OpenId string `json:"open_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *BotInfo) MarshalJSON() ([]byte, error) { - type cp BotInfo - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type BotGetResult struct { - Bot *BotInfo `json:"bot,omitempty"` -} diff --git a/service/calendar/v4/api.go b/service/calendar/v4/api.go deleted file mode 100644 index 1a472f2c..00000000 --- a/service/calendar/v4/api.go +++ /dev/null @@ -1,1046 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v4 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - Calendars *CalendarService - CalendarAcls *CalendarAclService - CalendarEvents *CalendarEventService - CalendarEventAttendees *CalendarEventAttendeeService - CalendarEventAttendeeChatMembers *CalendarEventAttendeeChatMemberService - Freebusys *FreebusyService - Settings *SettingService - TimeoffEvents *TimeoffEventService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Calendars = newCalendarService(s) - s.CalendarAcls = newCalendarAclService(s) - s.CalendarEvents = newCalendarEventService(s) - s.CalendarEventAttendees = newCalendarEventAttendeeService(s) - s.CalendarEventAttendeeChatMembers = newCalendarEventAttendeeChatMemberService(s) - s.Freebusys = newFreebusyService(s) - s.Settings = newSettingService(s) - s.TimeoffEvents = newTimeoffEventService(s) - return s -} - -type CalendarService struct { - service *Service -} - -func newCalendarService(service *Service) *CalendarService { - return &CalendarService{ - service: service, - } -} - -type CalendarAclService struct { - service *Service -} - -func newCalendarAclService(service *Service) *CalendarAclService { - return &CalendarAclService{ - service: service, - } -} - -type CalendarEventService struct { - service *Service -} - -func newCalendarEventService(service *Service) *CalendarEventService { - return &CalendarEventService{ - service: service, - } -} - -type CalendarEventAttendeeService struct { - service *Service -} - -func newCalendarEventAttendeeService(service *Service) *CalendarEventAttendeeService { - return &CalendarEventAttendeeService{ - service: service, - } -} - -type CalendarEventAttendeeChatMemberService struct { - service *Service -} - -func newCalendarEventAttendeeChatMemberService(service *Service) *CalendarEventAttendeeChatMemberService { - return &CalendarEventAttendeeChatMemberService{ - service: service, - } -} - -type FreebusyService struct { - service *Service -} - -func newFreebusyService(service *Service) *FreebusyService { - return &FreebusyService{ - service: service, - } -} - -type SettingService struct { - service *Service -} - -func newSettingService(service *Service) *SettingService { - return &SettingService{ - service: service, - } -} - -type TimeoffEventService struct { - service *Service -} - -func newTimeoffEventService(service *Service) *TimeoffEventService { - return &TimeoffEventService{ - service: service, - } -} - -type CalendarCreateReqCall struct { - ctx *core.Context - calendars *CalendarService - body *Calendar - optFns []request.OptFn -} - -func (rc *CalendarCreateReqCall) Do() (*CalendarCreateResult, error) { - var result = &CalendarCreateResult{} - req := request.NewRequest("/open-apis/calendar/v4/calendars", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendars.service.conf, req) - return result, err -} - -func (calendars *CalendarService) Create(ctx *core.Context, body *Calendar, optFns ...request.OptFn) *CalendarCreateReqCall { - return &CalendarCreateReqCall{ - ctx: ctx, - calendars: calendars, - body: body, - optFns: optFns, - } -} - -type CalendarEventDeleteReqCall struct { - ctx *core.Context - calendarEvents *CalendarEventService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarEventDeleteReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId -} -func (rc *CalendarEventDeleteReqCall) SetEventId(eventId string) { - rc.pathParams["event_id"] = eventId -} -func (rc *CalendarEventDeleteReqCall) SetNeedNotification(needNotification bool) { - rc.queryParams["need_notification"] = needNotification -} - -func (rc *CalendarEventDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/:calendar_id/events/:event_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarEvents.service.conf, req) - return result, err -} - -func (calendarEvents *CalendarEventService) Delete(ctx *core.Context, optFns ...request.OptFn) *CalendarEventDeleteReqCall { - return &CalendarEventDeleteReqCall{ - ctx: ctx, - calendarEvents: calendarEvents, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type CalendarEventGetReqCall struct { - ctx *core.Context - calendarEvents *CalendarEventService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarEventGetReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId -} -func (rc *CalendarEventGetReqCall) SetEventId(eventId string) { - rc.pathParams["event_id"] = eventId -} - -func (rc *CalendarEventGetReqCall) Do() (*CalendarEventGetResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &CalendarEventGetResult{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/:calendar_id/events/:event_id", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarEvents.service.conf, req) - return result, err -} - -func (calendarEvents *CalendarEventService) Get(ctx *core.Context, optFns ...request.OptFn) *CalendarEventGetReqCall { - return &CalendarEventGetReqCall{ - ctx: ctx, - calendarEvents: calendarEvents, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type CalendarPatchReqCall struct { - ctx *core.Context - calendars *CalendarService - body *Calendar - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarPatchReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId -} - -func (rc *CalendarPatchReqCall) Do() (*CalendarPatchResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &CalendarPatchResult{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/:calendar_id", "PATCH", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendars.service.conf, req) - return result, err -} - -func (calendars *CalendarService) Patch(ctx *core.Context, body *Calendar, optFns ...request.OptFn) *CalendarPatchReqCall { - return &CalendarPatchReqCall{ - ctx: ctx, - calendars: calendars, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type CalendarDeleteReqCall struct { - ctx *core.Context - calendars *CalendarService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarDeleteReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId -} - -func (rc *CalendarDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/:calendar_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendars.service.conf, req) - return result, err -} - -func (calendars *CalendarService) Delete(ctx *core.Context, optFns ...request.OptFn) *CalendarDeleteReqCall { - return &CalendarDeleteReqCall{ - ctx: ctx, - calendars: calendars, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type CalendarAclListReqCall struct { - ctx *core.Context - calendarAcls *CalendarAclService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarAclListReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId -} -func (rc *CalendarAclListReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *CalendarAclListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *CalendarAclListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *CalendarAclListReqCall) Do() (*CalendarAclListResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &CalendarAclListResult{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/:calendar_id/acls", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarAcls.service.conf, req) - return result, err -} - -func (calendarAcls *CalendarAclService) List(ctx *core.Context, optFns ...request.OptFn) *CalendarAclListReqCall { - return &CalendarAclListReqCall{ - ctx: ctx, - calendarAcls: calendarAcls, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type CalendarAclDeleteReqCall struct { - ctx *core.Context - calendarAcls *CalendarAclService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarAclDeleteReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId -} -func (rc *CalendarAclDeleteReqCall) SetAclId(aclId string) { - rc.pathParams["acl_id"] = aclId -} - -func (rc *CalendarAclDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/:calendar_id/acls/:acl_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarAcls.service.conf, req) - return result, err -} - -func (calendarAcls *CalendarAclService) Delete(ctx *core.Context, optFns ...request.OptFn) *CalendarAclDeleteReqCall { - return &CalendarAclDeleteReqCall{ - ctx: ctx, - calendarAcls: calendarAcls, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type CalendarAclCreateReqCall struct { - ctx *core.Context - calendarAcls *CalendarAclService - body *CalendarAcl - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarAclCreateReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId -} -func (rc *CalendarAclCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *CalendarAclCreateReqCall) Do() (*CalendarAcl, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &CalendarAcl{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/:calendar_id/acls", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarAcls.service.conf, req) - return result, err -} - -func (calendarAcls *CalendarAclService) Create(ctx *core.Context, body *CalendarAcl, optFns ...request.OptFn) *CalendarAclCreateReqCall { - return &CalendarAclCreateReqCall{ - ctx: ctx, - calendarAcls: calendarAcls, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type CalendarEventCreateReqCall struct { - ctx *core.Context - calendarEvents *CalendarEventService - body *CalendarEvent - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarEventCreateReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId -} - -func (rc *CalendarEventCreateReqCall) Do() (*CalendarEventCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &CalendarEventCreateResult{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/:calendar_id/events", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarEvents.service.conf, req) - return result, err -} - -func (calendarEvents *CalendarEventService) Create(ctx *core.Context, body *CalendarEvent, optFns ...request.OptFn) *CalendarEventCreateReqCall { - return &CalendarEventCreateReqCall{ - ctx: ctx, - calendarEvents: calendarEvents, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type CalendarListReqCall struct { - ctx *core.Context - calendars *CalendarService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} -func (rc *CalendarListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *CalendarListReqCall) SetSyncToken(syncToken string) { - rc.queryParams["sync_token"] = syncToken -} - -func (rc *CalendarListReqCall) Do() (*CalendarListResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &CalendarListResult{} - req := request.NewRequest("/open-apis/calendar/v4/calendars", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendars.service.conf, req) - return result, err -} - -func (calendars *CalendarService) List(ctx *core.Context, optFns ...request.OptFn) *CalendarListReqCall { - return &CalendarListReqCall{ - ctx: ctx, - calendars: calendars, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type CalendarEventAttendeeListReqCall struct { - ctx *core.Context - calendarEventAttendees *CalendarEventAttendeeService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarEventAttendeeListReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId -} -func (rc *CalendarEventAttendeeListReqCall) SetEventId(eventId string) { - rc.pathParams["event_id"] = eventId -} -func (rc *CalendarEventAttendeeListReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *CalendarEventAttendeeListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *CalendarEventAttendeeListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *CalendarEventAttendeeListReqCall) Do() (*CalendarEventAttendeeListResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &CalendarEventAttendeeListResult{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/:calendar_id/events/:event_id/attendees", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarEventAttendees.service.conf, req) - return result, err -} - -func (calendarEventAttendees *CalendarEventAttendeeService) List(ctx *core.Context, optFns ...request.OptFn) *CalendarEventAttendeeListReqCall { - return &CalendarEventAttendeeListReqCall{ - ctx: ctx, - calendarEventAttendees: calendarEventAttendees, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type CalendarEventAttendeeBatchDeleteReqCall struct { - ctx *core.Context - calendarEventAttendees *CalendarEventAttendeeService - body *CalendarEventAttendeeBatchDeleteReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarEventAttendeeBatchDeleteReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId -} -func (rc *CalendarEventAttendeeBatchDeleteReqCall) SetEventId(eventId string) { - rc.pathParams["event_id"] = eventId -} - -func (rc *CalendarEventAttendeeBatchDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/:calendar_id/events/:event_id/attendees/batch_delete", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarEventAttendees.service.conf, req) - return result, err -} - -func (calendarEventAttendees *CalendarEventAttendeeService) BatchDelete(ctx *core.Context, body *CalendarEventAttendeeBatchDeleteReqBody, optFns ...request.OptFn) *CalendarEventAttendeeBatchDeleteReqCall { - return &CalendarEventAttendeeBatchDeleteReqCall{ - ctx: ctx, - calendarEventAttendees: calendarEventAttendees, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type CalendarEventAttendeeCreateReqCall struct { - ctx *core.Context - calendarEventAttendees *CalendarEventAttendeeService - body *CalendarEventAttendeeCreateReqBody - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarEventAttendeeCreateReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId -} -func (rc *CalendarEventAttendeeCreateReqCall) SetEventId(eventId string) { - rc.pathParams["event_id"] = eventId -} -func (rc *CalendarEventAttendeeCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *CalendarEventAttendeeCreateReqCall) Do() (*CalendarEventAttendeeCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &CalendarEventAttendeeCreateResult{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/:calendar_id/events/:event_id/attendees", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarEventAttendees.service.conf, req) - return result, err -} - -func (calendarEventAttendees *CalendarEventAttendeeService) Create(ctx *core.Context, body *CalendarEventAttendeeCreateReqBody, optFns ...request.OptFn) *CalendarEventAttendeeCreateReqCall { - return &CalendarEventAttendeeCreateReqCall{ - ctx: ctx, - calendarEventAttendees: calendarEventAttendees, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type CalendarGetReqCall struct { - ctx *core.Context - calendars *CalendarService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarGetReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId -} - -func (rc *CalendarGetReqCall) Do() (*Calendar, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &Calendar{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/:calendar_id", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendars.service.conf, req) - return result, err -} - -func (calendars *CalendarService) Get(ctx *core.Context, optFns ...request.OptFn) *CalendarGetReqCall { - return &CalendarGetReqCall{ - ctx: ctx, - calendars: calendars, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type CalendarEventListReqCall struct { - ctx *core.Context - calendarEvents *CalendarEventService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarEventListReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId -} -func (rc *CalendarEventListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} -func (rc *CalendarEventListReqCall) SetAnchorTime(anchorTime string) { - rc.queryParams["anchor_time"] = anchorTime -} -func (rc *CalendarEventListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *CalendarEventListReqCall) SetSyncToken(syncToken string) { - rc.queryParams["sync_token"] = syncToken -} - -func (rc *CalendarEventListReqCall) Do() (*CalendarEventListResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &CalendarEventListResult{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/:calendar_id/events", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarEvents.service.conf, req) - return result, err -} - -func (calendarEvents *CalendarEventService) List(ctx *core.Context, optFns ...request.OptFn) *CalendarEventListReqCall { - return &CalendarEventListReqCall{ - ctx: ctx, - calendarEvents: calendarEvents, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type CalendarSearchReqCall struct { - ctx *core.Context - calendars *CalendarService - body *CalendarSearchReqBody - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarSearchReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *CalendarSearchReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *CalendarSearchReqCall) Do() (*CalendarSearchResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &CalendarSearchResult{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/search", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendars.service.conf, req) - return result, err -} - -func (calendars *CalendarService) Search(ctx *core.Context, body *CalendarSearchReqBody, optFns ...request.OptFn) *CalendarSearchReqCall { - return &CalendarSearchReqCall{ - ctx: ctx, - calendars: calendars, - body: body, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type FreebusyListReqCall struct { - ctx *core.Context - freebusys *FreebusyService - body *FreebusyListReqBody - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *FreebusyListReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *FreebusyListReqCall) Do() (*FreebusyListResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &FreebusyListResult{} - req := request.NewRequest("/open-apis/calendar/v4/freebusy/list", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.freebusys.service.conf, req) - return result, err -} - -func (freebusys *FreebusyService) List(ctx *core.Context, body *FreebusyListReqBody, optFns ...request.OptFn) *FreebusyListReqCall { - return &FreebusyListReqCall{ - ctx: ctx, - freebusys: freebusys, - body: body, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type CalendarEventPatchReqCall struct { - ctx *core.Context - calendarEvents *CalendarEventService - body *CalendarEvent - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarEventPatchReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId -} -func (rc *CalendarEventPatchReqCall) SetEventId(eventId string) { - rc.pathParams["event_id"] = eventId -} - -func (rc *CalendarEventPatchReqCall) Do() (*CalendarEventPatchResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &CalendarEventPatchResult{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/:calendar_id/events/:event_id", "PATCH", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarEvents.service.conf, req) - return result, err -} - -func (calendarEvents *CalendarEventService) Patch(ctx *core.Context, body *CalendarEvent, optFns ...request.OptFn) *CalendarEventPatchReqCall { - return &CalendarEventPatchReqCall{ - ctx: ctx, - calendarEvents: calendarEvents, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type TimeoffEventDeleteReqCall struct { - ctx *core.Context - timeoffEvents *TimeoffEventService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *TimeoffEventDeleteReqCall) SetTimeoffEventId(timeoffEventId string) { - rc.pathParams["timeoff_event_id"] = timeoffEventId -} - -func (rc *TimeoffEventDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/calendar/v4/timeoff_events/:timeoff_event_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.timeoffEvents.service.conf, req) - return result, err -} - -func (timeoffEvents *TimeoffEventService) Delete(ctx *core.Context, optFns ...request.OptFn) *TimeoffEventDeleteReqCall { - return &TimeoffEventDeleteReqCall{ - ctx: ctx, - timeoffEvents: timeoffEvents, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type TimeoffEventCreateReqCall struct { - ctx *core.Context - timeoffEvents *TimeoffEventService - body *TimeoffEvent - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *TimeoffEventCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *TimeoffEventCreateReqCall) Do() (*TimeoffEvent, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &TimeoffEvent{} - req := request.NewRequest("/open-apis/calendar/v4/timeoff_events", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.timeoffEvents.service.conf, req) - return result, err -} - -func (timeoffEvents *TimeoffEventService) Create(ctx *core.Context, body *TimeoffEvent, optFns ...request.OptFn) *TimeoffEventCreateReqCall { - return &TimeoffEventCreateReqCall{ - ctx: ctx, - timeoffEvents: timeoffEvents, - body: body, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type CalendarUnsubscribeReqCall struct { - ctx *core.Context - calendars *CalendarService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarUnsubscribeReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId -} - -func (rc *CalendarUnsubscribeReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/:calendar_id/unsubscribe", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendars.service.conf, req) - return result, err -} - -func (calendars *CalendarService) Unsubscribe(ctx *core.Context, optFns ...request.OptFn) *CalendarUnsubscribeReqCall { - return &CalendarUnsubscribeReqCall{ - ctx: ctx, - calendars: calendars, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type CalendarEventSearchReqCall struct { - ctx *core.Context - calendarEvents *CalendarEventService - body *CalendarEventSearchReqBody - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarEventSearchReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId -} -func (rc *CalendarEventSearchReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *CalendarEventSearchReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *CalendarEventSearchReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *CalendarEventSearchReqCall) Do() (*CalendarEventSearchResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &CalendarEventSearchResult{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/:calendar_id/events/search", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarEvents.service.conf, req) - return result, err -} - -func (calendarEvents *CalendarEventService) Search(ctx *core.Context, body *CalendarEventSearchReqBody, optFns ...request.OptFn) *CalendarEventSearchReqCall { - return &CalendarEventSearchReqCall{ - ctx: ctx, - calendarEvents: calendarEvents, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type CalendarSubscribeReqCall struct { - ctx *core.Context - calendars *CalendarService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarSubscribeReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId -} - -func (rc *CalendarSubscribeReqCall) Do() (*CalendarSubscribeResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &CalendarSubscribeResult{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/:calendar_id/subscribe", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendars.service.conf, req) - return result, err -} - -func (calendars *CalendarService) Subscribe(ctx *core.Context, optFns ...request.OptFn) *CalendarSubscribeReqCall { - return &CalendarSubscribeReqCall{ - ctx: ctx, - calendars: calendars, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SettingGenerateCaldavConfReqCall struct { - ctx *core.Context - settings *SettingService - body *SettingGenerateCaldavConfReqBody - optFns []request.OptFn -} - -func (rc *SettingGenerateCaldavConfReqCall) Do() (*SettingGenerateCaldavConfResult, error) { - var result = &SettingGenerateCaldavConfResult{} - req := request.NewRequest("/open-apis/calendar/v4/settings/generate_caldav_conf", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.settings.service.conf, req) - return result, err -} - -func (settings *SettingService) GenerateCaldavConf(ctx *core.Context, body *SettingGenerateCaldavConfReqBody, optFns ...request.OptFn) *SettingGenerateCaldavConfReqCall { - return &SettingGenerateCaldavConfReqCall{ - ctx: ctx, - settings: settings, - body: body, - optFns: optFns, - } -} - -type CalendarEventSubscriptionReqCall struct { - ctx *core.Context - calendarEvents *CalendarEventService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarEventSubscriptionReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId -} - -func (rc *CalendarEventSubscriptionReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/:calendar_id/events/subscription", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarEvents.service.conf, req) - return result, err -} - -func (calendarEvents *CalendarEventService) Subscription(ctx *core.Context, optFns ...request.OptFn) *CalendarEventSubscriptionReqCall { - return &CalendarEventSubscriptionReqCall{ - ctx: ctx, - calendarEvents: calendarEvents, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type CalendarSubscriptionReqCall struct { - ctx *core.Context - calendars *CalendarService - optFns []request.OptFn -} - -func (rc *CalendarSubscriptionReqCall) Do() (*response.NoData, error) { - var result = &response.NoData{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/subscription", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendars.service.conf, req) - return result, err -} - -func (calendars *CalendarService) Subscription(ctx *core.Context, optFns ...request.OptFn) *CalendarSubscriptionReqCall { - return &CalendarSubscriptionReqCall{ - ctx: ctx, - calendars: calendars, - optFns: optFns, - } -} - -type CalendarAclSubscriptionReqCall struct { - ctx *core.Context - calendarAcls *CalendarAclService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarAclSubscriptionReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId -} - -func (rc *CalendarAclSubscriptionReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/:calendar_id/acls/subscription", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarAcls.service.conf, req) - return result, err -} - -func (calendarAcls *CalendarAclService) Subscription(ctx *core.Context, optFns ...request.OptFn) *CalendarAclSubscriptionReqCall { - return &CalendarAclSubscriptionReqCall{ - ctx: ctx, - calendarAcls: calendarAcls, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type CalendarEventAttendeeChatMemberListReqCall struct { - ctx *core.Context - calendarEventAttendeeChatMembers *CalendarEventAttendeeChatMemberService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *CalendarEventAttendeeChatMemberListReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId -} -func (rc *CalendarEventAttendeeChatMemberListReqCall) SetEventId(eventId string) { - rc.pathParams["event_id"] = eventId -} -func (rc *CalendarEventAttendeeChatMemberListReqCall) SetAttendeeId(attendeeId string) { - rc.pathParams["attendee_id"] = attendeeId -} -func (rc *CalendarEventAttendeeChatMemberListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *CalendarEventAttendeeChatMemberListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *CalendarEventAttendeeChatMemberListReqCall) Do() (*CalendarEventAttendeeChatMemberListResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &CalendarEventAttendeeChatMemberListResult{} - req := request.NewRequest("/open-apis/calendar/v4/calendars/:calendar_id/events/:event_id/attendees/:attendee_id/chat_members", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarEventAttendeeChatMembers.service.conf, req) - return result, err -} - -func (calendarEventAttendeeChatMembers *CalendarEventAttendeeChatMemberService) List(ctx *core.Context, optFns ...request.OptFn) *CalendarEventAttendeeChatMemberListReqCall { - return &CalendarEventAttendeeChatMemberListReqCall{ - ctx: ctx, - calendarEventAttendeeChatMembers: calendarEventAttendeeChatMembers, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} diff --git a/service/calendar/v4/event.go b/service/calendar/v4/event.go deleted file mode 100644 index 2075c07d..00000000 --- a/service/calendar/v4/event.go +++ /dev/null @@ -1,72 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v4 - -import ( - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" - "github.com/larksuite/oapi-sdk-go/event" -) - -type CalendarEventChangedEventHandler struct { - Fn func(*core.Context, *CalendarEventChangedEvent) error -} - -func (h *CalendarEventChangedEventHandler) GetEvent() interface{} { - return &CalendarEventChangedEvent{} -} - -func (h *CalendarEventChangedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*CalendarEventChangedEvent)) -} - -func SetCalendarEventChangedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *CalendarEventChangedEvent) error) { - event.SetTypeHandler(conf, "calendar.calendar.event.changed_v4", &CalendarEventChangedEventHandler{Fn: fn}) -} - -type CalendarChangedEventHandler struct { - Fn func(*core.Context, *CalendarChangedEvent) error -} - -func (h *CalendarChangedEventHandler) GetEvent() interface{} { - return &CalendarChangedEvent{} -} - -func (h *CalendarChangedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*CalendarChangedEvent)) -} - -func SetCalendarChangedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *CalendarChangedEvent) error) { - event.SetTypeHandler(conf, "calendar.calendar.changed_v4", &CalendarChangedEventHandler{Fn: fn}) -} - -type CalendarAclCreatedEventHandler struct { - Fn func(*core.Context, *CalendarAclCreatedEvent) error -} - -func (h *CalendarAclCreatedEventHandler) GetEvent() interface{} { - return &CalendarAclCreatedEvent{} -} - -func (h *CalendarAclCreatedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*CalendarAclCreatedEvent)) -} - -func SetCalendarAclCreatedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *CalendarAclCreatedEvent) error) { - event.SetTypeHandler(conf, "calendar.calendar.acl.created_v4", &CalendarAclCreatedEventHandler{Fn: fn}) -} - -type CalendarAclDeletedEventHandler struct { - Fn func(*core.Context, *CalendarAclDeletedEvent) error -} - -func (h *CalendarAclDeletedEventHandler) GetEvent() interface{} { - return &CalendarAclDeletedEvent{} -} - -func (h *CalendarAclDeletedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*CalendarAclDeletedEvent)) -} - -func SetCalendarAclDeletedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *CalendarAclDeletedEvent) error) { - event.SetTypeHandler(conf, "calendar.calendar.acl.deleted_v4", &CalendarAclDeletedEventHandler{Fn: fn}) -} diff --git a/service/calendar/v4/model.go b/service/calendar/v4/model.go deleted file mode 100644 index 8fdbd669..00000000 --- a/service/calendar/v4/model.go +++ /dev/null @@ -1,521 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v4 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" - "github.com/larksuite/oapi-sdk-go/event/core/model" -) - -type UserId struct { - UserId string `json:"user_id,omitempty"` - OpenId string `json:"open_id,omitempty"` - UnionId string `json:"union_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *UserId) MarshalJSON() ([]byte, error) { - type cp UserId - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AclScope struct { - Type string `json:"type,omitempty"` - UserId string `json:"user_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AclScope) MarshalJSON() ([]byte, error) { - type cp AclScope - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AttendeeChatMember struct { - RsvpStatus string `json:"rsvp_status,omitempty"` - IsOptional bool `json:"is_optional,omitempty"` - DisplayName string `json:"display_name,omitempty"` - IsOrganizer bool `json:"is_organizer,omitempty"` - IsExternal bool `json:"is_external,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AttendeeChatMember) MarshalJSON() ([]byte, error) { - type cp AttendeeChatMember - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Calendar struct { - CalendarId string `json:"calendar_id,omitempty"` - Summary string `json:"summary,omitempty"` - Description string `json:"description,omitempty"` - Permissions string `json:"permissions,omitempty"` - Color int `json:"color,omitempty"` - Type string `json:"type,omitempty"` - SummaryAlias string `json:"summary_alias,omitempty"` - IsDeleted bool `json:"is_deleted,omitempty"` - IsThirdParty bool `json:"is_third_party,omitempty"` - Role string `json:"role,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Calendar) MarshalJSON() ([]byte, error) { - type cp Calendar - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type CalendarAcl struct { - AclId string `json:"acl_id,omitempty"` - Role string `json:"role,omitempty"` - Scope *AclScope `json:"scope,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *CalendarAcl) MarshalJSON() ([]byte, error) { - type cp CalendarAcl - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type CalendarEventAttendeeChatMember struct { - RsvpStatus string `json:"rsvp_status,omitempty"` - IsOptional bool `json:"is_optional,omitempty"` - DisplayName string `json:"display_name,omitempty"` - IsOrganizer bool `json:"is_organizer,omitempty"` - IsExternal bool `json:"is_external,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *CalendarEventAttendeeChatMember) MarshalJSON() ([]byte, error) { - type cp CalendarEventAttendeeChatMember - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type EventLocation struct { - Name string `json:"name,omitempty"` - Address string `json:"address,omitempty"` - Latitude float64 `json:"latitude,omitempty"` - Longitude float64 `json:"longitude,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *EventLocation) MarshalJSON() ([]byte, error) { - type cp EventLocation - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type EventSearchFilter struct { - StartTime *TimeInfo `json:"start_time,omitempty"` - EndTime *TimeInfo `json:"end_time,omitempty"` - UserIds []string `json:"user_ids,omitempty"` - RoomIds []string `json:"room_ids,omitempty"` - ChatIds []string `json:"chat_ids,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *EventSearchFilter) MarshalJSON() ([]byte, error) { - type cp EventSearchFilter - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Freebusy struct { - StartTime string `json:"start_time,omitempty"` - EndTime string `json:"end_time,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Freebusy) MarshalJSON() ([]byte, error) { - type cp Freebusy - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Reminder struct { - Minutes int `json:"minutes,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Reminder) MarshalJSON() ([]byte, error) { - type cp Reminder - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Schema struct { - UiName string `json:"ui_name,omitempty"` - UiStatus string `json:"ui_status,omitempty"` - AppLink string `json:"app_link,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Schema) MarshalJSON() ([]byte, error) { - type cp Schema - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Setting struct { -} - -type TimeInfo struct { - Date string `json:"date,omitempty"` - Timestamp string `json:"timestamp,omitempty"` - Timezone string `json:"timezone,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *TimeInfo) MarshalJSON() ([]byte, error) { - type cp TimeInfo - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type TimeoffEvent struct { - TimeoffEventId string `json:"timeoff_event_id,omitempty"` - UserId string `json:"user_id,omitempty"` - Timezone string `json:"timezone,omitempty"` - StartTime string `json:"start_time,omitempty"` - EndTime string `json:"end_time,omitempty"` - Title string `json:"title,omitempty"` - Description string `json:"description,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *TimeoffEvent) MarshalJSON() ([]byte, error) { - type cp TimeoffEvent - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AclScopeEvent struct { - Type string `json:"type,omitempty"` - UserId *UserId `json:"user_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AclScopeEvent) MarshalJSON() ([]byte, error) { - type cp AclScopeEvent - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type CalendarAclEvent struct { - AclId string `json:"acl_id,omitempty"` - Role string `json:"role,omitempty"` - Scope *AclScopeEvent `json:"scope,omitempty"` - UserIdList []*UserId `json:"user_id_list,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *CalendarAclEvent) MarshalJSON() ([]byte, error) { - type cp CalendarAclEvent - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type CalendarAttendeeResourceCustomization struct { - IndexKey string `json:"index_key,omitempty"` - InputContent string `json:"input_content,omitempty"` - Options []*CustomizationOption `json:"options,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *CalendarAttendeeResourceCustomization) MarshalJSON() ([]byte, error) { - type cp CalendarAttendeeResourceCustomization - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type CalendarEvent struct { - EventId string `json:"event_id,omitempty"` - Summary string `json:"summary,omitempty"` - Description string `json:"description,omitempty"` - NeedNotification bool `json:"need_notification,omitempty"` - StartTime *TimeInfo `json:"start_time,omitempty"` - EndTime *TimeInfo `json:"end_time,omitempty"` - Vchat *Vchat `json:"vchat,omitempty"` - Visibility string `json:"visibility,omitempty"` - AttendeeAbility string `json:"attendee_ability,omitempty"` - FreeBusyStatus string `json:"free_busy_status,omitempty"` - Location *EventLocation `json:"location,omitempty"` - Color int `json:"color,omitempty"` - Reminders []*Reminder `json:"reminders,omitempty"` - Recurrence string `json:"recurrence,omitempty"` - Status string `json:"status,omitempty"` - IsException bool `json:"is_exception,omitempty"` - RecurringEventId string `json:"recurring_event_id,omitempty"` - Schemas []*Schema `json:"schemas,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *CalendarEvent) MarshalJSON() ([]byte, error) { - type cp CalendarEvent - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type CalendarEventAttendee struct { - Type string `json:"type,omitempty"` - AttendeeId string `json:"attendee_id,omitempty"` - RsvpStatus string `json:"rsvp_status,omitempty"` - IsOptional bool `json:"is_optional,omitempty"` - IsOrganizer bool `json:"is_organizer,omitempty"` - IsExternal bool `json:"is_external,omitempty"` - DisplayName string `json:"display_name,omitempty"` - ChatMembers []*AttendeeChatMember `json:"chat_members,omitempty"` - UserId string `json:"user_id,omitempty"` - ChatId string `json:"chat_id,omitempty"` - RoomId string `json:"room_id,omitempty"` - ThirdPartyEmail string `json:"third_party_email,omitempty"` - OperateId string `json:"operate_id,omitempty"` - ResourceCustomization []*CalendarAttendeeResourceCustomization `json:"resource_customization,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *CalendarEventAttendee) MarshalJSON() ([]byte, error) { - type cp CalendarEventAttendee - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type CustomizationOption struct { - OptionKey string `json:"option_key,omitempty"` - OthersContent string `json:"others_content,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *CustomizationOption) MarshalJSON() ([]byte, error) { - type cp CustomizationOption - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ExchangeBinding struct { - AdminAccount string `json:"admin_account,omitempty"` - ExchangeAccount string `json:"exchange_account,omitempty"` - UserId string `json:"user_id,omitempty"` - Status string `json:"status,omitempty"` - ExchangeBindingId string `json:"exchange_binding_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ExchangeBinding) MarshalJSON() ([]byte, error) { - type cp ExchangeBinding - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Vchat struct { - VcType string `json:"vc_type,omitempty"` - IconType string `json:"icon_type,omitempty"` - Description string `json:"description,omitempty"` - MeetingUrl string `json:"meeting_url,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Vchat) MarshalJSON() ([]byte, error) { - type cp Vchat - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type CalendarCreateResult struct { - Calendar *Calendar `json:"calendar,omitempty"` -} - -type CalendarEventGetResult struct { - Event *CalendarEvent `json:"event,omitempty"` -} - -type CalendarPatchResult struct { - Calendar *Calendar `json:"calendar,omitempty"` -} - -type CalendarAclListResult struct { - Acls []*CalendarAcl `json:"acls,omitempty"` - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` -} - -type CalendarEventCreateResult struct { - Event *CalendarEvent `json:"event,omitempty"` -} - -type CalendarListResult struct { - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` - SyncToken string `json:"sync_token,omitempty"` - CalendarList []*Calendar `json:"calendar_list,omitempty"` -} - -type CalendarEventAttendeeListResult struct { - Items []*CalendarEventAttendee `json:"items,omitempty"` - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` -} - -type CalendarEventAttendeeBatchDeleteReqBody struct { - AttendeeIds []string `json:"attendee_ids,omitempty"` - NeedNotification bool `json:"need_notification,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *CalendarEventAttendeeBatchDeleteReqBody) MarshalJSON() ([]byte, error) { - type cp CalendarEventAttendeeBatchDeleteReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type CalendarEventAttendeeCreateReqBody struct { - Attendees []*CalendarEventAttendee `json:"attendees,omitempty"` - NeedNotification bool `json:"need_notification,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *CalendarEventAttendeeCreateReqBody) MarshalJSON() ([]byte, error) { - type cp CalendarEventAttendeeCreateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type CalendarEventAttendeeCreateResult struct { - Attendees []*CalendarEventAttendee `json:"attendees,omitempty"` -} - -type CalendarEventListResult struct { - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` - SyncToken string `json:"sync_token,omitempty"` - Items []*CalendarEvent `json:"items,omitempty"` -} - -type CalendarSearchReqBody struct { - Query string `json:"query,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *CalendarSearchReqBody) MarshalJSON() ([]byte, error) { - type cp CalendarSearchReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type CalendarSearchResult struct { - Items []*Calendar `json:"items,omitempty"` - PageToken string `json:"page_token,omitempty"` -} - -type FreebusyListReqBody struct { - TimeMin string `json:"time_min,omitempty"` - TimeMax string `json:"time_max,omitempty"` - UserId string `json:"user_id,omitempty"` - RoomId string `json:"room_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *FreebusyListReqBody) MarshalJSON() ([]byte, error) { - type cp FreebusyListReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type FreebusyListResult struct { - FreebusyList []*Freebusy `json:"freebusy_list,omitempty"` -} - -type CalendarEventPatchResult struct { - Event *CalendarEvent `json:"event,omitempty"` -} - -type CalendarEventSearchReqBody struct { - Query string `json:"query,omitempty"` - Filter *EventSearchFilter `json:"filter,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *CalendarEventSearchReqBody) MarshalJSON() ([]byte, error) { - type cp CalendarEventSearchReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type CalendarEventSearchResult struct { - Items []*CalendarEvent `json:"items,omitempty"` - PageToken string `json:"page_token,omitempty"` -} - -type CalendarSubscribeResult struct { - Calendar *Calendar `json:"calendar,omitempty"` -} - -type SettingGenerateCaldavConfReqBody struct { - DeviceName string `json:"device_name,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SettingGenerateCaldavConfReqBody) MarshalJSON() ([]byte, error) { - type cp SettingGenerateCaldavConfReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SettingGenerateCaldavConfResult struct { - Password string `json:"password,omitempty"` - UserName string `json:"user_name,omitempty"` - ServerAddress string `json:"server_address,omitempty"` - DeviceName string `json:"device_name,omitempty"` -} - -type CalendarEventAttendeeChatMemberListResult struct { - Items []*CalendarEventAttendeeChatMember `json:"items,omitempty"` - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` -} - -type CalendarEventChangedEventData struct { - CalendarId string `json:"calendar_id,omitempty"` - UserIdList []*UserId `json:"user_id_list,omitempty"` -} - -type CalendarEventChangedEvent struct { - *model.BaseEventV2 - Event *CalendarEventChangedEventData `json:"event"` -} - -type CalendarChangedEventData struct { - UserIdList []*UserId `json:"user_id_list,omitempty"` -} - -type CalendarChangedEvent struct { - *model.BaseEventV2 - Event *CalendarChangedEventData `json:"event"` -} - -type CalendarAclCreatedEventData struct { - AclId string `json:"acl_id,omitempty"` - Role string `json:"role,omitempty"` - Scope *AclScopeEvent `json:"scope,omitempty"` - UserIdList []*UserId `json:"user_id_list,omitempty"` -} - -type CalendarAclCreatedEvent struct { - *model.BaseEventV2 - Event *CalendarAclCreatedEventData `json:"event"` -} - -type CalendarAclDeletedEventData struct { - AclId string `json:"acl_id,omitempty"` - Role string `json:"role,omitempty"` - Scope *AclScopeEvent `json:"scope,omitempty"` - UserIdList []*UserId `json:"user_id_list,omitempty"` -} - -type CalendarAclDeletedEvent struct { - *model.BaseEventV2 - Event *CalendarAclDeletedEventData `json:"event"` -} diff --git a/service/contact/v3/api.go b/service/contact/v3/api.go deleted file mode 100644 index 6ebbae7e..00000000 --- a/service/contact/v3/api.go +++ /dev/null @@ -1,641 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v3 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - Users *UserService - UserGroups *UserGroupService - Departments *DepartmentService - Scopes *ScopeService - CustomAttrEvents *CustomAttrEventService - EmployeeTypeEnums *EmployeeTypeEnumService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Users = newUserService(s) - s.UserGroups = newUserGroupService(s) - s.Departments = newDepartmentService(s) - s.Scopes = newScopeService(s) - s.CustomAttrEvents = newCustomAttrEventService(s) - s.EmployeeTypeEnums = newEmployeeTypeEnumService(s) - return s -} - -type UserService struct { - service *Service -} - -func newUserService(service *Service) *UserService { - return &UserService{ - service: service, - } -} - -type UserGroupService struct { - service *Service -} - -func newUserGroupService(service *Service) *UserGroupService { - return &UserGroupService{ - service: service, - } -} - -type DepartmentService struct { - service *Service -} - -func newDepartmentService(service *Service) *DepartmentService { - return &DepartmentService{ - service: service, - } -} - -type ScopeService struct { - service *Service -} - -func newScopeService(service *Service) *ScopeService { - return &ScopeService{ - service: service, - } -} - -type CustomAttrEventService struct { - service *Service -} - -func newCustomAttrEventService(service *Service) *CustomAttrEventService { - return &CustomAttrEventService{ - service: service, - } -} - -type EmployeeTypeEnumService struct { - service *Service -} - -func newEmployeeTypeEnumService(service *Service) *EmployeeTypeEnumService { - return &EmployeeTypeEnumService{ - service: service, - } -} - -type DepartmentGetReqCall struct { - ctx *core.Context - departments *DepartmentService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *DepartmentGetReqCall) SetDepartmentId(departmentId string) { - rc.pathParams["department_id"] = departmentId -} -func (rc *DepartmentGetReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *DepartmentGetReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} - -func (rc *DepartmentGetReqCall) Do() (*DepartmentGetResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &DepartmentGetResult{} - req := request.NewRequest("contact/v3/departments/:department_id", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.departments.service.conf, req) - return result, err -} - -func (departments *DepartmentService) Get(ctx *core.Context, optFns ...request.OptFn) *DepartmentGetReqCall { - return &DepartmentGetReqCall{ - ctx: ctx, - departments: departments, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type UserDeleteReqCall struct { - ctx *core.Context - users *UserService - body *UserDeleteReqBody - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *UserDeleteReqCall) SetUserId(userId string) { - rc.pathParams["user_id"] = userId -} -func (rc *UserDeleteReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *UserDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &response.NoData{} - req := request.NewRequest("contact/v3/users/:user_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.users.service.conf, req) - return result, err -} - -func (users *UserService) Delete(ctx *core.Context, body *UserDeleteReqBody, optFns ...request.OptFn) *UserDeleteReqCall { - return &UserDeleteReqCall{ - ctx: ctx, - users: users, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type DepartmentListReqCall struct { - ctx *core.Context - departments *DepartmentService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *DepartmentListReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *DepartmentListReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} -func (rc *DepartmentListReqCall) SetParentDepartmentId(parentDepartmentId string) { - rc.queryParams["parent_department_id"] = parentDepartmentId -} -func (rc *DepartmentListReqCall) SetFetchChild(fetchChild bool) { - rc.queryParams["fetch_child"] = fetchChild -} -func (rc *DepartmentListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *DepartmentListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *DepartmentListReqCall) Do() (*DepartmentListResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &DepartmentListResult{} - req := request.NewRequest("contact/v3/departments", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.departments.service.conf, req) - return result, err -} - -func (departments *DepartmentService) List(ctx *core.Context, optFns ...request.OptFn) *DepartmentListReqCall { - return &DepartmentListReqCall{ - ctx: ctx, - departments: departments, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type DepartmentPatchReqCall struct { - ctx *core.Context - departments *DepartmentService - body *Department - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *DepartmentPatchReqCall) SetDepartmentId(departmentId string) { - rc.pathParams["department_id"] = departmentId -} -func (rc *DepartmentPatchReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *DepartmentPatchReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} - -func (rc *DepartmentPatchReqCall) Do() (*DepartmentPatchResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &DepartmentPatchResult{} - req := request.NewRequest("contact/v3/departments/:department_id", "PATCH", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.departments.service.conf, req) - return result, err -} - -func (departments *DepartmentService) Patch(ctx *core.Context, body *Department, optFns ...request.OptFn) *DepartmentPatchReqCall { - return &DepartmentPatchReqCall{ - ctx: ctx, - departments: departments, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type UserUpdateReqCall struct { - ctx *core.Context - users *UserService - body *User - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *UserUpdateReqCall) SetUserId(userId string) { - rc.pathParams["user_id"] = userId -} -func (rc *UserUpdateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *UserUpdateReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} - -func (rc *UserUpdateReqCall) Do() (*UserUpdateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &UserUpdateResult{} - req := request.NewRequest("contact/v3/users/:user_id", "PUT", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.users.service.conf, req) - return result, err -} - -func (users *UserService) Update(ctx *core.Context, body *User, optFns ...request.OptFn) *UserUpdateReqCall { - return &UserUpdateReqCall{ - ctx: ctx, - users: users, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type UserCreateReqCall struct { - ctx *core.Context - users *UserService - body *User - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *UserCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *UserCreateReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} -func (rc *UserCreateReqCall) SetClientToken(clientToken string) { - rc.queryParams["client_token"] = clientToken -} - -func (rc *UserCreateReqCall) Do() (*UserCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &UserCreateResult{} - req := request.NewRequest("contact/v3/users", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.users.service.conf, req) - return result, err -} - -func (users *UserService) Create(ctx *core.Context, body *User, optFns ...request.OptFn) *UserCreateReqCall { - return &UserCreateReqCall{ - ctx: ctx, - users: users, - body: body, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type UserPatchReqCall struct { - ctx *core.Context - users *UserService - body *User - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *UserPatchReqCall) SetUserId(userId string) { - rc.pathParams["user_id"] = userId -} -func (rc *UserPatchReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *UserPatchReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} - -func (rc *UserPatchReqCall) Do() (*UserPatchResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &UserPatchResult{} - req := request.NewRequest("contact/v3/users/:user_id", "PATCH", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.users.service.conf, req) - return result, err -} - -func (users *UserService) Patch(ctx *core.Context, body *User, optFns ...request.OptFn) *UserPatchReqCall { - return &UserPatchReqCall{ - ctx: ctx, - users: users, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type DepartmentCreateReqCall struct { - ctx *core.Context - departments *DepartmentService - body *Department - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *DepartmentCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *DepartmentCreateReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} -func (rc *DepartmentCreateReqCall) SetClientToken(clientToken string) { - rc.queryParams["client_token"] = clientToken -} - -func (rc *DepartmentCreateReqCall) Do() (*DepartmentCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &DepartmentCreateResult{} - req := request.NewRequest("contact/v3/departments", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.departments.service.conf, req) - return result, err -} - -func (departments *DepartmentService) Create(ctx *core.Context, body *Department, optFns ...request.OptFn) *DepartmentCreateReqCall { - return &DepartmentCreateReqCall{ - ctx: ctx, - departments: departments, - body: body, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type DepartmentDeleteReqCall struct { - ctx *core.Context - departments *DepartmentService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *DepartmentDeleteReqCall) SetDepartmentId(departmentId string) { - rc.pathParams["department_id"] = departmentId -} -func (rc *DepartmentDeleteReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} - -func (rc *DepartmentDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &response.NoData{} - req := request.NewRequest("contact/v3/departments/:department_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.departments.service.conf, req) - return result, err -} - -func (departments *DepartmentService) Delete(ctx *core.Context, optFns ...request.OptFn) *DepartmentDeleteReqCall { - return &DepartmentDeleteReqCall{ - ctx: ctx, - departments: departments, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type UserGetReqCall struct { - ctx *core.Context - users *UserService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *UserGetReqCall) SetUserId(userId string) { - rc.pathParams["user_id"] = userId -} -func (rc *UserGetReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *UserGetReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} - -func (rc *UserGetReqCall) Do() (*UserGetResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &UserGetResult{} - req := request.NewRequest("contact/v3/users/:user_id", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.users.service.conf, req) - return result, err -} - -func (users *UserService) Get(ctx *core.Context, optFns ...request.OptFn) *UserGetReqCall { - return &UserGetReqCall{ - ctx: ctx, - users: users, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type DepartmentUpdateReqCall struct { - ctx *core.Context - departments *DepartmentService - body *Department - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *DepartmentUpdateReqCall) SetDepartmentId(departmentId string) { - rc.pathParams["department_id"] = departmentId -} -func (rc *DepartmentUpdateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *DepartmentUpdateReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} - -func (rc *DepartmentUpdateReqCall) Do() (*DepartmentUpdateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &DepartmentUpdateResult{} - req := request.NewRequest("contact/v3/departments/:department_id", "PUT", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.departments.service.conf, req) - return result, err -} - -func (departments *DepartmentService) Update(ctx *core.Context, body *Department, optFns ...request.OptFn) *DepartmentUpdateReqCall { - return &DepartmentUpdateReqCall{ - ctx: ctx, - departments: departments, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type UserListReqCall struct { - ctx *core.Context - users *UserService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *UserListReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *UserListReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} -func (rc *UserListReqCall) SetDepartmentId(departmentId string) { - rc.queryParams["department_id"] = departmentId -} -func (rc *UserListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *UserListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *UserListReqCall) Do() (*UserListResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &UserListResult{} - req := request.NewRequest("contact/v3/users", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.users.service.conf, req) - return result, err -} - -func (users *UserService) List(ctx *core.Context, optFns ...request.OptFn) *UserListReqCall { - return &UserListReqCall{ - ctx: ctx, - users: users, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type DepartmentParentReqCall struct { - ctx *core.Context - departments *DepartmentService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *DepartmentParentReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *DepartmentParentReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} -func (rc *DepartmentParentReqCall) SetDepartmentId(departmentId string) { - rc.queryParams["department_id"] = departmentId -} -func (rc *DepartmentParentReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *DepartmentParentReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *DepartmentParentReqCall) Do() (*DepartmentParentResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &DepartmentParentResult{} - req := request.NewRequest("contact/v3/departments/parent", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.departments.service.conf, req) - return result, err -} - -func (departments *DepartmentService) Parent(ctx *core.Context, optFns ...request.OptFn) *DepartmentParentReqCall { - return &DepartmentParentReqCall{ - ctx: ctx, - departments: departments, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type DepartmentSearchReqCall struct { - ctx *core.Context - departments *DepartmentService - body *DepartmentSearchReqBody - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *DepartmentSearchReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *DepartmentSearchReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} -func (rc *DepartmentSearchReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *DepartmentSearchReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *DepartmentSearchReqCall) Do() (*DepartmentSearchResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &DepartmentSearchResult{} - req := request.NewRequest("contact/v3/departments/search", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.departments.service.conf, req) - return result, err -} - -func (departments *DepartmentService) Search(ctx *core.Context, body *DepartmentSearchReqBody, optFns ...request.OptFn) *DepartmentSearchReqCall { - return &DepartmentSearchReqCall{ - ctx: ctx, - departments: departments, - body: body, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} diff --git a/service/contact/v3/event.go b/service/contact/v3/event.go deleted file mode 100644 index 2133469a..00000000 --- a/service/contact/v3/event.go +++ /dev/null @@ -1,280 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v3 - -import ( - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" - "github.com/larksuite/oapi-sdk-go/event" -) - -type DepartmentCreatedEventHandler struct { - Fn func(*core.Context, *DepartmentCreatedEvent) error -} - -func (h *DepartmentCreatedEventHandler) GetEvent() interface{} { - return &DepartmentCreatedEvent{} -} - -func (h *DepartmentCreatedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*DepartmentCreatedEvent)) -} - -func SetDepartmentCreatedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *DepartmentCreatedEvent) error) { - event.SetTypeHandler(conf, "contact.department.created_v3", &DepartmentCreatedEventHandler{Fn: fn}) -} - -type DepartmentDeletedEventHandler struct { - Fn func(*core.Context, *DepartmentDeletedEvent) error -} - -func (h *DepartmentDeletedEventHandler) GetEvent() interface{} { - return &DepartmentDeletedEvent{} -} - -func (h *DepartmentDeletedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*DepartmentDeletedEvent)) -} - -func SetDepartmentDeletedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *DepartmentDeletedEvent) error) { - event.SetTypeHandler(conf, "contact.department.deleted_v3", &DepartmentDeletedEventHandler{Fn: fn}) -} - -type DepartmentUpdatedEventHandler struct { - Fn func(*core.Context, *DepartmentUpdatedEvent) error -} - -func (h *DepartmentUpdatedEventHandler) GetEvent() interface{} { - return &DepartmentUpdatedEvent{} -} - -func (h *DepartmentUpdatedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*DepartmentUpdatedEvent)) -} - -func SetDepartmentUpdatedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *DepartmentUpdatedEvent) error) { - event.SetTypeHandler(conf, "contact.department.updated_v3", &DepartmentUpdatedEventHandler{Fn: fn}) -} - -type UserCreatedEventHandler struct { - Fn func(*core.Context, *UserCreatedEvent) error -} - -func (h *UserCreatedEventHandler) GetEvent() interface{} { - return &UserCreatedEvent{} -} - -func (h *UserCreatedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*UserCreatedEvent)) -} - -func SetUserCreatedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *UserCreatedEvent) error) { - event.SetTypeHandler(conf, "contact.user.created_v3", &UserCreatedEventHandler{Fn: fn}) -} - -type UserDeletedEventHandler struct { - Fn func(*core.Context, *UserDeletedEvent) error -} - -func (h *UserDeletedEventHandler) GetEvent() interface{} { - return &UserDeletedEvent{} -} - -func (h *UserDeletedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*UserDeletedEvent)) -} - -func SetUserDeletedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *UserDeletedEvent) error) { - event.SetTypeHandler(conf, "contact.user.deleted_v3", &UserDeletedEventHandler{Fn: fn}) -} - -type UserUpdatedEventHandler struct { - Fn func(*core.Context, *UserUpdatedEvent) error -} - -func (h *UserUpdatedEventHandler) GetEvent() interface{} { - return &UserUpdatedEvent{} -} - -func (h *UserUpdatedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*UserUpdatedEvent)) -} - -func SetUserUpdatedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *UserUpdatedEvent) error) { - event.SetTypeHandler(conf, "contact.user.updated_v3", &UserUpdatedEventHandler{Fn: fn}) -} - -type UserGroupCreatedEventHandler struct { - Fn func(*core.Context, *UserGroupCreatedEvent) error -} - -func (h *UserGroupCreatedEventHandler) GetEvent() interface{} { - return &UserGroupCreatedEvent{} -} - -func (h *UserGroupCreatedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*UserGroupCreatedEvent)) -} - -func SetUserGroupCreatedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *UserGroupCreatedEvent) error) { - event.SetTypeHandler(conf, "contact.user_group.created_v3", &UserGroupCreatedEventHandler{Fn: fn}) -} - -type UserGroupDeletedEventHandler struct { - Fn func(*core.Context, *UserGroupDeletedEvent) error -} - -func (h *UserGroupDeletedEventHandler) GetEvent() interface{} { - return &UserGroupDeletedEvent{} -} - -func (h *UserGroupDeletedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*UserGroupDeletedEvent)) -} - -func SetUserGroupDeletedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *UserGroupDeletedEvent) error) { - event.SetTypeHandler(conf, "contact.user_group.deleted_v3", &UserGroupDeletedEventHandler{Fn: fn}) -} - -type UserGroupUpdatedEventHandler struct { - Fn func(*core.Context, *UserGroupUpdatedEvent) error -} - -func (h *UserGroupUpdatedEventHandler) GetEvent() interface{} { - return &UserGroupUpdatedEvent{} -} - -func (h *UserGroupUpdatedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*UserGroupUpdatedEvent)) -} - -func SetUserGroupUpdatedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *UserGroupUpdatedEvent) error) { - event.SetTypeHandler(conf, "contact.user_group.updated_v3", &UserGroupUpdatedEventHandler{Fn: fn}) -} - -type ScopeUpdatedEventHandler struct { - Fn func(*core.Context, *ScopeUpdatedEvent) error -} - -func (h *ScopeUpdatedEventHandler) GetEvent() interface{} { - return &ScopeUpdatedEvent{} -} - -func (h *ScopeUpdatedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*ScopeUpdatedEvent)) -} - -func SetScopeUpdatedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *ScopeUpdatedEvent) error) { - event.SetTypeHandler(conf, "contact.scope.updated_v3", &ScopeUpdatedEventHandler{Fn: fn}) -} - -type UserGroupMemberChangedEventHandler struct { - Fn func(*core.Context, *UserGroupMemberChangedEvent) error -} - -func (h *UserGroupMemberChangedEventHandler) GetEvent() interface{} { - return &UserGroupMemberChangedEvent{} -} - -func (h *UserGroupMemberChangedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*UserGroupMemberChangedEvent)) -} - -func SetUserGroupMemberChangedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *UserGroupMemberChangedEvent) error) { - event.SetTypeHandler(conf, "contact.user_group.member.changed_v3", &UserGroupMemberChangedEventHandler{Fn: fn}) -} - -type CustomAttrEventUpdatedEventHandler struct { - Fn func(*core.Context, *CustomAttrEventUpdatedEvent) error -} - -func (h *CustomAttrEventUpdatedEventHandler) GetEvent() interface{} { - return &CustomAttrEventUpdatedEvent{} -} - -func (h *CustomAttrEventUpdatedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*CustomAttrEventUpdatedEvent)) -} - -func SetCustomAttrEventUpdatedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *CustomAttrEventUpdatedEvent) error) { - event.SetTypeHandler(conf, "contact.custom_attr_event.updated_v3", &CustomAttrEventUpdatedEventHandler{Fn: fn}) -} - -type EmployeeTypeEnumActivedEventHandler struct { - Fn func(*core.Context, *EmployeeTypeEnumActivedEvent) error -} - -func (h *EmployeeTypeEnumActivedEventHandler) GetEvent() interface{} { - return &EmployeeTypeEnumActivedEvent{} -} - -func (h *EmployeeTypeEnumActivedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*EmployeeTypeEnumActivedEvent)) -} - -func SetEmployeeTypeEnumActivedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *EmployeeTypeEnumActivedEvent) error) { - event.SetTypeHandler(conf, "contact.employee_type_enum.actived_v3", &EmployeeTypeEnumActivedEventHandler{Fn: fn}) -} - -type EmployeeTypeEnumCreatedEventHandler struct { - Fn func(*core.Context, *EmployeeTypeEnumCreatedEvent) error -} - -func (h *EmployeeTypeEnumCreatedEventHandler) GetEvent() interface{} { - return &EmployeeTypeEnumCreatedEvent{} -} - -func (h *EmployeeTypeEnumCreatedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*EmployeeTypeEnumCreatedEvent)) -} - -func SetEmployeeTypeEnumCreatedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *EmployeeTypeEnumCreatedEvent) error) { - event.SetTypeHandler(conf, "contact.employee_type_enum.created_v3", &EmployeeTypeEnumCreatedEventHandler{Fn: fn}) -} - -type EmployeeTypeEnumDeactivatedEventHandler struct { - Fn func(*core.Context, *EmployeeTypeEnumDeactivatedEvent) error -} - -func (h *EmployeeTypeEnumDeactivatedEventHandler) GetEvent() interface{} { - return &EmployeeTypeEnumDeactivatedEvent{} -} - -func (h *EmployeeTypeEnumDeactivatedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*EmployeeTypeEnumDeactivatedEvent)) -} - -func SetEmployeeTypeEnumDeactivatedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *EmployeeTypeEnumDeactivatedEvent) error) { - event.SetTypeHandler(conf, "contact.employee_type_enum.deactivated_v3", &EmployeeTypeEnumDeactivatedEventHandler{Fn: fn}) -} - -type EmployeeTypeEnumDeletedEventHandler struct { - Fn func(*core.Context, *EmployeeTypeEnumDeletedEvent) error -} - -func (h *EmployeeTypeEnumDeletedEventHandler) GetEvent() interface{} { - return &EmployeeTypeEnumDeletedEvent{} -} - -func (h *EmployeeTypeEnumDeletedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*EmployeeTypeEnumDeletedEvent)) -} - -func SetEmployeeTypeEnumDeletedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *EmployeeTypeEnumDeletedEvent) error) { - event.SetTypeHandler(conf, "contact.employee_type_enum.deleted_v3", &EmployeeTypeEnumDeletedEventHandler{Fn: fn}) -} - -type EmployeeTypeEnumUpdatedEventHandler struct { - Fn func(*core.Context, *EmployeeTypeEnumUpdatedEvent) error -} - -func (h *EmployeeTypeEnumUpdatedEventHandler) GetEvent() interface{} { - return &EmployeeTypeEnumUpdatedEvent{} -} - -func (h *EmployeeTypeEnumUpdatedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*EmployeeTypeEnumUpdatedEvent)) -} - -func SetEmployeeTypeEnumUpdatedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *EmployeeTypeEnumUpdatedEvent) error) { - event.SetTypeHandler(conf, "contact.employee_type_enum.updated_v3", &EmployeeTypeEnumUpdatedEventHandler{Fn: fn}) -} diff --git a/service/contact/v3/model.go b/service/contact/v3/model.go deleted file mode 100644 index ee82b51c..00000000 --- a/service/contact/v3/model.go +++ /dev/null @@ -1,634 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v3 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" - "github.com/larksuite/oapi-sdk-go/event/core/model" -) - -type AvatarInfo struct { - Avatar72 string `json:"avatar_72,omitempty"` - Avatar240 string `json:"avatar_240,omitempty"` - Avatar640 string `json:"avatar_640,omitempty"` - AvatarOrigin string `json:"avatar_origin,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AvatarInfo) MarshalJSON() ([]byte, error) { - type cp AvatarInfo - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type CustomAttrEvent struct { - ContactFieldKey string `json:"contact_field_key,omitempty"` - FieldValueTypes string `json:"field_value_types,omitempty"` - I18nFieldNames string `json:"i18n_field_names,omitempty"` - AllowOpenQuery string `json:"allow_open_query,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *CustomAttrEvent) MarshalJSON() ([]byte, error) { - type cp CustomAttrEvent - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DepartmentI18nName struct { - ZhCn string `json:"zh_cn,omitempty"` - JaJp string `json:"ja_jp,omitempty"` - EnUs string `json:"en_us,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DepartmentI18nName) MarshalJSON() ([]byte, error) { - type cp DepartmentI18nName - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DepartmentStatus struct { - IsDeleted bool `json:"is_deleted,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DepartmentStatus) MarshalJSON() ([]byte, error) { - type cp DepartmentStatus - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DepartmentUnit struct { - UnitId string `json:"unit_id,omitempty"` - UnitType string `json:"unit_type,omitempty"` - UnitName string `json:"unit_name,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DepartmentUnit) MarshalJSON() ([]byte, error) { - type cp DepartmentUnit - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type GroupEvent struct { - UserGroupId string `json:"user_group_id,omitempty"` - Name string `json:"name,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *GroupEvent) MarshalJSON() ([]byte, error) { - type cp GroupEvent - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Scope struct { - Departments []*Department `json:"departments,omitempty"` - Users []*User `json:"users,omitempty"` - UserGroups []*UserGroup `json:"user_groups,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Scope) MarshalJSON() ([]byte, error) { - type cp Scope - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type UserCustomAttr struct { - Type string `json:"type,omitempty"` - Id string `json:"id,omitempty"` - Value *UserCustomAttrValue `json:"value,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *UserCustomAttr) MarshalJSON() ([]byte, error) { - type cp UserCustomAttr - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type UserCustomAttrValue struct { - Text string `json:"text,omitempty"` - Url string `json:"url,omitempty"` - PcUrl string `json:"pc_url,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *UserCustomAttrValue) MarshalJSON() ([]byte, error) { - type cp UserCustomAttrValue - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type UserGroup struct { - UserGroupId string `json:"user_group_id,omitempty"` - Name string `json:"name,omitempty"` - Type int `json:"type,omitempty"` - MemberCount int `json:"member_count,omitempty"` - Status int `json:"status,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *UserGroup) MarshalJSON() ([]byte, error) { - type cp UserGroup - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type UserGroupMember struct { -} - -type UserOrder struct { - DepartmentId string `json:"department_id,omitempty"` - UserOrder int `json:"user_order,omitempty"` - DepartmentOrder int `json:"department_order,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *UserOrder) MarshalJSON() ([]byte, error) { - type cp UserOrder - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type UserPosition struct { - PositionCode string `json:"position_code,omitempty"` - PositionName string `json:"position_name,omitempty"` - DepartmentId string `json:"department_id,omitempty"` - LeaderUserId string `json:"leader_user_id,omitempty"` - LeaderPositionCode string `json:"leader_position_code,omitempty"` - IsMajor bool `json:"is_major,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *UserPosition) MarshalJSON() ([]byte, error) { - type cp UserPosition - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type UserStatus struct { - IsFrozen bool `json:"is_frozen,omitempty"` - IsResigned bool `json:"is_resigned,omitempty"` - IsActivated bool `json:"is_activated,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *UserStatus) MarshalJSON() ([]byte, error) { - type cp UserStatus - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Department struct { - Name string `json:"name,omitempty"` - I18nName *DepartmentI18nName `json:"i18n_name,omitempty"` - ParentDepartmentId string `json:"parent_department_id,omitempty"` - DepartmentId string `json:"department_id,omitempty"` - OpenDepartmentId string `json:"open_department_id,omitempty"` - LeaderUserId string `json:"leader_user_id,omitempty"` - ChatId string `json:"chat_id,omitempty"` - Order int64 `json:"order,omitempty,string"` - UnitIds []string `json:"unit_ids,omitempty"` - MemberCount int `json:"member_count,omitempty"` - Status *DepartmentStatus `json:"status,omitempty"` - CreateGroupChat bool `json:"create_group_chat,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Department) MarshalJSON() ([]byte, error) { - type cp Department - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DepartmentCount struct { - DepartmentId string `json:"department_id,omitempty"` - DirectDepartmentCount int `json:"direct_department_count,omitempty"` - DirectUserCount int `json:"direct_user_count,omitempty"` - DepartmentCount int `json:"department_count,omitempty"` - UserCount int `json:"user_count,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DepartmentCount) MarshalJSON() ([]byte, error) { - type cp DepartmentCount - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DepartmentEvent struct { - Name string `json:"name,omitempty"` - ParentDepartmentId string `json:"parent_department_id,omitempty"` - DepartmentId string `json:"department_id,omitempty"` - OpenDepartmentId string `json:"open_department_id,omitempty"` - LeaderUserId string `json:"leader_user_id,omitempty"` - ChatId string `json:"chat_id,omitempty"` - Order int `json:"order,omitempty"` - - Status *DepartmentStatus `json:"status,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DepartmentEvent) MarshalJSON() ([]byte, error) { - type cp DepartmentEvent - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DepartmentParent struct { - DepartmentId string `json:"department_id,omitempty"` - ParentIds []string `json:"parent_ids,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DepartmentParent) MarshalJSON() ([]byte, error) { - type cp DepartmentParent - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type EmployeeTypeEnum struct { - EnumId string `json:"enum_id,omitempty"` - EnumValue int64 `json:"enum_value,omitempty,string"` - Content string `json:"content,omitempty"` - EnumType int `json:"enum_type,omitempty"` - EnumStatus int `json:"enum_status,omitempty"` - I18nContent []*I18nContent `json:"i18n_content,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *EmployeeTypeEnum) MarshalJSON() ([]byte, error) { - type cp EmployeeTypeEnum - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type I18nContent struct { - Locale string `json:"locale,omitempty"` - Value string `json:"value,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *I18nContent) MarshalJSON() ([]byte, error) { - type cp I18nContent - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type NotificationOption struct { - Channels []string `json:"channels,omitempty"` - Language string `json:"language,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *NotificationOption) MarshalJSON() ([]byte, error) { - type cp NotificationOption - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type OldDepartmentObject struct { - Status *DepartmentStatus `json:"status,omitempty"` - OpenDepartmentId string `json:"open_department_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *OldDepartmentObject) MarshalJSON() ([]byte, error) { - type cp OldDepartmentObject - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type OldUserObject struct { - DepartmentIds []string `json:"department_ids,omitempty"` - OpenId string `json:"open_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *OldUserObject) MarshalJSON() ([]byte, error) { - type cp OldUserObject - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type UserEvent struct { - OpenId string `json:"open_id,omitempty"` - UserId string `json:"user_id,omitempty"` - Name string `json:"name,omitempty"` - EnName string `json:"en_name,omitempty"` - Email string `json:"email,omitempty"` - Mobile string `json:"mobile,omitempty"` - - Gender int `json:"gender,omitempty"` - Avatar *AvatarInfo `json:"avatar,omitempty"` - Status *UserStatus `json:"status,omitempty"` - DepartmentIds []string `json:"department_ids,omitempty"` - LeaderUserId string `json:"leader_user_id,omitempty"` - City string `json:"city,omitempty"` - Country string `json:"country,omitempty"` - WorkStation string `json:"work_station,omitempty"` - JoinTime int `json:"join_time,omitempty"` - - EmployeeNo string `json:"employee_no,omitempty"` - EmployeeType int `json:"employee_type,omitempty"` - - Orders []*UserOrder `json:"orders,omitempty"` - - CustomAttrs []*UserCustomAttr `json:"custom_attrs,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *UserEvent) MarshalJSON() ([]byte, error) { - type cp UserEvent - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type User struct { - UnionId string `json:"union_id,omitempty"` - UserId string `json:"user_id,omitempty"` - OpenId string `json:"open_id,omitempty"` - Name string `json:"name,omitempty"` - EnName string `json:"en_name,omitempty"` - Email string `json:"email,omitempty"` - Mobile string `json:"mobile,omitempty"` - MobileVisible bool `json:"mobile_visible,omitempty"` - Gender int `json:"gender,omitempty"` - AvatarKey string `json:"avatar_key,omitempty"` - Avatar *AvatarInfo `json:"avatar,omitempty"` - Status *UserStatus `json:"status,omitempty"` - DepartmentIds []string `json:"department_ids,omitempty"` - LeaderUserId string `json:"leader_user_id,omitempty"` - City string `json:"city,omitempty"` - Country string `json:"country,omitempty"` - WorkStation string `json:"work_station,omitempty"` - JoinTime int `json:"join_time,omitempty"` - IsTenantManager bool `json:"is_tenant_manager,omitempty"` - EmployeeNo string `json:"employee_no,omitempty"` - EmployeeType int `json:"employee_type,omitempty"` - - Orders []*UserOrder `json:"orders,omitempty"` - CustomAttrs []*UserCustomAttr `json:"custom_attrs,omitempty"` - EnterpriseEmail string `json:"enterprise_email,omitempty"` - - JobTitle string `json:"job_title,omitempty"` - NeedSendNotification bool `json:"need_send_notification,omitempty"` - NotificationOption *NotificationOption `json:"notification_option,omitempty"` - IsFrozen bool `json:"is_frozen,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *User) MarshalJSON() ([]byte, error) { - type cp User - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DepartmentGetResult struct { - Department *Department `json:"department,omitempty"` -} - -type UserDeleteReqBody struct { - DepartmentChatAcceptorUserId string `json:"department_chat_acceptor_user_id,omitempty"` - ExternalChatAcceptorUserId string `json:"external_chat_acceptor_user_id,omitempty"` - DocsAcceptorUserId string `json:"docs_acceptor_user_id,omitempty"` - CalendarAcceptorUserId string `json:"calendar_acceptor_user_id,omitempty"` - ApplicationAcceptorUserId string `json:"application_acceptor_user_id,omitempty"` - HelpdeskAcceptorUserId string `json:"helpdesk_acceptor_user_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *UserDeleteReqBody) MarshalJSON() ([]byte, error) { - type cp UserDeleteReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DepartmentListResult struct { - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` - Items []*Department `json:"items,omitempty"` -} - -type DepartmentPatchResult struct { - Department *Department `json:"department,omitempty"` -} - -type UserUpdateResult struct { - User *User `json:"user,omitempty"` -} - -type UserCreateResult struct { - User *User `json:"user,omitempty"` -} - -type UserPatchResult struct { - User *User `json:"user,omitempty"` -} - -type DepartmentCreateResult struct { - Department *Department `json:"department,omitempty"` -} - -type UserGetResult struct { - User *User `json:"user,omitempty"` -} - -type DepartmentUpdateResult struct { - Department *Department `json:"department,omitempty"` -} - -type UserListResult struct { - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` - Items []*User `json:"items,omitempty"` -} - -type DepartmentParentResult struct { - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` - Items []*Department `json:"items,omitempty"` -} - -type DepartmentSearchReqBody struct { - Query string `json:"query,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DepartmentSearchReqBody) MarshalJSON() ([]byte, error) { - type cp DepartmentSearchReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DepartmentSearchResult struct { - Items []*Department `json:"items,omitempty"` - PageToken string `json:"page_token,omitempty"` - HasMore bool `json:"has_more,omitempty"` -} - -type DepartmentCreatedEventData struct { - Object *DepartmentEvent `json:"object,omitempty"` -} - -type DepartmentCreatedEvent struct { - *model.BaseEventV2 - Event *DepartmentCreatedEventData `json:"event"` -} - -type DepartmentDeletedEventData struct { - Object *DepartmentEvent `json:"object,omitempty"` - OldObject *OldDepartmentObject `json:"old_object,omitempty"` -} - -type DepartmentDeletedEvent struct { - *model.BaseEventV2 - Event *DepartmentDeletedEventData `json:"event"` -} - -type DepartmentUpdatedEventData struct { - Object *DepartmentEvent `json:"object,omitempty"` - OldObject *DepartmentEvent `json:"old_object,omitempty"` -} - -type DepartmentUpdatedEvent struct { - *model.BaseEventV2 - Event *DepartmentUpdatedEventData `json:"event"` -} - -type UserCreatedEventData struct { - Object *UserEvent `json:"object,omitempty"` -} - -type UserCreatedEvent struct { - *model.BaseEventV2 - Event *UserCreatedEventData `json:"event"` -} - -type UserDeletedEventData struct { - Object *UserEvent `json:"object,omitempty"` - OldObject *OldUserObject `json:"old_object,omitempty"` -} - -type UserDeletedEvent struct { - *model.BaseEventV2 - Event *UserDeletedEventData `json:"event"` -} - -type UserUpdatedEventData struct { - Object *UserEvent `json:"object,omitempty"` - OldObject *UserEvent `json:"old_object,omitempty"` -} - -type UserUpdatedEvent struct { - *model.BaseEventV2 - Event *UserUpdatedEventData `json:"event"` -} - -type UserGroupCreatedEventData struct { - Object *GroupEvent `json:"object,omitempty"` -} - -type UserGroupCreatedEvent struct { - *model.BaseEventV2 - Event *UserGroupCreatedEventData `json:"event"` -} - -type UserGroupDeletedEventData struct { - Object *GroupEvent `json:"object,omitempty"` -} - -type UserGroupDeletedEvent struct { - *model.BaseEventV2 - Event *UserGroupDeletedEventData `json:"event"` -} - -type UserGroupUpdatedEventData struct { - Object *GroupEvent `json:"object,omitempty"` - OldObject *GroupEvent `json:"old_object,omitempty"` -} - -type UserGroupUpdatedEvent struct { - *model.BaseEventV2 - Event *UserGroupUpdatedEventData `json:"event"` -} - -type ScopeUpdatedEventData struct { - Added *Scope `json:"added,omitempty"` - Removed *Scope `json:"removed,omitempty"` -} - -type ScopeUpdatedEvent struct { - *model.BaseEventV2 - Event *ScopeUpdatedEventData `json:"event"` -} - -type UserGroupMemberChangedEventData struct { - Object *GroupEvent `json:"object,omitempty"` -} - -type UserGroupMemberChangedEvent struct { - *model.BaseEventV2 - Event *UserGroupMemberChangedEventData `json:"event"` -} - -type CustomAttrEventUpdatedEventData struct { - Object *CustomAttrEvent `json:"object,omitempty"` - OldObject *CustomAttrEvent `json:"old_object,omitempty"` -} - -type CustomAttrEventUpdatedEvent struct { - *model.BaseEventV2 - Event *CustomAttrEventUpdatedEventData `json:"event"` -} - -type EmployeeTypeEnumActivedEventData struct { - OldEnum *EmployeeTypeEnum `json:"old_enum,omitempty"` - NewEnum *EmployeeTypeEnum `json:"new_enum,omitempty"` -} - -type EmployeeTypeEnumActivedEvent struct { - *model.BaseEventV2 - Event *EmployeeTypeEnumActivedEventData `json:"event"` -} - -type EmployeeTypeEnumCreatedEventData struct { - NewEnum *EmployeeTypeEnum `json:"new_enum,omitempty"` -} - -type EmployeeTypeEnumCreatedEvent struct { - *model.BaseEventV2 - Event *EmployeeTypeEnumCreatedEventData `json:"event"` -} - -type EmployeeTypeEnumDeactivatedEventData struct { - OldEnum *EmployeeTypeEnum `json:"old_enum,omitempty"` - NewEnum *EmployeeTypeEnum `json:"new_enum,omitempty"` -} - -type EmployeeTypeEnumDeactivatedEvent struct { - *model.BaseEventV2 - Event *EmployeeTypeEnumDeactivatedEventData `json:"event"` -} - -type EmployeeTypeEnumDeletedEventData struct { - OldEnum *EmployeeTypeEnum `json:"old_enum,omitempty"` -} - -type EmployeeTypeEnumDeletedEvent struct { - *model.BaseEventV2 - Event *EmployeeTypeEnumDeletedEventData `json:"event"` -} - -type EmployeeTypeEnumUpdatedEventData struct { - OldEnum *EmployeeTypeEnum `json:"old_enum,omitempty"` - NewEnum *EmployeeTypeEnum `json:"new_enum,omitempty"` -} - -type EmployeeTypeEnumUpdatedEvent struct { - *model.BaseEventV2 - Event *EmployeeTypeEnumUpdatedEventData `json:"event"` -} diff --git a/service/doc/v2/api.go b/service/doc/v2/api.go deleted file mode 100644 index 46ce1904..00000000 --- a/service/doc/v2/api.go +++ /dev/null @@ -1,175 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v2 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - Docs *DocService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Docs = newDocService(s) - return s -} - -type DocService struct { - service *Service -} - -func newDocService(service *Service) *DocService { - return &DocService{ - service: service, - } -} - -type DocBatchUpdateReqCall struct { - ctx *core.Context - docs *DocService - body *DocBatchUpdateReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *DocBatchUpdateReqCall) SetDocToken(docToken string) { - rc.pathParams["docToken"] = docToken -} - -func (rc *DocBatchUpdateReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/doc/v2/:docToken/batch_update", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.docs.service.conf, req) - return result, err -} - -func (docs *DocService) BatchUpdate(ctx *core.Context, body *DocBatchUpdateReqBody, optFns ...request.OptFn) *DocBatchUpdateReqCall { - return &DocBatchUpdateReqCall{ - ctx: ctx, - docs: docs, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type DocContentReqCall struct { - ctx *core.Context - docs *DocService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *DocContentReqCall) SetDocToken(docToken string) { - rc.pathParams["docToken"] = docToken -} - -func (rc *DocContentReqCall) Do() (*DocContentResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &DocContentResult{} - req := request.NewRequest("/open-apis/doc/v2/:docToken/content", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.docs.service.conf, req) - return result, err -} - -func (docs *DocService) Content(ctx *core.Context, optFns ...request.OptFn) *DocContentReqCall { - return &DocContentReqCall{ - ctx: ctx, - docs: docs, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type DocCreateReqCall struct { - ctx *core.Context - docs *DocService - body *DocCreateReqBody - optFns []request.OptFn -} - -func (rc *DocCreateReqCall) Do() (*DocCreateResult, error) { - var result = &DocCreateResult{} - req := request.NewRequest("/open-apis/doc/v2/create", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.docs.service.conf, req) - return result, err -} - -func (docs *DocService) Create(ctx *core.Context, body *DocCreateReqBody, optFns ...request.OptFn) *DocCreateReqCall { - return &DocCreateReqCall{ - ctx: ctx, - docs: docs, - body: body, - optFns: optFns, - } -} - -type DocMetaReqCall struct { - ctx *core.Context - docs *DocService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *DocMetaReqCall) SetDocToken(docToken string) { - rc.pathParams["docToken"] = docToken -} - -func (rc *DocMetaReqCall) Do() (*DocMetaResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &DocMetaResult{} - req := request.NewRequest("/open-apis/doc/v2/meta/:docToken", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.docs.service.conf, req) - return result, err -} - -func (docs *DocService) Meta(ctx *core.Context, optFns ...request.OptFn) *DocMetaReqCall { - return &DocMetaReqCall{ - ctx: ctx, - docs: docs, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type DocRawContentReqCall struct { - ctx *core.Context - docs *DocService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *DocRawContentReqCall) SetDocToken(docToken string) { - rc.pathParams["docToken"] = docToken -} - -func (rc *DocRawContentReqCall) Do() (*DocRawContentResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &DocRawContentResult{} - req := request.NewRequest("/open-apis/doc/v2/:docToken/raw_content", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.docs.service.conf, req) - return result, err -} - -func (docs *DocService) RawContent(ctx *core.Context, optFns ...request.OptFn) *DocRawContentReqCall { - return &DocRawContentReqCall{ - ctx: ctx, - docs: docs, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} diff --git a/service/doc/v2/model.go b/service/doc/v2/model.go deleted file mode 100644 index fd41436e..00000000 --- a/service/doc/v2/model.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v2 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" -) - -type Doc struct { -} - -type DocBatchUpdateReqBody struct { - Revision int `json:"Revision,omitempty"` - Requests []string `json:"Requests,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DocBatchUpdateReqBody) MarshalJSON() ([]byte, error) { - type cp DocBatchUpdateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DocContentResult struct { - Content string `json:"content,omitempty"` - Revision int `json:"revision,omitempty"` -} - -type DocCreateReqBody struct { - FolderToken string `json:"FolderToken,omitempty"` - Content string `json:"Content,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DocCreateReqBody) MarshalJSON() ([]byte, error) { - type cp DocCreateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DocCreateResult struct { - ObjToken string `json:"objToken,omitempty"` - Url string `json:"url,omitempty"` -} - -type DocMetaResult struct { - CreateDate string `json:"create_date,omitempty"` - CreateTime int `json:"create_time,omitempty"` - Creator string `json:"creator,omitempty"` - CreateUserName string `json:"create_user_name,omitempty"` - DeleteFlag int `json:"delete_flag,omitempty"` - EditTime int `json:"edit_time,omitempty"` - EditUserName string `json:"edit_user_name,omitempty"` - IsExternal bool `json:"is_external,omitempty"` - IsPined bool `json:"is_pined,omitempty"` - IsStared bool `json:"is_stared,omitempty"` - ObjType string `json:"obj_type,omitempty"` - Owner string `json:"owner,omitempty"` - OwnerUserName string `json:"owner_user_name,omitempty"` - ServerTime int `json:"server_time,omitempty"` - TenantId string `json:"tenant_id,omitempty"` - Title string `json:"title,omitempty"` - Type int `json:"type,omitempty"` - Url string `json:"url,omitempty"` -} - -type DocRawContentResult struct { - Content string `json:"content,omitempty"` -} diff --git a/service/drive/v1/api.go b/service/drive/v1/api.go deleted file mode 100644 index 10a41299..00000000 --- a/service/drive/v1/api.go +++ /dev/null @@ -1,991 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" - "io" -) - -type Service struct { - conf *config.Config - Files *FileService - FileComments *FileCommentService - FileCommentReplys *FileCommentReplyService - Medias *MediaService - FileStatisticss *FileStatisticsService - ImportTasks *ImportTaskService - PermissionMembers *PermissionMemberService - PermissionPublics *PermissionPublicService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Files = newFileService(s) - s.FileComments = newFileCommentService(s) - s.FileCommentReplys = newFileCommentReplyService(s) - s.Medias = newMediaService(s) - s.FileStatisticss = newFileStatisticsService(s) - s.ImportTasks = newImportTaskService(s) - s.PermissionMembers = newPermissionMemberService(s) - s.PermissionPublics = newPermissionPublicService(s) - return s -} - -type FileService struct { - service *Service -} - -func newFileService(service *Service) *FileService { - return &FileService{ - service: service, - } -} - -type FileCommentService struct { - service *Service -} - -func newFileCommentService(service *Service) *FileCommentService { - return &FileCommentService{ - service: service, - } -} - -type FileCommentReplyService struct { - service *Service -} - -func newFileCommentReplyService(service *Service) *FileCommentReplyService { - return &FileCommentReplyService{ - service: service, - } -} - -type MediaService struct { - service *Service -} - -func newMediaService(service *Service) *MediaService { - return &MediaService{ - service: service, - } -} - -type FileStatisticsService struct { - service *Service -} - -func newFileStatisticsService(service *Service) *FileStatisticsService { - return &FileStatisticsService{ - service: service, - } -} - -type ImportTaskService struct { - service *Service -} - -func newImportTaskService(service *Service) *ImportTaskService { - return &ImportTaskService{ - service: service, - } -} - -type PermissionMemberService struct { - service *Service -} - -func newPermissionMemberService(service *Service) *PermissionMemberService { - return &PermissionMemberService{ - service: service, - } -} - -type PermissionPublicService struct { - service *Service -} - -func newPermissionPublicService(service *Service) *PermissionPublicService { - return &PermissionPublicService{ - service: service, - } -} - -type MediaUploadPartReqCall struct { - ctx *core.Context - medias *MediaService - body *request.FormData - optFns []request.OptFn -} - -func (rc *MediaUploadPartReqCall) SetUploadId(uploadId string) { - rc.body.AddParam("upload_id", uploadId) -} -func (rc *MediaUploadPartReqCall) SetSeq(seq int) { - rc.body.AddParam("seq", seq) -} -func (rc *MediaUploadPartReqCall) SetSize(size int) { - rc.body.AddParam("size", size) -} -func (rc *MediaUploadPartReqCall) SetChecksum(checksum string) { - rc.body.AddParam("checksum", checksum) -} -func (rc *MediaUploadPartReqCall) SetFile(file *request.File) { - rc.body.AddFile("file", file) -} - -func (rc *MediaUploadPartReqCall) Do() (*response.NoData, error) { - var result = &response.NoData{} - req := request.NewRequest("/open-apis/drive/v1/medias/upload_part", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.medias.service.conf, req) - return result, err -} - -func (medias *MediaService) UploadPart(ctx *core.Context, optFns ...request.OptFn) *MediaUploadPartReqCall { - return &MediaUploadPartReqCall{ - ctx: ctx, - medias: medias, - body: request.NewFormData(), - optFns: optFns, - } -} - -type FileUploadFinishReqCall struct { - ctx *core.Context - files *FileService - body *FileUploadFinishReqBody - optFns []request.OptFn -} - -func (rc *FileUploadFinishReqCall) Do() (*FileUploadFinishResult, error) { - var result = &FileUploadFinishResult{} - req := request.NewRequest("/open-apis/drive/v1/files/upload_finish", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.files.service.conf, req) - return result, err -} - -func (files *FileService) UploadFinish(ctx *core.Context, body *FileUploadFinishReqBody, optFns ...request.OptFn) *FileUploadFinishReqCall { - return &FileUploadFinishReqCall{ - ctx: ctx, - files: files, - body: body, - optFns: optFns, - } -} - -type FileUploadPrepareReqCall struct { - ctx *core.Context - files *FileService - body *FileUploadInfo - optFns []request.OptFn -} - -func (rc *FileUploadPrepareReqCall) Do() (*FileUploadPrepareResult, error) { - var result = &FileUploadPrepareResult{} - req := request.NewRequest("/open-apis/drive/v1/files/upload_prepare", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.files.service.conf, req) - return result, err -} - -func (files *FileService) UploadPrepare(ctx *core.Context, body *FileUploadInfo, optFns ...request.OptFn) *FileUploadPrepareReqCall { - return &FileUploadPrepareReqCall{ - ctx: ctx, - files: files, - body: body, - optFns: optFns, - } -} - -type MediaUploadAllReqCall struct { - ctx *core.Context - medias *MediaService - body *request.FormData - optFns []request.OptFn -} - -func (rc *MediaUploadAllReqCall) SetFileName(fileName string) { - rc.body.AddParam("file_name", fileName) -} -func (rc *MediaUploadAllReqCall) SetParentType(parentType string) { - rc.body.AddParam("parent_type", parentType) -} -func (rc *MediaUploadAllReqCall) SetParentNode(parentNode string) { - rc.body.AddParam("parent_node", parentNode) -} -func (rc *MediaUploadAllReqCall) SetSize(size int) { - rc.body.AddParam("size", size) -} -func (rc *MediaUploadAllReqCall) SetChecksum(checksum string) { - rc.body.AddParam("checksum", checksum) -} -func (rc *MediaUploadAllReqCall) SetExtra(extra string) { - rc.body.AddParam("extra", extra) -} -func (rc *MediaUploadAllReqCall) SetFile(file *request.File) { - rc.body.AddFile("file", file) -} - -func (rc *MediaUploadAllReqCall) Do() (*MediaUploadAllResult, error) { - var result = &MediaUploadAllResult{} - req := request.NewRequest("/open-apis/drive/v1/medias/upload_all", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.medias.service.conf, req) - return result, err -} - -func (medias *MediaService) UploadAll(ctx *core.Context, optFns ...request.OptFn) *MediaUploadAllReqCall { - return &MediaUploadAllReqCall{ - ctx: ctx, - medias: medias, - body: request.NewFormData(), - optFns: optFns, - } -} - -type MediaUploadFinishReqCall struct { - ctx *core.Context - medias *MediaService - body *MediaUploadFinishReqBody - optFns []request.OptFn -} - -func (rc *MediaUploadFinishReqCall) Do() (*MediaUploadFinishResult, error) { - var result = &MediaUploadFinishResult{} - req := request.NewRequest("/open-apis/drive/v1/medias/upload_finish", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.medias.service.conf, req) - return result, err -} - -func (medias *MediaService) UploadFinish(ctx *core.Context, body *MediaUploadFinishReqBody, optFns ...request.OptFn) *MediaUploadFinishReqCall { - return &MediaUploadFinishReqCall{ - ctx: ctx, - medias: medias, - body: body, - optFns: optFns, - } -} - -type FileUploadAllReqCall struct { - ctx *core.Context - files *FileService - body *request.FormData - optFns []request.OptFn -} - -func (rc *FileUploadAllReqCall) SetFileName(fileName string) { - rc.body.AddParam("file_name", fileName) -} -func (rc *FileUploadAllReqCall) SetParentType(parentType string) { - rc.body.AddParam("parent_type", parentType) -} -func (rc *FileUploadAllReqCall) SetParentNode(parentNode string) { - rc.body.AddParam("parent_node", parentNode) -} -func (rc *FileUploadAllReqCall) SetSize(size int) { - rc.body.AddParam("size", size) -} -func (rc *FileUploadAllReqCall) SetChecksum(checksum string) { - rc.body.AddParam("checksum", checksum) -} -func (rc *FileUploadAllReqCall) SetFile(file *request.File) { - rc.body.AddFile("file", file) -} - -func (rc *FileUploadAllReqCall) Do() (*FileUploadAllResult, error) { - var result = &FileUploadAllResult{} - req := request.NewRequest("/open-apis/drive/v1/files/upload_all", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.files.service.conf, req) - return result, err -} - -func (files *FileService) UploadAll(ctx *core.Context, optFns ...request.OptFn) *FileUploadAllReqCall { - return &FileUploadAllReqCall{ - ctx: ctx, - files: files, - body: request.NewFormData(), - optFns: optFns, - } -} - -type MediaUploadPrepareReqCall struct { - ctx *core.Context - medias *MediaService - body *MediaUploadInfo - optFns []request.OptFn -} - -func (rc *MediaUploadPrepareReqCall) Do() (*MediaUploadPrepareResult, error) { - var result = &MediaUploadPrepareResult{} - req := request.NewRequest("/open-apis/drive/v1/medias/upload_prepare", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.medias.service.conf, req) - return result, err -} - -func (medias *MediaService) UploadPrepare(ctx *core.Context, body *MediaUploadInfo, optFns ...request.OptFn) *MediaUploadPrepareReqCall { - return &MediaUploadPrepareReqCall{ - ctx: ctx, - medias: medias, - body: body, - optFns: optFns, - } -} - -type FileUploadPartReqCall struct { - ctx *core.Context - files *FileService - body *request.FormData - optFns []request.OptFn -} - -func (rc *FileUploadPartReqCall) SetUploadId(uploadId string) { - rc.body.AddParam("upload_id", uploadId) -} -func (rc *FileUploadPartReqCall) SetSeq(seq int) { - rc.body.AddParam("seq", seq) -} -func (rc *FileUploadPartReqCall) SetSize(size int) { - rc.body.AddParam("size", size) -} -func (rc *FileUploadPartReqCall) SetChecksum(checksum string) { - rc.body.AddParam("checksum", checksum) -} -func (rc *FileUploadPartReqCall) SetFile(file *request.File) { - rc.body.AddFile("file", file) -} - -func (rc *FileUploadPartReqCall) Do() (*response.NoData, error) { - var result = &response.NoData{} - req := request.NewRequest("/open-apis/drive/v1/files/upload_part", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.files.service.conf, req) - return result, err -} - -func (files *FileService) UploadPart(ctx *core.Context, optFns ...request.OptFn) *FileUploadPartReqCall { - return &FileUploadPartReqCall{ - ctx: ctx, - files: files, - body: request.NewFormData(), - optFns: optFns, - } -} - -type MediaBatchGetTmpDownloadUrlReqCall struct { - ctx *core.Context - medias *MediaService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MediaBatchGetTmpDownloadUrlReqCall) SetFileTokens(fileTokens ...string) { - rc.queryParams["file_tokens"] = fileTokens -} -func (rc *MediaBatchGetTmpDownloadUrlReqCall) SetExtra(extra string) { - rc.queryParams["extra"] = extra -} - -func (rc *MediaBatchGetTmpDownloadUrlReqCall) Do() (*MediaBatchGetTmpDownloadUrlResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &MediaBatchGetTmpDownloadUrlResult{} - req := request.NewRequest("/open-apis/drive/v1/medias/batch_get_tmp_download_url", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.medias.service.conf, req) - return result, err -} - -func (medias *MediaService) BatchGetTmpDownloadUrl(ctx *core.Context, optFns ...request.OptFn) *MediaBatchGetTmpDownloadUrlReqCall { - return &MediaBatchGetTmpDownloadUrlReqCall{ - ctx: ctx, - medias: medias, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type FileDownloadReqCall struct { - ctx *core.Context - files *FileService - pathParams map[string]interface{} - optFns []request.OptFn - result io.Writer -} - -func (rc *FileDownloadReqCall) SetFileToken(fileToken string) { - rc.pathParams["file_token"] = fileToken -} -func (rc *FileDownloadReqCall) SetResponseStream(result io.Writer) { - rc.result = result -} - -func (rc *FileDownloadReqCall) Do() (io.Writer, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetResponseStream()) - req := request.NewRequest("/open-apis/drive/v1/files/:file_token/download", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, rc.result, rc.optFns...) - err := api.Send(rc.ctx, rc.files.service.conf, req) - return rc.result, err -} - -func (files *FileService) Download(ctx *core.Context, optFns ...request.OptFn) *FileDownloadReqCall { - return &FileDownloadReqCall{ - ctx: ctx, - files: files, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MediaDownloadReqCall struct { - ctx *core.Context - medias *MediaService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn - result io.Writer -} - -func (rc *MediaDownloadReqCall) SetFileToken(fileToken string) { - rc.pathParams["file_token"] = fileToken -} -func (rc *MediaDownloadReqCall) SetExtra(extra string) { - rc.queryParams["extra"] = extra -} -func (rc *MediaDownloadReqCall) SetResponseStream(result io.Writer) { - rc.result = result -} - -func (rc *MediaDownloadReqCall) Do() (io.Writer, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - rc.optFns = append(rc.optFns, request.SetResponseStream()) - req := request.NewRequest("/open-apis/drive/v1/medias/:file_token/download", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, rc.result, rc.optFns...) - err := api.Send(rc.ctx, rc.medias.service.conf, req) - return rc.result, err -} - -func (medias *MediaService) Download(ctx *core.Context, optFns ...request.OptFn) *MediaDownloadReqCall { - return &MediaDownloadReqCall{ - ctx: ctx, - medias: medias, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type FileCommentCreateReqCall struct { - ctx *core.Context - fileComments *FileCommentService - body *FileComment - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *FileCommentCreateReqCall) SetFileToken(fileToken string) { - rc.pathParams["file_token"] = fileToken -} -func (rc *FileCommentCreateReqCall) SetFileType(fileType string) { - rc.queryParams["file_type"] = fileType -} -func (rc *FileCommentCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *FileCommentCreateReqCall) Do() (*FileComment, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &FileComment{} - req := request.NewRequest("/open-apis/drive/v1/files/:file_token/comments", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.fileComments.service.conf, req) - return result, err -} - -func (fileComments *FileCommentService) Create(ctx *core.Context, body *FileComment, optFns ...request.OptFn) *FileCommentCreateReqCall { - return &FileCommentCreateReqCall{ - ctx: ctx, - fileComments: fileComments, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type FileCommentGetReqCall struct { - ctx *core.Context - fileComments *FileCommentService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *FileCommentGetReqCall) SetFileToken(fileToken string) { - rc.pathParams["file_token"] = fileToken -} -func (rc *FileCommentGetReqCall) SetCommentId(commentId int64) { - rc.pathParams["comment_id"] = commentId -} -func (rc *FileCommentGetReqCall) SetFileType(fileType string) { - rc.queryParams["file_type"] = fileType -} -func (rc *FileCommentGetReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *FileCommentGetReqCall) Do() (*FileComment, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &FileComment{} - req := request.NewRequest("/open-apis/drive/v1/files/:file_token/comments/:comment_id", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.fileComments.service.conf, req) - return result, err -} - -func (fileComments *FileCommentService) Get(ctx *core.Context, optFns ...request.OptFn) *FileCommentGetReqCall { - return &FileCommentGetReqCall{ - ctx: ctx, - fileComments: fileComments, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type FileCommentReplyUpdateReqCall struct { - ctx *core.Context - fileCommentReplys *FileCommentReplyService - body *FileCommentReplyUpdateReqBody - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *FileCommentReplyUpdateReqCall) SetFileToken(fileToken string) { - rc.pathParams["file_token"] = fileToken -} -func (rc *FileCommentReplyUpdateReqCall) SetCommentId(commentId int64) { - rc.pathParams["comment_id"] = commentId -} -func (rc *FileCommentReplyUpdateReqCall) SetReplyId(replyId int64) { - rc.pathParams["reply_id"] = replyId -} -func (rc *FileCommentReplyUpdateReqCall) SetFileType(fileType string) { - rc.queryParams["file_type"] = fileType -} -func (rc *FileCommentReplyUpdateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *FileCommentReplyUpdateReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/drive/v1/files/:file_token/comments/:comment_id/replies/:reply_id", "PUT", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.fileCommentReplys.service.conf, req) - return result, err -} - -func (fileCommentReplys *FileCommentReplyService) Update(ctx *core.Context, body *FileCommentReplyUpdateReqBody, optFns ...request.OptFn) *FileCommentReplyUpdateReqCall { - return &FileCommentReplyUpdateReqCall{ - ctx: ctx, - fileCommentReplys: fileCommentReplys, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type FileCommentListReqCall struct { - ctx *core.Context - fileComments *FileCommentService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *FileCommentListReqCall) SetFileToken(fileToken string) { - rc.pathParams["file_token"] = fileToken -} -func (rc *FileCommentListReqCall) SetFileType(fileType string) { - rc.queryParams["file_type"] = fileType -} -func (rc *FileCommentListReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *FileCommentListReqCall) SetIsSolved(isSolved bool) { - rc.queryParams["is_solved"] = isSolved -} -func (rc *FileCommentListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *FileCommentListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *FileCommentListReqCall) Do() (*FileCommentListResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &FileCommentListResult{} - req := request.NewRequest("/open-apis/drive/v1/files/:file_token/comments", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.fileComments.service.conf, req) - return result, err -} - -func (fileComments *FileCommentService) List(ctx *core.Context, optFns ...request.OptFn) *FileCommentListReqCall { - return &FileCommentListReqCall{ - ctx: ctx, - fileComments: fileComments, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type FileCommentPatchReqCall struct { - ctx *core.Context - fileComments *FileCommentService - body *FileCommentPatchReqBody - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *FileCommentPatchReqCall) SetFileToken(fileToken string) { - rc.pathParams["file_token"] = fileToken -} -func (rc *FileCommentPatchReqCall) SetCommentId(commentId int64) { - rc.pathParams["comment_id"] = commentId -} -func (rc *FileCommentPatchReqCall) SetFileType(fileType string) { - rc.queryParams["file_type"] = fileType -} - -func (rc *FileCommentPatchReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/drive/v1/files/:file_token/comments/:comment_id", "PATCH", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.fileComments.service.conf, req) - return result, err -} - -func (fileComments *FileCommentService) Patch(ctx *core.Context, body *FileCommentPatchReqBody, optFns ...request.OptFn) *FileCommentPatchReqCall { - return &FileCommentPatchReqCall{ - ctx: ctx, - fileComments: fileComments, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type FileCommentReplyDeleteReqCall struct { - ctx *core.Context - fileCommentReplys *FileCommentReplyService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *FileCommentReplyDeleteReqCall) SetFileToken(fileToken string) { - rc.pathParams["file_token"] = fileToken -} -func (rc *FileCommentReplyDeleteReqCall) SetCommentId(commentId int64) { - rc.pathParams["comment_id"] = commentId -} -func (rc *FileCommentReplyDeleteReqCall) SetReplyId(replyId int64) { - rc.pathParams["reply_id"] = replyId -} -func (rc *FileCommentReplyDeleteReqCall) SetFileType(fileType string) { - rc.queryParams["file_type"] = fileType -} - -func (rc *FileCommentReplyDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/drive/v1/files/:file_token/comments/:comment_id/replies/:reply_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.fileCommentReplys.service.conf, req) - return result, err -} - -func (fileCommentReplys *FileCommentReplyService) Delete(ctx *core.Context, optFns ...request.OptFn) *FileCommentReplyDeleteReqCall { - return &FileCommentReplyDeleteReqCall{ - ctx: ctx, - fileCommentReplys: fileCommentReplys, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type PermissionMemberCreateReqCall struct { - ctx *core.Context - permissionMembers *PermissionMemberService - body *Member - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *PermissionMemberCreateReqCall) SetToken(token string) { - rc.pathParams["token"] = token -} -func (rc *PermissionMemberCreateReqCall) SetType(type_ string) { - rc.queryParams["type"] = type_ -} -func (rc *PermissionMemberCreateReqCall) SetNeedNotification(needNotification bool) { - rc.queryParams["need_notification"] = needNotification -} - -func (rc *PermissionMemberCreateReqCall) Do() (*PermissionMemberCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &PermissionMemberCreateResult{} - req := request.NewRequest("/open-apis/drive/v1/permissions/:token/members", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.permissionMembers.service.conf, req) - return result, err -} - -func (permissionMembers *PermissionMemberService) Create(ctx *core.Context, body *Member, optFns ...request.OptFn) *PermissionMemberCreateReqCall { - return &PermissionMemberCreateReqCall{ - ctx: ctx, - permissionMembers: permissionMembers, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type PermissionPublicPatchReqCall struct { - ctx *core.Context - permissionPublics *PermissionPublicService - body *PermissionPublic - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *PermissionPublicPatchReqCall) SetToken(token string) { - rc.pathParams["token"] = token -} -func (rc *PermissionPublicPatchReqCall) SetType(type_ string) { - rc.queryParams["type"] = type_ -} - -func (rc *PermissionPublicPatchReqCall) Do() (*PermissionPublicPatchResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &PermissionPublicPatchResult{} - req := request.NewRequest("/open-apis/drive/v1/permissions/:token/public", "PATCH", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.permissionPublics.service.conf, req) - return result, err -} - -func (permissionPublics *PermissionPublicService) Patch(ctx *core.Context, body *PermissionPublic, optFns ...request.OptFn) *PermissionPublicPatchReqCall { - return &PermissionPublicPatchReqCall{ - ctx: ctx, - permissionPublics: permissionPublics, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ImportTaskCreateReqCall struct { - ctx *core.Context - importTasks *ImportTaskService - body *ImportTask - optFns []request.OptFn -} - -func (rc *ImportTaskCreateReqCall) Do() (*ImportTaskCreateResult, error) { - var result = &ImportTaskCreateResult{} - req := request.NewRequest("/open-apis/drive/v1/import_tasks", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.importTasks.service.conf, req) - return result, err -} - -func (importTasks *ImportTaskService) Create(ctx *core.Context, body *ImportTask, optFns ...request.OptFn) *ImportTaskCreateReqCall { - return &ImportTaskCreateReqCall{ - ctx: ctx, - importTasks: importTasks, - body: body, - optFns: optFns, - } -} - -type ImportTaskGetReqCall struct { - ctx *core.Context - importTasks *ImportTaskService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ImportTaskGetReqCall) SetTicket(ticket string) { - rc.pathParams["ticket"] = ticket -} - -func (rc *ImportTaskGetReqCall) Do() (*ImportTaskGetResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &ImportTaskGetResult{} - req := request.NewRequest("/open-apis/drive/v1/import_tasks/:ticket", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.importTasks.service.conf, req) - return result, err -} - -func (importTasks *ImportTaskService) Get(ctx *core.Context, optFns ...request.OptFn) *ImportTaskGetReqCall { - return &ImportTaskGetReqCall{ - ctx: ctx, - importTasks: importTasks, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type FileStatisticsGetReqCall struct { - ctx *core.Context - fileStatisticss *FileStatisticsService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *FileStatisticsGetReqCall) SetFileToken(fileToken string) { - rc.pathParams["file_token"] = fileToken -} -func (rc *FileStatisticsGetReqCall) SetFileType(fileType string) { - rc.queryParams["file_type"] = fileType -} - -func (rc *FileStatisticsGetReqCall) Do() (*FileStatisticsGetResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &FileStatisticsGetResult{} - req := request.NewRequest("/open-apis/drive/v1/files/:file_token/statistics", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.fileStatisticss.service.conf, req) - return result, err -} - -func (fileStatisticss *FileStatisticsService) Get(ctx *core.Context, optFns ...request.OptFn) *FileStatisticsGetReqCall { - return &FileStatisticsGetReqCall{ - ctx: ctx, - fileStatisticss: fileStatisticss, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type PermissionMemberDeleteReqCall struct { - ctx *core.Context - permissionMembers *PermissionMemberService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *PermissionMemberDeleteReqCall) SetToken(token string) { - rc.pathParams["token"] = token -} -func (rc *PermissionMemberDeleteReqCall) SetMemberId(memberId string) { - rc.pathParams["member_id"] = memberId -} -func (rc *PermissionMemberDeleteReqCall) SetType(type_ string) { - rc.queryParams["type"] = type_ -} -func (rc *PermissionMemberDeleteReqCall) SetMemberType(memberType string) { - rc.queryParams["member_type"] = memberType -} - -func (rc *PermissionMemberDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/drive/v1/permissions/:token/members/:member_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.permissionMembers.service.conf, req) - return result, err -} - -func (permissionMembers *PermissionMemberService) Delete(ctx *core.Context, optFns ...request.OptFn) *PermissionMemberDeleteReqCall { - return &PermissionMemberDeleteReqCall{ - ctx: ctx, - permissionMembers: permissionMembers, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type PermissionMemberUpdateReqCall struct { - ctx *core.Context - permissionMembers *PermissionMemberService - body *Member - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *PermissionMemberUpdateReqCall) SetToken(token string) { - rc.pathParams["token"] = token -} -func (rc *PermissionMemberUpdateReqCall) SetMemberId(memberId string) { - rc.pathParams["member_id"] = memberId -} -func (rc *PermissionMemberUpdateReqCall) SetNeedNotification(needNotification bool) { - rc.queryParams["need_notification"] = needNotification -} -func (rc *PermissionMemberUpdateReqCall) SetType(type_ string) { - rc.queryParams["type"] = type_ -} - -func (rc *PermissionMemberUpdateReqCall) Do() (*PermissionMemberUpdateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &PermissionMemberUpdateResult{} - req := request.NewRequest("/open-apis/drive/v1/permissions/:token/members/:member_id", "PUT", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.permissionMembers.service.conf, req) - return result, err -} - -func (permissionMembers *PermissionMemberService) Update(ctx *core.Context, body *Member, optFns ...request.OptFn) *PermissionMemberUpdateReqCall { - return &PermissionMemberUpdateReqCall{ - ctx: ctx, - permissionMembers: permissionMembers, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} diff --git a/service/drive/v1/model.go b/service/drive/v1/model.go deleted file mode 100644 index 14045480..00000000 --- a/service/drive/v1/model.go +++ /dev/null @@ -1,415 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" -) - -type Collaborator struct { - MemberType string `json:"member_type,omitempty"` - MemberOpenId string `json:"member_open_id,omitempty"` - MemberUserId string `json:"member_user_id,omitempty"` - Perm string `json:"perm,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Collaborator) MarshalJSON() ([]byte, error) { - type cp Collaborator - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DocsLink struct { - Url string `json:"url,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DocsLink) MarshalJSON() ([]byte, error) { - type cp DocsLink - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type File struct { - FileToken string `json:"file_token,omitempty"` - FileName string `json:"file_name,omitempty"` - Size int `json:"size,omitempty"` - MimeType string `json:"mime_type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *File) MarshalJSON() ([]byte, error) { - type cp File - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type FileComment struct { - CommentId string `json:"comment_id,omitempty"` - UserId string `json:"user_id,omitempty"` - CreateTime int `json:"create_time,omitempty"` - UpdateTime int `json:"update_time,omitempty"` - IsSolved bool `json:"is_solved,omitempty"` - SolvedTime int `json:"solved_time,omitempty"` - SolverUserId string `json:"solver_user_id,omitempty"` - ReplyList *ReplyList `json:"reply_list,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *FileComment) MarshalJSON() ([]byte, error) { - type cp FileComment - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type FileCommentReply struct { - ReplyId string `json:"reply_id,omitempty"` - UserId string `json:"user_id,omitempty"` - CreateTime int `json:"create_time,omitempty"` - UpdateTime int `json:"update_time,omitempty"` - Content *ReplyContent `json:"content,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *FileCommentReply) MarshalJSON() ([]byte, error) { - type cp FileCommentReply - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Media struct { - FileToken string `json:"file_token,omitempty"` - FileName string `json:"file_name,omitempty"` - Size int `json:"size,omitempty"` - MimeType string `json:"mime_type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Media) MarshalJSON() ([]byte, error) { - type cp Media - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Member struct { - MemberType string `json:"member_type,omitempty"` - MemberId string `json:"member_id,omitempty"` - Perm string `json:"perm,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Member) MarshalJSON() ([]byte, error) { - type cp Member - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Owner struct { - MemberType string `json:"member_type,omitempty"` - MemberId string `json:"member_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Owner) MarshalJSON() ([]byte, error) { - type cp Owner - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Person struct { - UserId string `json:"user_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Person) MarshalJSON() ([]byte, error) { - type cp Person - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ReplyContent struct { - Elements []*ReplyElement `json:"elements,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ReplyContent) MarshalJSON() ([]byte, error) { - type cp ReplyContent - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ReplyElement struct { - Type string `json:"type,omitempty"` - TextRun *TextRun `json:"text_run,omitempty"` - DocsLink *DocsLink `json:"docs_link,omitempty"` - Person *Person `json:"person,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ReplyElement) MarshalJSON() ([]byte, error) { - type cp ReplyElement - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ReplyList struct { - Replies []*FileCommentReply `json:"replies,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ReplyList) MarshalJSON() ([]byte, error) { - type cp ReplyList - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type TextRun struct { - Text string `json:"text,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *TextRun) MarshalJSON() ([]byte, error) { - type cp TextRun - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type TmpDownloadUrl struct { - FileToken string `json:"file_token,omitempty"` - TmpDownloadUrl string `json:"tmp_download_url,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *TmpDownloadUrl) MarshalJSON() ([]byte, error) { - type cp TmpDownloadUrl - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type TokenType struct { - Token string `json:"token,omitempty"` - Type string `json:"type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *TokenType) MarshalJSON() ([]byte, error) { - type cp TokenType - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type FileStatistics struct { - Uv int `json:"uv,omitempty"` - Pv int `json:"pv,omitempty"` - LikeCount int `json:"like_count,omitempty"` - Timestamp int `json:"timestamp,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *FileStatistics) MarshalJSON() ([]byte, error) { - type cp FileStatistics - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type FileUploadInfo struct { - FileName string `json:"file_name,omitempty"` - ParentType string `json:"parent_type,omitempty"` - ParentNode string `json:"parent_node,omitempty"` - Size int `json:"size,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *FileUploadInfo) MarshalJSON() ([]byte, error) { - type cp FileUploadInfo - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ImportTask struct { - Ticket string `json:"ticket,omitempty"` - FileExtension string `json:"file_extension,omitempty"` - FileToken string `json:"file_token,omitempty"` - Type string `json:"type,omitempty"` - FileName string `json:"file_name,omitempty"` - Point *ImportTaskMountPoint `json:"point,omitempty"` - JobStatus int `json:"job_status,omitempty"` - JobErrorMsg string `json:"job_error_msg,omitempty"` - Token string `json:"token,omitempty"` - Url string `json:"url,omitempty"` - Extra []string `json:"extra,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ImportTask) MarshalJSON() ([]byte, error) { - type cp ImportTask - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ImportTaskMountPoint struct { - MountType int `json:"mount_type,omitempty"` - MountKey string `json:"mount_key,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ImportTaskMountPoint) MarshalJSON() ([]byte, error) { - type cp ImportTaskMountPoint - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MediaUploadInfo struct { - FileName string `json:"file_name,omitempty"` - ParentType string `json:"parent_type,omitempty"` - ParentNode string `json:"parent_node,omitempty"` - Size int `json:"size,omitempty"` - Extra string `json:"extra,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MediaUploadInfo) MarshalJSON() ([]byte, error) { - type cp MediaUploadInfo - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type PermissionPublic struct { - ExternalAccess bool `json:"external_access,omitempty"` - SecurityEntity string `json:"security_entity,omitempty"` - CommentEntity string `json:"comment_entity,omitempty"` - ShareEntity string `json:"share_entity,omitempty"` - LinkShareEntity string `json:"link_share_entity,omitempty"` - InviteExternal bool `json:"invite_external,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *PermissionPublic) MarshalJSON() ([]byte, error) { - type cp PermissionPublic - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type UploadInfo struct { - FileName string `json:"file_name,omitempty"` - ParentType string `json:"parent_type,omitempty"` - ParentNode string `json:"parent_node,omitempty"` - Size int `json:"size,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *UploadInfo) MarshalJSON() ([]byte, error) { - type cp UploadInfo - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type FileUploadFinishReqBody struct { - UploadId string `json:"upload_id,omitempty"` - BlockNum int `json:"block_num,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *FileUploadFinishReqBody) MarshalJSON() ([]byte, error) { - type cp FileUploadFinishReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type FileUploadFinishResult struct { - FileToken string `json:"file_token,omitempty"` -} - -type FileUploadPrepareResult struct { - UploadId string `json:"upload_id,omitempty"` - BlockSize int `json:"block_size,omitempty"` - BlockNum int `json:"block_num,omitempty"` -} - -type MediaUploadAllResult struct { - FileToken string `json:"file_token,omitempty"` -} - -type MediaUploadFinishReqBody struct { - UploadId string `json:"upload_id,omitempty"` - BlockNum int `json:"block_num,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MediaUploadFinishReqBody) MarshalJSON() ([]byte, error) { - type cp MediaUploadFinishReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MediaUploadFinishResult struct { - FileToken string `json:"file_token,omitempty"` -} - -type FileUploadAllResult struct { - FileToken string `json:"file_token,omitempty"` -} - -type MediaUploadPrepareResult struct { - UploadId string `json:"upload_id,omitempty"` - BlockSize int `json:"block_size,omitempty"` - BlockNum int `json:"block_num,omitempty"` -} - -type MediaBatchGetTmpDownloadUrlResult struct { - TmpDownloadUrls []*TmpDownloadUrl `json:"tmp_download_urls,omitempty"` -} - -type FileCommentReplyUpdateReqBody struct { - Content *ReplyContent `json:"content,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *FileCommentReplyUpdateReqBody) MarshalJSON() ([]byte, error) { - type cp FileCommentReplyUpdateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type FileCommentListResult struct { - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` - Items []*FileComment `json:"items,omitempty"` -} - -type FileCommentPatchReqBody struct { - IsSolved bool `json:"is_solved,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *FileCommentPatchReqBody) MarshalJSON() ([]byte, error) { - type cp FileCommentPatchReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type PermissionMemberCreateResult struct { - Member *Member `json:"member,omitempty"` -} - -type PermissionPublicPatchResult struct { - PermissionPublic *PermissionPublic `json:"permission_public,omitempty"` -} - -type ImportTaskCreateResult struct { - Ticket string `json:"ticket,omitempty"` -} - -type ImportTaskGetResult struct { - Result *ImportTask `json:"result,omitempty"` -} - -type FileStatisticsGetResult struct { - FileToken string `json:"file_token,omitempty"` - FileType string `json:"file_type,omitempty"` - Statistics *FileStatistics `json:"statistics,omitempty"` -} - -type PermissionMemberUpdateResult struct { - Member *Member `json:"member,omitempty"` -} diff --git a/service/drive_explorer/v2/api.go b/service/drive_explorer/v2/api.go deleted file mode 100644 index 87070cb1..00000000 --- a/service/drive_explorer/v2/api.go +++ /dev/null @@ -1,281 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v2 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - Files *FileService - Folders *FolderService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Files = newFileService(s) - s.Folders = newFolderService(s) - return s -} - -type FileService struct { - service *Service -} - -func newFileService(service *Service) *FileService { - return &FileService{ - service: service, - } -} - -type FolderService struct { - service *Service -} - -func newFolderService(service *Service) *FolderService { - return &FolderService{ - service: service, - } -} - -type FolderChildrenReqCall struct { - ctx *core.Context - folders *FolderService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *FolderChildrenReqCall) SetFolderToken(folderToken string) { - rc.pathParams["folderToken"] = folderToken -} -func (rc *FolderChildrenReqCall) SetTypes(types ...string) { - rc.queryParams["types"] = types -} - -func (rc *FolderChildrenReqCall) Do() (*FolderChildrenResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &FolderChildrenResult{} - req := request.NewRequest("/open-apis/drive/explorer/v2/folder/:folderToken/children", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.folders.service.conf, req) - return result, err -} - -func (folders *FolderService) Children(ctx *core.Context, optFns ...request.OptFn) *FolderChildrenReqCall { - return &FolderChildrenReqCall{ - ctx: ctx, - folders: folders, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type FileCopyReqCall struct { - ctx *core.Context - files *FileService - body *FileCopyReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *FileCopyReqCall) SetFileToken(fileToken string) { - rc.pathParams["fileToken"] = fileToken -} - -func (rc *FileCopyReqCall) Do() (*FileCopyResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &FileCopyResult{} - req := request.NewRequest("/open-apis/drive/explorer/v2/file/copy/files/:fileToken", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.files.service.conf, req) - return result, err -} - -func (files *FileService) Copy(ctx *core.Context, body *FileCopyReqBody, optFns ...request.OptFn) *FileCopyReqCall { - return &FileCopyReqCall{ - ctx: ctx, - files: files, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type FileCreateReqCall struct { - ctx *core.Context - files *FileService - body *FileCreateReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *FileCreateReqCall) SetFolderToken(folderToken string) { - rc.pathParams["folderToken"] = folderToken -} - -func (rc *FileCreateReqCall) Do() (*FileCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &FileCreateResult{} - req := request.NewRequest("/open-apis/drive/explorer/v2/file/:folderToken", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.files.service.conf, req) - return result, err -} - -func (files *FileService) Create(ctx *core.Context, body *FileCreateReqBody, optFns ...request.OptFn) *FileCreateReqCall { - return &FileCreateReqCall{ - ctx: ctx, - files: files, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type FolderCreateReqCall struct { - ctx *core.Context - folders *FolderService - body *FolderCreateReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *FolderCreateReqCall) SetFolderToken(folderToken string) { - rc.pathParams["folderToken"] = folderToken -} - -func (rc *FolderCreateReqCall) Do() (*FolderCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &FolderCreateResult{} - req := request.NewRequest("/open-apis/drive/explorer/v2/folder/:folderToken", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.folders.service.conf, req) - return result, err -} - -func (folders *FolderService) Create(ctx *core.Context, body *FolderCreateReqBody, optFns ...request.OptFn) *FolderCreateReqCall { - return &FolderCreateReqCall{ - ctx: ctx, - folders: folders, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type FileDocsDeleteReqCall struct { - ctx *core.Context - files *FileService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *FileDocsDeleteReqCall) SetDocToken(docToken string) { - rc.pathParams["docToken"] = docToken -} - -func (rc *FileDocsDeleteReqCall) Do() (*FileDocsDeleteResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &FileDocsDeleteResult{} - req := request.NewRequest("/open-apis/drive/explorer/v2/file/docs/:docToken", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.files.service.conf, req) - return result, err -} - -func (files *FileService) DocsDelete(ctx *core.Context, optFns ...request.OptFn) *FileDocsDeleteReqCall { - return &FileDocsDeleteReqCall{ - ctx: ctx, - files: files, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type FolderMetaReqCall struct { - ctx *core.Context - folders *FolderService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *FolderMetaReqCall) SetFolderToken(folderToken string) { - rc.pathParams["folderToken"] = folderToken -} - -func (rc *FolderMetaReqCall) Do() (*FolderMetaResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &FolderMetaResult{} - req := request.NewRequest("/open-apis/drive/explorer/v2/folder/:folderToken/meta", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.folders.service.conf, req) - return result, err -} - -func (folders *FolderService) Meta(ctx *core.Context, optFns ...request.OptFn) *FolderMetaReqCall { - return &FolderMetaReqCall{ - ctx: ctx, - folders: folders, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type FolderRootMetaReqCall struct { - ctx *core.Context - folders *FolderService - optFns []request.OptFn -} - -func (rc *FolderRootMetaReqCall) Do() (*FolderRootMetaResult, error) { - var result = &FolderRootMetaResult{} - req := request.NewRequest("/open-apis/drive/explorer/v2/root_folder/meta", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.folders.service.conf, req) - return result, err -} - -func (folders *FolderService) RootMeta(ctx *core.Context, optFns ...request.OptFn) *FolderRootMetaReqCall { - return &FolderRootMetaReqCall{ - ctx: ctx, - folders: folders, - optFns: optFns, - } -} - -type FileSpreadsheetsDeleteReqCall struct { - ctx *core.Context - files *FileService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *FileSpreadsheetsDeleteReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *FileSpreadsheetsDeleteReqCall) Do() (*FileSpreadsheetsDeleteResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &FileSpreadsheetsDeleteResult{} - req := request.NewRequest("/open-apis/drive/explorer/v2/file/spreadsheets/:spreadsheetToken", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.files.service.conf, req) - return result, err -} - -func (files *FileService) SpreadsheetsDelete(ctx *core.Context, optFns ...request.OptFn) *FileSpreadsheetsDeleteReqCall { - return &FileSpreadsheetsDeleteReqCall{ - ctx: ctx, - files: files, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} diff --git a/service/drive_explorer/v2/model.go b/service/drive_explorer/v2/model.go deleted file mode 100644 index cc3ed6b7..00000000 --- a/service/drive_explorer/v2/model.go +++ /dev/null @@ -1,126 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v2 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" -) - -type Child struct { - Token string `json:"token,omitempty"` - Name string `json:"name,omitempty"` - Type string `json:"type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Child) MarshalJSON() ([]byte, error) { - type cp Child - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type File struct { -} - -type Folder struct { -} - -type OperatorId struct { - OpenId string `json:"open_id,omitempty"` - UnionId string `json:"union_id,omitempty"` - UserId string `json:"user_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *OperatorId) MarshalJSON() ([]byte, error) { - type cp OperatorId - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type FolderChildrenResult struct { - ParentToken string `json:"parentToken,omitempty"` - Children map[string]*Child `json:"children,omitempty"` -} - -type FileCopyReqBody struct { - Type string `json:"type,omitempty"` - DstFolderToken string `json:"dstFolderToken,omitempty"` - DstName string `json:"dstName,omitempty"` - CommentNeeded bool `json:"commentNeeded,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *FileCopyReqBody) MarshalJSON() ([]byte, error) { - type cp FileCopyReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type FileCopyResult struct { - FolderToken string `json:"folderToken,omitempty"` - Revision int `json:"revision,omitempty"` - Token string `json:"token,omitempty"` - Type string `json:"type,omitempty"` - Url string `json:"url,omitempty"` -} - -type FileCreateReqBody struct { - Title string `json:"title,omitempty"` - Type string `json:"type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *FileCreateReqBody) MarshalJSON() ([]byte, error) { - type cp FileCreateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type FileCreateResult struct { - Url string `json:"url,omitempty"` - Revision int `json:"revision,omitempty"` - Token string `json:"token,omitempty"` -} - -type FolderCreateReqBody struct { - Title string `json:"title,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *FolderCreateReqBody) MarshalJSON() ([]byte, error) { - type cp FolderCreateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type FolderCreateResult struct { - Url string `json:"url,omitempty"` - Revision int `json:"revision,omitempty"` - Token string `json:"token,omitempty"` -} - -type FileDocsDeleteResult struct { - Id string `json:"id,omitempty"` - Result bool `json:"result,omitempty"` -} - -type FolderMetaResult struct { - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Token string `json:"token,omitempty"` - CreateUid string `json:"createUid,omitempty"` - EditUid string `json:"editUid,omitempty"` - ParentId string `json:"parentId,omitempty"` - OwnUid string `json:"ownUid,omitempty"` -} - -type FolderRootMetaResult struct { - Token string `json:"token,omitempty"` - Id string `json:"id,omitempty"` - UserId string `json:"user_id,omitempty"` -} - -type FileSpreadsheetsDeleteResult struct { - Id string `json:"id,omitempty"` - Result bool `json:"result,omitempty"` -} diff --git a/service/drive_permission/v1/api.go b/service/drive_permission/v1/api.go deleted file mode 100644 index ac3b4393..00000000 --- a/service/drive_permission/v1/api.go +++ /dev/null @@ -1,212 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - Members *MemberService - Publics *PublicService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Members = newMemberService(s) - s.Publics = newPublicService(s) - return s -} - -type MemberService struct { - service *Service -} - -func newMemberService(service *Service) *MemberService { - return &MemberService{ - service: service, - } -} - -type PublicService struct { - service *Service -} - -func newPublicService(service *Service) *PublicService { - return &PublicService{ - service: service, - } -} - -type MemberCreateReqCall struct { - ctx *core.Context - members *MemberService - body *MemberCreateReqBody - optFns []request.OptFn -} - -func (rc *MemberCreateReqCall) Do() (*MemberCreateResult, error) { - var result = &MemberCreateResult{} - req := request.NewRequest("/open-apis/drive/permission/member/create", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.members.service.conf, req) - return result, err -} - -func (members *MemberService) Create(ctx *core.Context, body *MemberCreateReqBody, optFns ...request.OptFn) *MemberCreateReqCall { - return &MemberCreateReqCall{ - ctx: ctx, - members: members, - body: body, - optFns: optFns, - } -} - -type MemberDeleteReqCall struct { - ctx *core.Context - members *MemberService - body *MemberDeleteReqBody - optFns []request.OptFn -} - -func (rc *MemberDeleteReqCall) Do() (*MemberDeleteResult, error) { - var result = &MemberDeleteResult{} - req := request.NewRequest("/open-apis/drive/permission/member/delete", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.members.service.conf, req) - return result, err -} - -func (members *MemberService) Delete(ctx *core.Context, body *MemberDeleteReqBody, optFns ...request.OptFn) *MemberDeleteReqCall { - return &MemberDeleteReqCall{ - ctx: ctx, - members: members, - body: body, - optFns: optFns, - } -} - -type MemberListReqCall struct { - ctx *core.Context - members *MemberService - body *MemberListReqBody - optFns []request.OptFn -} - -func (rc *MemberListReqCall) Do() (*MemberListResult, error) { - var result = &MemberListResult{} - req := request.NewRequest("/open-apis/drive/permission/member/list", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.members.service.conf, req) - return result, err -} - -func (members *MemberService) List(ctx *core.Context, body *MemberListReqBody, optFns ...request.OptFn) *MemberListReqCall { - return &MemberListReqCall{ - ctx: ctx, - members: members, - body: body, - optFns: optFns, - } -} - -type MemberPermittedReqCall struct { - ctx *core.Context - members *MemberService - body *MemberPermittedReqBody - optFns []request.OptFn -} - -func (rc *MemberPermittedReqCall) Do() (*MemberPermittedResult, error) { - var result = &MemberPermittedResult{} - req := request.NewRequest("/open-apis/drive/permission/member/permitted", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.members.service.conf, req) - return result, err -} - -func (members *MemberService) Permitted(ctx *core.Context, body *MemberPermittedReqBody, optFns ...request.OptFn) *MemberPermittedReqCall { - return &MemberPermittedReqCall{ - ctx: ctx, - members: members, - body: body, - optFns: optFns, - } -} - -type MemberTransferReqCall struct { - ctx *core.Context - members *MemberService - body *MemberTransferReqBody - optFns []request.OptFn -} - -func (rc *MemberTransferReqCall) Do() (*MemberTransferResult, error) { - var result = &MemberTransferResult{} - req := request.NewRequest("/open-apis/drive/permission/member/transfer", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.members.service.conf, req) - return result, err -} - -func (members *MemberService) Transfer(ctx *core.Context, body *MemberTransferReqBody, optFns ...request.OptFn) *MemberTransferReqCall { - return &MemberTransferReqCall{ - ctx: ctx, - members: members, - body: body, - optFns: optFns, - } -} - -type PublicUpdateReqCall struct { - ctx *core.Context - publics *PublicService - body *PublicUpdateReqBody - optFns []request.OptFn -} - -func (rc *PublicUpdateReqCall) Do() (*PublicUpdateResult, error) { - var result = &PublicUpdateResult{} - req := request.NewRequest("/open-apis/drive/permission/public/update", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.publics.service.conf, req) - return result, err -} - -func (publics *PublicService) Update(ctx *core.Context, body *PublicUpdateReqBody, optFns ...request.OptFn) *PublicUpdateReqCall { - return &PublicUpdateReqCall{ - ctx: ctx, - publics: publics, - body: body, - optFns: optFns, - } -} - -type MemberUpdateReqCall struct { - ctx *core.Context - members *MemberService - body *MemberUpdateReqBody - optFns []request.OptFn -} - -func (rc *MemberUpdateReqCall) Do() (*MemberUpdateResult, error) { - var result = &MemberUpdateResult{} - req := request.NewRequest("/open-apis/drive/permission/member/update", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.members.service.conf, req) - return result, err -} - -func (members *MemberService) Update(ctx *core.Context, body *MemberUpdateReqBody, optFns ...request.OptFn) *MemberUpdateReqCall { - return &MemberUpdateReqCall{ - ctx: ctx, - members: members, - body: body, - optFns: optFns, - } -} diff --git a/service/drive_permission/v1/model.go b/service/drive_permission/v1/model.go deleted file mode 100644 index a26c3ebd..00000000 --- a/service/drive_permission/v1/model.go +++ /dev/null @@ -1,182 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" -) - -type Collaborator struct { - MemberType string `json:"member_type,omitempty"` - MemberOpenId string `json:"member_open_id,omitempty"` - MemberUserId string `json:"member_user_id,omitempty"` - Perm string `json:"perm,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Collaborator) MarshalJSON() ([]byte, error) { - type cp Collaborator - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Member struct { - MemberType string `json:"member_type,omitempty"` - MemberId string `json:"member_id,omitempty"` - Perm string `json:"perm,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Member) MarshalJSON() ([]byte, error) { - type cp Member - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Owner struct { - MemberType string `json:"member_type,omitempty"` - MemberId string `json:"member_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Owner) MarshalJSON() ([]byte, error) { - type cp Owner - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Public struct { -} - -type MemberCreateReqBody struct { - Token string `json:"token,omitempty"` - Type string `json:"type,omitempty"` - Members []*Member `json:"members,omitempty"` - NotifyLark bool `json:"notify_lark,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MemberCreateReqBody) MarshalJSON() ([]byte, error) { - type cp MemberCreateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MemberCreateResult struct { - IsAllSuccess bool `json:"is_all_success,omitempty"` - FailMembers []*Member `json:"fail_members,omitempty"` -} - -type MemberDeleteReqBody struct { - Token string `json:"token,omitempty"` - Type string `json:"type,omitempty"` - MemberType string `json:"member_type,omitempty"` - MemberId string `json:"member_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MemberDeleteReqBody) MarshalJSON() ([]byte, error) { - type cp MemberDeleteReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MemberDeleteResult struct { - IsSuccess bool `json:"is_success,omitempty"` -} - -type MemberListReqBody struct { - Token string `json:"token,omitempty"` - Type string `json:"type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MemberListReqBody) MarshalJSON() ([]byte, error) { - type cp MemberListReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MemberListResult struct { - Members []*Collaborator `json:"members,omitempty"` -} - -type MemberPermittedReqBody struct { - Token string `json:"token,omitempty"` - Type string `json:"type,omitempty"` - Perm string `json:"perm,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MemberPermittedReqBody) MarshalJSON() ([]byte, error) { - type cp MemberPermittedReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MemberPermittedResult struct { - IsPermitted bool `json:"is_permitted,omitempty"` -} - -type MemberTransferReqBody struct { - Token string `json:"token,omitempty"` - Type string `json:"type,omitempty"` - Owner *Owner `json:"owner,omitempty"` - RemoveOldOwner bool `json:"remove_old_owner,omitempty"` - CancelNotify bool `json:"cancel_notify,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MemberTransferReqBody) MarshalJSON() ([]byte, error) { - type cp MemberTransferReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MemberTransferResult struct { - IsSuccess bool `json:"is_success,omitempty"` - Type string `json:"type,omitempty"` - Token string `json:"token,omitempty"` - Owner *Owner `json:"owner,omitempty"` -} - -type PublicUpdateReqBody struct { - Token string `json:"token,omitempty"` - Type string `json:"type,omitempty"` - CopyPrintExportStatus bool `json:"copy_print_export_status,omitempty"` - Comment bool `json:"comment,omitempty"` - TenantShareable bool `json:"tenant_shareable,omitempty"` - LinkShareEntity string `json:"link_share_entity,omitempty"` - ExternalAccess bool `json:"external_access,omitempty"` - InviteExternal bool `json:"invite_external,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *PublicUpdateReqBody) MarshalJSON() ([]byte, error) { - type cp PublicUpdateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type PublicUpdateResult struct { - IsSuccess bool `json:"is_success,omitempty"` -} - -type MemberUpdateReqBody struct { - Token string `json:"token,omitempty"` - Type string `json:"type,omitempty"` - MemberType string `json:"member_type,omitempty"` - MemberId string `json:"member_id,omitempty"` - Perm string `json:"perm,omitempty"` - NotifyLark bool `json:"notify_lark,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MemberUpdateReqBody) MarshalJSON() ([]byte, error) { - type cp MemberUpdateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MemberUpdateResult struct { - IsSuccess bool `json:"is_success,omitempty"` -} diff --git a/service/drive_permission/v2/api.go b/service/drive_permission/v2/api.go deleted file mode 100644 index e04e93b4..00000000 --- a/service/drive_permission/v2/api.go +++ /dev/null @@ -1,81 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v2 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - Publics *PublicService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Publics = newPublicService(s) - return s -} - -type PublicService struct { - service *Service -} - -func newPublicService(service *Service) *PublicService { - return &PublicService{ - service: service, - } -} - -type PublicGetReqCall struct { - ctx *core.Context - publics *PublicService - body *PublicGetReqBody - optFns []request.OptFn -} - -func (rc *PublicGetReqCall) Do() (*PublicGetResult, error) { - var result = &PublicGetResult{} - req := request.NewRequest("/open-apis/drive/permission/v2/public", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.publics.service.conf, req) - return result, err -} - -func (publics *PublicService) Get(ctx *core.Context, body *PublicGetReqBody, optFns ...request.OptFn) *PublicGetReqCall { - return &PublicGetReqCall{ - ctx: ctx, - publics: publics, - body: body, - optFns: optFns, - } -} - -type PublicUpdateReqCall struct { - ctx *core.Context - publics *PublicService - body *PublicUpdateReqBody - optFns []request.OptFn -} - -func (rc *PublicUpdateReqCall) Do() (*response.NoData, error) { - var result = &response.NoData{} - req := request.NewRequest("/open-apis/drive/permission/v2/public/update", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.publics.service.conf, req) - return result, err -} - -func (publics *PublicService) Update(ctx *core.Context, body *PublicUpdateReqBody, optFns ...request.OptFn) *PublicUpdateReqCall { - return &PublicUpdateReqCall{ - ctx: ctx, - publics: publics, - body: body, - optFns: optFns, - } -} diff --git a/service/drive_permission/v2/model.go b/service/drive_permission/v2/model.go deleted file mode 100644 index 7dc1d2eb..00000000 --- a/service/drive_permission/v2/model.go +++ /dev/null @@ -1,49 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v2 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" -) - -type Public struct { -} - -type PublicGetReqBody struct { - Token string `json:"token,omitempty"` - Type string `json:"type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *PublicGetReqBody) MarshalJSON() ([]byte, error) { - type cp PublicGetReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type PublicGetResult struct { - SecurityEntity string `json:"security_entity,omitempty"` - CommentEntity string `json:"comment_entity,omitempty"` - ShareEntity string `json:"share_entity,omitempty"` - LinkShareEntity string `json:"link_share_entity,omitempty"` - ExternalAccess bool `json:"external_access,omitempty"` - InviteExternal bool `json:"invite_external,omitempty"` - PermissionVerision string `json:"permission_verision,omitempty"` -} - -type PublicUpdateReqBody struct { - Token string `json:"token,omitempty"` - Type string `json:"type,omitempty"` - SecurityEntity string `json:"security_entity,omitempty"` - CommentEntity string `json:"comment_entity,omitempty"` - ShareEntity string `json:"share_entity,omitempty"` - LinkShareEntity string `json:"link_share_entity,omitempty"` - ExternalAccess bool `json:"external_access,omitempty"` - InviteExternal bool `json:"invite_external,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *PublicUpdateReqBody) MarshalJSON() ([]byte, error) { - type cp PublicUpdateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} diff --git a/service/ehr/v1/api.go b/service/ehr/v1/api.go deleted file mode 100644 index e78bda2e..00000000 --- a/service/ehr/v1/api.go +++ /dev/null @@ -1,131 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" - "io" -) - -type Service struct { - conf *config.Config - Attachments *AttachmentService - Employees *EmployeeService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Attachments = newAttachmentService(s) - s.Employees = newEmployeeService(s) - return s -} - -type AttachmentService struct { - service *Service -} - -func newAttachmentService(service *Service) *AttachmentService { - return &AttachmentService{ - service: service, - } -} - -type EmployeeService struct { - service *Service -} - -func newEmployeeService(service *Service) *EmployeeService { - return &EmployeeService{ - service: service, - } -} - -type AttachmentGetReqCall struct { - ctx *core.Context - attachments *AttachmentService - pathParams map[string]interface{} - optFns []request.OptFn - result io.Writer -} - -func (rc *AttachmentGetReqCall) SetToken(token string) { - rc.pathParams["token"] = token -} -func (rc *AttachmentGetReqCall) SetResponseStream(result io.Writer) { - rc.result = result -} - -func (rc *AttachmentGetReqCall) Do() (io.Writer, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetResponseStream()) - req := request.NewRequest("/open-apis/ehr/v1/attachments/:token", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, rc.result, rc.optFns...) - err := api.Send(rc.ctx, rc.attachments.service.conf, req) - return rc.result, err -} - -func (attachments *AttachmentService) Get(ctx *core.Context, optFns ...request.OptFn) *AttachmentGetReqCall { - return &AttachmentGetReqCall{ - ctx: ctx, - attachments: attachments, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type EmployeeListReqCall struct { - ctx *core.Context - employees *EmployeeService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *EmployeeListReqCall) SetView(view string) { - rc.queryParams["view"] = view -} -func (rc *EmployeeListReqCall) SetStatus(status ...int) { - rc.queryParams["status"] = status -} -func (rc *EmployeeListReqCall) SetType(type_ ...int) { - rc.queryParams["type"] = type_ -} -func (rc *EmployeeListReqCall) SetStartTime(startTime int64) { - rc.queryParams["start_time"] = startTime -} -func (rc *EmployeeListReqCall) SetEndTime(endTime int64) { - rc.queryParams["end_time"] = endTime -} -func (rc *EmployeeListReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *EmployeeListReqCall) SetUserIds(userIds string) { - rc.queryParams["user_ids"] = userIds -} -func (rc *EmployeeListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *EmployeeListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *EmployeeListReqCall) Do() (*EmployeeListResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &EmployeeListResult{} - req := request.NewRequest("/open-apis/ehr/v1/employees", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.employees.service.conf, req) - return result, err -} - -func (employees *EmployeeService) List(ctx *core.Context, optFns ...request.OptFn) *EmployeeListReqCall { - return &EmployeeListReqCall{ - ctx: ctx, - employees: employees, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} diff --git a/service/ehr/v1/model.go b/service/ehr/v1/model.go deleted file mode 100644 index 55be54a1..00000000 --- a/service/ehr/v1/model.go +++ /dev/null @@ -1,242 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" -) - -type Attachment struct { - Id string `json:"id,omitempty"` - MimeType string `json:"mime_type,omitempty"` - Name string `json:"name,omitempty"` - Size int64 `json:"size,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Attachment) MarshalJSON() ([]byte, error) { - type cp Attachment - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ContractCompany struct { - Id int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ContractCompany) MarshalJSON() ([]byte, error) { - type cp ContractCompany - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type CustomFields struct { - Key string `json:"key,omitempty"` - Label string `json:"label,omitempty"` - Type string `json:"type,omitempty"` - Value string `json:"value,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *CustomFields) MarshalJSON() ([]byte, error) { - type cp CustomFields - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Education struct { - Level int `json:"level,omitempty"` - School string `json:"school,omitempty"` - Major string `json:"major,omitempty"` - Degree int `json:"degree,omitempty"` - Start string `json:"start,omitempty"` - End string `json:"end,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Education) MarshalJSON() ([]byte, error) { - type cp Education - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type EmergencyContact struct { - Name string `json:"name,omitempty"` - Relationship int `json:"relationship,omitempty"` - Mobile string `json:"mobile,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *EmergencyContact) MarshalJSON() ([]byte, error) { - type cp EmergencyContact - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Employee struct { - UserId string `json:"user_id,omitempty"` - SystemFields *SystemFields `json:"system_fields,omitempty"` - CustomFields []*CustomFields `json:"custom_fields,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Employee) MarshalJSON() ([]byte, error) { - type cp Employee - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Job struct { - Id int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Job) MarshalJSON() ([]byte, error) { - type cp Job - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type JobLevel struct { - Id int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *JobLevel) MarshalJSON() ([]byte, error) { - type cp JobLevel - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Manager struct { - UserId string `json:"user_id,omitempty"` - Name string `json:"name,omitempty"` - EnName string `json:"en_name,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Manager) MarshalJSON() ([]byte, error) { - type cp Manager - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type NativeRegion struct { - IsoCode string `json:"iso_code,omitempty"` - Name string `json:"name,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *NativeRegion) MarshalJSON() ([]byte, error) { - type cp NativeRegion - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SystemFields struct { - Name string `json:"name,omitempty"` - EnName string `json:"en_name,omitempty"` - Email string `json:"email,omitempty"` - Mobile string `json:"mobile,omitempty"` - DepartmentId string `json:"department_id,omitempty"` - Manager *Manager `json:"manager,omitempty"` - Job *Job `json:"job,omitempty"` - JobLevel *JobLevel `json:"job_level,omitempty"` - WorkLocation *WorkLocation `json:"work_location,omitempty"` - Gender int `json:"gender,omitempty"` - Birthday string `json:"birthday,omitempty"` - NativeRegion *NativeRegion `json:"native_region,omitempty"` - Ethnicity int `json:"ethnicity,omitempty"` - MaritalStatus int `json:"marital_status,omitempty"` - PoliticalStatus int `json:"political_status,omitempty"` - EnteredWorkforceDate string `json:"entered_workforce_date,omitempty"` - IdType int `json:"id_type,omitempty"` - IdNumber string `json:"id_number,omitempty"` - HukouType int `json:"hukou_type,omitempty"` - HukouLocation string `json:"hukou_location,omitempty"` - BankAccountNumber string `json:"bank_account_number,omitempty"` - BankName string `json:"bank_name,omitempty"` - SocialSecurityAccount string `json:"social_security_account,omitempty"` - ProvidentFundAccount string `json:"provident_fund_account,omitempty"` - EmployeeNo string `json:"employee_no,omitempty"` - EmployeeType int `json:"employee_type,omitempty"` - Status int `json:"status,omitempty"` - HireDate string `json:"hire_date,omitempty"` - ProbationMonths float64 `json:"probation_months,omitempty"` - ConversionDate string `json:"conversion_date,omitempty"` - Application int `json:"application,omitempty"` - ApplicationStatus int `json:"application_status,omitempty"` - LastDay string `json:"last_day,omitempty"` - DepartureType int `json:"departure_type,omitempty"` - DepartureReason int `json:"departure_reason,omitempty"` - DepartureNotes string `json:"departure_notes,omitempty"` - ContractCompany *ContractCompany `json:"contract_company,omitempty"` - ContractType int `json:"contract_type,omitempty"` - ContractStartDate string `json:"contract_start_date,omitempty"` - ContractExpirationDate string `json:"contract_expiration_date,omitempty"` - ContractSignTimes int `json:"contract_sign_times,omitempty"` - PersonalEmail string `json:"personal_email,omitempty"` - FamilyAddress string `json:"family_address,omitempty"` - PrimaryEmergencyContact *EmergencyContact `json:"primary_emergency_contact,omitempty"` - EmergencyContact []*EmergencyContact `json:"emergency_contact,omitempty"` - HighestLevelOfEdu *Education `json:"highest_level_of_edu,omitempty"` - Education []*Education `json:"education,omitempty"` - FormerWorkExp *WorkExperience `json:"former_work_exp,omitempty"` - WorkExp []*WorkExperience `json:"work_exp,omitempty"` - IdPhotoPoSide []*Attachment `json:"id_photo_po_side,omitempty"` - IdPhotoEmSide []*Attachment `json:"id_photo_em_side,omitempty"` - IdPhoto []*Attachment `json:"id_photo,omitempty"` - DiplomaPhoto []*Attachment `json:"diploma_photo,omitempty"` - GraduationCert []*Attachment `json:"graduation_cert,omitempty"` - CertOfMerit []*Attachment `json:"cert_of_merit,omitempty"` - OffboardingFile []*Attachment `json:"offboarding_file,omitempty"` - CancelOnboardingReason int `json:"cancel_onboarding_reason,omitempty"` - CancelOnboardingNotes string `json:"cancel_onboarding_notes,omitempty"` - EmployeeFormStatus int `json:"employee_form_status,omitempty"` - CreateTime int64 `json:"create_time,omitempty"` - UpdateTime int64 `json:"update_time,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SystemFields) MarshalJSON() ([]byte, error) { - type cp SystemFields - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type WorkExperience struct { - Company string `json:"company,omitempty"` - Department string `json:"department,omitempty"` - Job string `json:"job,omitempty"` - Start string `json:"start,omitempty"` - End string `json:"end,omitempty"` - Description string `json:"description,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *WorkExperience) MarshalJSON() ([]byte, error) { - type cp WorkExperience - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type WorkLocation struct { - Id int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *WorkLocation) MarshalJSON() ([]byte, error) { - type cp WorkLocation - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type EmployeeListResult struct { - Items []*Employee `json:"items,omitempty"` - PageToken string `json:"page_token,omitempty"` - HasMore bool `json:"has_more,omitempty"` -} diff --git a/service/face_verify/v1/api.go b/service/face_verify/v1/api.go deleted file mode 100644 index 7e716da3..00000000 --- a/service/face_verify/v1/api.go +++ /dev/null @@ -1,20 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - return s -} diff --git a/service/face_verify/v1/model.go b/service/face_verify/v1/model.go deleted file mode 100644 index 81de7b08..00000000 --- a/service/face_verify/v1/model.go +++ /dev/null @@ -1,2 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 diff --git a/service/human_authentication/v1/api.go b/service/human_authentication/v1/api.go deleted file mode 100644 index a4bfcab4..00000000 --- a/service/human_authentication/v1/api.go +++ /dev/null @@ -1,66 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - Identitys *IdentityService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Identitys = newIdentityService(s) - return s -} - -type IdentityService struct { - service *Service -} - -func newIdentityService(service *Service) *IdentityService { - return &IdentityService{ - service: service, - } -} - -type IdentityCreateReqCall struct { - ctx *core.Context - identitys *IdentityService - body *IdentityCreateReqBody - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *IdentityCreateReqCall) SetUserId(userId string) { - rc.queryParams["user_id"] = userId -} -func (rc *IdentityCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *IdentityCreateReqCall) Do() (*IdentityCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &IdentityCreateResult{} - req := request.NewRequest("/open-apis/human_authentication/v1/identities", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.identitys.service.conf, req) - return result, err -} - -func (identitys *IdentityService) Create(ctx *core.Context, body *IdentityCreateReqBody, optFns ...request.OptFn) *IdentityCreateReqCall { - return &IdentityCreateReqCall{ - ctx: ctx, - identitys: identitys, - body: body, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} diff --git a/service/human_authentication/v1/model.go b/service/human_authentication/v1/model.go deleted file mode 100644 index d0a0ce1c..00000000 --- a/service/human_authentication/v1/model.go +++ /dev/null @@ -1,36 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" -) - -type Identity struct { - IdentityName string `json:"identity_name,omitempty"` - IdentityCode string `json:"identity_code,omitempty"` - Mobile string `json:"mobile,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Identity) MarshalJSON() ([]byte, error) { - type cp Identity - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type IdentityCreateReqBody struct { - IdentityName string `json:"identity_name,omitempty"` - IdentityCode string `json:"identity_code,omitempty"` - Mobile string `json:"mobile,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *IdentityCreateReqBody) MarshalJSON() ([]byte, error) { - type cp IdentityCreateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type IdentityCreateResult struct { - VerifyUid string `json:"verify_uid,omitempty"` -} diff --git a/service/im/v1/api.go b/service/im/v1/api.go deleted file mode 100644 index 5d8b9f74..00000000 --- a/service/im/v1/api.go +++ /dev/null @@ -1,986 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" - "io" -) - -type Service struct { - conf *config.Config - Messages *MessageService - Chats *ChatService - ChatMemberUsers *ChatMemberUserService - ChatMemberBots *ChatMemberBotService - ChatAnnouncements *ChatAnnouncementService - ChatMemberss *ChatMembersService - Files *FileService - Images *ImageService - MessageResources *MessageResourceService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Messages = newMessageService(s) - s.Chats = newChatService(s) - s.ChatMemberUsers = newChatMemberUserService(s) - s.ChatMemberBots = newChatMemberBotService(s) - s.ChatAnnouncements = newChatAnnouncementService(s) - s.ChatMemberss = newChatMembersService(s) - s.Files = newFileService(s) - s.Images = newImageService(s) - s.MessageResources = newMessageResourceService(s) - return s -} - -type MessageService struct { - service *Service -} - -func newMessageService(service *Service) *MessageService { - return &MessageService{ - service: service, - } -} - -type ChatService struct { - service *Service -} - -func newChatService(service *Service) *ChatService { - return &ChatService{ - service: service, - } -} - -type ChatMemberUserService struct { - service *Service -} - -func newChatMemberUserService(service *Service) *ChatMemberUserService { - return &ChatMemberUserService{ - service: service, - } -} - -type ChatMemberBotService struct { - service *Service -} - -func newChatMemberBotService(service *Service) *ChatMemberBotService { - return &ChatMemberBotService{ - service: service, - } -} - -type ChatAnnouncementService struct { - service *Service -} - -func newChatAnnouncementService(service *Service) *ChatAnnouncementService { - return &ChatAnnouncementService{ - service: service, - } -} - -type ChatMembersService struct { - service *Service -} - -func newChatMembersService(service *Service) *ChatMembersService { - return &ChatMembersService{ - service: service, - } -} - -type FileService struct { - service *Service -} - -func newFileService(service *Service) *FileService { - return &FileService{ - service: service, - } -} - -type ImageService struct { - service *Service -} - -func newImageService(service *Service) *ImageService { - return &ImageService{ - service: service, - } -} - -type MessageResourceService struct { - service *Service -} - -func newMessageResourceService(service *Service) *MessageResourceService { - return &MessageResourceService{ - service: service, - } -} - -type MessageListReqCall struct { - ctx *core.Context - messages *MessageService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MessageListReqCall) SetContainerIdType(containerIdType string) { - rc.queryParams["container_id_type"] = containerIdType -} -func (rc *MessageListReqCall) SetContainerId(containerId string) { - rc.queryParams["container_id"] = containerId -} -func (rc *MessageListReqCall) SetStartTime(startTime string) { - rc.queryParams["start_time"] = startTime -} -func (rc *MessageListReqCall) SetEndTime(endTime string) { - rc.queryParams["end_time"] = endTime -} -func (rc *MessageListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *MessageListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *MessageListReqCall) Do() (*MessageListResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &MessageListResult{} - req := request.NewRequest("/open-apis/im/v1/messages", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.messages.service.conf, req) - return result, err -} - -func (messages *MessageService) List(ctx *core.Context, optFns ...request.OptFn) *MessageListReqCall { - return &MessageListReqCall{ - ctx: ctx, - messages: messages, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MessagePatchReqCall struct { - ctx *core.Context - messages *MessageService - body *MessagePatchReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MessagePatchReqCall) SetMessageId(messageId string) { - rc.pathParams["message_id"] = messageId -} - -func (rc *MessagePatchReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/im/v1/messages/:message_id", "PATCH", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.messages.service.conf, req) - return result, err -} - -func (messages *MessageService) Patch(ctx *core.Context, body *MessagePatchReqBody, optFns ...request.OptFn) *MessagePatchReqCall { - return &MessagePatchReqCall{ - ctx: ctx, - messages: messages, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MessageReplyReqCall struct { - ctx *core.Context - messages *MessageService - body *MessageReplyReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MessageReplyReqCall) SetMessageId(messageId string) { - rc.pathParams["message_id"] = messageId -} - -func (rc *MessageReplyReqCall) Do() (*Message, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &Message{} - req := request.NewRequest("/open-apis/im/v1/messages/:message_id/reply", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.messages.service.conf, req) - return result, err -} - -func (messages *MessageService) Reply(ctx *core.Context, body *MessageReplyReqBody, optFns ...request.OptFn) *MessageReplyReqCall { - return &MessageReplyReqCall{ - ctx: ctx, - messages: messages, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MessageCreateReqCall struct { - ctx *core.Context - messages *MessageService - body *MessageCreateReqBody - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MessageCreateReqCall) SetReceiveIdType(receiveIdType string) { - rc.queryParams["receive_id_type"] = receiveIdType -} - -func (rc *MessageCreateReqCall) Do() (*Message, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &Message{} - req := request.NewRequest("/open-apis/im/v1/messages", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.messages.service.conf, req) - return result, err -} - -func (messages *MessageService) Create(ctx *core.Context, body *MessageCreateReqBody, optFns ...request.OptFn) *MessageCreateReqCall { - return &MessageCreateReqCall{ - ctx: ctx, - messages: messages, - body: body, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MessageDeleteReqCall struct { - ctx *core.Context - messages *MessageService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MessageDeleteReqCall) SetMessageId(messageId string) { - rc.pathParams["message_id"] = messageId -} - -func (rc *MessageDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/im/v1/messages/:message_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.messages.service.conf, req) - return result, err -} - -func (messages *MessageService) Delete(ctx *core.Context, optFns ...request.OptFn) *MessageDeleteReqCall { - return &MessageDeleteReqCall{ - ctx: ctx, - messages: messages, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MessageReadUsersReqCall struct { - ctx *core.Context - messages *MessageService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MessageReadUsersReqCall) SetMessageId(messageId string) { - rc.pathParams["message_id"] = messageId -} -func (rc *MessageReadUsersReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *MessageReadUsersReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} -func (rc *MessageReadUsersReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} - -func (rc *MessageReadUsersReqCall) Do() (*MessageReadUsersResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &MessageReadUsersResult{} - req := request.NewRequest("/open-apis/im/v1/messages/:message_id/read_users", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.messages.service.conf, req) - return result, err -} - -func (messages *MessageService) ReadUsers(ctx *core.Context, optFns ...request.OptFn) *MessageReadUsersReqCall { - return &MessageReadUsersReqCall{ - ctx: ctx, - messages: messages, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ChatUpdateReqCall struct { - ctx *core.Context - chats *ChatService - body *ChatUpdateReqBody - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ChatUpdateReqCall) SetChatId(chatId string) { - rc.pathParams["chat_id"] = chatId -} -func (rc *ChatUpdateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *ChatUpdateReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/im/v1/chats/:chat_id", "PUT", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.chats.service.conf, req) - return result, err -} - -func (chats *ChatService) Update(ctx *core.Context, body *ChatUpdateReqBody, optFns ...request.OptFn) *ChatUpdateReqCall { - return &ChatUpdateReqCall{ - ctx: ctx, - chats: chats, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type FileCreateReqCall struct { - ctx *core.Context - files *FileService - body *request.FormData - optFns []request.OptFn -} - -func (rc *FileCreateReqCall) SetFileType(fileType string) { - rc.body.AddParam("file_type", fileType) -} -func (rc *FileCreateReqCall) SetFileName(fileName string) { - rc.body.AddParam("file_name", fileName) -} -func (rc *FileCreateReqCall) SetDuration(duration int) { - rc.body.AddParam("duration", duration) -} -func (rc *FileCreateReqCall) SetFile(file *request.File) { - rc.body.AddFile("file", file) -} - -func (rc *FileCreateReqCall) Do() (*FileCreateResult, error) { - var result = &FileCreateResult{} - req := request.NewRequest("/open-apis/im/v1/files", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.files.service.conf, req) - return result, err -} - -func (files *FileService) Create(ctx *core.Context, optFns ...request.OptFn) *FileCreateReqCall { - return &FileCreateReqCall{ - ctx: ctx, - files: files, - body: request.NewFormData(), - optFns: optFns, - } -} - -type FileGetReqCall struct { - ctx *core.Context - files *FileService - pathParams map[string]interface{} - optFns []request.OptFn - result io.Writer -} - -func (rc *FileGetReqCall) SetFileKey(fileKey string) { - rc.pathParams["file_key"] = fileKey -} -func (rc *FileGetReqCall) SetResponseStream(result io.Writer) { - rc.result = result -} - -func (rc *FileGetReqCall) Do() (io.Writer, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetResponseStream()) - req := request.NewRequest("/open-apis/im/v1/files/:file_key", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, rc.result, rc.optFns...) - err := api.Send(rc.ctx, rc.files.service.conf, req) - return rc.result, err -} - -func (files *FileService) Get(ctx *core.Context, optFns ...request.OptFn) *FileGetReqCall { - return &FileGetReqCall{ - ctx: ctx, - files: files, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ChatListReqCall struct { - ctx *core.Context - chats *ChatService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ChatListReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *ChatListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *ChatListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *ChatListReqCall) Do() (*ChatListResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &ChatListResult{} - req := request.NewRequest("/open-apis/im/v1/chats", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.chats.service.conf, req) - return result, err -} - -func (chats *ChatService) List(ctx *core.Context, optFns ...request.OptFn) *ChatListReqCall { - return &ChatListReqCall{ - ctx: ctx, - chats: chats, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ImageCreateReqCall struct { - ctx *core.Context - images *ImageService - body *request.FormData - optFns []request.OptFn -} - -func (rc *ImageCreateReqCall) SetImageType(imageType string) { - rc.body.AddParam("image_type", imageType) -} -func (rc *ImageCreateReqCall) SetImage(image *request.File) { - rc.body.AddFile("image", image) -} - -func (rc *ImageCreateReqCall) Do() (*ImageCreateResult, error) { - var result = &ImageCreateResult{} - req := request.NewRequest("/open-apis/im/v1/images", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.images.service.conf, req) - return result, err -} - -func (images *ImageService) Create(ctx *core.Context, optFns ...request.OptFn) *ImageCreateReqCall { - return &ImageCreateReqCall{ - ctx: ctx, - images: images, - body: request.NewFormData(), - optFns: optFns, - } -} - -type ChatDeleteReqCall struct { - ctx *core.Context - chats *ChatService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ChatDeleteReqCall) SetChatId(chatId string) { - rc.pathParams["chat_id"] = chatId -} - -func (rc *ChatDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/im/v1/chats/:chat_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.chats.service.conf, req) - return result, err -} - -func (chats *ChatService) Delete(ctx *core.Context, optFns ...request.OptFn) *ChatDeleteReqCall { - return &ChatDeleteReqCall{ - ctx: ctx, - chats: chats, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ImageGetReqCall struct { - ctx *core.Context - images *ImageService - pathParams map[string]interface{} - optFns []request.OptFn - result io.Writer -} - -func (rc *ImageGetReqCall) SetImageKey(imageKey string) { - rc.pathParams["image_key"] = imageKey -} -func (rc *ImageGetReqCall) SetResponseStream(result io.Writer) { - rc.result = result -} - -func (rc *ImageGetReqCall) Do() (io.Writer, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetResponseStream()) - req := request.NewRequest("/open-apis/im/v1/images/:image_key", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, rc.result, rc.optFns...) - err := api.Send(rc.ctx, rc.images.service.conf, req) - return rc.result, err -} - -func (images *ImageService) Get(ctx *core.Context, optFns ...request.OptFn) *ImageGetReqCall { - return &ImageGetReqCall{ - ctx: ctx, - images: images, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ChatGetReqCall struct { - ctx *core.Context - chats *ChatService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ChatGetReqCall) SetChatId(chatId string) { - rc.pathParams["chat_id"] = chatId -} -func (rc *ChatGetReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *ChatGetReqCall) Do() (*ChatGetResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &ChatGetResult{} - req := request.NewRequest("/open-apis/im/v1/chats/:chat_id", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.chats.service.conf, req) - return result, err -} - -func (chats *ChatService) Get(ctx *core.Context, optFns ...request.OptFn) *ChatGetReqCall { - return &ChatGetReqCall{ - ctx: ctx, - chats: chats, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ChatCreateReqCall struct { - ctx *core.Context - chats *ChatService - body *ChatCreateReqBody - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ChatCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *ChatCreateReqCall) Do() (*ChatCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &ChatCreateResult{} - req := request.NewRequest("/open-apis/im/v1/chats", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.chats.service.conf, req) - return result, err -} - -func (chats *ChatService) Create(ctx *core.Context, body *ChatCreateReqBody, optFns ...request.OptFn) *ChatCreateReqCall { - return &ChatCreateReqCall{ - ctx: ctx, - chats: chats, - body: body, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ChatSearchReqCall struct { - ctx *core.Context - chats *ChatService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ChatSearchReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *ChatSearchReqCall) SetQuery(query string) { - rc.queryParams["query"] = query -} -func (rc *ChatSearchReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *ChatSearchReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *ChatSearchReqCall) Do() (*ChatSearchResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &ChatSearchResult{} - req := request.NewRequest("/open-apis/im/v1/chats/search", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.chats.service.conf, req) - return result, err -} - -func (chats *ChatService) Search(ctx *core.Context, optFns ...request.OptFn) *ChatSearchReqCall { - return &ChatSearchReqCall{ - ctx: ctx, - chats: chats, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MessageGetReqCall struct { - ctx *core.Context - messages *MessageService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MessageGetReqCall) SetMessageId(messageId string) { - rc.pathParams["message_id"] = messageId -} - -func (rc *MessageGetReqCall) Do() (*MessageGetResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &MessageGetResult{} - req := request.NewRequest("/open-apis/im/v1/messages/:message_id", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.messages.service.conf, req) - return result, err -} - -func (messages *MessageService) Get(ctx *core.Context, optFns ...request.OptFn) *MessageGetReqCall { - return &MessageGetReqCall{ - ctx: ctx, - messages: messages, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ChatMembersCreateReqCall struct { - ctx *core.Context - chatMemberss *ChatMembersService - body *ChatMembersCreateReqBody - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ChatMembersCreateReqCall) SetChatId(chatId string) { - rc.pathParams["chat_id"] = chatId -} -func (rc *ChatMembersCreateReqCall) SetMemberIdType(memberIdType string) { - rc.queryParams["member_id_type"] = memberIdType -} - -func (rc *ChatMembersCreateReqCall) Do() (*ChatMembersCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &ChatMembersCreateResult{} - req := request.NewRequest("/open-apis/im/v1/chats/:chat_id/members", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.chatMemberss.service.conf, req) - return result, err -} - -func (chatMemberss *ChatMembersService) Create(ctx *core.Context, body *ChatMembersCreateReqBody, optFns ...request.OptFn) *ChatMembersCreateReqCall { - return &ChatMembersCreateReqCall{ - ctx: ctx, - chatMemberss: chatMemberss, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ChatMembersDeleteReqCall struct { - ctx *core.Context - chatMemberss *ChatMembersService - body *ChatMembersDeleteReqBody - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ChatMembersDeleteReqCall) SetChatId(chatId string) { - rc.pathParams["chat_id"] = chatId -} -func (rc *ChatMembersDeleteReqCall) SetMemberIdType(memberIdType string) { - rc.queryParams["member_id_type"] = memberIdType -} - -func (rc *ChatMembersDeleteReqCall) Do() (*ChatMembersDeleteResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &ChatMembersDeleteResult{} - req := request.NewRequest("/open-apis/im/v1/chats/:chat_id/members", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.chatMemberss.service.conf, req) - return result, err -} - -func (chatMemberss *ChatMembersService) Delete(ctx *core.Context, body *ChatMembersDeleteReqBody, optFns ...request.OptFn) *ChatMembersDeleteReqCall { - return &ChatMembersDeleteReqCall{ - ctx: ctx, - chatMemberss: chatMemberss, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MessageResourceGetReqCall struct { - ctx *core.Context - messageResources *MessageResourceService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn - result io.Writer -} - -func (rc *MessageResourceGetReqCall) SetMessageId(messageId string) { - rc.pathParams["message_id"] = messageId -} -func (rc *MessageResourceGetReqCall) SetFileKey(fileKey string) { - rc.pathParams["file_key"] = fileKey -} -func (rc *MessageResourceGetReqCall) SetType(type_ string) { - rc.queryParams["type"] = type_ -} -func (rc *MessageResourceGetReqCall) SetResponseStream(result io.Writer) { - rc.result = result -} - -func (rc *MessageResourceGetReqCall) Do() (io.Writer, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - rc.optFns = append(rc.optFns, request.SetResponseStream()) - req := request.NewRequest("/open-apis/im/v1/messages/:message_id/resources/:file_key", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, rc.result, rc.optFns...) - err := api.Send(rc.ctx, rc.messageResources.service.conf, req) - return rc.result, err -} - -func (messageResources *MessageResourceService) Get(ctx *core.Context, optFns ...request.OptFn) *MessageResourceGetReqCall { - return &MessageResourceGetReqCall{ - ctx: ctx, - messageResources: messageResources, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ChatMembersGetReqCall struct { - ctx *core.Context - chatMemberss *ChatMembersService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ChatMembersGetReqCall) SetChatId(chatId string) { - rc.pathParams["chat_id"] = chatId -} -func (rc *ChatMembersGetReqCall) SetMemberIdType(memberIdType string) { - rc.queryParams["member_id_type"] = memberIdType -} -func (rc *ChatMembersGetReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *ChatMembersGetReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *ChatMembersGetReqCall) Do() (*ChatMembersGetResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &ChatMembersGetResult{} - req := request.NewRequest("/open-apis/im/v1/chats/:chat_id/members", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.chatMemberss.service.conf, req) - return result, err -} - -func (chatMemberss *ChatMembersService) Get(ctx *core.Context, optFns ...request.OptFn) *ChatMembersGetReqCall { - return &ChatMembersGetReqCall{ - ctx: ctx, - chatMemberss: chatMemberss, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ChatAnnouncementGetReqCall struct { - ctx *core.Context - chatAnnouncements *ChatAnnouncementService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ChatAnnouncementGetReqCall) SetChatId(chatId string) { - rc.pathParams["chat_id"] = chatId -} -func (rc *ChatAnnouncementGetReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *ChatAnnouncementGetReqCall) Do() (*ChatAnnouncementGetResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &ChatAnnouncementGetResult{} - req := request.NewRequest("/open-apis/im/v1/chats/:chat_id/announcement", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.chatAnnouncements.service.conf, req) - return result, err -} - -func (chatAnnouncements *ChatAnnouncementService) Get(ctx *core.Context, optFns ...request.OptFn) *ChatAnnouncementGetReqCall { - return &ChatAnnouncementGetReqCall{ - ctx: ctx, - chatAnnouncements: chatAnnouncements, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ChatMembersIsInChatReqCall struct { - ctx *core.Context - chatMemberss *ChatMembersService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ChatMembersIsInChatReqCall) SetChatId(chatId string) { - rc.pathParams["chat_id"] = chatId -} - -func (rc *ChatMembersIsInChatReqCall) Do() (*ChatMembersIsInChatResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &ChatMembersIsInChatResult{} - req := request.NewRequest("/open-apis/im/v1/chats/:chat_id/members/is_in_chat", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.chatMemberss.service.conf, req) - return result, err -} - -func (chatMemberss *ChatMembersService) IsInChat(ctx *core.Context, optFns ...request.OptFn) *ChatMembersIsInChatReqCall { - return &ChatMembersIsInChatReqCall{ - ctx: ctx, - chatMemberss: chatMemberss, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ChatMembersMeJoinReqCall struct { - ctx *core.Context - chatMemberss *ChatMembersService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ChatMembersMeJoinReqCall) SetChatId(chatId string) { - rc.pathParams["chat_id"] = chatId -} - -func (rc *ChatMembersMeJoinReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/im/v1/chats/:chat_id/members/me_join", "PATCH", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.chatMemberss.service.conf, req) - return result, err -} - -func (chatMemberss *ChatMembersService) MeJoin(ctx *core.Context, optFns ...request.OptFn) *ChatMembersMeJoinReqCall { - return &ChatMembersMeJoinReqCall{ - ctx: ctx, - chatMemberss: chatMemberss, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ChatAnnouncementPatchReqCall struct { - ctx *core.Context - chatAnnouncements *ChatAnnouncementService - body *ChatAnnouncementPatchReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ChatAnnouncementPatchReqCall) SetChatId(chatId string) { - rc.pathParams["chat_id"] = chatId -} - -func (rc *ChatAnnouncementPatchReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/im/v1/chats/:chat_id/announcement", "PATCH", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.chatAnnouncements.service.conf, req) - return result, err -} - -func (chatAnnouncements *ChatAnnouncementService) Patch(ctx *core.Context, body *ChatAnnouncementPatchReqBody, optFns ...request.OptFn) *ChatAnnouncementPatchReqCall { - return &ChatAnnouncementPatchReqCall{ - ctx: ctx, - chatAnnouncements: chatAnnouncements, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} diff --git a/service/im/v1/event.go b/service/im/v1/event.go deleted file mode 100644 index 4fa40162..00000000 --- a/service/im/v1/event.go +++ /dev/null @@ -1,152 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" - "github.com/larksuite/oapi-sdk-go/event" -) - -type MessageReceiveEventHandler struct { - Fn func(*core.Context, *MessageReceiveEvent) error -} - -func (h *MessageReceiveEventHandler) GetEvent() interface{} { - return &MessageReceiveEvent{} -} - -func (h *MessageReceiveEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*MessageReceiveEvent)) -} - -func SetMessageReceiveEventHandler(conf *config.Config, fn func(ctx *core.Context, event *MessageReceiveEvent) error) { - event.SetTypeHandler(conf, "im.message.receive_v1", &MessageReceiveEventHandler{Fn: fn}) -} - -type ChatUpdatedEventHandler struct { - Fn func(*core.Context, *ChatUpdatedEvent) error -} - -func (h *ChatUpdatedEventHandler) GetEvent() interface{} { - return &ChatUpdatedEvent{} -} - -func (h *ChatUpdatedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*ChatUpdatedEvent)) -} - -func SetChatUpdatedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *ChatUpdatedEvent) error) { - event.SetTypeHandler(conf, "im.chat.updated_v1", &ChatUpdatedEventHandler{Fn: fn}) -} - -type ChatDisbandedEventHandler struct { - Fn func(*core.Context, *ChatDisbandedEvent) error -} - -func (h *ChatDisbandedEventHandler) GetEvent() interface{} { - return &ChatDisbandedEvent{} -} - -func (h *ChatDisbandedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*ChatDisbandedEvent)) -} - -func SetChatDisbandedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *ChatDisbandedEvent) error) { - event.SetTypeHandler(conf, "im.chat.disbanded_v1", &ChatDisbandedEventHandler{Fn: fn}) -} - -type ChatMemberBotAddedEventHandler struct { - Fn func(*core.Context, *ChatMemberBotAddedEvent) error -} - -func (h *ChatMemberBotAddedEventHandler) GetEvent() interface{} { - return &ChatMemberBotAddedEvent{} -} - -func (h *ChatMemberBotAddedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*ChatMemberBotAddedEvent)) -} - -func SetChatMemberBotAddedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *ChatMemberBotAddedEvent) error) { - event.SetTypeHandler(conf, "im.chat.member.bot.added_v1", &ChatMemberBotAddedEventHandler{Fn: fn}) -} - -type ChatMemberUserAddedEventHandler struct { - Fn func(*core.Context, *ChatMemberUserAddedEvent) error -} - -func (h *ChatMemberUserAddedEventHandler) GetEvent() interface{} { - return &ChatMemberUserAddedEvent{} -} - -func (h *ChatMemberUserAddedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*ChatMemberUserAddedEvent)) -} - -func SetChatMemberUserAddedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *ChatMemberUserAddedEvent) error) { - event.SetTypeHandler(conf, "im.chat.member.user.added_v1", &ChatMemberUserAddedEventHandler{Fn: fn}) -} - -type ChatMemberBotDeletedEventHandler struct { - Fn func(*core.Context, *ChatMemberBotDeletedEvent) error -} - -func (h *ChatMemberBotDeletedEventHandler) GetEvent() interface{} { - return &ChatMemberBotDeletedEvent{} -} - -func (h *ChatMemberBotDeletedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*ChatMemberBotDeletedEvent)) -} - -func SetChatMemberBotDeletedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *ChatMemberBotDeletedEvent) error) { - event.SetTypeHandler(conf, "im.chat.member.bot.deleted_v1", &ChatMemberBotDeletedEventHandler{Fn: fn}) -} - -type ChatMemberUserWithdrawnEventHandler struct { - Fn func(*core.Context, *ChatMemberUserWithdrawnEvent) error -} - -func (h *ChatMemberUserWithdrawnEventHandler) GetEvent() interface{} { - return &ChatMemberUserWithdrawnEvent{} -} - -func (h *ChatMemberUserWithdrawnEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*ChatMemberUserWithdrawnEvent)) -} - -func SetChatMemberUserWithdrawnEventHandler(conf *config.Config, fn func(ctx *core.Context, event *ChatMemberUserWithdrawnEvent) error) { - event.SetTypeHandler(conf, "im.chat.member.user.withdrawn_v1", &ChatMemberUserWithdrawnEventHandler{Fn: fn}) -} - -type ChatMemberUserDeletedEventHandler struct { - Fn func(*core.Context, *ChatMemberUserDeletedEvent) error -} - -func (h *ChatMemberUserDeletedEventHandler) GetEvent() interface{} { - return &ChatMemberUserDeletedEvent{} -} - -func (h *ChatMemberUserDeletedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*ChatMemberUserDeletedEvent)) -} - -func SetChatMemberUserDeletedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *ChatMemberUserDeletedEvent) error) { - event.SetTypeHandler(conf, "im.chat.member.user.deleted_v1", &ChatMemberUserDeletedEventHandler{Fn: fn}) -} - -type MessageMessageReadEventHandler struct { - Fn func(*core.Context, *MessageMessageReadEvent) error -} - -func (h *MessageMessageReadEventHandler) GetEvent() interface{} { - return &MessageMessageReadEvent{} -} - -func (h *MessageMessageReadEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*MessageMessageReadEvent)) -} - -func SetMessageMessageReadEventHandler(conf *config.Config, fn func(ctx *core.Context, event *MessageMessageReadEvent) error) { - event.SetTypeHandler(conf, "im.message.message_read_v1", &MessageMessageReadEventHandler{Fn: fn}) -} diff --git a/service/im/v1/model.go b/service/im/v1/model.go deleted file mode 100644 index 91790c5b..00000000 --- a/service/im/v1/model.go +++ /dev/null @@ -1,727 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" - "github.com/larksuite/oapi-sdk-go/event/core/model" -) - -type UserId struct { - UserId string `json:"user_id,omitempty"` - OpenId string `json:"open_id,omitempty"` - UnionId string `json:"union_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *UserId) MarshalJSON() ([]byte, error) { - type cp UserId - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ChatAnnouncement struct { -} - -type ChatMember struct { - UserId string `json:"user_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ChatMember) MarshalJSON() ([]byte, error) { - type cp ChatMember - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ChatMemberBot struct { - BotId string `json:"bot_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ChatMemberBot) MarshalJSON() ([]byte, error) { - type cp ChatMemberBot - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ChatMembers struct { - UserId string `json:"user_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ChatMembers) MarshalJSON() ([]byte, error) { - type cp ChatMembers - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type EventMessage struct { - MessageId string `json:"message_id,omitempty"` - RootId string `json:"root_id,omitempty"` - ParentId string `json:"parent_id,omitempty"` - CreateTime int64 `json:"create_time,omitempty,string"` - ChatId string `json:"chat_id,omitempty"` - ChatType string `json:"chat_type,omitempty"` - MessageType string `json:"message_type,omitempty"` - Content string `json:"content,omitempty"` - Mentions []*MentionEvent `json:"mentions,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *EventMessage) MarshalJSON() ([]byte, error) { - type cp EventMessage - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type File struct { -} - -type I18nNames struct { - ZhCn string `json:"zh_cn,omitempty"` - EnUs string `json:"en_us,omitempty"` - JaJp string `json:"ja_jp,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *I18nNames) MarshalJSON() ([]byte, error) { - type cp I18nNames - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Image struct { -} - -type Message struct { - MessageId string `json:"message_id,omitempty"` - RootId string `json:"root_id,omitempty"` - ParentId string `json:"parent_id,omitempty"` - MsgType string `json:"msg_type,omitempty"` - CreateTime int64 `json:"create_time,omitempty,string"` - UpdateTime int64 `json:"update_time,omitempty,string"` - Deleted bool `json:"deleted,omitempty"` - Updated bool `json:"updated,omitempty"` - ChatId string `json:"chat_id,omitempty"` - Sender *Sender `json:"sender,omitempty"` - Body *MessageBody `json:"body,omitempty"` - Mentions []*Mention `json:"mentions,omitempty"` - UpperMessageId string `json:"upper_message_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Message) MarshalJSON() ([]byte, error) { - type cp Message - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MessageResource struct { -} - -type MessageBody struct { - Content string `json:"content,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MessageBody) MarshalJSON() ([]byte, error) { - type cp MessageBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ModeratorList struct { - AddedMemberList []*ListEventModerator `json:"added_member_list,omitempty"` - RemovedMemberList []*ListEventModerator `json:"removed_member_list,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ModeratorList) MarshalJSON() ([]byte, error) { - type cp ModeratorList - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type UrgentReceivers struct { - UserIdList []string `json:"user_id_list,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *UrgentReceivers) MarshalJSON() ([]byte, error) { - type cp UrgentReceivers - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Chat struct { - ChatId string `json:"chat_id,omitempty"` - Avatar string `json:"avatar,omitempty"` - Name string `json:"name,omitempty"` - Description string `json:"description,omitempty"` - I18nNames *I18nNames `json:"i18n_names,omitempty"` - OnlyOwnerAdd bool `json:"only_owner_add,omitempty"` - ShareAllowed bool `json:"share_allowed,omitempty"` - OnlyOwnerAtAll bool `json:"only_owner_at_all,omitempty"` - OnlyOwnerEdit bool `json:"only_owner_edit,omitempty"` - OwnerUserId string `json:"owner_user_id,omitempty"` - Type string `json:"type,omitempty"` - - ForceSendFields []string `json:"-"` -} - -func (s *Chat) MarshalJSON() ([]byte, error) { - type cp Chat - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ChatMemberUser struct { - Name string `json:"name,omitempty"` - TenantKey string `json:"tenant_key,omitempty"` - UserId *UserId `json:"user_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ChatMemberUser) MarshalJSON() ([]byte, error) { - type cp ChatMemberUser - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ChatChange struct { - Avatar string `json:"avatar,omitempty"` - Name string `json:"name,omitempty"` - Description string `json:"description,omitempty"` - I18nNames *I18nNames `json:"i18n_names,omitempty"` - AddMemberPermission string `json:"add_member_permission,omitempty"` - ShareCardPermission string `json:"share_card_permission,omitempty"` - AtAllPermission string `json:"at_all_permission,omitempty"` - EditPermission string `json:"edit_permission,omitempty"` - MembershipApproval string `json:"membership_approval,omitempty"` - JoinMessageVisibility string `json:"join_message_visibility,omitempty"` - LeaveMessageVisibility string `json:"leave_message_visibility,omitempty"` - ModerationPermission string `json:"moderation_permission,omitempty"` - OwnerId *UserId `json:"owner_id,omitempty"` - - ForceSendFields []string `json:"-"` -} - -func (s *ChatChange) MarshalJSON() ([]byte, error) { - type cp ChatChange - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Emoji struct { - EmojiType string `json:"emoji_type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Emoji) MarshalJSON() ([]byte, error) { - type cp Emoji - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type EventMessageReader struct { - ReaderId *UserId `json:"reader_id,omitempty"` - ReadTime string `json:"read_time,omitempty"` - TenantKey string `json:"tenant_key,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *EventMessageReader) MarshalJSON() ([]byte, error) { - type cp EventMessageReader - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type EventSender struct { - SenderId *UserId `json:"sender_id,omitempty"` - SenderType string `json:"sender_type,omitempty"` - TenantKey string `json:"tenant_key,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *EventSender) MarshalJSON() ([]byte, error) { - type cp EventSender - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ListChat struct { - ChatId string `json:"chat_id,omitempty"` - Avatar string `json:"avatar,omitempty"` - Name string `json:"name,omitempty"` - Description string `json:"description,omitempty"` - OwnerId string `json:"owner_id,omitempty"` - OwnerIdType string `json:"owner_id_type,omitempty"` - External bool `json:"external,omitempty"` - TenantKey string `json:"tenant_key,omitempty"` - - ForceSendFields []string `json:"-"` -} - -func (s *ListChat) MarshalJSON() ([]byte, error) { - type cp ListChat - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ListEventModerator struct { - TenantKey string `json:"tenant_key,omitempty"` - UserId *UserId `json:"user_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ListEventModerator) MarshalJSON() ([]byte, error) { - type cp ListEventModerator - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ListMember struct { - MemberIdType string `json:"member_id_type,omitempty"` - MemberId string `json:"member_id,omitempty"` - Name string `json:"name,omitempty"` - TenantKey string `json:"tenant_key,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ListMember) MarshalJSON() ([]byte, error) { - type cp ListMember - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ListModerator struct { - UserIdType string `json:"user_id_type,omitempty"` - UserId string `json:"user_id,omitempty"` - TenantKey string `json:"tenant_key,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ListModerator) MarshalJSON() ([]byte, error) { - type cp ListModerator - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Mention struct { - Key string `json:"key,omitempty"` - Id string `json:"id,omitempty"` - IdType string `json:"id_type,omitempty"` - Name string `json:"name,omitempty"` - TenantKey string `json:"tenant_key,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Mention) MarshalJSON() ([]byte, error) { - type cp Mention - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MentionEvent struct { - Key string `json:"key,omitempty"` - Id *UserId `json:"id,omitempty"` - Name string `json:"name,omitempty"` - TenantKey string `json:"tenant_key,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MentionEvent) MarshalJSON() ([]byte, error) { - type cp MentionEvent - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MessageReaction struct { - ReactionId string `json:"reaction_id,omitempty"` - Operator *Operator `json:"operator,omitempty"` - ActionTime string `json:"action_time,omitempty"` - ReactionType *Emoji `json:"reaction_type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MessageReaction) MarshalJSON() ([]byte, error) { - type cp MessageReaction - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Operator struct { - OperatorId string `json:"operator_id,omitempty"` - OperatorType string `json:"operator_type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Operator) MarshalJSON() ([]byte, error) { - type cp Operator - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ReadUser struct { - UserIdType string `json:"user_id_type,omitempty"` - UserId string `json:"user_id,omitempty"` - Timestamp string `json:"timestamp,omitempty"` - TenantKey string `json:"tenant_key,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ReadUser) MarshalJSON() ([]byte, error) { - type cp ReadUser - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Sender struct { - Id string `json:"id,omitempty"` - IdType string `json:"id_type,omitempty"` - SenderType string `json:"sender_type,omitempty"` - TenantKey string `json:"tenant_key,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Sender) MarshalJSON() ([]byte, error) { - type cp Sender - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MessageListResult struct { - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` - Items []*Message `json:"items,omitempty"` -} - -type MessagePatchReqBody struct { - Content string `json:"content,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MessagePatchReqBody) MarshalJSON() ([]byte, error) { - type cp MessagePatchReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MessageReplyReqBody struct { - Content string `json:"content,omitempty"` - MsgType string `json:"msg_type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MessageReplyReqBody) MarshalJSON() ([]byte, error) { - type cp MessageReplyReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MessageCreateReqBody struct { - ReceiveId string `json:"receive_id,omitempty"` - Content string `json:"content,omitempty"` - MsgType string `json:"msg_type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MessageCreateReqBody) MarshalJSON() ([]byte, error) { - type cp MessageCreateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MessageReadUsersResult struct { - Items []*ReadUser `json:"items,omitempty"` - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` -} - -type ChatUpdateReqBody struct { - Avatar string `json:"avatar,omitempty"` - Name string `json:"name,omitempty"` - Description string `json:"description,omitempty"` - I18nNames *I18nNames `json:"i18n_names,omitempty"` - AddMemberPermission string `json:"add_member_permission,omitempty"` - ShareCardPermission string `json:"share_card_permission,omitempty"` - AtAllPermission string `json:"at_all_permission,omitempty"` - EditPermission string `json:"edit_permission,omitempty"` - OwnerId string `json:"owner_id,omitempty"` - JoinMessageVisibility string `json:"join_message_visibility,omitempty"` - LeaveMessageVisibility string `json:"leave_message_visibility,omitempty"` - MembershipApproval string `json:"membership_approval,omitempty"` - - ForceSendFields []string `json:"-"` -} - -func (s *ChatUpdateReqBody) MarshalJSON() ([]byte, error) { - type cp ChatUpdateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type FileCreateResult struct { - FileKey string `json:"file_key,omitempty"` -} - -type ChatListResult struct { - Items []*ListChat `json:"items,omitempty"` - PageToken string `json:"page_token,omitempty"` - HasMore bool `json:"has_more,omitempty"` -} - -type ImageCreateResult struct { - ImageKey string `json:"image_key,omitempty"` -} - -type ChatGetResult struct { - Avatar string `json:"avatar,omitempty"` - Name string `json:"name,omitempty"` - Description string `json:"description,omitempty"` - I18nNames *I18nNames `json:"i18n_names,omitempty"` - AddMemberPermission string `json:"add_member_permission,omitempty"` - ShareCardPermission string `json:"share_card_permission,omitempty"` - AtAllPermission string `json:"at_all_permission,omitempty"` - EditPermission string `json:"edit_permission,omitempty"` - OwnerIdType string `json:"owner_id_type,omitempty"` - OwnerId string `json:"owner_id,omitempty"` - ChatMode string `json:"chat_mode,omitempty"` - ChatType string `json:"chat_type,omitempty"` - ChatTag string `json:"chat_tag,omitempty"` - JoinMessageVisibility string `json:"join_message_visibility,omitempty"` - LeaveMessageVisibility string `json:"leave_message_visibility,omitempty"` - MembershipApproval string `json:"membership_approval,omitempty"` - ModerationPermission string `json:"moderation_permission,omitempty"` - External bool `json:"external,omitempty"` - TenantKey string `json:"tenant_key,omitempty"` -} - -type ChatCreateReqBody struct { - Avatar string `json:"avatar,omitempty"` - Name string `json:"name,omitempty"` - Description string `json:"description,omitempty"` - I18nNames *I18nNames `json:"i18n_names,omitempty"` - OwnerId string `json:"owner_id,omitempty"` - ChatMode string `json:"chat_mode,omitempty"` - ChatType string `json:"chat_type,omitempty"` - External bool `json:"external,omitempty"` - JoinMessageVisibility string `json:"join_message_visibility,omitempty"` - LeaveMessageVisibility string `json:"leave_message_visibility,omitempty"` - MembershipApproval string `json:"membership_approval,omitempty"` - - ForceSendFields []string `json:"-"` -} - -func (s *ChatCreateReqBody) MarshalJSON() ([]byte, error) { - type cp ChatCreateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ChatCreateResult struct { - ChatId string `json:"chat_id,omitempty"` - Avatar string `json:"avatar,omitempty"` - Name string `json:"name,omitempty"` - Description string `json:"description,omitempty"` - I18nNames *I18nNames `json:"i18n_names,omitempty"` - OwnerId string `json:"owner_id,omitempty"` - OwnerIdType string `json:"owner_id_type,omitempty"` - AddMemberPermission string `json:"add_member_permission,omitempty"` - ShareCardPermission string `json:"share_card_permission,omitempty"` - AtAllPermission string `json:"at_all_permission,omitempty"` - EditPermission string `json:"edit_permission,omitempty"` - ChatMode string `json:"chat_mode,omitempty"` - ChatType string `json:"chat_type,omitempty"` - ChatTag string `json:"chat_tag,omitempty"` - External bool `json:"external,omitempty"` - TenantKey string `json:"tenant_key,omitempty"` - JoinMessageVisibility string `json:"join_message_visibility,omitempty"` - LeaveMessageVisibility string `json:"leave_message_visibility,omitempty"` - MembershipApproval string `json:"membership_approval,omitempty"` - ModerationPermission string `json:"moderation_permission,omitempty"` -} - -type ChatSearchResult struct { - Items []*ListChat `json:"items,omitempty"` - PageToken string `json:"page_token,omitempty"` - HasMore bool `json:"has_more,omitempty"` -} - -type MessageGetResult struct { - Items []*Message `json:"items,omitempty"` -} - -type ChatMembersCreateReqBody struct { - IdList []string `json:"id_list,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ChatMembersCreateReqBody) MarshalJSON() ([]byte, error) { - type cp ChatMembersCreateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ChatMembersCreateResult struct { - InvalidIdList []string `json:"invalid_id_list,omitempty"` -} - -type ChatMembersDeleteReqBody struct { - IdList []string `json:"id_list,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ChatMembersDeleteReqBody) MarshalJSON() ([]byte, error) { - type cp ChatMembersDeleteReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ChatMembersDeleteResult struct { - InvalidIdList []string `json:"invalid_id_list,omitempty"` -} - -type ChatMembersGetResult struct { - Items []*ListMember `json:"items,omitempty"` - PageToken string `json:"page_token,omitempty"` - HasMore bool `json:"has_more,omitempty"` - MemberTotal int `json:"member_total,omitempty"` -} - -type ChatAnnouncementGetResult struct { - Content string `json:"content,omitempty"` - Revision string `json:"revision,omitempty"` - CreateTime string `json:"create_time,omitempty"` - UpdateTime string `json:"update_time,omitempty"` - OwnerIdType string `json:"owner_id_type,omitempty"` - OwnerId string `json:"owner_id,omitempty"` - ModifierIdType string `json:"modifier_id_type,omitempty"` - ModifierId string `json:"modifier_id,omitempty"` -} - -type ChatMembersIsInChatResult struct { - IsInChat bool `json:"is_in_chat,omitempty"` -} - -type ChatAnnouncementPatchReqBody struct { - Revision string `json:"revision,omitempty"` - Requests []string `json:"requests,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ChatAnnouncementPatchReqBody) MarshalJSON() ([]byte, error) { - type cp ChatAnnouncementPatchReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MessageReceiveEventData struct { - Sender *EventSender `json:"sender,omitempty"` - Message *EventMessage `json:"message,omitempty"` -} - -type MessageReceiveEvent struct { - *model.BaseEventV2 - Event *MessageReceiveEventData `json:"event"` -} - -type ChatUpdatedEventData struct { - ChatId string `json:"chat_id,omitempty"` - OperatorId *UserId `json:"operator_id,omitempty"` - External bool `json:"external,omitempty"` - OperatorTenantKey string `json:"operator_tenant_key,omitempty"` - AfterChange *ChatChange `json:"after_change,omitempty"` - BeforeChange *ChatChange `json:"before_change,omitempty"` - ModeratorList *ModeratorList `json:"moderator_list,omitempty"` -} - -type ChatUpdatedEvent struct { - *model.BaseEventV2 - Event *ChatUpdatedEventData `json:"event"` -} - -type ChatDisbandedEventData struct { - ChatId string `json:"chat_id,omitempty"` - OperatorId *UserId `json:"operator_id,omitempty"` - External bool `json:"external,omitempty"` - OperatorTenantKey string `json:"operator_tenant_key,omitempty"` -} - -type ChatDisbandedEvent struct { - *model.BaseEventV2 - Event *ChatDisbandedEventData `json:"event"` -} - -type ChatMemberBotAddedEventData struct { - ChatId string `json:"chat_id,omitempty"` - OperatorId *UserId `json:"operator_id,omitempty"` - External bool `json:"external,omitempty"` - OperatorTenantKey string `json:"operator_tenant_key,omitempty"` -} - -type ChatMemberBotAddedEvent struct { - *model.BaseEventV2 - Event *ChatMemberBotAddedEventData `json:"event"` -} - -type ChatMemberUserAddedEventData struct { - ChatId string `json:"chat_id,omitempty"` - OperatorId *UserId `json:"operator_id,omitempty"` - External bool `json:"external,omitempty"` - OperatorTenantKey string `json:"operator_tenant_key,omitempty"` - Users []*ChatMemberUser `json:"users,omitempty"` -} - -type ChatMemberUserAddedEvent struct { - *model.BaseEventV2 - Event *ChatMemberUserAddedEventData `json:"event"` -} - -type ChatMemberBotDeletedEventData struct { - ChatId string `json:"chat_id,omitempty"` - OperatorId *UserId `json:"operator_id,omitempty"` - External bool `json:"external,omitempty"` - OperatorTenantKey string `json:"operator_tenant_key,omitempty"` -} - -type ChatMemberBotDeletedEvent struct { - *model.BaseEventV2 - Event *ChatMemberBotDeletedEventData `json:"event"` -} - -type ChatMemberUserWithdrawnEventData struct { - ChatId string `json:"chat_id,omitempty"` - OperatorId *UserId `json:"operator_id,omitempty"` - External bool `json:"external,omitempty"` - OperatorTenantKey string `json:"operator_tenant_key,omitempty"` - Users []*ChatMemberUser `json:"users,omitempty"` -} - -type ChatMemberUserWithdrawnEvent struct { - *model.BaseEventV2 - Event *ChatMemberUserWithdrawnEventData `json:"event"` -} - -type ChatMemberUserDeletedEventData struct { - ChatId string `json:"chat_id,omitempty"` - OperatorId *UserId `json:"operator_id,omitempty"` - External bool `json:"external,omitempty"` - OperatorTenantKey string `json:"operator_tenant_key,omitempty"` - Users []*ChatMemberUser `json:"users,omitempty"` -} - -type ChatMemberUserDeletedEvent struct { - *model.BaseEventV2 - Event *ChatMemberUserDeletedEventData `json:"event"` -} - -type MessageMessageReadEventData struct { - Reader *EventMessageReader `json:"reader,omitempty"` - MessageIdList []string `json:"message_id_list,omitempty"` -} - -type MessageMessageReadEvent struct { - *model.BaseEventV2 - Event *MessageMessageReadEventData `json:"event"` -} diff --git a/service/image/v4/api.go b/service/image/v4/api.go deleted file mode 100644 index 8fb98eb1..00000000 --- a/service/image/v4/api.go +++ /dev/null @@ -1,97 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v4 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" - "io" -) - -type Service struct { - conf *config.Config - Images *ImageService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Images = newImageService(s) - return s -} - -type ImageService struct { - service *Service -} - -func newImageService(service *Service) *ImageService { - return &ImageService{ - service: service, - } -} - -type ImageGetReqCall struct { - ctx *core.Context - images *ImageService - queryParams map[string]interface{} - optFns []request.OptFn - result io.Writer -} - -func (rc *ImageGetReqCall) SetImageKey(imageKey string) { - rc.queryParams["image_key"] = imageKey -} -func (rc *ImageGetReqCall) SetResponseStream(result io.Writer) { - rc.result = result -} - -func (rc *ImageGetReqCall) Do() (io.Writer, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - rc.optFns = append(rc.optFns, request.SetResponseStream()) - req := request.NewRequest("/open-apis/image/v4/get", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, rc.result, rc.optFns...) - err := api.Send(rc.ctx, rc.images.service.conf, req) - return rc.result, err -} - -func (images *ImageService) Get(ctx *core.Context, optFns ...request.OptFn) *ImageGetReqCall { - return &ImageGetReqCall{ - ctx: ctx, - images: images, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ImagePutReqCall struct { - ctx *core.Context - images *ImageService - body *request.FormData - optFns []request.OptFn -} - -func (rc *ImagePutReqCall) SetImage(image *request.File) { - rc.body.AddFile("image", image) -} -func (rc *ImagePutReqCall) SetImageType(imageType string) { - rc.body.AddParam("image_type", imageType) -} - -func (rc *ImagePutReqCall) Do() (*Image, error) { - var result = &Image{} - req := request.NewRequest("/open-apis/image/v4/put", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.images.service.conf, req) - return result, err -} - -func (images *ImageService) Put(ctx *core.Context, optFns ...request.OptFn) *ImagePutReqCall { - return &ImagePutReqCall{ - ctx: ctx, - images: images, - body: request.NewFormData(), - optFns: optFns, - } -} diff --git a/service/image/v4/model.go b/service/image/v4/model.go deleted file mode 100644 index 47219b71..00000000 --- a/service/image/v4/model.go +++ /dev/null @@ -1,17 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v4 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" -) - -type Image struct { - ImageKey string `json:"image_key,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Image) MarshalJSON() ([]byte, error) { - type cp Image - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} diff --git a/service/mail/v1/api.go b/service/mail/v1/api.go deleted file mode 100644 index 63a07ae0..00000000 --- a/service/mail/v1/api.go +++ /dev/null @@ -1,895 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - MailgroupMembers *MailgroupMemberService - MailgroupPermissionMembers *MailgroupPermissionMemberService - PublicMailboxs *PublicMailboxService - PublicMailboxMembers *PublicMailboxMemberService - Mailgroups *MailgroupService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.MailgroupMembers = newMailgroupMemberService(s) - s.MailgroupPermissionMembers = newMailgroupPermissionMemberService(s) - s.PublicMailboxs = newPublicMailboxService(s) - s.PublicMailboxMembers = newPublicMailboxMemberService(s) - s.Mailgroups = newMailgroupService(s) - return s -} - -type MailgroupMemberService struct { - service *Service -} - -func newMailgroupMemberService(service *Service) *MailgroupMemberService { - return &MailgroupMemberService{ - service: service, - } -} - -type MailgroupPermissionMemberService struct { - service *Service -} - -func newMailgroupPermissionMemberService(service *Service) *MailgroupPermissionMemberService { - return &MailgroupPermissionMemberService{ - service: service, - } -} - -type PublicMailboxService struct { - service *Service -} - -func newPublicMailboxService(service *Service) *PublicMailboxService { - return &PublicMailboxService{ - service: service, - } -} - -type PublicMailboxMemberService struct { - service *Service -} - -func newPublicMailboxMemberService(service *Service) *PublicMailboxMemberService { - return &PublicMailboxMemberService{ - service: service, - } -} - -type MailgroupService struct { - service *Service -} - -func newMailgroupService(service *Service) *MailgroupService { - return &MailgroupService{ - service: service, - } -} - -type MailgroupPermissionMemberDeleteReqCall struct { - ctx *core.Context - mailgroupPermissionMembers *MailgroupPermissionMemberService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MailgroupPermissionMemberDeleteReqCall) SetMailgroupId(mailgroupId string) { - rc.pathParams["mailgroup_id"] = mailgroupId -} -func (rc *MailgroupPermissionMemberDeleteReqCall) SetPermissionMemberId(permissionMemberId string) { - rc.pathParams["permission_member_id"] = permissionMemberId -} - -func (rc *MailgroupPermissionMemberDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/mail/v1/mailgroups/:mailgroup_id/permission_members/:permission_member_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.mailgroupPermissionMembers.service.conf, req) - return result, err -} - -func (mailgroupPermissionMembers *MailgroupPermissionMemberService) Delete(ctx *core.Context, optFns ...request.OptFn) *MailgroupPermissionMemberDeleteReqCall { - return &MailgroupPermissionMemberDeleteReqCall{ - ctx: ctx, - mailgroupPermissionMembers: mailgroupPermissionMembers, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type PublicMailboxMemberGetReqCall struct { - ctx *core.Context - publicMailboxMembers *PublicMailboxMemberService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *PublicMailboxMemberGetReqCall) SetPublicMailboxId(publicMailboxId string) { - rc.pathParams["public_mailbox_id"] = publicMailboxId -} -func (rc *PublicMailboxMemberGetReqCall) SetMemberId(memberId string) { - rc.pathParams["member_id"] = memberId -} -func (rc *PublicMailboxMemberGetReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *PublicMailboxMemberGetReqCall) Do() (*PublicMailboxMember, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &PublicMailboxMember{} - req := request.NewRequest("/open-apis/mail/v1/public_mailboxes/:public_mailbox_id/members/:member_id", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.publicMailboxMembers.service.conf, req) - return result, err -} - -func (publicMailboxMembers *PublicMailboxMemberService) Get(ctx *core.Context, optFns ...request.OptFn) *PublicMailboxMemberGetReqCall { - return &PublicMailboxMemberGetReqCall{ - ctx: ctx, - publicMailboxMembers: publicMailboxMembers, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type PublicMailboxMemberDeleteReqCall struct { - ctx *core.Context - publicMailboxMembers *PublicMailboxMemberService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *PublicMailboxMemberDeleteReqCall) SetPublicMailboxId(publicMailboxId string) { - rc.pathParams["public_mailbox_id"] = publicMailboxId -} -func (rc *PublicMailboxMemberDeleteReqCall) SetMemberId(memberId string) { - rc.pathParams["member_id"] = memberId -} - -func (rc *PublicMailboxMemberDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/mail/v1/public_mailboxes/:public_mailbox_id/members/:member_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.publicMailboxMembers.service.conf, req) - return result, err -} - -func (publicMailboxMembers *PublicMailboxMemberService) Delete(ctx *core.Context, optFns ...request.OptFn) *PublicMailboxMemberDeleteReqCall { - return &PublicMailboxMemberDeleteReqCall{ - ctx: ctx, - publicMailboxMembers: publicMailboxMembers, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MailgroupMemberListReqCall struct { - ctx *core.Context - mailgroupMembers *MailgroupMemberService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MailgroupMemberListReqCall) SetMailgroupId(mailgroupId string) { - rc.pathParams["mailgroup_id"] = mailgroupId -} -func (rc *MailgroupMemberListReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *MailgroupMemberListReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} -func (rc *MailgroupMemberListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *MailgroupMemberListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *MailgroupMemberListReqCall) Do() (*MailgroupMemberListResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &MailgroupMemberListResult{} - req := request.NewRequest("/open-apis/mail/v1/mailgroups/:mailgroup_id/members", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.mailgroupMembers.service.conf, req) - return result, err -} - -func (mailgroupMembers *MailgroupMemberService) List(ctx *core.Context, optFns ...request.OptFn) *MailgroupMemberListReqCall { - return &MailgroupMemberListReqCall{ - ctx: ctx, - mailgroupMembers: mailgroupMembers, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MailgroupPermissionMemberGetReqCall struct { - ctx *core.Context - mailgroupPermissionMembers *MailgroupPermissionMemberService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MailgroupPermissionMemberGetReqCall) SetMailgroupId(mailgroupId string) { - rc.pathParams["mailgroup_id"] = mailgroupId -} -func (rc *MailgroupPermissionMemberGetReqCall) SetPermissionMemberId(permissionMemberId string) { - rc.pathParams["permission_member_id"] = permissionMemberId -} -func (rc *MailgroupPermissionMemberGetReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *MailgroupPermissionMemberGetReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} - -func (rc *MailgroupPermissionMemberGetReqCall) Do() (*MailgroupPermissionMember, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &MailgroupPermissionMember{} - req := request.NewRequest("/open-apis/mail/v1/mailgroups/:mailgroup_id/permission_members/:permission_member_id", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.mailgroupPermissionMembers.service.conf, req) - return result, err -} - -func (mailgroupPermissionMembers *MailgroupPermissionMemberService) Get(ctx *core.Context, optFns ...request.OptFn) *MailgroupPermissionMemberGetReqCall { - return &MailgroupPermissionMemberGetReqCall{ - ctx: ctx, - mailgroupPermissionMembers: mailgroupPermissionMembers, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MailgroupPermissionMemberListReqCall struct { - ctx *core.Context - mailgroupPermissionMembers *MailgroupPermissionMemberService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MailgroupPermissionMemberListReqCall) SetMailgroupId(mailgroupId string) { - rc.pathParams["mailgroup_id"] = mailgroupId -} -func (rc *MailgroupPermissionMemberListReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *MailgroupPermissionMemberListReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} -func (rc *MailgroupPermissionMemberListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *MailgroupPermissionMemberListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *MailgroupPermissionMemberListReqCall) Do() (*MailgroupPermissionMemberListResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &MailgroupPermissionMemberListResult{} - req := request.NewRequest("/open-apis/mail/v1/mailgroups/:mailgroup_id/permission_members", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.mailgroupPermissionMembers.service.conf, req) - return result, err -} - -func (mailgroupPermissionMembers *MailgroupPermissionMemberService) List(ctx *core.Context, optFns ...request.OptFn) *MailgroupPermissionMemberListReqCall { - return &MailgroupPermissionMemberListReqCall{ - ctx: ctx, - mailgroupPermissionMembers: mailgroupPermissionMembers, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type PublicMailboxUpdateReqCall struct { - ctx *core.Context - publicMailboxs *PublicMailboxService - body *PublicMailbox - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *PublicMailboxUpdateReqCall) SetPublicMailboxId(publicMailboxId string) { - rc.pathParams["public_mailbox_id"] = publicMailboxId -} - -func (rc *PublicMailboxUpdateReqCall) Do() (*PublicMailbox, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &PublicMailbox{} - req := request.NewRequest("/open-apis/mail/v1/public_mailboxes/:public_mailbox_id", "PUT", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.publicMailboxs.service.conf, req) - return result, err -} - -func (publicMailboxs *PublicMailboxService) Update(ctx *core.Context, body *PublicMailbox, optFns ...request.OptFn) *PublicMailboxUpdateReqCall { - return &PublicMailboxUpdateReqCall{ - ctx: ctx, - publicMailboxs: publicMailboxs, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type PublicMailboxMemberClearReqCall struct { - ctx *core.Context - publicMailboxMembers *PublicMailboxMemberService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *PublicMailboxMemberClearReqCall) SetPublicMailboxId(publicMailboxId string) { - rc.pathParams["public_mailbox_id"] = publicMailboxId -} - -func (rc *PublicMailboxMemberClearReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/mail/v1/public_mailboxes/:public_mailbox_id/members/clear", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.publicMailboxMembers.service.conf, req) - return result, err -} - -func (publicMailboxMembers *PublicMailboxMemberService) Clear(ctx *core.Context, optFns ...request.OptFn) *PublicMailboxMemberClearReqCall { - return &PublicMailboxMemberClearReqCall{ - ctx: ctx, - publicMailboxMembers: publicMailboxMembers, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type PublicMailboxMemberListReqCall struct { - ctx *core.Context - publicMailboxMembers *PublicMailboxMemberService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *PublicMailboxMemberListReqCall) SetPublicMailboxId(publicMailboxId string) { - rc.pathParams["public_mailbox_id"] = publicMailboxId -} -func (rc *PublicMailboxMemberListReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *PublicMailboxMemberListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *PublicMailboxMemberListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *PublicMailboxMemberListReqCall) Do() (*PublicMailboxMemberListResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &PublicMailboxMemberListResult{} - req := request.NewRequest("/open-apis/mail/v1/public_mailboxes/:public_mailbox_id/members", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.publicMailboxMembers.service.conf, req) - return result, err -} - -func (publicMailboxMembers *PublicMailboxMemberService) List(ctx *core.Context, optFns ...request.OptFn) *PublicMailboxMemberListReqCall { - return &PublicMailboxMemberListReqCall{ - ctx: ctx, - publicMailboxMembers: publicMailboxMembers, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type PublicMailboxMemberCreateReqCall struct { - ctx *core.Context - publicMailboxMembers *PublicMailboxMemberService - body *PublicMailboxMember - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *PublicMailboxMemberCreateReqCall) SetPublicMailboxId(publicMailboxId string) { - rc.pathParams["public_mailbox_id"] = publicMailboxId -} -func (rc *PublicMailboxMemberCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *PublicMailboxMemberCreateReqCall) Do() (*PublicMailboxMember, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &PublicMailboxMember{} - req := request.NewRequest("/open-apis/mail/v1/public_mailboxes/:public_mailbox_id/members", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.publicMailboxMembers.service.conf, req) - return result, err -} - -func (publicMailboxMembers *PublicMailboxMemberService) Create(ctx *core.Context, body *PublicMailboxMember, optFns ...request.OptFn) *PublicMailboxMemberCreateReqCall { - return &PublicMailboxMemberCreateReqCall{ - ctx: ctx, - publicMailboxMembers: publicMailboxMembers, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MailgroupGetReqCall struct { - ctx *core.Context - mailgroups *MailgroupService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MailgroupGetReqCall) SetMailgroupId(mailgroupId string) { - rc.pathParams["mailgroup_id"] = mailgroupId -} - -func (rc *MailgroupGetReqCall) Do() (*Mailgroup, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &Mailgroup{} - req := request.NewRequest("/open-apis/mail/v1/mailgroups/:mailgroup_id", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.mailgroups.service.conf, req) - return result, err -} - -func (mailgroups *MailgroupService) Get(ctx *core.Context, optFns ...request.OptFn) *MailgroupGetReqCall { - return &MailgroupGetReqCall{ - ctx: ctx, - mailgroups: mailgroups, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MailgroupUpdateReqCall struct { - ctx *core.Context - mailgroups *MailgroupService - body *Mailgroup - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MailgroupUpdateReqCall) SetMailgroupId(mailgroupId string) { - rc.pathParams["mailgroup_id"] = mailgroupId -} - -func (rc *MailgroupUpdateReqCall) Do() (*Mailgroup, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &Mailgroup{} - req := request.NewRequest("/open-apis/mail/v1/mailgroups/:mailgroup_id", "PUT", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.mailgroups.service.conf, req) - return result, err -} - -func (mailgroups *MailgroupService) Update(ctx *core.Context, body *Mailgroup, optFns ...request.OptFn) *MailgroupUpdateReqCall { - return &MailgroupUpdateReqCall{ - ctx: ctx, - mailgroups: mailgroups, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type PublicMailboxListReqCall struct { - ctx *core.Context - publicMailboxs *PublicMailboxService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *PublicMailboxListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *PublicMailboxListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *PublicMailboxListReqCall) Do() (*PublicMailboxListResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &PublicMailboxListResult{} - req := request.NewRequest("/open-apis/mail/v1/public_mailboxes", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.publicMailboxs.service.conf, req) - return result, err -} - -func (publicMailboxs *PublicMailboxService) List(ctx *core.Context, optFns ...request.OptFn) *PublicMailboxListReqCall { - return &PublicMailboxListReqCall{ - ctx: ctx, - publicMailboxs: publicMailboxs, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MailgroupDeleteReqCall struct { - ctx *core.Context - mailgroups *MailgroupService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MailgroupDeleteReqCall) SetMailgroupId(mailgroupId string) { - rc.pathParams["mailgroup_id"] = mailgroupId -} - -func (rc *MailgroupDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/mail/v1/mailgroups/:mailgroup_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.mailgroups.service.conf, req) - return result, err -} - -func (mailgroups *MailgroupService) Delete(ctx *core.Context, optFns ...request.OptFn) *MailgroupDeleteReqCall { - return &MailgroupDeleteReqCall{ - ctx: ctx, - mailgroups: mailgroups, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MailgroupPermissionMemberCreateReqCall struct { - ctx *core.Context - mailgroupPermissionMembers *MailgroupPermissionMemberService - body *MailgroupPermissionMember - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MailgroupPermissionMemberCreateReqCall) SetMailgroupId(mailgroupId string) { - rc.pathParams["mailgroup_id"] = mailgroupId -} -func (rc *MailgroupPermissionMemberCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *MailgroupPermissionMemberCreateReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} - -func (rc *MailgroupPermissionMemberCreateReqCall) Do() (*MailgroupPermissionMember, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &MailgroupPermissionMember{} - req := request.NewRequest("/open-apis/mail/v1/mailgroups/:mailgroup_id/permission_members", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.mailgroupPermissionMembers.service.conf, req) - return result, err -} - -func (mailgroupPermissionMembers *MailgroupPermissionMemberService) Create(ctx *core.Context, body *MailgroupPermissionMember, optFns ...request.OptFn) *MailgroupPermissionMemberCreateReqCall { - return &MailgroupPermissionMemberCreateReqCall{ - ctx: ctx, - mailgroupPermissionMembers: mailgroupPermissionMembers, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type PublicMailboxCreateReqCall struct { - ctx *core.Context - publicMailboxs *PublicMailboxService - body *PublicMailbox - optFns []request.OptFn -} - -func (rc *PublicMailboxCreateReqCall) Do() (*PublicMailbox, error) { - var result = &PublicMailbox{} - req := request.NewRequest("/open-apis/mail/v1/public_mailboxes", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.publicMailboxs.service.conf, req) - return result, err -} - -func (publicMailboxs *PublicMailboxService) Create(ctx *core.Context, body *PublicMailbox, optFns ...request.OptFn) *PublicMailboxCreateReqCall { - return &PublicMailboxCreateReqCall{ - ctx: ctx, - publicMailboxs: publicMailboxs, - body: body, - optFns: optFns, - } -} - -type MailgroupMemberGetReqCall struct { - ctx *core.Context - mailgroupMembers *MailgroupMemberService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MailgroupMemberGetReqCall) SetMailgroupId(mailgroupId string) { - rc.pathParams["mailgroup_id"] = mailgroupId -} -func (rc *MailgroupMemberGetReqCall) SetMemberId(memberId string) { - rc.pathParams["member_id"] = memberId -} -func (rc *MailgroupMemberGetReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *MailgroupMemberGetReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} - -func (rc *MailgroupMemberGetReqCall) Do() (*MailgroupMember, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &MailgroupMember{} - req := request.NewRequest("/open-apis/mail/v1/mailgroups/:mailgroup_id/members/:member_id", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.mailgroupMembers.service.conf, req) - return result, err -} - -func (mailgroupMembers *MailgroupMemberService) Get(ctx *core.Context, optFns ...request.OptFn) *MailgroupMemberGetReqCall { - return &MailgroupMemberGetReqCall{ - ctx: ctx, - mailgroupMembers: mailgroupMembers, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type PublicMailboxGetReqCall struct { - ctx *core.Context - publicMailboxs *PublicMailboxService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *PublicMailboxGetReqCall) SetPublicMailboxId(publicMailboxId string) { - rc.pathParams["public_mailbox_id"] = publicMailboxId -} - -func (rc *PublicMailboxGetReqCall) Do() (*PublicMailbox, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &PublicMailbox{} - req := request.NewRequest("/open-apis/mail/v1/public_mailboxes/:public_mailbox_id", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.publicMailboxs.service.conf, req) - return result, err -} - -func (publicMailboxs *PublicMailboxService) Get(ctx *core.Context, optFns ...request.OptFn) *PublicMailboxGetReqCall { - return &PublicMailboxGetReqCall{ - ctx: ctx, - publicMailboxs: publicMailboxs, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type PublicMailboxPatchReqCall struct { - ctx *core.Context - publicMailboxs *PublicMailboxService - body *PublicMailbox - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *PublicMailboxPatchReqCall) SetPublicMailboxId(publicMailboxId string) { - rc.pathParams["public_mailbox_id"] = publicMailboxId -} - -func (rc *PublicMailboxPatchReqCall) Do() (*PublicMailbox, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &PublicMailbox{} - req := request.NewRequest("/open-apis/mail/v1/public_mailboxes/:public_mailbox_id", "PATCH", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.publicMailboxs.service.conf, req) - return result, err -} - -func (publicMailboxs *PublicMailboxService) Patch(ctx *core.Context, body *PublicMailbox, optFns ...request.OptFn) *PublicMailboxPatchReqCall { - return &PublicMailboxPatchReqCall{ - ctx: ctx, - publicMailboxs: publicMailboxs, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MailgroupCreateReqCall struct { - ctx *core.Context - mailgroups *MailgroupService - body *Mailgroup - optFns []request.OptFn -} - -func (rc *MailgroupCreateReqCall) Do() (*Mailgroup, error) { - var result = &Mailgroup{} - req := request.NewRequest("/open-apis/mail/v1/mailgroups", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.mailgroups.service.conf, req) - return result, err -} - -func (mailgroups *MailgroupService) Create(ctx *core.Context, body *Mailgroup, optFns ...request.OptFn) *MailgroupCreateReqCall { - return &MailgroupCreateReqCall{ - ctx: ctx, - mailgroups: mailgroups, - body: body, - optFns: optFns, - } -} - -type MailgroupListReqCall struct { - ctx *core.Context - mailgroups *MailgroupService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MailgroupListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *MailgroupListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *MailgroupListReqCall) Do() (*MailgroupListResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &MailgroupListResult{} - req := request.NewRequest("/open-apis/mail/v1/mailgroups", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.mailgroups.service.conf, req) - return result, err -} - -func (mailgroups *MailgroupService) List(ctx *core.Context, optFns ...request.OptFn) *MailgroupListReqCall { - return &MailgroupListReqCall{ - ctx: ctx, - mailgroups: mailgroups, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MailgroupPatchReqCall struct { - ctx *core.Context - mailgroups *MailgroupService - body *Mailgroup - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MailgroupPatchReqCall) SetMailgroupId(mailgroupId string) { - rc.pathParams["mailgroup_id"] = mailgroupId -} - -func (rc *MailgroupPatchReqCall) Do() (*Mailgroup, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &Mailgroup{} - req := request.NewRequest("/open-apis/mail/v1/mailgroups/:mailgroup_id", "PATCH", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.mailgroups.service.conf, req) - return result, err -} - -func (mailgroups *MailgroupService) Patch(ctx *core.Context, body *Mailgroup, optFns ...request.OptFn) *MailgroupPatchReqCall { - return &MailgroupPatchReqCall{ - ctx: ctx, - mailgroups: mailgroups, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MailgroupMemberCreateReqCall struct { - ctx *core.Context - mailgroupMembers *MailgroupMemberService - body *MailgroupMember - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MailgroupMemberCreateReqCall) SetMailgroupId(mailgroupId string) { - rc.pathParams["mailgroup_id"] = mailgroupId -} -func (rc *MailgroupMemberCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *MailgroupMemberCreateReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType -} - -func (rc *MailgroupMemberCreateReqCall) Do() (*MailgroupMember, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &MailgroupMember{} - req := request.NewRequest("/open-apis/mail/v1/mailgroups/:mailgroup_id/members", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.mailgroupMembers.service.conf, req) - return result, err -} - -func (mailgroupMembers *MailgroupMemberService) Create(ctx *core.Context, body *MailgroupMember, optFns ...request.OptFn) *MailgroupMemberCreateReqCall { - return &MailgroupMemberCreateReqCall{ - ctx: ctx, - mailgroupMembers: mailgroupMembers, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MailgroupMemberDeleteReqCall struct { - ctx *core.Context - mailgroupMembers *MailgroupMemberService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MailgroupMemberDeleteReqCall) SetMailgroupId(mailgroupId string) { - rc.pathParams["mailgroup_id"] = mailgroupId -} -func (rc *MailgroupMemberDeleteReqCall) SetMemberId(memberId string) { - rc.pathParams["member_id"] = memberId -} - -func (rc *MailgroupMemberDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/mail/v1/mailgroups/:mailgroup_id/members/:member_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.mailgroupMembers.service.conf, req) - return result, err -} - -func (mailgroupMembers *MailgroupMemberService) Delete(ctx *core.Context, optFns ...request.OptFn) *MailgroupMemberDeleteReqCall { - return &MailgroupMemberDeleteReqCall{ - ctx: ctx, - mailgroupMembers: mailgroupMembers, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} diff --git a/service/mail/v1/model.go b/service/mail/v1/model.go deleted file mode 100644 index f62b6a58..00000000 --- a/service/mail/v1/model.go +++ /dev/null @@ -1,109 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" -) - -type Mailgroup struct { - MailgroupId string `json:"mailgroup_id,omitempty"` - Email string `json:"email,omitempty"` - Name string `json:"name,omitempty"` - Description string `json:"description,omitempty"` - DirectMembersCount string `json:"direct_members_count,omitempty"` - IncludeExternalMember bool `json:"include_external_member,omitempty"` - IncludeAllCompanyMember bool `json:"include_all_company_member,omitempty"` - WhoCanSendMail string `json:"who_can_send_mail,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Mailgroup) MarshalJSON() ([]byte, error) { - type cp Mailgroup - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MailgroupMember struct { - MemberId string `json:"member_id,omitempty"` - Email string `json:"email,omitempty"` - UserId string `json:"user_id,omitempty"` - DepartmentId string `json:"department_id,omitempty"` - Type string `json:"type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MailgroupMember) MarshalJSON() ([]byte, error) { - type cp MailgroupMember - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MailgroupPermissionMember struct { - PermissionMemberId string `json:"permission_member_id,omitempty"` - UserId string `json:"user_id,omitempty"` - DepartmentId string `json:"department_id,omitempty"` - Type string `json:"type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MailgroupPermissionMember) MarshalJSON() ([]byte, error) { - type cp MailgroupPermissionMember - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type PublicMailbox struct { - PublicMailboxId string `json:"public_mailbox_id,omitempty"` - Email string `json:"email,omitempty"` - Name string `json:"name,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *PublicMailbox) MarshalJSON() ([]byte, error) { - type cp PublicMailbox - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type PublicMailboxMember struct { - MemberId string `json:"member_id,omitempty"` - UserId string `json:"user_id,omitempty"` - Type string `json:"type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *PublicMailboxMember) MarshalJSON() ([]byte, error) { - type cp PublicMailboxMember - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MailgroupMemberListResult struct { - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` - Items []*MailgroupMember `json:"items,omitempty"` -} - -type MailgroupPermissionMemberListResult struct { - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` - Items []*MailgroupPermissionMember `json:"items,omitempty"` -} - -type PublicMailboxMemberListResult struct { - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` - Items []*PublicMailboxMember `json:"items,omitempty"` -} - -type PublicMailboxListResult struct { - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` - Items []*PublicMailbox `json:"items,omitempty"` -} - -type MailgroupListResult struct { - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` - Items []*Mailgroup `json:"items,omitempty"` -} diff --git a/service/meeting_room/v1/api.go b/service/meeting_room/v1/api.go deleted file mode 100644 index 2eb313d8..00000000 --- a/service/meeting_room/v1/api.go +++ /dev/null @@ -1,596 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - Buildings *BuildingService - Countrys *CountryService - Districts *DistrictService - Freebusys *FreebusyService - Instances *InstanceService - Rooms *RoomService - Summarys *SummaryService - MeetingRooms *MeetingRoomService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Buildings = newBuildingService(s) - s.Countrys = newCountryService(s) - s.Districts = newDistrictService(s) - s.Freebusys = newFreebusyService(s) - s.Instances = newInstanceService(s) - s.Rooms = newRoomService(s) - s.Summarys = newSummaryService(s) - s.MeetingRooms = newMeetingRoomService(s) - return s -} - -type BuildingService struct { - service *Service -} - -func newBuildingService(service *Service) *BuildingService { - return &BuildingService{ - service: service, - } -} - -type CountryService struct { - service *Service -} - -func newCountryService(service *Service) *CountryService { - return &CountryService{ - service: service, - } -} - -type DistrictService struct { - service *Service -} - -func newDistrictService(service *Service) *DistrictService { - return &DistrictService{ - service: service, - } -} - -type FreebusyService struct { - service *Service -} - -func newFreebusyService(service *Service) *FreebusyService { - return &FreebusyService{ - service: service, - } -} - -type InstanceService struct { - service *Service -} - -func newInstanceService(service *Service) *InstanceService { - return &InstanceService{ - service: service, - } -} - -type RoomService struct { - service *Service -} - -func newRoomService(service *Service) *RoomService { - return &RoomService{ - service: service, - } -} - -type SummaryService struct { - service *Service -} - -func newSummaryService(service *Service) *SummaryService { - return &SummaryService{ - service: service, - } -} - -type MeetingRoomService struct { - service *Service -} - -func newMeetingRoomService(service *Service) *MeetingRoomService { - return &MeetingRoomService{ - service: service, - } -} - -type FreebusyBatchGetReqCall struct { - ctx *core.Context - freebusys *FreebusyService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *FreebusyBatchGetReqCall) SetRoomIds(roomIds ...string) { - rc.queryParams["room_ids"] = roomIds -} -func (rc *FreebusyBatchGetReqCall) SetTimeMin(timeMin string) { - rc.queryParams["time_min"] = timeMin -} -func (rc *FreebusyBatchGetReqCall) SetTimeMax(timeMax string) { - rc.queryParams["time_max"] = timeMax -} - -func (rc *FreebusyBatchGetReqCall) Do() (*FreebusyBatchGetResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &FreebusyBatchGetResult{} - req := request.NewRequest("/open-apis/meeting_room/freebusy/batch_get", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.freebusys.service.conf, req) - return result, err -} - -func (freebusys *FreebusyService) BatchGet(ctx *core.Context, optFns ...request.OptFn) *FreebusyBatchGetReqCall { - return &FreebusyBatchGetReqCall{ - ctx: ctx, - freebusys: freebusys, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SummaryBatchGetReqCall struct { - ctx *core.Context - summarys *SummaryService - body *SummaryBatchGetReqBody - optFns []request.OptFn -} - -func (rc *SummaryBatchGetReqCall) Do() (*SummaryBatchGetResult, error) { - var result = &SummaryBatchGetResult{} - req := request.NewRequest("/open-apis/meeting_room/summary/batch_get", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.summarys.service.conf, req) - return result, err -} - -func (summarys *SummaryService) BatchGet(ctx *core.Context, body *SummaryBatchGetReqBody, optFns ...request.OptFn) *SummaryBatchGetReqCall { - return &SummaryBatchGetReqCall{ - ctx: ctx, - summarys: summarys, - body: body, - optFns: optFns, - } -} - -type BuildingBatchGetReqCall struct { - ctx *core.Context - buildings *BuildingService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *BuildingBatchGetReqCall) SetBuildingIds(buildingIds ...string) { - rc.queryParams["building_ids"] = buildingIds -} -func (rc *BuildingBatchGetReqCall) SetFields(fields string) { - rc.queryParams["fields"] = fields -} - -func (rc *BuildingBatchGetReqCall) Do() (*BuildingBatchGetResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &BuildingBatchGetResult{} - req := request.NewRequest("/open-apis/meeting_room/building/batch_get", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.buildings.service.conf, req) - return result, err -} - -func (buildings *BuildingService) BatchGet(ctx *core.Context, optFns ...request.OptFn) *BuildingBatchGetReqCall { - return &BuildingBatchGetReqCall{ - ctx: ctx, - buildings: buildings, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type RoomBatchGetReqCall struct { - ctx *core.Context - rooms *RoomService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *RoomBatchGetReqCall) SetRoomIds(roomIds ...string) { - rc.queryParams["room_ids"] = roomIds -} -func (rc *RoomBatchGetReqCall) SetFields(fields string) { - rc.queryParams["fields"] = fields -} - -func (rc *RoomBatchGetReqCall) Do() (*RoomBatchGetResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &RoomBatchGetResult{} - req := request.NewRequest("/open-apis/meeting_room/room/batch_get", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.rooms.service.conf, req) - return result, err -} - -func (rooms *RoomService) BatchGet(ctx *core.Context, optFns ...request.OptFn) *RoomBatchGetReqCall { - return &RoomBatchGetReqCall{ - ctx: ctx, - rooms: rooms, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type BuildingBatchGetIdReqCall struct { - ctx *core.Context - buildings *BuildingService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *BuildingBatchGetIdReqCall) SetCustomBuildingIds(customBuildingIds ...string) { - rc.queryParams["custom_building_ids"] = customBuildingIds -} - -func (rc *BuildingBatchGetIdReqCall) Do() (*BuildingBatchGetIdResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &BuildingBatchGetIdResult{} - req := request.NewRequest("/open-apis/meeting_room/building/batch_get_id", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.buildings.service.conf, req) - return result, err -} - -func (buildings *BuildingService) BatchGetId(ctx *core.Context, optFns ...request.OptFn) *BuildingBatchGetIdReqCall { - return &BuildingBatchGetIdReqCall{ - ctx: ctx, - buildings: buildings, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type RoomBatchGetIdReqCall struct { - ctx *core.Context - rooms *RoomService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *RoomBatchGetIdReqCall) SetCustomRoomIds(customRoomIds ...string) { - rc.queryParams["custom_room_ids"] = customRoomIds -} - -func (rc *RoomBatchGetIdReqCall) Do() (*RoomBatchGetIdResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &RoomBatchGetIdResult{} - req := request.NewRequest("/open-apis/meeting_room/room/batch_get_id", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.rooms.service.conf, req) - return result, err -} - -func (rooms *RoomService) BatchGetId(ctx *core.Context, optFns ...request.OptFn) *RoomBatchGetIdReqCall { - return &RoomBatchGetIdReqCall{ - ctx: ctx, - rooms: rooms, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type RoomCreateReqCall struct { - ctx *core.Context - rooms *RoomService - body *RoomCreateReqBody - optFns []request.OptFn -} - -func (rc *RoomCreateReqCall) Do() (*RoomCreateResult, error) { - var result = &RoomCreateResult{} - req := request.NewRequest("/open-apis/meeting_room/room/create", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.rooms.service.conf, req) - return result, err -} - -func (rooms *RoomService) Create(ctx *core.Context, body *RoomCreateReqBody, optFns ...request.OptFn) *RoomCreateReqCall { - return &RoomCreateReqCall{ - ctx: ctx, - rooms: rooms, - body: body, - optFns: optFns, - } -} - -type BuildingCreateReqCall struct { - ctx *core.Context - buildings *BuildingService - body *BuildingCreateReqBody - optFns []request.OptFn -} - -func (rc *BuildingCreateReqCall) Do() (*BuildingCreateResult, error) { - var result = &BuildingCreateResult{} - req := request.NewRequest("/open-apis/meeting_room/building/create", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.buildings.service.conf, req) - return result, err -} - -func (buildings *BuildingService) Create(ctx *core.Context, body *BuildingCreateReqBody, optFns ...request.OptFn) *BuildingCreateReqCall { - return &BuildingCreateReqCall{ - ctx: ctx, - buildings: buildings, - body: body, - optFns: optFns, - } -} - -type BuildingDeleteReqCall struct { - ctx *core.Context - buildings *BuildingService - body *BuildingDeleteReqBody - optFns []request.OptFn -} - -func (rc *BuildingDeleteReqCall) Do() (*response.NoData, error) { - var result = &response.NoData{} - req := request.NewRequest("/open-apis/meeting_room/building/delete", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.buildings.service.conf, req) - return result, err -} - -func (buildings *BuildingService) Delete(ctx *core.Context, body *BuildingDeleteReqBody, optFns ...request.OptFn) *BuildingDeleteReqCall { - return &BuildingDeleteReqCall{ - ctx: ctx, - buildings: buildings, - body: body, - optFns: optFns, - } -} - -type RoomDeleteReqCall struct { - ctx *core.Context - rooms *RoomService - body *RoomDeleteReqBody - optFns []request.OptFn -} - -func (rc *RoomDeleteReqCall) Do() (*response.NoData, error) { - var result = &response.NoData{} - req := request.NewRequest("/open-apis/meeting_room/room/delete", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.rooms.service.conf, req) - return result, err -} - -func (rooms *RoomService) Delete(ctx *core.Context, body *RoomDeleteReqBody, optFns ...request.OptFn) *RoomDeleteReqCall { - return &RoomDeleteReqCall{ - ctx: ctx, - rooms: rooms, - body: body, - optFns: optFns, - } -} - -type CountryListReqCall struct { - ctx *core.Context - countrys *CountryService - optFns []request.OptFn -} - -func (rc *CountryListReqCall) Do() (*CountryListResult, error) { - var result = &CountryListResult{} - req := request.NewRequest("/open-apis/meeting_room/country/list", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.countrys.service.conf, req) - return result, err -} - -func (countrys *CountryService) List(ctx *core.Context, optFns ...request.OptFn) *CountryListReqCall { - return &CountryListReqCall{ - ctx: ctx, - countrys: countrys, - optFns: optFns, - } -} - -type BuildingListReqCall struct { - ctx *core.Context - buildings *BuildingService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *BuildingListReqCall) SetOrderBy(orderBy string) { - rc.queryParams["order_by"] = orderBy -} -func (rc *BuildingListReqCall) SetFields(fields string) { - rc.queryParams["fields"] = fields -} -func (rc *BuildingListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *BuildingListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *BuildingListReqCall) Do() (*BuildingListResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &BuildingListResult{} - req := request.NewRequest("/open-apis/meeting_room/building/list", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.buildings.service.conf, req) - return result, err -} - -func (buildings *BuildingService) List(ctx *core.Context, optFns ...request.OptFn) *BuildingListReqCall { - return &BuildingListReqCall{ - ctx: ctx, - buildings: buildings, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type RoomListReqCall struct { - ctx *core.Context - rooms *RoomService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *RoomListReqCall) SetBuildingId(buildingId string) { - rc.queryParams["building_id"] = buildingId -} -func (rc *RoomListReqCall) SetOrderBy(orderBy string) { - rc.queryParams["order_by"] = orderBy -} -func (rc *RoomListReqCall) SetFields(fields string) { - rc.queryParams["fields"] = fields -} -func (rc *RoomListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *RoomListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} - -func (rc *RoomListReqCall) Do() (*RoomListResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &RoomListResult{} - req := request.NewRequest("/open-apis/meeting_room/room/list", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.rooms.service.conf, req) - return result, err -} - -func (rooms *RoomService) List(ctx *core.Context, optFns ...request.OptFn) *RoomListReqCall { - return &RoomListReqCall{ - ctx: ctx, - rooms: rooms, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type DistrictListReqCall struct { - ctx *core.Context - districts *DistrictService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *DistrictListReqCall) SetCountryId(countryId int) { - rc.queryParams["country_id"] = countryId -} - -func (rc *DistrictListReqCall) Do() (*DistrictListResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &DistrictListResult{} - req := request.NewRequest("/open-apis/meeting_room/district/list", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.districts.service.conf, req) - return result, err -} - -func (districts *DistrictService) List(ctx *core.Context, optFns ...request.OptFn) *DistrictListReqCall { - return &DistrictListReqCall{ - ctx: ctx, - districts: districts, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type InstanceReplyReqCall struct { - ctx *core.Context - instances *InstanceService - body *InstanceReplyReqBody - optFns []request.OptFn -} - -func (rc *InstanceReplyReqCall) Do() (*response.NoData, error) { - var result = &response.NoData{} - req := request.NewRequest("/open-apis/meeting_room/instance/reply", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.instances.service.conf, req) - return result, err -} - -func (instances *InstanceService) Reply(ctx *core.Context, body *InstanceReplyReqBody, optFns ...request.OptFn) *InstanceReplyReqCall { - return &InstanceReplyReqCall{ - ctx: ctx, - instances: instances, - body: body, - optFns: optFns, - } -} - -type BuildingUpdateReqCall struct { - ctx *core.Context - buildings *BuildingService - body *BuildingUpdateReqBody - optFns []request.OptFn -} - -func (rc *BuildingUpdateReqCall) Do() (*response.NoData, error) { - var result = &response.NoData{} - req := request.NewRequest("/open-apis/meeting_room/building/update", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.buildings.service.conf, req) - return result, err -} - -func (buildings *BuildingService) Update(ctx *core.Context, body *BuildingUpdateReqBody, optFns ...request.OptFn) *BuildingUpdateReqCall { - return &BuildingUpdateReqCall{ - ctx: ctx, - buildings: buildings, - body: body, - optFns: optFns, - } -} - -type RoomUpdateReqCall struct { - ctx *core.Context - rooms *RoomService - body *RoomUpdateReqBody - optFns []request.OptFn -} - -func (rc *RoomUpdateReqCall) Do() (*response.NoData, error) { - var result = &response.NoData{} - req := request.NewRequest("/open-apis/meeting_room/room/update", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.rooms.service.conf, req) - return result, err -} - -func (rooms *RoomService) Update(ctx *core.Context, body *RoomUpdateReqBody, optFns ...request.OptFn) *RoomUpdateReqCall { - return &RoomUpdateReqCall{ - ctx: ctx, - rooms: rooms, - body: body, - optFns: optFns, - } -} diff --git a/service/meeting_room/v1/event.go b/service/meeting_room/v1/event.go deleted file mode 100644 index a7bbd6be..00000000 --- a/service/meeting_room/v1/event.go +++ /dev/null @@ -1,136 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" - "github.com/larksuite/oapi-sdk-go/event" -) - -type RoomCreatedEventHandler struct { - Fn func(*core.Context, *RoomCreatedEvent) error -} - -func (h *RoomCreatedEventHandler) GetEvent() interface{} { - return &RoomCreatedEvent{} -} - -func (h *RoomCreatedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*RoomCreatedEvent)) -} - -func SetRoomCreatedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *RoomCreatedEvent) error) { - event.SetTypeHandler(conf, "meeting_room.room.created_v1", &RoomCreatedEventHandler{Fn: fn}) -} - -type RoomDeletedEventHandler struct { - Fn func(*core.Context, *RoomDeletedEvent) error -} - -func (h *RoomDeletedEventHandler) GetEvent() interface{} { - return &RoomDeletedEvent{} -} - -func (h *RoomDeletedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*RoomDeletedEvent)) -} - -func SetRoomDeletedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *RoomDeletedEvent) error) { - event.SetTypeHandler(conf, "meeting_room.room.deleted_v1", &RoomDeletedEventHandler{Fn: fn}) -} - -type RoomStatusChangedEventHandler struct { - Fn func(*core.Context, *RoomStatusChangedEvent) error -} - -func (h *RoomStatusChangedEventHandler) GetEvent() interface{} { - return &RoomStatusChangedEvent{} -} - -func (h *RoomStatusChangedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*RoomStatusChangedEvent)) -} - -func SetRoomStatusChangedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *RoomStatusChangedEvent) error) { - event.SetTypeHandler(conf, "meeting_room.room.status_changed_v1", &RoomStatusChangedEventHandler{Fn: fn}) -} - -type RoomUpdatedEventHandler struct { - Fn func(*core.Context, *RoomUpdatedEvent) error -} - -func (h *RoomUpdatedEventHandler) GetEvent() interface{} { - return &RoomUpdatedEvent{} -} - -func (h *RoomUpdatedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*RoomUpdatedEvent)) -} - -func SetRoomUpdatedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *RoomUpdatedEvent) error) { - event.SetTypeHandler(conf, "meeting_room.room.updated_v1", &RoomUpdatedEventHandler{Fn: fn}) -} - -type MeetingRoomStatusChangedEventHandler struct { - Fn func(*core.Context, *MeetingRoomStatusChangedEvent) error -} - -func (h *MeetingRoomStatusChangedEventHandler) GetEvent() interface{} { - return &MeetingRoomStatusChangedEvent{} -} - -func (h *MeetingRoomStatusChangedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*MeetingRoomStatusChangedEvent)) -} - -func SetMeetingRoomStatusChangedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *MeetingRoomStatusChangedEvent) error) { - event.SetTypeHandler(conf, "meeting_room.meeting_room.status_changed_v1", &MeetingRoomStatusChangedEventHandler{Fn: fn}) -} - -type MeetingRoomCreatedEventHandler struct { - Fn func(*core.Context, *MeetingRoomCreatedEvent) error -} - -func (h *MeetingRoomCreatedEventHandler) GetEvent() interface{} { - return &MeetingRoomCreatedEvent{} -} - -func (h *MeetingRoomCreatedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*MeetingRoomCreatedEvent)) -} - -func SetMeetingRoomCreatedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *MeetingRoomCreatedEvent) error) { - event.SetTypeHandler(conf, "meeting_room.meeting_room.created_v1", &MeetingRoomCreatedEventHandler{Fn: fn}) -} - -type MeetingRoomDeletedEventHandler struct { - Fn func(*core.Context, *MeetingRoomDeletedEvent) error -} - -func (h *MeetingRoomDeletedEventHandler) GetEvent() interface{} { - return &MeetingRoomDeletedEvent{} -} - -func (h *MeetingRoomDeletedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*MeetingRoomDeletedEvent)) -} - -func SetMeetingRoomDeletedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *MeetingRoomDeletedEvent) error) { - event.SetTypeHandler(conf, "meeting_room.meeting_room.deleted_v1", &MeetingRoomDeletedEventHandler{Fn: fn}) -} - -type MeetingRoomUpdatedEventHandler struct { - Fn func(*core.Context, *MeetingRoomUpdatedEvent) error -} - -func (h *MeetingRoomUpdatedEventHandler) GetEvent() interface{} { - return &MeetingRoomUpdatedEvent{} -} - -func (h *MeetingRoomUpdatedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*MeetingRoomUpdatedEvent)) -} - -func SetMeetingRoomUpdatedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *MeetingRoomUpdatedEvent) error) { - event.SetTypeHandler(conf, "meeting_room.meeting_room.updated_v1", &MeetingRoomUpdatedEventHandler{Fn: fn}) -} diff --git a/service/meeting_room/v1/model.go b/service/meeting_room/v1/model.go deleted file mode 100644 index 7bc15a0a..00000000 --- a/service/meeting_room/v1/model.go +++ /dev/null @@ -1,417 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" - "github.com/larksuite/oapi-sdk-go/event/core/model" -) - -type Building struct { - BuildingId string `json:"building_id,omitempty"` - Description string `json:"description,omitempty"` - Floors []string `json:"floors,omitempty"` - Name string `json:"name,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Building) MarshalJSON() ([]byte, error) { - type cp Building - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type BuildingId struct { - BuildingId string `json:"building_id,omitempty"` - CustomBuildingId string `json:"custom_building_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *BuildingId) MarshalJSON() ([]byte, error) { - type cp BuildingId - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Country struct { - CountryId string `json:"country_id,omitempty"` - Name string `json:"name,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Country) MarshalJSON() ([]byte, error) { - type cp Country - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type District struct { - DistrictId string `json:"district_id,omitempty"` - Name string `json:"name,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *District) MarshalJSON() ([]byte, error) { - type cp District - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ErrorEventUid struct { - Uid string `json:"uid,omitempty"` - OriginalTime int `json:"original_time,omitempty"` - ErrorMsg string `json:"error_msg,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ErrorEventUid) MarshalJSON() ([]byte, error) { - type cp ErrorEventUid - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type EventInfo struct { - Uid string `json:"uid,omitempty"` - OriginalTime int `json:"original_time,omitempty"` - Summary string `json:"summary,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *EventInfo) MarshalJSON() ([]byte, error) { - type cp EventInfo - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type EventUid struct { - Uid string `json:"uid,omitempty"` - OriginalTime int `json:"original_time,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *EventUid) MarshalJSON() ([]byte, error) { - type cp EventUid - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Freebusy struct { -} - -type Instance struct { -} - -type OrganizerInfo struct { - Name string `json:"name,omitempty"` - OpenId string `json:"open_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *OrganizerInfo) MarshalJSON() ([]byte, error) { - type cp OrganizerInfo - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Room struct { - RoomId string `json:"room_id,omitempty"` - BuildingId string `json:"building_id,omitempty"` - BuildingName string `json:"building_name,omitempty"` - Capacity int `json:"capacity,omitempty"` - Description string `json:"description,omitempty"` - DisplayId string `json:"display_id,omitempty"` - FloorName string `json:"floor_name,omitempty"` - IsDisabled bool `json:"is_disabled,omitempty"` - Name string `json:"name,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Room) MarshalJSON() ([]byte, error) { - type cp Room - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type RoomFreeBusy struct { - StartTime string `json:"start_time,omitempty"` - EndTime string `json:"end_time,omitempty"` - Uid string `json:"uid,omitempty"` - OriginalTime int `json:"original_time,omitempty"` - OrganizerInfo *OrganizerInfo `json:"organizer_info,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *RoomFreeBusy) MarshalJSON() ([]byte, error) { - type cp RoomFreeBusy - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type RoomId struct { - RoomId string `json:"room_id,omitempty"` - CustomRoomId string `json:"custom_room_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *RoomId) MarshalJSON() ([]byte, error) { - type cp RoomId - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Summary struct { -} - -type MeetingRoom struct { - RoomId int `json:"room_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MeetingRoom) MarshalJSON() ([]byte, error) { - type cp MeetingRoom - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type FreebusyBatchGetResult struct { - TimeMin string `json:"time_min,omitempty"` - TimeMax string `json:"time_max,omitempty"` - FreeBusy map[string][]*RoomFreeBusy `json:"free_busy,omitempty"` -} - -type SummaryBatchGetReqBody struct { - EventUids []*EventUid `json:"EventUids,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SummaryBatchGetReqBody) MarshalJSON() ([]byte, error) { - type cp SummaryBatchGetReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SummaryBatchGetResult struct { - EventInfos []*EventInfo `json:"EventInfos,omitempty"` - ErrorEventUids []*ErrorEventUid `json:"ErrorEventUids,omitempty"` -} - -type BuildingBatchGetResult struct { - Buildings []*Building `json:"buildings,omitempty"` -} - -type RoomBatchGetResult struct { - Rooms []*Room `json:"rooms,omitempty"` -} - -type BuildingBatchGetIdResult struct { - Buildings []*BuildingId `json:"buildings,omitempty"` -} - -type RoomBatchGetIdResult struct { - Rooms []*RoomId `json:"rooms,omitempty"` -} - -type RoomCreateReqBody struct { - BuildingId string `json:"building_id,omitempty"` - Floor string `json:"floor,omitempty"` - Name string `json:"name,omitempty"` - Capacity int `json:"capacity,omitempty"` - IsDisabled bool `json:"is_disabled,omitempty"` - CustomRoomId string `json:"custom_room_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *RoomCreateReqBody) MarshalJSON() ([]byte, error) { - type cp RoomCreateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type RoomCreateResult struct { - RoomId string `json:"room_id,omitempty"` -} - -type BuildingCreateReqBody struct { - Name string `json:"name,omitempty"` - Floors []string `json:"floors,omitempty"` - CountryId string `json:"country_id,omitempty"` - DistrictId string `json:"district_id,omitempty"` - CustomBuildingId string `json:"custom_building_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *BuildingCreateReqBody) MarshalJSON() ([]byte, error) { - type cp BuildingCreateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type BuildingCreateResult struct { - BuildingId string `json:"building_id,omitempty"` -} - -type BuildingDeleteReqBody struct { - BuildingId string `json:"building_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *BuildingDeleteReqBody) MarshalJSON() ([]byte, error) { - type cp BuildingDeleteReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type RoomDeleteReqBody struct { - RoomId string `json:"room_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *RoomDeleteReqBody) MarshalJSON() ([]byte, error) { - type cp RoomDeleteReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type CountryListResult struct { - Countries []*Country `json:"countries,omitempty"` -} - -type BuildingListResult struct { - PageToken string `json:"page_token,omitempty"` - HasMore bool `json:"has_more,omitempty"` - Buildings []*Building `json:"buildings,omitempty"` -} - -type RoomListResult struct { - PageToken string `json:"page_token,omitempty"` - HasMore bool `json:"has_more,omitempty"` - Rooms []*Room `json:"rooms,omitempty"` -} - -type DistrictListResult struct { - Districts []*District `json:"districts,omitempty"` -} - -type InstanceReplyReqBody struct { - RoomId string `json:"room_id,omitempty"` - Uid string `json:"uid,omitempty"` - OriginalTime int `json:"original_time,omitempty"` - Status string `json:"status,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *InstanceReplyReqBody) MarshalJSON() ([]byte, error) { - type cp InstanceReplyReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type BuildingUpdateReqBody struct { - BuildingId string `json:"building_id,omitempty"` - Name string `json:"name,omitempty"` - Floors []string `json:"floors,omitempty"` - CountryId string `json:"country_id,omitempty"` - DistrictId string `json:"district_id,omitempty"` - CustomBuildingId string `json:"custom_building_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *BuildingUpdateReqBody) MarshalJSON() ([]byte, error) { - type cp BuildingUpdateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type RoomUpdateReqBody struct { - RoomId string `json:"room_id,omitempty"` - Name string `json:"name,omitempty"` - Capacity int `json:"capacity,omitempty"` - IsDisabled bool `json:"is_disabled,omitempty"` - CustomRoomId string `json:"custom_room_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *RoomUpdateReqBody) MarshalJSON() ([]byte, error) { - type cp RoomUpdateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type RoomCreatedEventData struct { - RoomId string `json:"room_id,omitempty"` - RoomName string `json:"room_name,omitempty"` -} - -type RoomCreatedEvent struct { - *model.BaseEventV2 - Event *RoomCreatedEventData `json:"event"` -} - -type RoomDeletedEventData struct { - RoomId string `json:"room_id,omitempty"` - RoomName string `json:"room_name,omitempty"` -} - -type RoomDeletedEvent struct { - *model.BaseEventV2 - Event *RoomDeletedEventData `json:"event"` -} - -type RoomStatusChangedEventData struct { - RoomId string `json:"room_id,omitempty"` - RoomName string `json:"room_name,omitempty"` -} - -type RoomStatusChangedEvent struct { - *model.BaseEventV2 - Event *RoomStatusChangedEventData `json:"event"` -} - -type RoomUpdatedEventData struct { - RoomId string `json:"room_id,omitempty"` - RoomName string `json:"room_name,omitempty"` -} - -type RoomUpdatedEvent struct { - *model.BaseEventV2 - Event *RoomUpdatedEventData `json:"event"` -} - -type MeetingRoomStatusChangedEventData struct { - RoomName string `json:"room_name,omitempty"` - RoomId string `json:"room_id,omitempty"` -} - -type MeetingRoomStatusChangedEvent struct { - *model.BaseEventV2 - Event *MeetingRoomStatusChangedEventData `json:"event"` -} - -type MeetingRoomCreatedEventData struct { - RoomName string `json:"room_name,omitempty"` - RoomId string `json:"room_id,omitempty"` -} - -type MeetingRoomCreatedEvent struct { - *model.BaseEventV2 - Event *MeetingRoomCreatedEventData `json:"event"` -} - -type MeetingRoomDeletedEventData struct { - RoomName string `json:"room_name,omitempty"` - RoomId string `json:"room_id,omitempty"` -} - -type MeetingRoomDeletedEvent struct { - *model.BaseEventV2 - Event *MeetingRoomDeletedEventData `json:"event"` -} - -type MeetingRoomUpdatedEventData struct { - RoomName string `json:"room_name,omitempty"` - RoomId string `json:"room_id,omitempty"` -} - -type MeetingRoomUpdatedEvent struct { - *model.BaseEventV2 - Event *MeetingRoomUpdatedEventData `json:"event"` -} diff --git a/service/optical_char_recognition/v1/api.go b/service/optical_char_recognition/v1/api.go deleted file mode 100644 index 4a872b4c..00000000 --- a/service/optical_char_recognition/v1/api.go +++ /dev/null @@ -1,56 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - Images *ImageService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Images = newImageService(s) - return s -} - -type ImageService struct { - service *Service -} - -func newImageService(service *Service) *ImageService { - return &ImageService{ - service: service, - } -} - -type ImageBasicRecognizeReqCall struct { - ctx *core.Context - images *ImageService - body *ImageBasicRecognizeReqBody - optFns []request.OptFn -} - -func (rc *ImageBasicRecognizeReqCall) Do() (*ImageBasicRecognizeResult, error) { - var result = &ImageBasicRecognizeResult{} - req := request.NewRequest("/open-apis/optical_char_recognition/v1/image/basic_recognize", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.images.service.conf, req) - return result, err -} - -func (images *ImageService) BasicRecognize(ctx *core.Context, body *ImageBasicRecognizeReqBody, optFns ...request.OptFn) *ImageBasicRecognizeReqCall { - return &ImageBasicRecognizeReqCall{ - ctx: ctx, - images: images, - body: body, - optFns: optFns, - } -} diff --git a/service/optical_char_recognition/v1/model.go b/service/optical_char_recognition/v1/model.go deleted file mode 100644 index b0dc568b..00000000 --- a/service/optical_char_recognition/v1/model.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" -) - -type Image struct { -} - -type ImageBasicRecognizeReqBody struct { - Image string `json:"image,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ImageBasicRecognizeReqBody) MarshalJSON() ([]byte, error) { - type cp ImageBasicRecognizeReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ImageBasicRecognizeResult struct { - TextList []string `json:"text_list,omitempty"` -} diff --git a/service/sheets/v2/api.go b/service/sheets/v2/api.go deleted file mode 100644 index 82b6c989..00000000 --- a/service/sheets/v2/api.go +++ /dev/null @@ -1,1067 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v2 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - Spreadsheetss *SpreadsheetsService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Spreadsheetss = newSpreadsheetsService(s) - return s -} - -type SpreadsheetsService struct { - service *Service -} - -func newSpreadsheetsService(service *Service) *SpreadsheetsService { - return &SpreadsheetsService{ - service: service, - } -} - -type SpreadsheetsConditionFormatsBatchCreateReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsConditionFormatsBatchCreateReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsConditionFormatsBatchCreateReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsConditionFormatsBatchCreateReqCall) Do() (*SpreadsheetsConditionFormatsBatchCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsConditionFormatsBatchCreateResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/condition_formats/batch_create", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) ConditionFormatsBatchCreate(ctx *core.Context, body *SpreadsheetsConditionFormatsBatchCreateReqBody, optFns ...request.OptFn) *SpreadsheetsConditionFormatsBatchCreateReqCall { - return &SpreadsheetsConditionFormatsBatchCreateReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsConditionFormatsBatchDeleteReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsConditionFormatsBatchDeleteReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsConditionFormatsBatchDeleteReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsConditionFormatsBatchDeleteReqCall) Do() (*SpreadsheetsConditionFormatsBatchDeleteResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsConditionFormatsBatchDeleteResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/condition_formats/batch_delete", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) ConditionFormatsBatchDelete(ctx *core.Context, body *SpreadsheetsConditionFormatsBatchDeleteReqBody, optFns ...request.OptFn) *SpreadsheetsConditionFormatsBatchDeleteReqCall { - return &SpreadsheetsConditionFormatsBatchDeleteReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsConditionFormatsBatchGetReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsConditionFormatsBatchGetReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} -func (rc *SpreadsheetsConditionFormatsBatchGetReqCall) SetSheetIds(sheetIds ...string) { - rc.queryParams["sheet_ids"] = sheetIds -} - -func (rc *SpreadsheetsConditionFormatsBatchGetReqCall) Do() (*SpreadsheetsConditionFormatsBatchGetResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &SpreadsheetsConditionFormatsBatchGetResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/condition_formats", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) ConditionFormatsBatchGet(ctx *core.Context, optFns ...request.OptFn) *SpreadsheetsConditionFormatsBatchGetReqCall { - return &SpreadsheetsConditionFormatsBatchGetReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsConditionFormatsBatchUpdateReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsConditionFormatsBatchUpdateReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsConditionFormatsBatchUpdateReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsConditionFormatsBatchUpdateReqCall) Do() (*SpreadsheetsConditionFormatsBatchUpdateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsConditionFormatsBatchUpdateResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/condition_formats/batch_update", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) ConditionFormatsBatchUpdate(ctx *core.Context, body *SpreadsheetsConditionFormatsBatchUpdateReqBody, optFns ...request.OptFn) *SpreadsheetsConditionFormatsBatchUpdateReqCall { - return &SpreadsheetsConditionFormatsBatchUpdateReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsDataValidationCreateReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsDataValidationCreateReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsDataValidationCreateReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsDataValidationCreateReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/dataValidation", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) DataValidationCreate(ctx *core.Context, body *SpreadsheetsDataValidationCreateReqBody, optFns ...request.OptFn) *SpreadsheetsDataValidationCreateReqCall { - return &SpreadsheetsDataValidationCreateReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsDataValidationDeleteReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsDataValidationDeleteReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsDataValidationDeleteReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsDataValidationDeleteReqCall) Do() (*SpreadsheetsDataValidationDeleteResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsDataValidationDeleteResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/dataValidation", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) DataValidationDelete(ctx *core.Context, body *SpreadsheetsDataValidationDeleteReqBody, optFns ...request.OptFn) *SpreadsheetsDataValidationDeleteReqCall { - return &SpreadsheetsDataValidationDeleteReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsDataValidationGetReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsDataValidationGetReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} -func (rc *SpreadsheetsDataValidationGetReqCall) SetRange(range_ string) { - rc.pathParams["range"] = range_ -} -func (rc *SpreadsheetsDataValidationGetReqCall) SetDataValidationType(dataValidationType string) { - rc.pathParams["dataValidationType"] = dataValidationType -} - -func (rc *SpreadsheetsDataValidationGetReqCall) Do() (*SpreadsheetsDataValidationGetResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsDataValidationGetResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/dataValidation", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) DataValidationGet(ctx *core.Context, optFns ...request.OptFn) *SpreadsheetsDataValidationGetReqCall { - return &SpreadsheetsDataValidationGetReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsDataValidationUpdateReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsDataValidationUpdateReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsDataValidationUpdateReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} -func (rc *SpreadsheetsDataValidationUpdateReqCall) SetSheetId(sheetId string) { - rc.pathParams["sheetId"] = sheetId -} -func (rc *SpreadsheetsDataValidationUpdateReqCall) SetDataValidationId(dataValidationId int) { - rc.pathParams["dataValidationId"] = dataValidationId -} - -func (rc *SpreadsheetsDataValidationUpdateReqCall) Do() (*SpreadsheetsDataValidationUpdateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsDataValidationUpdateResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/dataValidation/:sheetId/:dataValidationId", "PUT", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) DataValidationUpdate(ctx *core.Context, body *SpreadsheetsDataValidationUpdateReqBody, optFns ...request.OptFn) *SpreadsheetsDataValidationUpdateReqCall { - return &SpreadsheetsDataValidationUpdateReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsDimensionRangeAddReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsDimensionRangeAddReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsDimensionRangeAddReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsDimensionRangeAddReqCall) Do() (*SpreadsheetsDimensionRangeAddResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsDimensionRangeAddResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/dimension_range", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) DimensionRangeAdd(ctx *core.Context, body *SpreadsheetsDimensionRangeAddReqBody, optFns ...request.OptFn) *SpreadsheetsDimensionRangeAddReqCall { - return &SpreadsheetsDimensionRangeAddReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsDimensionRangeDeleteReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsDimensionRangeDeleteReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsDimensionRangeDeleteReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsDimensionRangeDeleteReqCall) Do() (*SpreadsheetsDimensionRangeDeleteResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsDimensionRangeDeleteResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/dimension_range", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) DimensionRangeDelete(ctx *core.Context, body *SpreadsheetsDimensionRangeDeleteReqBody, optFns ...request.OptFn) *SpreadsheetsDimensionRangeDeleteReqCall { - return &SpreadsheetsDimensionRangeDeleteReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsDimensionRangeUpdateReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsDimensionRangeUpdateReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsDimensionRangeUpdateReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsDimensionRangeUpdateReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/dimension_range", "PUT", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) DimensionRangeUpdate(ctx *core.Context, body *SpreadsheetsDimensionRangeUpdateReqBody, optFns ...request.OptFn) *SpreadsheetsDimensionRangeUpdateReqCall { - return &SpreadsheetsDimensionRangeUpdateReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsImportReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsImportReqBody - optFns []request.OptFn -} - -func (rc *SpreadsheetsImportReqCall) Do() (*SpreadsheetsImportResult, error) { - var result = &SpreadsheetsImportResult{} - req := request.NewRequest("/open-apis/sheets/v2/import", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) Import(ctx *core.Context, body *SpreadsheetsImportReqBody, optFns ...request.OptFn) *SpreadsheetsImportReqCall { - return &SpreadsheetsImportReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - optFns: optFns, - } -} - -type SpreadsheetsImportResultReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsImportResultReqCall) SetTicket(ticket string) { - rc.queryParams["ticket"] = ticket -} - -func (rc *SpreadsheetsImportResultReqCall) Do() (*SpreadsheetsImportResultResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &SpreadsheetsImportResultResult{} - req := request.NewRequest("/open-apis/sheets/v2/import/result", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) ImportResult(ctx *core.Context, optFns ...request.OptFn) *SpreadsheetsImportResultReqCall { - return &SpreadsheetsImportResultReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsInsertDimensionRangeReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsInsertDimensionRangeReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsInsertDimensionRangeReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsInsertDimensionRangeReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/insert_dimension_range", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) InsertDimensionRange(ctx *core.Context, body *SpreadsheetsInsertDimensionRangeReqBody, optFns ...request.OptFn) *SpreadsheetsInsertDimensionRangeReqCall { - return &SpreadsheetsInsertDimensionRangeReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsMergeCellsReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsMergeCellsReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsMergeCellsReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsMergeCellsReqCall) Do() (*SpreadsheetsMergeCellsResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsMergeCellsResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/merge_cells", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) MergeCells(ctx *core.Context, body *SpreadsheetsMergeCellsReqBody, optFns ...request.OptFn) *SpreadsheetsMergeCellsReqCall { - return &SpreadsheetsMergeCellsReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsMetainfoReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsMetainfoReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} -func (rc *SpreadsheetsMetainfoReqCall) SetExtFields(extFields string) { - rc.queryParams["extFields"] = extFields -} - -func (rc *SpreadsheetsMetainfoReqCall) Do() (*SpreadsheetsMetainfoResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &SpreadsheetsMetainfoResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/metainfo", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) Metainfo(ctx *core.Context, optFns ...request.OptFn) *SpreadsheetsMetainfoReqCall { - return &SpreadsheetsMetainfoReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsProtectedRangeBatchCreateReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsProtectedRangeBatchCreateReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsProtectedRangeBatchCreateReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsProtectedRangeBatchCreateReqCall) Do() (*SpreadsheetsProtectedRangeBatchCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsProtectedRangeBatchCreateResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/protected_dimension", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) ProtectedRangeBatchCreate(ctx *core.Context, body *SpreadsheetsProtectedRangeBatchCreateReqBody, optFns ...request.OptFn) *SpreadsheetsProtectedRangeBatchCreateReqCall { - return &SpreadsheetsProtectedRangeBatchCreateReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsProtectedRangeBatchDeleteReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsProtectedRangeBatchDeleteReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsProtectedRangeBatchDeleteReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsProtectedRangeBatchDeleteReqCall) Do() (*SpreadsheetsProtectedRangeBatchDeleteResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsProtectedRangeBatchDeleteResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/protected_range_batch_del", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) ProtectedRangeBatchDelete(ctx *core.Context, body *SpreadsheetsProtectedRangeBatchDeleteReqBody, optFns ...request.OptFn) *SpreadsheetsProtectedRangeBatchDeleteReqCall { - return &SpreadsheetsProtectedRangeBatchDeleteReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsProtectedRangeBatchGetReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsProtectedRangeBatchGetReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} -func (rc *SpreadsheetsProtectedRangeBatchGetReqCall) SetProtectIds(protectIds ...string) { - rc.queryParams["protectIds"] = protectIds -} -func (rc *SpreadsheetsProtectedRangeBatchGetReqCall) SetMemberType(memberType string) { - rc.queryParams["memberType"] = memberType -} - -func (rc *SpreadsheetsProtectedRangeBatchGetReqCall) Do() (*SpreadsheetsProtectedRangeBatchGetResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &SpreadsheetsProtectedRangeBatchGetResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/protected_range_batch_get", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) ProtectedRangeBatchGet(ctx *core.Context, optFns ...request.OptFn) *SpreadsheetsProtectedRangeBatchGetReqCall { - return &SpreadsheetsProtectedRangeBatchGetReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsProtectedRangeBatchUpdateReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsProtectedRangeBatchUpdateReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsProtectedRangeBatchUpdateReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsProtectedRangeBatchUpdateReqCall) Do() (*SpreadsheetsProtectedRangeBatchUpdateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsProtectedRangeBatchUpdateResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/protected_range_batch_update", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) ProtectedRangeBatchUpdate(ctx *core.Context, body *SpreadsheetsProtectedRangeBatchUpdateReqBody, optFns ...request.OptFn) *SpreadsheetsProtectedRangeBatchUpdateReqCall { - return &SpreadsheetsProtectedRangeBatchUpdateReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsSheetsBatchUpdateReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsSheetsBatchUpdateReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsSheetsBatchUpdateReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsSheetsBatchUpdateReqCall) Do() (*SpreadsheetsSheetsBatchUpdateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsSheetsBatchUpdateResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/sheets_batch_update", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) SheetsBatchUpdate(ctx *core.Context, body *SpreadsheetsSheetsBatchUpdateReqBody, optFns ...request.OptFn) *SpreadsheetsSheetsBatchUpdateReqCall { - return &SpreadsheetsSheetsBatchUpdateReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsSheetsUpdatePropertiesReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsSheetsUpdatePropertiesReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsSheetsUpdatePropertiesReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsSheetsUpdatePropertiesReqCall) Do() (*SpreadsheetsSheetsUpdatePropertiesResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsSheetsUpdatePropertiesResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/properties", "PUT", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) SheetsUpdateProperties(ctx *core.Context, body *SpreadsheetsSheetsUpdatePropertiesReqBody, optFns ...request.OptFn) *SpreadsheetsSheetsUpdatePropertiesReqCall { - return &SpreadsheetsSheetsUpdatePropertiesReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsStyleUpdateReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsStyleUpdateReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsStyleUpdateReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsStyleUpdateReqCall) Do() (*SpreadsheetsStyleUpdateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsStyleUpdateResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/style", "PUT", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) StyleUpdate(ctx *core.Context, body *SpreadsheetsStyleUpdateReqBody, optFns ...request.OptFn) *SpreadsheetsStyleUpdateReqCall { - return &SpreadsheetsStyleUpdateReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsStylesBatchUpdateReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsStylesBatchUpdateReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsStylesBatchUpdateReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsStylesBatchUpdateReqCall) Do() (*SpreadsheetsStylesBatchUpdateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsStylesBatchUpdateResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/styles_batch_update", "PUT", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) StylesBatchUpdate(ctx *core.Context, body *SpreadsheetsStylesBatchUpdateReqBody, optFns ...request.OptFn) *SpreadsheetsStylesBatchUpdateReqCall { - return &SpreadsheetsStylesBatchUpdateReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsUnmergeCellsReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsUnmergeCellsReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsUnmergeCellsReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsUnmergeCellsReqCall) Do() (*SpreadsheetsUnmergeCellsResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsUnmergeCellsResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/unmerge_cells", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) UnmergeCells(ctx *core.Context, body *SpreadsheetsUnmergeCellsReqBody, optFns ...request.OptFn) *SpreadsheetsUnmergeCellsReqCall { - return &SpreadsheetsUnmergeCellsReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsValuesAppendReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsValuesAppendReqBody - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsValuesAppendReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} -func (rc *SpreadsheetsValuesAppendReqCall) SetInsertDataOption(insertDataOption string) { - rc.queryParams["insertDataOption"] = insertDataOption -} - -func (rc *SpreadsheetsValuesAppendReqCall) Do() (*SpreadsheetsValuesAppendResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &SpreadsheetsValuesAppendResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/values_append", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) ValuesAppend(ctx *core.Context, body *SpreadsheetsValuesAppendReqBody, optFns ...request.OptFn) *SpreadsheetsValuesAppendReqCall { - return &SpreadsheetsValuesAppendReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsValuesBatchGetReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsValuesBatchGetReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} -func (rc *SpreadsheetsValuesBatchGetReqCall) SetRanges(ranges ...string) { - rc.queryParams["ranges"] = ranges -} -func (rc *SpreadsheetsValuesBatchGetReqCall) SetValueRenderOption(valueRenderOption string) { - rc.queryParams["valueRenderOption"] = valueRenderOption -} -func (rc *SpreadsheetsValuesBatchGetReqCall) SetDateTimeRenderOption(dateTimeRenderOption string) { - rc.queryParams["dateTimeRenderOption"] = dateTimeRenderOption -} - -func (rc *SpreadsheetsValuesBatchGetReqCall) Do() (*SpreadsheetsValuesBatchGetResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &SpreadsheetsValuesBatchGetResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/values_batch_get", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) ValuesBatchGet(ctx *core.Context, optFns ...request.OptFn) *SpreadsheetsValuesBatchGetReqCall { - return &SpreadsheetsValuesBatchGetReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsValuesBatchUpdateReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsValuesBatchUpdateReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsValuesBatchUpdateReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsValuesBatchUpdateReqCall) Do() (*SpreadsheetsValuesBatchUpdateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsValuesBatchUpdateResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/values_batch_update", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) ValuesBatchUpdate(ctx *core.Context, body *SpreadsheetsValuesBatchUpdateReqBody, optFns ...request.OptFn) *SpreadsheetsValuesBatchUpdateReqCall { - return &SpreadsheetsValuesBatchUpdateReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsValuesGetReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsValuesGetReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} -func (rc *SpreadsheetsValuesGetReqCall) SetRange(range_ string) { - rc.pathParams["range"] = range_ -} -func (rc *SpreadsheetsValuesGetReqCall) SetValueRenderOption(valueRenderOption string) { - rc.queryParams["valueRenderOption"] = valueRenderOption -} -func (rc *SpreadsheetsValuesGetReqCall) SetDateTimeRenderOption(dateTimeRenderOption string) { - rc.queryParams["dateTimeRenderOption"] = dateTimeRenderOption -} - -func (rc *SpreadsheetsValuesGetReqCall) Do() (*SpreadsheetsValuesGetResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &SpreadsheetsValuesGetResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/values/:range", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) ValuesGet(ctx *core.Context, optFns ...request.OptFn) *SpreadsheetsValuesGetReqCall { - return &SpreadsheetsValuesGetReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsValuesImageReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsValuesImageReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsValuesImageReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsValuesImageReqCall) Do() (*SpreadsheetsValuesImageResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsValuesImageResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/values_image", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) ValuesImage(ctx *core.Context, body *SpreadsheetsValuesImageReqBody, optFns ...request.OptFn) *SpreadsheetsValuesImageReqCall { - return &SpreadsheetsValuesImageReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsValuesPrependReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsValuesPrependReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsValuesPrependReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsValuesPrependReqCall) Do() (*SpreadsheetsValuesPrependResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsValuesPrependResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/values_prepend", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) ValuesPrepend(ctx *core.Context, body *SpreadsheetsValuesPrependReqBody, optFns ...request.OptFn) *SpreadsheetsValuesPrependReqCall { - return &SpreadsheetsValuesPrependReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type SpreadsheetsValuesUpdateReqCall struct { - ctx *core.Context - spreadsheetss *SpreadsheetsService - body *SpreadsheetsValuesUpdateReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *SpreadsheetsValuesUpdateReqCall) SetSpreadsheetToken(spreadsheetToken string) { - rc.pathParams["spreadsheetToken"] = spreadsheetToken -} - -func (rc *SpreadsheetsValuesUpdateReqCall) Do() (*SpreadsheetsValuesUpdateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &SpreadsheetsValuesUpdateResult{} - req := request.NewRequest("/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/values", "PUT", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.spreadsheetss.service.conf, req) - return result, err -} - -func (spreadsheetss *SpreadsheetsService) ValuesUpdate(ctx *core.Context, body *SpreadsheetsValuesUpdateReqBody, optFns ...request.OptFn) *SpreadsheetsValuesUpdateReqCall { - return &SpreadsheetsValuesUpdateReqCall{ - ctx: ctx, - spreadsheetss: spreadsheetss, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} diff --git a/service/sheets/v2/model.go b/service/sheets/v2/model.go deleted file mode 100644 index a214917e..00000000 --- a/service/sheets/v2/model.go +++ /dev/null @@ -1,1039 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v2 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" -) - -type AddProtectedDimension struct { - Dimension *Dimension `json:"dimension,omitempty"` - Editors []int64 `json:"editors,omitempty"` - LockInfo string `json:"lockInfo,omitempty"` - ProtectId string `json:"protectId,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AddProtectedDimension) MarshalJSON() ([]byte, error) { - type cp AddProtectedDimension - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AddSheet struct { - Properties *Properties `json:"properties,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AddSheet) MarshalJSON() ([]byte, error) { - type cp AddSheet - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AppendStyle struct { - Range string `json:"range,omitempty"` - Style *Style `json:"style,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AppendStyle) MarshalJSON() ([]byte, error) { - type cp AppendStyle - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type AppendStyleBatch struct { - Ranges []string `json:"ranges,omitempty"` - Style *Style `json:"style,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *AppendStyleBatch) MarshalJSON() ([]byte, error) { - type cp AppendStyleBatch - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type BlockInfo struct { - BlockToken string `json:"blockToken,omitempty"` - BlockType string `json:"blockType,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *BlockInfo) MarshalJSON() ([]byte, error) { - type cp BlockInfo - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ConditionFormat struct { - CfId string `json:"cf_id,omitempty"` - Ranges []string `json:"ranges,omitempty"` - RuleType string `json:"rule_type,omitempty"` - Attrs []*ConditionFormatAttr `json:"attrs,omitempty"` - Style *ConditionFormatStyle `json:"style,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ConditionFormat) MarshalJSON() ([]byte, error) { - type cp ConditionFormat - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ConditionFormatAttr struct { - Operator string `json:"operator,omitempty"` - TimePeriod string `json:"time_period,omitempty"` - Formula []string `json:"formula,omitempty"` - Text string `json:"text,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ConditionFormatAttr) MarshalJSON() ([]byte, error) { - type cp ConditionFormatAttr - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ConditionFormatFont struct { - Bold bool `json:"bold,omitempty"` - Italic bool `json:"italic,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ConditionFormatFont) MarshalJSON() ([]byte, error) { - type cp ConditionFormatFont - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ConditionFormatResponse struct { - SheetId string `json:"sheet_id,omitempty"` - CfId string `json:"cf_id,omitempty"` - ResCode int `json:"res_code,omitempty"` - ResMsg string `json:"res_msg,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ConditionFormatResponse) MarshalJSON() ([]byte, error) { - type cp ConditionFormatResponse - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ConditionFormatStyle struct { - Font *ConditionFormatFont `json:"font,omitempty"` - TextDecoration int `json:"text_decoration,omitempty"` - ForeColor string `json:"fore_color,omitempty"` - BackColor string `json:"back_color,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ConditionFormatStyle) MarshalJSON() ([]byte, error) { - type cp ConditionFormatStyle - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type CopySheet struct { - Source *Source `json:"source,omitempty"` - Destination *Destination `json:"destination,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *CopySheet) MarshalJSON() ([]byte, error) { - type cp CopySheet - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type CopySheetReply struct { - Properties *Properties `json:"properties,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *CopySheetReply) MarshalJSON() ([]byte, error) { - type cp CopySheetReply - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DataValidationDeleteResult struct { - Range string `json:"range,omitempty"` - Msg string `json:"msg,omitempty"` - Success bool `json:"success,omitempty"` - UpdatedCells int `json:"updatedCells,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DataValidationDeleteResult) MarshalJSON() ([]byte, error) { - type cp DataValidationDeleteResult - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DataValidationRange struct { - Range string `json:"range,omitempty"` - DataValidationIds []int `json:"dataValidationIds,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DataValidationRange) MarshalJSON() ([]byte, error) { - type cp DataValidationRange - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DataValidationRequest struct { - ConditionValues []string `json:"conditionValues,omitempty"` - DataValidationId int `json:"dataValidationId,omitempty"` - DataValidationType string `json:"dataValidationType,omitempty"` - Options *Options `json:"options,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DataValidationRequest) MarshalJSON() ([]byte, error) { - type cp DataValidationRequest - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DataValidationResponse struct { - ConditionValues []string `json:"conditionValues,omitempty"` - DataValidationId int `json:"dataValidationId,omitempty"` - DataValidationType string `json:"dataValidationType,omitempty"` - Options *OptionsResponse `json:"options,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DataValidationResponse) MarshalJSON() ([]byte, error) { - type cp DataValidationResponse - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DeleteSheet struct { - SheetId string `json:"sheetId,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DeleteSheet) MarshalJSON() ([]byte, error) { - type cp DeleteSheet - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DeleteSheetReply struct { - Result bool `json:"result,omitempty"` - SheetId string `json:"sheetId,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DeleteSheetReply) MarshalJSON() ([]byte, error) { - type cp DeleteSheetReply - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Destination struct { - Title string `json:"title,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Destination) MarshalJSON() ([]byte, error) { - type cp Destination - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Dimension struct { - SheetId string `json:"sheetId,omitempty"` - MajorDimension string `json:"majorDimension,omitempty"` - StartIndex int `json:"startIndex,omitempty"` - EndIndex int `json:"endIndex,omitempty"` - Length int `json:"length,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Dimension) MarshalJSON() ([]byte, error) { - type cp Dimension - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DimensionProperties struct { - Visible bool `json:"visible,omitempty"` - FixedSize int `json:"fixedSize,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DimensionProperties) MarshalJSON() ([]byte, error) { - type cp DimensionProperties - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Editors struct { - Users []*User `json:"users,omitempty"` - AddEditors []*User `json:"addEditors,omitempty"` - DelEditors []*User `json:"delEditors,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Editors) MarshalJSON() ([]byte, error) { - type cp Editors - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Font struct { - Bold bool `json:"bold,omitempty"` - Italic bool `json:"italic,omitempty"` - FontSize string `json:"fontSize,omitempty"` - Clean bool `json:"clean,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Font) MarshalJSON() ([]byte, error) { - type cp Font - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Merge struct { - StartRowIndex int `json:"startRowIndex,omitempty"` - StartColumnIndex int `json:"startColumnIndex,omitempty"` - RowCount int `json:"rowCount,omitempty"` - ColumnCount int `json:"columnCount,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Merge) MarshalJSON() ([]byte, error) { - type cp Merge - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MetainfoProperties struct { - Title string `json:"title,omitempty"` - OwnerUser int64 `json:"ownerUser,omitempty"` - SheetCount int `json:"sheetCount,omitempty"` - Revision int `json:"revision,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MetainfoProperties) MarshalJSON() ([]byte, error) { - type cp MetainfoProperties - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Options struct { - MultipleValues bool `json:"multipleValues,omitempty"` - HighlightValidData bool `json:"highlightValidData,omitempty"` - Colors []string `json:"colors,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Options) MarshalJSON() ([]byte, error) { - type cp Options - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type OptionsResponse struct { - MultipleValues bool `json:"multipleValues,omitempty"` - HighlightValidData bool `json:"highlightValidData,omitempty"` - ColorValueMap map[string]string `json:"colorValueMap,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *OptionsResponse) MarshalJSON() ([]byte, error) { - type cp OptionsResponse - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Properties struct { - SheetId string `json:"sheetId,omitempty"` - Title string `json:"title,omitempty"` - Index int `json:"index,omitempty"` - Hidden bool `json:"hidden,omitempty"` - FrozenRowCount int `json:"frozenRowCount,omitempty"` - FrozenColCount int `json:"frozenColCount,omitempty"` - Protect *Protect `json:"protect,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Properties) MarshalJSON() ([]byte, error) { - type cp Properties - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Protect struct { - Lock string `json:"lock,omitempty"` - LockInfo string `json:"lockInfo,omitempty"` - UserIds []int64 `json:"userIds,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Protect) MarshalJSON() ([]byte, error) { - type cp Protect - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ProtectedRange struct { - ProtectId string `json:"protectId,omitempty"` - Dimension *Dimension `json:"dimension,omitempty"` - SheetId string `json:"sheetId,omitempty"` - LockInfo string `json:"lockInfo,omitempty"` - Editors *Editors `json:"editors,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ProtectedRange) MarshalJSON() ([]byte, error) { - type cp ProtectedRange - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ProtectedRangeUpdate struct { - ProtectId string `json:"protectId,omitempty"` - Dimension *Dimension `json:"dimension,omitempty"` - SheetId string `json:"sheetId,omitempty"` - LockInfo string `json:"lockInfo,omitempty"` - Editors *Editors `json:"editors,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ProtectedRangeUpdate) MarshalJSON() ([]byte, error) { - type cp ProtectedRangeUpdate - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Reply struct { - UpdateSheet *Properties `json:"updateSheet,omitempty"` - AddSheet *AddSheet `json:"addSheet,omitempty"` - CopySheet *CopySheetReply `json:"copySheet,omitempty"` - DeleteSheet *DeleteSheetReply `json:"deleteSheet,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Reply) MarshalJSON() ([]byte, error) { - type cp Reply - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Request struct { - AddSheet *AddSheet `json:"addSheet,omitempty"` - CopySheet *CopySheet `json:"copySheet,omitempty"` - DeleteSheet *DeleteSheet `json:"deleteSheet,omitempty"` - UpdateSheet *UpdateSheet `json:"updateSheet,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Request) MarshalJSON() ([]byte, error) { - type cp Request - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Sheet struct { - SheetId string `json:"sheetId,omitempty"` - Title string `json:"title,omitempty"` - Index int `json:"index,omitempty"` - RowCount int `json:"rowCount,omitempty"` - ColumnCount int `json:"columnCount,omitempty"` - FrozenRowCount int `json:"frozenRowCount,omitempty"` - FrozenColCount int `json:"frozenColCount,omitempty"` - Merges []*Merge `json:"merges,omitempty"` - ProtectedRange []*ProtectedRange `json:"protectedRange,omitempty"` - BlockInfo *BlockInfo `json:"blockInfo,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Sheet) MarshalJSON() ([]byte, error) { - type cp Sheet - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SheetCfId struct { - SheetId string `json:"sheet_id,omitempty"` - CfId string `json:"cf_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SheetCfId) MarshalJSON() ([]byte, error) { - type cp SheetCfId - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SheetConditionFormat struct { - SheetId string `json:"sheet_id,omitempty"` - ConditionFormat *ConditionFormat `json:"condition_format,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SheetConditionFormat) MarshalJSON() ([]byte, error) { - type cp SheetConditionFormat - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Source struct { - SheetId string `json:"sheetId,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Source) MarshalJSON() ([]byte, error) { - type cp Source - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetToken struct { - Range string `json:"range,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetToken) MarshalJSON() ([]byte, error) { - type cp SpreadsheetToken - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Style struct { - Font *Font `json:"font,omitempty"` - TextDecoration int `json:"textDecoration,omitempty"` - Formatter string `json:"formatter,omitempty"` - HAlign int `json:"hAlign,omitempty"` - VAlign int `json:"vAlign,omitempty"` - ForeColor string `json:"foreColor,omitempty"` - BackColor string `json:"backColor,omitempty"` - BorderType string `json:"borderType,omitempty"` - BorderColor string `json:"borderColor,omitempty"` - Clean bool `json:"clean,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Style) MarshalJSON() ([]byte, error) { - type cp Style - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type UpdateResponse struct { - SpreadsheetToken string `json:"spreadsheetToken,omitempty"` - UpdatedRange string `json:"updatedRange,omitempty"` - UpdatedRows int `json:"updatedRows,omitempty"` - UpdatedColumns int `json:"updatedColumns,omitempty"` - UpdatedCells int `json:"updatedCells,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *UpdateResponse) MarshalJSON() ([]byte, error) { - type cp UpdateResponse - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type UpdateSheet struct { - Properties *Properties `json:"properties,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *UpdateSheet) MarshalJSON() ([]byte, error) { - type cp UpdateSheet - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Updates struct { - SpreadsheetToken string `json:"spreadsheetToken,omitempty"` - UpdatedRange string `json:"updatedRange,omitempty"` - UpdatedRows int `json:"updatedRows,omitempty"` - UpdatedColumns int `json:"updatedColumns,omitempty"` - UpdatedCells int `json:"updatedCells,omitempty"` - Revision int `json:"revision,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Updates) MarshalJSON() ([]byte, error) { - type cp Updates - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type User struct { - MemberType string `json:"memberType,omitempty"` - MemberId string `json:"memberId,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *User) MarshalJSON() ([]byte, error) { - type cp User - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ValueRange struct { - MajorDimension string `json:"majorDimension,omitempty"` - Range string `json:"range,omitempty"` - Revision int `json:"revision,omitempty"` - Values []interface{} `json:"values,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ValueRange) MarshalJSON() ([]byte, error) { - type cp ValueRange - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsConditionFormatsBatchCreateReqBody struct { - SheetConditionFormats []*SheetConditionFormat `json:"sheet_condition_formats,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsConditionFormatsBatchCreateReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsConditionFormatsBatchCreateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsConditionFormatsBatchCreateResult struct { - Responses []*ConditionFormatResponse `json:"responses,omitempty"` -} - -type SpreadsheetsConditionFormatsBatchDeleteReqBody struct { - SheetCfIds []*SheetCfId `json:"sheet_cf_ids,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsConditionFormatsBatchDeleteReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsConditionFormatsBatchDeleteReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsConditionFormatsBatchDeleteResult struct { - Responses []*ConditionFormatResponse `json:"responses,omitempty"` -} - -type SpreadsheetsConditionFormatsBatchGetResult struct { - SheetConditionFormats []*SheetConditionFormat `json:"sheet_condition_formats,omitempty"` -} - -type SpreadsheetsConditionFormatsBatchUpdateReqBody struct { - SheetConditionFormats []*SheetConditionFormat `json:"sheet_condition_formats,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsConditionFormatsBatchUpdateReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsConditionFormatsBatchUpdateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsConditionFormatsBatchUpdateResult struct { - Responses []*ConditionFormatResponse `json:"responses,omitempty"` -} - -type SpreadsheetsDataValidationCreateReqBody struct { - Range string `json:"range,omitempty"` - DataValidationType string `json:"dataValidationType,omitempty"` - DataValidation *DataValidationRequest `json:"dataValidation,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsDataValidationCreateReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsDataValidationCreateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsDataValidationDeleteReqBody struct { - DataValidationRanges []*DataValidationRange `json:"dataValidationRanges,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsDataValidationDeleteReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsDataValidationDeleteReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsDataValidationDeleteResult struct { - RangeResults []*DataValidationDeleteResult `json:"rangeResults,omitempty"` -} - -type SpreadsheetsDataValidationGetResult struct { - SpreadsheetToken string `json:"spreadsheetToken,omitempty"` - SheetId string `json:"sheetId,omitempty"` - DataValidations []*DataValidationResponse `json:"dataValidations,omitempty"` - Revision int `json:"revision,omitempty"` -} - -type SpreadsheetsDataValidationUpdateReqBody struct { - DataValidationType string `json:"dataValidationType,omitempty"` - DataValidation *DataValidationRequest `json:"dataValidation,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsDataValidationUpdateReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsDataValidationUpdateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsDataValidationUpdateResult struct { - SpreadsheetToken string `json:"spreadsheetToken,omitempty"` - SheetId string `json:"sheetId,omitempty"` - DataValidation *DataValidationResponse `json:"dataValidation,omitempty"` -} - -type SpreadsheetsDimensionRangeAddReqBody struct { - Dimension *Dimension `json:"dimension,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsDimensionRangeAddReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsDimensionRangeAddReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsDimensionRangeAddResult struct { - AddCount int `json:"addCount,omitempty"` - MajorDimension string `json:"majorDimension,omitempty"` -} - -type SpreadsheetsDimensionRangeDeleteReqBody struct { - Dimension *Dimension `json:"dimension,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsDimensionRangeDeleteReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsDimensionRangeDeleteReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsDimensionRangeDeleteResult struct { - DelCount int `json:"delCount,omitempty"` - MajorDimension string `json:"majorDimension,omitempty"` -} - -type SpreadsheetsDimensionRangeUpdateReqBody struct { - Dimension *Dimension `json:"dimension,omitempty"` - DimensionProperties *DimensionProperties `json:"dimensionProperties,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsDimensionRangeUpdateReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsDimensionRangeUpdateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsImportReqBody struct { - File []byte `json:"file,omitempty"` - Name string `json:"name,omitempty"` - FolderToken string `json:"folderToken,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsImportReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsImportReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsImportResult struct { - Ticket string `json:"ticket,omitempty"` -} - -type SpreadsheetsImportResultResult struct { - Ticket string `json:"ticket,omitempty"` - Url string `json:"url,omitempty"` - WarningCode int `json:"warningCode,omitempty"` -} - -type SpreadsheetsInsertDimensionRangeReqBody struct { - Dimension *Dimension `json:"dimension,omitempty"` - InheritStyle string `json:"inheritStyle,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsInsertDimensionRangeReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsInsertDimensionRangeReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsMergeCellsReqBody struct { - SpreadsheetToken string `json:"spreadsheetToken,omitempty"` - Range string `json:"range,omitempty"` - MergeType string `json:"mergeType,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsMergeCellsReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsMergeCellsReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsMergeCellsResult struct { - SpreadsheetToken string `json:"spreadsheetToken,omitempty"` -} - -type SpreadsheetsMetainfoResult struct { - SpreadsheetToken string `json:"spreadsheetToken,omitempty"` - Properties *MetainfoProperties `json:"properties,omitempty"` - Sheets []*Sheet `json:"sheets,omitempty"` -} - -type SpreadsheetsProtectedRangeBatchCreateReqBody struct { - AddProtectedDimension []*AddProtectedDimension `json:"addProtectedDimension,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsProtectedRangeBatchCreateReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsProtectedRangeBatchCreateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsProtectedRangeBatchCreateResult struct { - AddProtectedDimension []*AddProtectedDimension `json:"addProtectedDimension,omitempty"` -} - -type SpreadsheetsProtectedRangeBatchDeleteReqBody struct { - ProtectIds []string `json:"protectIds,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsProtectedRangeBatchDeleteReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsProtectedRangeBatchDeleteReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsProtectedRangeBatchDeleteResult struct { - DelProtectIds []string `json:"delProtectIds,omitempty"` -} - -type SpreadsheetsProtectedRangeBatchGetResult struct { - ProtectedRange []*ProtectedRange `json:"protectedRange,omitempty"` -} - -type SpreadsheetsProtectedRangeBatchUpdateReqBody struct { - Requests []*ProtectedRangeUpdate `json:"requests,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsProtectedRangeBatchUpdateReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsProtectedRangeBatchUpdateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsProtectedRangeBatchUpdateResult struct { - Replies []*ProtectedRangeUpdate `json:"replies,omitempty"` -} - -type SpreadsheetsSheetsBatchUpdateReqBody struct { - Requests []*Request `json:"requests,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsSheetsBatchUpdateReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsSheetsBatchUpdateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsSheetsBatchUpdateResult struct { - Replies []*Reply `json:"replies,omitempty"` -} - -type SpreadsheetsSheetsUpdatePropertiesReqBody struct { - Properties *Properties `json:"properties,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsSheetsUpdatePropertiesReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsSheetsUpdatePropertiesReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsSheetsUpdatePropertiesResult struct { - SpreadsheetToken string `json:"spreadsheetToken,omitempty"` - Title string `json:"title,omitempty"` -} - -type SpreadsheetsStyleUpdateReqBody struct { - AppendStyle *AppendStyle `json:"appendStyle,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsStyleUpdateReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsStyleUpdateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsStyleUpdateResult struct { - SpreadsheetToken string `json:"spreadsheetToken,omitempty"` - UpdatedRange string `json:"updatedRange,omitempty"` - UpdatedRows int `json:"updatedRows,omitempty"` - UpdatedColumns int `json:"updatedColumns,omitempty"` - UpdatedCells int `json:"updatedCells,omitempty"` - Revision int `json:"revision,omitempty"` -} - -type SpreadsheetsStylesBatchUpdateReqBody struct { - Data *AppendStyleBatch `json:"data,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsStylesBatchUpdateReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsStylesBatchUpdateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsStylesBatchUpdateResult struct { - SpreadsheetToken string `json:"spreadsheetToken,omitempty"` - TotalUpdatedRows int `json:"totalUpdatedRows,omitempty"` - TotalUpdatedColumns int `json:"totalUpdatedColumns,omitempty"` - TotalUpdatedCells int `json:"totalUpdatedCells,omitempty"` - Revision int `json:"revision,omitempty"` - Responses []*UpdateResponse `json:"responses,omitempty"` -} - -type SpreadsheetsUnmergeCellsReqBody struct { - Range string `json:"range,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsUnmergeCellsReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsUnmergeCellsReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsUnmergeCellsResult struct { - SpreadsheetToken string `json:"spreadsheetToken,omitempty"` -} - -type SpreadsheetsValuesAppendReqBody struct { - ValueRange *ValueRange `json:"valueRange,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsValuesAppendReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsValuesAppendReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsValuesAppendResult struct { - SpreadsheetToken string `json:"spreadsheetToken,omitempty"` - TableRange string `json:"tableRange,omitempty"` - Revision int `json:"revision,omitempty"` - Updates *Updates `json:"updates,omitempty"` -} - -type SpreadsheetsValuesBatchGetResult struct { - Revision int `json:"revision,omitempty"` - SpreadsheetToken string `json:"spreadsheetToken,omitempty"` - TotalCells int `json:"totalCells,omitempty"` - ValueRanges []*ValueRange `json:"valueRanges,omitempty"` -} - -type SpreadsheetsValuesBatchUpdateReqBody struct { - ValueRanges []*ValueRange `json:"valueRanges,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsValuesBatchUpdateReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsValuesBatchUpdateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsValuesBatchUpdateResult struct { - Responses []*UpdateResponse `json:"responses,omitempty"` - Revision int `json:"revision,omitempty"` - SpreadsheetToken string `json:"spreadsheetToken,omitempty"` -} - -type SpreadsheetsValuesGetResult struct { - Revision int `json:"revision,omitempty"` - SpreadsheetToken string `json:"spreadsheetToken,omitempty"` - ValueRange *ValueRange `json:"valueRange,omitempty"` -} - -type SpreadsheetsValuesImageReqBody struct { - Range string `json:"range,omitempty"` - Image []byte `json:"image,omitempty"` - Name string `json:"name,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsValuesImageReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsValuesImageReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsValuesImageResult struct { - SpreadsheetToken string `json:"spreadsheetToken,omitempty"` -} - -type SpreadsheetsValuesPrependReqBody struct { - ValueRange *ValueRange `json:"valueRange,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsValuesPrependReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsValuesPrependReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsValuesPrependResult struct { - SpreadsheetToken string `json:"spreadsheetToken,omitempty"` - TableRange string `json:"tableRange,omitempty"` - Revision int `json:"revision,omitempty"` - Updates *Updates `json:"updates,omitempty"` -} - -type SpreadsheetsValuesUpdateReqBody struct { - ValueRange *ValueRange `json:"valueRange,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpreadsheetsValuesUpdateReqBody) MarshalJSON() ([]byte, error) { - type cp SpreadsheetsValuesUpdateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpreadsheetsValuesUpdateResult struct { - SpreadsheetToken string `json:"spreadsheetToken,omitempty"` - UpdatedRange string `json:"updatedRange,omitempty"` - UpdatedRows int `json:"updatedRows,omitempty"` - UpdatedColumns int `json:"updatedColumns,omitempty"` - UpdatedCells int `json:"updatedCells,omitempty"` - Revision int `json:"revision,omitempty"` -} diff --git a/service/speech_to_text/v1/api.go b/service/speech_to_text/v1/api.go deleted file mode 100644 index c0c7d24d..00000000 --- a/service/speech_to_text/v1/api.go +++ /dev/null @@ -1,80 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - Speechs *SpeechService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Speechs = newSpeechService(s) - return s -} - -type SpeechService struct { - service *Service -} - -func newSpeechService(service *Service) *SpeechService { - return &SpeechService{ - service: service, - } -} - -type SpeechFileRecognizeReqCall struct { - ctx *core.Context - speechs *SpeechService - body *SpeechFileRecognizeReqBody - optFns []request.OptFn -} - -func (rc *SpeechFileRecognizeReqCall) Do() (*SpeechFileRecognizeResult, error) { - var result = &SpeechFileRecognizeResult{} - req := request.NewRequest("/open-apis/speech_to_text/v1/speech/file_recognize", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.speechs.service.conf, req) - return result, err -} - -func (speechs *SpeechService) FileRecognize(ctx *core.Context, body *SpeechFileRecognizeReqBody, optFns ...request.OptFn) *SpeechFileRecognizeReqCall { - return &SpeechFileRecognizeReqCall{ - ctx: ctx, - speechs: speechs, - body: body, - optFns: optFns, - } -} - -type SpeechStreamRecognizeReqCall struct { - ctx *core.Context - speechs *SpeechService - body *SpeechStreamRecognizeReqBody - optFns []request.OptFn -} - -func (rc *SpeechStreamRecognizeReqCall) Do() (*SpeechStreamRecognizeResult, error) { - var result = &SpeechStreamRecognizeResult{} - req := request.NewRequest("/open-apis/speech_to_text/v1/speech/stream_recognize", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.speechs.service.conf, req) - return result, err -} - -func (speechs *SpeechService) StreamRecognize(ctx *core.Context, body *SpeechStreamRecognizeReqBody, optFns ...request.OptFn) *SpeechStreamRecognizeReqCall { - return &SpeechStreamRecognizeReqCall{ - ctx: ctx, - speechs: speechs, - body: body, - optFns: optFns, - } -} diff --git a/service/speech_to_text/v1/model.go b/service/speech_to_text/v1/model.go deleted file mode 100644 index cf175e62..00000000 --- a/service/speech_to_text/v1/model.go +++ /dev/null @@ -1,80 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" -) - -type FileConfig struct { - FileId string `json:"file_id,omitempty"` - Format string `json:"format,omitempty"` - EngineType string `json:"engine_type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *FileConfig) MarshalJSON() ([]byte, error) { - type cp FileConfig - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Speech struct { - Speech string `json:"speech,omitempty"` - SpeechKey string `json:"speech_key,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Speech) MarshalJSON() ([]byte, error) { - type cp Speech - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type StreamConfig struct { - StreamId string `json:"stream_id,omitempty"` - SequenceId int `json:"sequence_id,omitempty"` - Action int `json:"action,omitempty"` - Format string `json:"format,omitempty"` - EngineType string `json:"engine_type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *StreamConfig) MarshalJSON() ([]byte, error) { - type cp StreamConfig - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpeechFileRecognizeReqBody struct { - Speech *Speech `json:"speech,omitempty"` - Config *FileConfig `json:"config,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpeechFileRecognizeReqBody) MarshalJSON() ([]byte, error) { - type cp SpeechFileRecognizeReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpeechFileRecognizeResult struct { - RecognitionText string `json:"recognition_text,omitempty"` -} - -type SpeechStreamRecognizeReqBody struct { - Speech *Speech `json:"speech,omitempty"` - Config *StreamConfig `json:"config,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *SpeechStreamRecognizeReqBody) MarshalJSON() ([]byte, error) { - type cp SpeechStreamRecognizeReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type SpeechStreamRecognizeResult struct { - StreamId string `json:"stream_id,omitempty"` - SequenceId int `json:"sequence_id,omitempty"` - RecognitionText string `json:"recognition_text,omitempty"` -} diff --git a/service/suite/v1/api.go b/service/suite/v1/api.go deleted file mode 100644 index 5524b5c8..00000000 --- a/service/suite/v1/api.go +++ /dev/null @@ -1,80 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - DocsApis *DocsApiService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.DocsApis = newDocsApiService(s) - return s -} - -type DocsApiService struct { - service *Service -} - -func newDocsApiService(service *Service) *DocsApiService { - return &DocsApiService{ - service: service, - } -} - -type DocsApiMetaReqCall struct { - ctx *core.Context - docsApis *DocsApiService - body *DocsApiMetaReqBody - optFns []request.OptFn -} - -func (rc *DocsApiMetaReqCall) Do() (*DocsApiMetaResult, error) { - var result = &DocsApiMetaResult{} - req := request.NewRequest("/open-apis/suite/docs-api/meta", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.docsApis.service.conf, req) - return result, err -} - -func (docsApis *DocsApiService) Meta(ctx *core.Context, body *DocsApiMetaReqBody, optFns ...request.OptFn) *DocsApiMetaReqCall { - return &DocsApiMetaReqCall{ - ctx: ctx, - docsApis: docsApis, - body: body, - optFns: optFns, - } -} - -type DocsApiSearchReqCall struct { - ctx *core.Context - docsApis *DocsApiService - body *DocsApiSearchReqBody - optFns []request.OptFn -} - -func (rc *DocsApiSearchReqCall) Do() (*DocsApiSearchResult, error) { - var result = &DocsApiSearchResult{} - req := request.NewRequest("/open-apis/suite/docs-api/search/object", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.docsApis.service.conf, req) - return result, err -} - -func (docsApis *DocsApiService) Search(ctx *core.Context, body *DocsApiSearchReqBody, optFns ...request.OptFn) *DocsApiSearchReqCall { - return &DocsApiSearchReqCall{ - ctx: ctx, - docsApis: docsApis, - body: body, - optFns: optFns, - } -} diff --git a/service/suite/v1/model.go b/service/suite/v1/model.go deleted file mode 100644 index 345bbff5..00000000 --- a/service/suite/v1/model.go +++ /dev/null @@ -1,89 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" -) - -type DocsApi struct { -} - -type DocsEntity struct { - DocsToken string `json:"docs_token,omitempty"` - DocsType string `json:"docs_type,omitempty"` - Title string `json:"title,omitempty"` - DocsOwner string `json:"docs_owner,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DocsEntity) MarshalJSON() ([]byte, error) { - type cp DocsEntity - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DocsMeta struct { - DocsToken string `json:"docs_token,omitempty"` - DocsType string `json:"docs_type,omitempty"` - Title string `json:"title,omitempty"` - OwnerId string `json:"owner_id,omitempty"` - CreateTime int `json:"create_time,omitempty"` - LatestModifyUser string `json:"latest_modify_user,omitempty"` - LatestModifyTime int `json:"latest_modify_time,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DocsMeta) MarshalJSON() ([]byte, error) { - type cp DocsMeta - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type RequestDoc struct { - DocsToken string `json:"docs_token,omitempty"` - DocsType string `json:"docs_type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *RequestDoc) MarshalJSON() ([]byte, error) { - type cp RequestDoc - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DocsApiMetaReqBody struct { - RequestDocs []*RequestDoc `json:"request_docs,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DocsApiMetaReqBody) MarshalJSON() ([]byte, error) { - type cp DocsApiMetaReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DocsApiMetaResult struct { - DocsMetas []*DocsMeta `json:"docs_metas,omitempty"` -} - -type DocsApiSearchReqBody struct { - SearchKey string `json:"search_key,omitempty"` - Count int `json:"count,omitempty"` - Offset int `json:"offset,omitempty"` - OwnerIds []string `json:"owner_ids,omitempty"` - ChatIds []string `json:"chat_ids,omitempty"` - DocsTypes []string `json:"docs_types,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *DocsApiSearchReqBody) MarshalJSON() ([]byte, error) { - type cp DocsApiSearchReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type DocsApiSearchResult struct { - DocsEntities []*DocsEntity `json:"docs_entities,omitempty"` - HasMore bool `json:"has_more,omitempty"` - Total int `json:"total,omitempty"` -} diff --git a/service/task/v1/api.go b/service/task/v1/api.go deleted file mode 100644 index e69f3820..00000000 --- a/service/task/v1/api.go +++ /dev/null @@ -1,580 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - Tasks *TaskService - TaskCollaborators *TaskCollaboratorService - TaskFollowers *TaskFollowerService - TaskReminders *TaskReminderService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Tasks = newTaskService(s) - s.TaskCollaborators = newTaskCollaboratorService(s) - s.TaskFollowers = newTaskFollowerService(s) - s.TaskReminders = newTaskReminderService(s) - return s -} - -type TaskService struct { - service *Service -} - -func newTaskService(service *Service) *TaskService { - return &TaskService{ - service: service, - } -} - -type TaskCollaboratorService struct { - service *Service -} - -func newTaskCollaboratorService(service *Service) *TaskCollaboratorService { - return &TaskCollaboratorService{ - service: service, - } -} - -type TaskFollowerService struct { - service *Service -} - -func newTaskFollowerService(service *Service) *TaskFollowerService { - return &TaskFollowerService{ - service: service, - } -} - -type TaskReminderService struct { - service *Service -} - -func newTaskReminderService(service *Service) *TaskReminderService { - return &TaskReminderService{ - service: service, - } -} - -type TaskCompleteReqCall struct { - ctx *core.Context - tasks *TaskService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *TaskCompleteReqCall) SetTaskId(taskId string) { - rc.pathParams["task_id"] = taskId -} - -func (rc *TaskCompleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/task/v1/tasks/:task_id/complete", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.tasks.service.conf, req) - return result, err -} - -func (tasks *TaskService) Complete(ctx *core.Context, optFns ...request.OptFn) *TaskCompleteReqCall { - return &TaskCompleteReqCall{ - ctx: ctx, - tasks: tasks, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type TaskCollaboratorCreateReqCall struct { - ctx *core.Context - taskCollaborators *TaskCollaboratorService - body *Collaborator - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *TaskCollaboratorCreateReqCall) SetTaskId(taskId string) { - rc.pathParams["task_id"] = taskId -} -func (rc *TaskCollaboratorCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *TaskCollaboratorCreateReqCall) Do() (*TaskCollaboratorCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &TaskCollaboratorCreateResult{} - req := request.NewRequest("/open-apis/task/v1/tasks/:task_id/collaborators", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.taskCollaborators.service.conf, req) - return result, err -} - -func (taskCollaborators *TaskCollaboratorService) Create(ctx *core.Context, body *Collaborator, optFns ...request.OptFn) *TaskCollaboratorCreateReqCall { - return &TaskCollaboratorCreateReqCall{ - ctx: ctx, - taskCollaborators: taskCollaborators, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type TaskFollowerCreateReqCall struct { - ctx *core.Context - taskFollowers *TaskFollowerService - body *Follower - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *TaskFollowerCreateReqCall) SetTaskId(taskId string) { - rc.pathParams["task_id"] = taskId -} -func (rc *TaskFollowerCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *TaskFollowerCreateReqCall) Do() (*TaskFollowerCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &TaskFollowerCreateResult{} - req := request.NewRequest("/open-apis/task/v1/tasks/:task_id/followers", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.taskFollowers.service.conf, req) - return result, err -} - -func (taskFollowers *TaskFollowerService) Create(ctx *core.Context, body *Follower, optFns ...request.OptFn) *TaskFollowerCreateReqCall { - return &TaskFollowerCreateReqCall{ - ctx: ctx, - taskFollowers: taskFollowers, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type TaskReminderCreateReqCall struct { - ctx *core.Context - taskReminders *TaskReminderService - body *Reminder - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *TaskReminderCreateReqCall) SetTaskId(taskId string) { - rc.pathParams["task_id"] = taskId -} - -func (rc *TaskReminderCreateReqCall) Do() (*TaskReminderCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &TaskReminderCreateResult{} - req := request.NewRequest("/open-apis/task/v1/tasks/:task_id/reminders", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.taskReminders.service.conf, req) - return result, err -} - -func (taskReminders *TaskReminderService) Create(ctx *core.Context, body *Reminder, optFns ...request.OptFn) *TaskReminderCreateReqCall { - return &TaskReminderCreateReqCall{ - ctx: ctx, - taskReminders: taskReminders, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type TaskCreateReqCall struct { - ctx *core.Context - tasks *TaskService - body *Task - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *TaskCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *TaskCreateReqCall) Do() (*TaskCreateResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &TaskCreateResult{} - req := request.NewRequest("/open-apis/task/v1/tasks", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.tasks.service.conf, req) - return result, err -} - -func (tasks *TaskService) Create(ctx *core.Context, body *Task, optFns ...request.OptFn) *TaskCreateReqCall { - return &TaskCreateReqCall{ - ctx: ctx, - tasks: tasks, - body: body, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type TaskDeleteReqCall struct { - ctx *core.Context - tasks *TaskService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *TaskDeleteReqCall) SetTaskId(taskId string) { - rc.pathParams["task_id"] = taskId -} - -func (rc *TaskDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/task/v1/tasks/:task_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.tasks.service.conf, req) - return result, err -} - -func (tasks *TaskService) Delete(ctx *core.Context, optFns ...request.OptFn) *TaskDeleteReqCall { - return &TaskDeleteReqCall{ - ctx: ctx, - tasks: tasks, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type TaskFollowerDeleteReqCall struct { - ctx *core.Context - taskFollowers *TaskFollowerService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *TaskFollowerDeleteReqCall) SetTaskId(taskId string) { - rc.pathParams["task_id"] = taskId -} -func (rc *TaskFollowerDeleteReqCall) SetFollowerId(followerId string) { - rc.pathParams["follower_id"] = followerId -} - -func (rc *TaskFollowerDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/task/v1/tasks/:task_id/followers/:follower_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.taskFollowers.service.conf, req) - return result, err -} - -func (taskFollowers *TaskFollowerService) Delete(ctx *core.Context, optFns ...request.OptFn) *TaskFollowerDeleteReqCall { - return &TaskFollowerDeleteReqCall{ - ctx: ctx, - taskFollowers: taskFollowers, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type TaskCollaboratorDeleteReqCall struct { - ctx *core.Context - taskCollaborators *TaskCollaboratorService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *TaskCollaboratorDeleteReqCall) SetTaskId(taskId string) { - rc.pathParams["task_id"] = taskId -} -func (rc *TaskCollaboratorDeleteReqCall) SetCollaboratorId(collaboratorId string) { - rc.pathParams["collaborator_id"] = collaboratorId -} - -func (rc *TaskCollaboratorDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/task/v1/tasks/:task_id/collaborators/:collaborator_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.taskCollaborators.service.conf, req) - return result, err -} - -func (taskCollaborators *TaskCollaboratorService) Delete(ctx *core.Context, optFns ...request.OptFn) *TaskCollaboratorDeleteReqCall { - return &TaskCollaboratorDeleteReqCall{ - ctx: ctx, - taskCollaborators: taskCollaborators, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type TaskReminderDeleteReqCall struct { - ctx *core.Context - taskReminders *TaskReminderService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *TaskReminderDeleteReqCall) SetTaskId(taskId string) { - rc.pathParams["task_id"] = taskId -} -func (rc *TaskReminderDeleteReqCall) SetReminderId(reminderId string) { - rc.pathParams["reminder_id"] = reminderId -} - -func (rc *TaskReminderDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/task/v1/tasks/:task_id/reminders/:reminder_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.taskReminders.service.conf, req) - return result, err -} - -func (taskReminders *TaskReminderService) Delete(ctx *core.Context, optFns ...request.OptFn) *TaskReminderDeleteReqCall { - return &TaskReminderDeleteReqCall{ - ctx: ctx, - taskReminders: taskReminders, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type TaskGetReqCall struct { - ctx *core.Context - tasks *TaskService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *TaskGetReqCall) SetTaskId(taskId string) { - rc.pathParams["task_id"] = taskId -} -func (rc *TaskGetReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *TaskGetReqCall) Do() (*TaskGetResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &TaskGetResult{} - req := request.NewRequest("/open-apis/task/v1/tasks/:task_id", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.tasks.service.conf, req) - return result, err -} - -func (tasks *TaskService) Get(ctx *core.Context, optFns ...request.OptFn) *TaskGetReqCall { - return &TaskGetReqCall{ - ctx: ctx, - tasks: tasks, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type TaskFollowerListReqCall struct { - ctx *core.Context - taskFollowers *TaskFollowerService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *TaskFollowerListReqCall) SetTaskId(taskId string) { - rc.pathParams["task_id"] = taskId -} -func (rc *TaskFollowerListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} -func (rc *TaskFollowerListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *TaskFollowerListReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *TaskFollowerListReqCall) Do() (*TaskFollowerListResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &TaskFollowerListResult{} - req := request.NewRequest("/open-apis/task/v1/tasks/:task_id/followers", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.taskFollowers.service.conf, req) - return result, err -} - -func (taskFollowers *TaskFollowerService) List(ctx *core.Context, optFns ...request.OptFn) *TaskFollowerListReqCall { - return &TaskFollowerListReqCall{ - ctx: ctx, - taskFollowers: taskFollowers, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type TaskReminderListReqCall struct { - ctx *core.Context - taskReminders *TaskReminderService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *TaskReminderListReqCall) SetTaskId(taskId string) { - rc.pathParams["task_id"] = taskId -} -func (rc *TaskReminderListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} -func (rc *TaskReminderListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} - -func (rc *TaskReminderListReqCall) Do() (*TaskReminderListResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &TaskReminderListResult{} - req := request.NewRequest("/open-apis/task/v1/tasks/:task_id/reminders", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.taskReminders.service.conf, req) - return result, err -} - -func (taskReminders *TaskReminderService) List(ctx *core.Context, optFns ...request.OptFn) *TaskReminderListReqCall { - return &TaskReminderListReqCall{ - ctx: ctx, - taskReminders: taskReminders, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type TaskCollaboratorListReqCall struct { - ctx *core.Context - taskCollaborators *TaskCollaboratorService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *TaskCollaboratorListReqCall) SetTaskId(taskId string) { - rc.pathParams["task_id"] = taskId -} -func (rc *TaskCollaboratorListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize -} -func (rc *TaskCollaboratorListReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken -} -func (rc *TaskCollaboratorListReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *TaskCollaboratorListReqCall) Do() (*TaskCollaboratorListResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &TaskCollaboratorListResult{} - req := request.NewRequest("/open-apis/task/v1/tasks/:task_id/collaborators", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.taskCollaborators.service.conf, req) - return result, err -} - -func (taskCollaborators *TaskCollaboratorService) List(ctx *core.Context, optFns ...request.OptFn) *TaskCollaboratorListReqCall { - return &TaskCollaboratorListReqCall{ - ctx: ctx, - taskCollaborators: taskCollaborators, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type TaskPatchReqCall struct { - ctx *core.Context - tasks *TaskService - body *TaskPatchReqBody - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *TaskPatchReqCall) SetTaskId(taskId string) { - rc.pathParams["task_id"] = taskId -} -func (rc *TaskPatchReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *TaskPatchReqCall) Do() (*TaskPatchResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &TaskPatchResult{} - req := request.NewRequest("/open-apis/task/v1/tasks/:task_id", "PATCH", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.tasks.service.conf, req) - return result, err -} - -func (tasks *TaskService) Patch(ctx *core.Context, body *TaskPatchReqBody, optFns ...request.OptFn) *TaskPatchReqCall { - return &TaskPatchReqCall{ - ctx: ctx, - tasks: tasks, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type TaskUncompleteReqCall struct { - ctx *core.Context - tasks *TaskService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *TaskUncompleteReqCall) SetTaskId(taskId string) { - rc.pathParams["task_id"] = taskId -} - -func (rc *TaskUncompleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/task/v1/tasks/:task_id/uncomplete", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.tasks.service.conf, req) - return result, err -} - -func (tasks *TaskService) Uncomplete(ctx *core.Context, optFns ...request.OptFn) *TaskUncompleteReqCall { - return &TaskUncompleteReqCall{ - ctx: ctx, - tasks: tasks, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} diff --git a/service/task/v1/model.go b/service/task/v1/model.go deleted file mode 100644 index 537efa8c..00000000 --- a/service/task/v1/model.go +++ /dev/null @@ -1,173 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" -) - -type Href struct { - Url string `json:"url,omitempty"` - Title string `json:"title,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Href) MarshalJSON() ([]byte, error) { - type cp Href - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type TaskCollaborator struct { -} - -type TaskFollower struct { -} - -type TaskReminder struct { -} - -type Collaborator struct { - Id string `json:"id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Collaborator) MarshalJSON() ([]byte, error) { - type cp Collaborator - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Comment struct { - Content string `json:"content,omitempty"` - ParentId int64 `json:"parent_id,omitempty,string"` - Id int64 `json:"id,omitempty,string"` - ForceSendFields []string `json:"-"` -} - -func (s *Comment) MarshalJSON() ([]byte, error) { - type cp Comment - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Due struct { - Time int64 `json:"time,omitempty,string"` - Timezone string `json:"timezone,omitempty"` - IsAllDay bool `json:"is_all_day,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Due) MarshalJSON() ([]byte, error) { - type cp Due - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Follower struct { - Id string `json:"id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Follower) MarshalJSON() ([]byte, error) { - type cp Follower - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Origin struct { - PlatformI18nName string `json:"platform_i18n_name,omitempty"` - Href *Href `json:"href,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Origin) MarshalJSON() ([]byte, error) { - type cp Origin - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Reminder struct { - Id int64 `json:"id,omitempty,string"` - RelativeFireMinute int `json:"relative_fire_minute,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Reminder) MarshalJSON() ([]byte, error) { - type cp Reminder - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Task struct { - Id string `json:"id,omitempty"` - Summary string `json:"summary,omitempty"` - Description string `json:"description,omitempty"` - CompleteTime int64 `json:"complete_time,omitempty,string"` - CreatorId string `json:"creator_id,omitempty"` - Extra string `json:"extra,omitempty"` - CreateTime int64 `json:"create_time,omitempty,string"` - UpdateTime int64 `json:"update_time,omitempty,string"` - Due *Due `json:"due,omitempty"` - Origin *Origin `json:"origin,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Task) MarshalJSON() ([]byte, error) { - type cp Task - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type TaskCollaboratorCreateResult struct { - Collaborator *Collaborator `json:"collaborator,omitempty"` -} - -type TaskFollowerCreateResult struct { - Follower *Follower `json:"follower,omitempty"` -} - -type TaskReminderCreateResult struct { - Reminder *Reminder `json:"reminder,omitempty"` -} - -type TaskCreateResult struct { - Task *Task `json:"task,omitempty"` -} - -type TaskGetResult struct { - Task *Task `json:"task,omitempty"` -} - -type TaskFollowerListResult struct { - Items []*Follower `json:"items,omitempty"` - PageToken string `json:"page_token,omitempty"` - HasMore bool `json:"has_more,omitempty"` -} - -type TaskReminderListResult struct { - Items []*Reminder `json:"items,omitempty"` - PageToken string `json:"page_token,omitempty"` - HasMore bool `json:"has_more,omitempty"` -} - -type TaskCollaboratorListResult struct { - Items []*Collaborator `json:"items,omitempty"` - PageToken string `json:"page_token,omitempty"` - HasMore bool `json:"has_more,omitempty"` -} - -type TaskPatchReqBody struct { - Task *Task `json:"task,omitempty"` - UpdateFields []string `json:"update_fields,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *TaskPatchReqBody) MarshalJSON() ([]byte, error) { - type cp TaskPatchReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type TaskPatchResult struct { - Task *Task `json:"task,omitempty"` -} diff --git a/service/tenant/v2/api.go b/service/tenant/v2/api.go deleted file mode 100644 index bc65a8c6..00000000 --- a/service/tenant/v2/api.go +++ /dev/null @@ -1,54 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v2 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - Tenants *TenantService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Tenants = newTenantService(s) - return s -} - -type TenantService struct { - service *Service -} - -func newTenantService(service *Service) *TenantService { - return &TenantService{ - service: service, - } -} - -type TenantQueryReqCall struct { - ctx *core.Context - tenants *TenantService - optFns []request.OptFn -} - -func (rc *TenantQueryReqCall) Do() (*TenantQueryResult, error) { - var result = &TenantQueryResult{} - req := request.NewRequest("/open-apis/tenant/v2/tenant/query", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.tenants.service.conf, req) - return result, err -} - -func (tenants *TenantService) Query(ctx *core.Context, optFns ...request.OptFn) *TenantQueryReqCall { - return &TenantQueryReqCall{ - ctx: ctx, - tenants: tenants, - optFns: optFns, - } -} diff --git a/service/tenant/v2/model.go b/service/tenant/v2/model.go deleted file mode 100644 index 0ca62735..00000000 --- a/service/tenant/v2/model.go +++ /dev/null @@ -1,39 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v2 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" -) - -type Avatar struct { - AvatarOrigin string `json:"avatar_origin,omitempty"` - Avatar72 string `json:"avatar_72,omitempty"` - Avatar240 string `json:"avatar_240,omitempty"` - Avatar640 string `json:"avatar_640,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Avatar) MarshalJSON() ([]byte, error) { - type cp Avatar - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Tenant struct { - Name string `json:"name,omitempty"` - DisplayId string `json:"display_id,omitempty"` - TenantTag int `json:"tenant_tag,omitempty"` - TenantKey string `json:"tenant_key,omitempty"` - Avatar *Avatar `json:"avatar,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Tenant) MarshalJSON() ([]byte, error) { - type cp Tenant - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type TenantQueryResult struct { - Tenant *Tenant `json:"tenant,omitempty"` -} diff --git a/service/translation/v1/api.go b/service/translation/v1/api.go deleted file mode 100644 index ecb7bfe0..00000000 --- a/service/translation/v1/api.go +++ /dev/null @@ -1,80 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - Texts *TextService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Texts = newTextService(s) - return s -} - -type TextService struct { - service *Service -} - -func newTextService(service *Service) *TextService { - return &TextService{ - service: service, - } -} - -type TextTranslateReqCall struct { - ctx *core.Context - texts *TextService - body *TextTranslateReqBody - optFns []request.OptFn -} - -func (rc *TextTranslateReqCall) Do() (*TextTranslateResult, error) { - var result = &TextTranslateResult{} - req := request.NewRequest("/open-apis/translation/v1/text/translate", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.texts.service.conf, req) - return result, err -} - -func (texts *TextService) Translate(ctx *core.Context, body *TextTranslateReqBody, optFns ...request.OptFn) *TextTranslateReqCall { - return &TextTranslateReqCall{ - ctx: ctx, - texts: texts, - body: body, - optFns: optFns, - } -} - -type TextDetectReqCall struct { - ctx *core.Context - texts *TextService - body *TextDetectReqBody - optFns []request.OptFn -} - -func (rc *TextDetectReqCall) Do() (*TextDetectResult, error) { - var result = &TextDetectResult{} - req := request.NewRequest("/open-apis/translation/v1/text/detect", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.texts.service.conf, req) - return result, err -} - -func (texts *TextService) Detect(ctx *core.Context, body *TextDetectReqBody, optFns ...request.OptFn) *TextDetectReqCall { - return &TextDetectReqCall{ - ctx: ctx, - texts: texts, - body: body, - optFns: optFns, - } -} diff --git a/service/translation/v1/model.go b/service/translation/v1/model.go deleted file mode 100644 index 0fa12a83..00000000 --- a/service/translation/v1/model.go +++ /dev/null @@ -1,54 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" -) - -type Term struct { - From string `json:"from,omitempty"` - To string `json:"to,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Term) MarshalJSON() ([]byte, error) { - type cp Term - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Text struct { -} - -type TextTranslateReqBody struct { - SourceLanguage string `json:"source_language,omitempty"` - Text string `json:"text,omitempty"` - TargetLanguage string `json:"target_language,omitempty"` - Glossary []*Term `json:"glossary,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *TextTranslateReqBody) MarshalJSON() ([]byte, error) { - type cp TextTranslateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type TextTranslateResult struct { - Text string `json:"text,omitempty"` -} - -type TextDetectReqBody struct { - Text string `json:"text,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *TextDetectReqBody) MarshalJSON() ([]byte, error) { - type cp TextDetectReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type TextDetectResult struct { - Language string `json:"language,omitempty"` -} diff --git a/service/vc/v1/api.go b/service/vc/v1/api.go deleted file mode 100644 index 069e6f38..00000000 --- a/service/vc/v1/api.go +++ /dev/null @@ -1,699 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api" - "github.com/larksuite/oapi-sdk-go/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" -) - -type Service struct { - conf *config.Config - Meetings *MeetingService - MeetingRecordings *MeetingRecordingService - Reports *ReportService - Reserves *ReserveService - RoomConfigs *RoomConfigService -} - -func NewService(conf *config.Config) *Service { - s := &Service{ - conf: conf, - } - s.Meetings = newMeetingService(s) - s.MeetingRecordings = newMeetingRecordingService(s) - s.Reports = newReportService(s) - s.Reserves = newReserveService(s) - s.RoomConfigs = newRoomConfigService(s) - return s -} - -type MeetingService struct { - service *Service -} - -func newMeetingService(service *Service) *MeetingService { - return &MeetingService{ - service: service, - } -} - -type MeetingRecordingService struct { - service *Service -} - -func newMeetingRecordingService(service *Service) *MeetingRecordingService { - return &MeetingRecordingService{ - service: service, - } -} - -type ReportService struct { - service *Service -} - -func newReportService(service *Service) *ReportService { - return &ReportService{ - service: service, - } -} - -type ReserveService struct { - service *Service -} - -func newReserveService(service *Service) *ReserveService { - return &ReserveService{ - service: service, - } -} - -type RoomConfigService struct { - service *Service -} - -func newRoomConfigService(service *Service) *RoomConfigService { - return &RoomConfigService{ - service: service, - } -} - -type RoomConfigQueryReqCall struct { - ctx *core.Context - roomConfigs *RoomConfigService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *RoomConfigQueryReqCall) SetScope(scope int) { - rc.queryParams["scope"] = scope -} -func (rc *RoomConfigQueryReqCall) SetCountryId(countryId int64) { - rc.queryParams["country_id"] = countryId -} -func (rc *RoomConfigQueryReqCall) SetDistrictId(districtId int64) { - rc.queryParams["district_id"] = districtId -} -func (rc *RoomConfigQueryReqCall) SetBuildingId(buildingId int64) { - rc.queryParams["building_id"] = buildingId -} -func (rc *RoomConfigQueryReqCall) SetFloorName(floorName string) { - rc.queryParams["floor_name"] = floorName -} -func (rc *RoomConfigQueryReqCall) SetRoomId(roomId int64) { - rc.queryParams["room_id"] = roomId -} - -func (rc *RoomConfigQueryReqCall) Do() (*RoomConfig, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &RoomConfig{} - req := request.NewRequest("/open-apis/vc/v1/room_configs/query", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.roomConfigs.service.conf, req) - return result, err -} - -func (roomConfigs *RoomConfigService) Query(ctx *core.Context, optFns ...request.OptFn) *RoomConfigQueryReqCall { - return &RoomConfigQueryReqCall{ - ctx: ctx, - roomConfigs: roomConfigs, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MeetingInviteReqCall struct { - ctx *core.Context - meetings *MeetingService - body *MeetingInviteReqBody - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MeetingInviteReqCall) SetMeetingId(meetingId int64) { - rc.pathParams["meeting_id"] = meetingId -} -func (rc *MeetingInviteReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *MeetingInviteReqCall) Do() (*MeetingInviteResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &MeetingInviteResult{} - req := request.NewRequest("/open-apis/vc/v1/meetings/:meeting_id/invite", "PATCH", - []request.AccessTokenType{request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.meetings.service.conf, req) - return result, err -} - -func (meetings *MeetingService) Invite(ctx *core.Context, body *MeetingInviteReqBody, optFns ...request.OptFn) *MeetingInviteReqCall { - return &MeetingInviteReqCall{ - ctx: ctx, - meetings: meetings, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ReportGetTopUserReqCall struct { - ctx *core.Context - reports *ReportService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ReportGetTopUserReqCall) SetStartTime(startTime int64) { - rc.queryParams["start_time"] = startTime -} -func (rc *ReportGetTopUserReqCall) SetEndTime(endTime int64) { - rc.queryParams["end_time"] = endTime -} -func (rc *ReportGetTopUserReqCall) SetLimit(limit int) { - rc.queryParams["limit"] = limit -} -func (rc *ReportGetTopUserReqCall) SetOrderBy(orderBy int) { - rc.queryParams["order_by"] = orderBy -} -func (rc *ReportGetTopUserReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *ReportGetTopUserReqCall) Do() (*ReportGetTopUserResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &ReportGetTopUserResult{} - req := request.NewRequest("/open-apis/vc/v1/reports/get_top_user", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.reports.service.conf, req) - return result, err -} - -func (reports *ReportService) GetTopUser(ctx *core.Context, optFns ...request.OptFn) *ReportGetTopUserReqCall { - return &ReportGetTopUserReqCall{ - ctx: ctx, - reports: reports, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MeetingSetHostReqCall struct { - ctx *core.Context - meetings *MeetingService - body *MeetingSetHostReqBody - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MeetingSetHostReqCall) SetMeetingId(meetingId int64) { - rc.pathParams["meeting_id"] = meetingId -} -func (rc *MeetingSetHostReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *MeetingSetHostReqCall) Do() (*MeetingSetHostResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &MeetingSetHostResult{} - req := request.NewRequest("/open-apis/vc/v1/meetings/:meeting_id/set_host", "PATCH", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.meetings.service.conf, req) - return result, err -} - -func (meetings *MeetingService) SetHost(ctx *core.Context, body *MeetingSetHostReqBody, optFns ...request.OptFn) *MeetingSetHostReqCall { - return &MeetingSetHostReqCall{ - ctx: ctx, - meetings: meetings, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MeetingRecordingGetReqCall struct { - ctx *core.Context - meetingRecordings *MeetingRecordingService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MeetingRecordingGetReqCall) SetMeetingId(meetingId int64) { - rc.pathParams["meeting_id"] = meetingId -} - -func (rc *MeetingRecordingGetReqCall) Do() (*MeetingRecordingGetResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &MeetingRecordingGetResult{} - req := request.NewRequest("/open-apis/vc/v1/meetings/:meeting_id/recording", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.meetingRecordings.service.conf, req) - return result, err -} - -func (meetingRecordings *MeetingRecordingService) Get(ctx *core.Context, optFns ...request.OptFn) *MeetingRecordingGetReqCall { - return &MeetingRecordingGetReqCall{ - ctx: ctx, - meetingRecordings: meetingRecordings, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MeetingEndReqCall struct { - ctx *core.Context - meetings *MeetingService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MeetingEndReqCall) SetMeetingId(meetingId int64) { - rc.pathParams["meeting_id"] = meetingId -} - -func (rc *MeetingEndReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/vc/v1/meetings/:meeting_id/end", "PATCH", - []request.AccessTokenType{request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.meetings.service.conf, req) - return result, err -} - -func (meetings *MeetingService) End(ctx *core.Context, optFns ...request.OptFn) *MeetingEndReqCall { - return &MeetingEndReqCall{ - ctx: ctx, - meetings: meetings, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MeetingRecordingStopReqCall struct { - ctx *core.Context - meetingRecordings *MeetingRecordingService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MeetingRecordingStopReqCall) SetMeetingId(meetingId int64) { - rc.pathParams["meeting_id"] = meetingId -} - -func (rc *MeetingRecordingStopReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/vc/v1/meetings/:meeting_id/recording/stop", "PATCH", - []request.AccessTokenType{request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.meetingRecordings.service.conf, req) - return result, err -} - -func (meetingRecordings *MeetingRecordingService) Stop(ctx *core.Context, optFns ...request.OptFn) *MeetingRecordingStopReqCall { - return &MeetingRecordingStopReqCall{ - ctx: ctx, - meetingRecordings: meetingRecordings, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ReportGetDailyReqCall struct { - ctx *core.Context - reports *ReportService - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ReportGetDailyReqCall) SetStartTime(startTime int64) { - rc.queryParams["start_time"] = startTime -} -func (rc *ReportGetDailyReqCall) SetEndTime(endTime int64) { - rc.queryParams["end_time"] = endTime -} - -func (rc *ReportGetDailyReqCall) Do() (*ReportGetDailyResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &ReportGetDailyResult{} - req := request.NewRequest("/open-apis/vc/v1/reports/get_daily", "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.reports.service.conf, req) - return result, err -} - -func (reports *ReportService) GetDaily(ctx *core.Context, optFns ...request.OptFn) *ReportGetDailyReqCall { - return &ReportGetDailyReqCall{ - ctx: ctx, - reports: reports, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MeetingGetReqCall struct { - ctx *core.Context - meetings *MeetingService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MeetingGetReqCall) SetMeetingId(meetingId int64) { - rc.pathParams["meeting_id"] = meetingId -} -func (rc *MeetingGetReqCall) SetWithParticipants(withParticipants bool) { - rc.queryParams["with_participants"] = withParticipants -} -func (rc *MeetingGetReqCall) SetWithMeetingAbility(withMeetingAbility bool) { - rc.queryParams["with_meeting_ability"] = withMeetingAbility -} -func (rc *MeetingGetReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *MeetingGetReqCall) Do() (*MeetingGetResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &MeetingGetResult{} - req := request.NewRequest("/open-apis/vc/v1/meetings/:meeting_id", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.meetings.service.conf, req) - return result, err -} - -func (meetings *MeetingService) Get(ctx *core.Context, optFns ...request.OptFn) *MeetingGetReqCall { - return &MeetingGetReqCall{ - ctx: ctx, - meetings: meetings, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type RoomConfigSetReqCall struct { - ctx *core.Context - roomConfigs *RoomConfigService - body *RoomConfigSetReqBody - optFns []request.OptFn -} - -func (rc *RoomConfigSetReqCall) Do() (*response.NoData, error) { - var result = &response.NoData{} - req := request.NewRequest("/open-apis/vc/v1/room_configs/set", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.roomConfigs.service.conf, req) - return result, err -} - -func (roomConfigs *RoomConfigService) Set(ctx *core.Context, body *RoomConfigSetReqBody, optFns ...request.OptFn) *RoomConfigSetReqCall { - return &RoomConfigSetReqCall{ - ctx: ctx, - roomConfigs: roomConfigs, - body: body, - optFns: optFns, - } -} - -type MeetingRecordingSetPermissionReqCall struct { - ctx *core.Context - meetingRecordings *MeetingRecordingService - body *MeetingRecordingSetPermissionReqBody - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MeetingRecordingSetPermissionReqCall) SetMeetingId(meetingId int64) { - rc.pathParams["meeting_id"] = meetingId -} -func (rc *MeetingRecordingSetPermissionReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *MeetingRecordingSetPermissionReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/vc/v1/meetings/:meeting_id/recording/set_permission", "PATCH", - []request.AccessTokenType{request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.meetingRecordings.service.conf, req) - return result, err -} - -func (meetingRecordings *MeetingRecordingService) SetPermission(ctx *core.Context, body *MeetingRecordingSetPermissionReqBody, optFns ...request.OptFn) *MeetingRecordingSetPermissionReqCall { - return &MeetingRecordingSetPermissionReqCall{ - ctx: ctx, - meetingRecordings: meetingRecordings, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MeetingRecordingStartReqCall struct { - ctx *core.Context - meetingRecordings *MeetingRecordingService - body *MeetingRecordingStartReqBody - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MeetingRecordingStartReqCall) SetMeetingId(meetingId int64) { - rc.pathParams["meeting_id"] = meetingId -} - -func (rc *MeetingRecordingStartReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/vc/v1/meetings/:meeting_id/recording/start", "PATCH", - []request.AccessTokenType{request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.meetingRecordings.service.conf, req) - return result, err -} - -func (meetingRecordings *MeetingRecordingService) Start(ctx *core.Context, body *MeetingRecordingStartReqBody, optFns ...request.OptFn) *MeetingRecordingStartReqCall { - return &MeetingRecordingStartReqCall{ - ctx: ctx, - meetingRecordings: meetingRecordings, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ReserveUpdateReqCall struct { - ctx *core.Context - reserves *ReserveService - body *ReserveUpdateReqBody - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ReserveUpdateReqCall) SetReserveId(reserveId int64) { - rc.pathParams["reserve_id"] = reserveId -} -func (rc *ReserveUpdateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *ReserveUpdateReqCall) Do() (*ReserveUpdateResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &ReserveUpdateResult{} - req := request.NewRequest("/open-apis/vc/v1/reserves/:reserve_id", "PUT", - []request.AccessTokenType{request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.reserves.service.conf, req) - return result, err -} - -func (reserves *ReserveService) Update(ctx *core.Context, body *ReserveUpdateReqBody, optFns ...request.OptFn) *ReserveUpdateReqCall { - return &ReserveUpdateReqCall{ - ctx: ctx, - reserves: reserves, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ReserveApplyReqCall struct { - ctx *core.Context - reserves *ReserveService - body *ReserveApplyReqBody - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ReserveApplyReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *ReserveApplyReqCall) Do() (*ReserveApplyResult, error) { - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &ReserveApplyResult{} - req := request.NewRequest("/open-apis/vc/v1/reserves/apply", "POST", - []request.AccessTokenType{request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.reserves.service.conf, req) - return result, err -} - -func (reserves *ReserveService) Apply(ctx *core.Context, body *ReserveApplyReqBody, optFns ...request.OptFn) *ReserveApplyReqCall { - return &ReserveApplyReqCall{ - ctx: ctx, - reserves: reserves, - body: body, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ReserveGetReqCall struct { - ctx *core.Context - reserves *ReserveService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ReserveGetReqCall) SetReserveId(reserveId int64) { - rc.pathParams["reserve_id"] = reserveId -} -func (rc *ReserveGetReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *ReserveGetReqCall) Do() (*ReserveGetResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &ReserveGetResult{} - req := request.NewRequest("/open-apis/vc/v1/reserves/:reserve_id", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.reserves.service.conf, req) - return result, err -} - -func (reserves *ReserveService) Get(ctx *core.Context, optFns ...request.OptFn) *ReserveGetReqCall { - return &ReserveGetReqCall{ - ctx: ctx, - reserves: reserves, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ReserveGetActiveMeetingReqCall struct { - ctx *core.Context - reserves *ReserveService - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ReserveGetActiveMeetingReqCall) SetReserveId(reserveId int64) { - rc.pathParams["reserve_id"] = reserveId -} -func (rc *ReserveGetActiveMeetingReqCall) SetWithParticipants(withParticipants bool) { - rc.queryParams["with_participants"] = withParticipants -} -func (rc *ReserveGetActiveMeetingReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *ReserveGetActiveMeetingReqCall) Do() (*ReserveGetActiveMeetingResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &ReserveGetActiveMeetingResult{} - req := request.NewRequest("/open-apis/vc/v1/reserves/:reserve_id/get_active_meeting", "GET", - []request.AccessTokenType{request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.reserves.service.conf, req) - return result, err -} - -func (reserves *ReserveService) GetActiveMeeting(ctx *core.Context, optFns ...request.OptFn) *ReserveGetActiveMeetingReqCall { - return &ReserveGetActiveMeetingReqCall{ - ctx: ctx, - reserves: reserves, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type ReserveDeleteReqCall struct { - ctx *core.Context - reserves *ReserveService - pathParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *ReserveDeleteReqCall) SetReserveId(reserveId int64) { - rc.pathParams["reserve_id"] = reserveId -} - -func (rc *ReserveDeleteReqCall) Do() (*response.NoData, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest("/open-apis/vc/v1/reserves/:reserve_id", "DELETE", - []request.AccessTokenType{request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.reserves.service.conf, req) - return result, err -} - -func (reserves *ReserveService) Delete(ctx *core.Context, optFns ...request.OptFn) *ReserveDeleteReqCall { - return &ReserveDeleteReqCall{ - ctx: ctx, - reserves: reserves, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type MeetingKickoutReqCall struct { - ctx *core.Context - meetings *MeetingService - body *MeetingKickoutReqBody - pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn -} - -func (rc *MeetingKickoutReqCall) SetMeetingId(meetingId int64) { - rc.pathParams["meeting_id"] = meetingId -} -func (rc *MeetingKickoutReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} - -func (rc *MeetingKickoutReqCall) Do() (*MeetingKickoutResult, error) { - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &MeetingKickoutResult{} - req := request.NewRequest("/open-apis/vc/v1/meetings/:meeting_id/kickout", "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.meetings.service.conf, req) - return result, err -} - -func (meetings *MeetingService) Kickout(ctx *core.Context, body *MeetingKickoutReqBody, optFns ...request.OptFn) *MeetingKickoutReqCall { - return &MeetingKickoutReqCall{ - ctx: ctx, - meetings: meetings, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} diff --git a/service/vc/v1/event.go b/service/vc/v1/event.go deleted file mode 100644 index ce9e35bf..00000000 --- a/service/vc/v1/event.go +++ /dev/null @@ -1,152 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/core" - "github.com/larksuite/oapi-sdk-go/core/config" - "github.com/larksuite/oapi-sdk-go/event" -) - -type MeetingLeaveMeetingEventHandler struct { - Fn func(*core.Context, *MeetingLeaveMeetingEvent) error -} - -func (h *MeetingLeaveMeetingEventHandler) GetEvent() interface{} { - return &MeetingLeaveMeetingEvent{} -} - -func (h *MeetingLeaveMeetingEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*MeetingLeaveMeetingEvent)) -} - -func SetMeetingLeaveMeetingEventHandler(conf *config.Config, fn func(ctx *core.Context, event *MeetingLeaveMeetingEvent) error) { - event.SetTypeHandler(conf, "vc.meeting.leave_meeting_v1", &MeetingLeaveMeetingEventHandler{Fn: fn}) -} - -type MeetingMeetingEndedEventHandler struct { - Fn func(*core.Context, *MeetingMeetingEndedEvent) error -} - -func (h *MeetingMeetingEndedEventHandler) GetEvent() interface{} { - return &MeetingMeetingEndedEvent{} -} - -func (h *MeetingMeetingEndedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*MeetingMeetingEndedEvent)) -} - -func SetMeetingMeetingEndedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *MeetingMeetingEndedEvent) error) { - event.SetTypeHandler(conf, "vc.meeting.meeting_ended_v1", &MeetingMeetingEndedEventHandler{Fn: fn}) -} - -type MeetingMeetingStartedEventHandler struct { - Fn func(*core.Context, *MeetingMeetingStartedEvent) error -} - -func (h *MeetingMeetingStartedEventHandler) GetEvent() interface{} { - return &MeetingMeetingStartedEvent{} -} - -func (h *MeetingMeetingStartedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*MeetingMeetingStartedEvent)) -} - -func SetMeetingMeetingStartedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *MeetingMeetingStartedEvent) error) { - event.SetTypeHandler(conf, "vc.meeting.meeting_started_v1", &MeetingMeetingStartedEventHandler{Fn: fn}) -} - -type MeetingRecordingEndedEventHandler struct { - Fn func(*core.Context, *MeetingRecordingEndedEvent) error -} - -func (h *MeetingRecordingEndedEventHandler) GetEvent() interface{} { - return &MeetingRecordingEndedEvent{} -} - -func (h *MeetingRecordingEndedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*MeetingRecordingEndedEvent)) -} - -func SetMeetingRecordingEndedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *MeetingRecordingEndedEvent) error) { - event.SetTypeHandler(conf, "vc.meeting.recording_ended_v1", &MeetingRecordingEndedEventHandler{Fn: fn}) -} - -type MeetingShareEndedEventHandler struct { - Fn func(*core.Context, *MeetingShareEndedEvent) error -} - -func (h *MeetingShareEndedEventHandler) GetEvent() interface{} { - return &MeetingShareEndedEvent{} -} - -func (h *MeetingShareEndedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*MeetingShareEndedEvent)) -} - -func SetMeetingShareEndedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *MeetingShareEndedEvent) error) { - event.SetTypeHandler(conf, "vc.meeting.share_ended_v1", &MeetingShareEndedEventHandler{Fn: fn}) -} - -type MeetingJoinMeetingEventHandler struct { - Fn func(*core.Context, *MeetingJoinMeetingEvent) error -} - -func (h *MeetingJoinMeetingEventHandler) GetEvent() interface{} { - return &MeetingJoinMeetingEvent{} -} - -func (h *MeetingJoinMeetingEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*MeetingJoinMeetingEvent)) -} - -func SetMeetingJoinMeetingEventHandler(conf *config.Config, fn func(ctx *core.Context, event *MeetingJoinMeetingEvent) error) { - event.SetTypeHandler(conf, "vc.meeting.join_meeting_v1", &MeetingJoinMeetingEventHandler{Fn: fn}) -} - -type MeetingRecordingStartedEventHandler struct { - Fn func(*core.Context, *MeetingRecordingStartedEvent) error -} - -func (h *MeetingRecordingStartedEventHandler) GetEvent() interface{} { - return &MeetingRecordingStartedEvent{} -} - -func (h *MeetingRecordingStartedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*MeetingRecordingStartedEvent)) -} - -func SetMeetingRecordingStartedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *MeetingRecordingStartedEvent) error) { - event.SetTypeHandler(conf, "vc.meeting.recording_started_v1", &MeetingRecordingStartedEventHandler{Fn: fn}) -} - -type MeetingShareStartedEventHandler struct { - Fn func(*core.Context, *MeetingShareStartedEvent) error -} - -func (h *MeetingShareStartedEventHandler) GetEvent() interface{} { - return &MeetingShareStartedEvent{} -} - -func (h *MeetingShareStartedEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*MeetingShareStartedEvent)) -} - -func SetMeetingShareStartedEventHandler(conf *config.Config, fn func(ctx *core.Context, event *MeetingShareStartedEvent) error) { - event.SetTypeHandler(conf, "vc.meeting.share_started_v1", &MeetingShareStartedEventHandler{Fn: fn}) -} - -type MeetingRecordingReadyEventHandler struct { - Fn func(*core.Context, *MeetingRecordingReadyEvent) error -} - -func (h *MeetingRecordingReadyEventHandler) GetEvent() interface{} { - return &MeetingRecordingReadyEvent{} -} - -func (h *MeetingRecordingReadyEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*MeetingRecordingReadyEvent)) -} - -func SetMeetingRecordingReadyEventHandler(conf *config.Config, fn func(ctx *core.Context, event *MeetingRecordingReadyEvent) error) { - event.SetTypeHandler(conf, "vc.meeting.recording_ready_v1", &MeetingRecordingReadyEventHandler{Fn: fn}) -} diff --git a/service/vc/v1/model.go b/service/vc/v1/model.go deleted file mode 100644 index 4aa1a08e..00000000 --- a/service/vc/v1/model.go +++ /dev/null @@ -1,636 +0,0 @@ -// Code generated by lark suite oapi sdk gen -package v1 - -import ( - "github.com/larksuite/oapi-sdk-go/api/core/tools" - "github.com/larksuite/oapi-sdk-go/event/core/model" -) - -type UserId struct { - UserId string `json:"user_id,omitempty"` - OpenId string `json:"open_id,omitempty"` - UnionId string `json:"union_id,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *UserId) MarshalJSON() ([]byte, error) { - type cp UserId - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Meeting struct { - Id int64 `json:"id,omitempty,string"` - Topic string `json:"topic,omitempty"` - Url string `json:"url,omitempty"` - CreateTime int64 `json:"create_time,omitempty,string"` - StartTime int64 `json:"start_time,omitempty,string"` - EndTime int64 `json:"end_time,omitempty,string"` - HostUser *MeetingUser `json:"host_user,omitempty"` - Status int `json:"status,omitempty"` - ParticipantCount int64 `json:"participant_count,omitempty,string"` - Participants []*MeetingParticipant `json:"participants,omitempty"` - Ability *MeetingAbility `json:"ability,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Meeting) MarshalJSON() ([]byte, error) { - type cp Meeting - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MeetingRecording struct { - Id int64 `json:"id,omitempty,string"` - MeetingId int64 `json:"meeting_id,omitempty,string"` - Url string `json:"url,omitempty"` - Duration int64 `json:"duration,omitempty,string"` - ForceSendFields []string `json:"-"` -} - -func (s *MeetingRecording) MarshalJSON() ([]byte, error) { - type cp MeetingRecording - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MeetingAbility struct { - UseVideo bool `json:"use_video,omitempty"` - UseAudio bool `json:"use_audio,omitempty"` - UseShareScreen bool `json:"use_share_screen,omitempty"` - UseFollowScreen bool `json:"use_follow_screen,omitempty"` - UseRecording bool `json:"use_recording,omitempty"` - UsePstn bool `json:"use_pstn,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MeetingAbility) MarshalJSON() ([]byte, error) { - type cp MeetingAbility - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MeetingEventMeeting struct { - Id int64 `json:"id,omitempty,string"` - Topic string `json:"topic,omitempty"` - MeetingNo string `json:"meeting_no,omitempty"` - StartTime int64 `json:"start_time,omitempty,string"` - EndTime int64 `json:"end_time,omitempty,string"` - HostUser *MeetingEventUser `json:"host_user,omitempty"` - Owner *MeetingEventUser `json:"owner,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MeetingEventMeeting) MarshalJSON() ([]byte, error) { - type cp MeetingEventMeeting - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MeetingEventUser struct { - Id *UserId `json:"id,omitempty"` - UserRole int `json:"user_role,omitempty"` - UserType int `json:"user_type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MeetingEventUser) MarshalJSON() ([]byte, error) { - type cp MeetingEventUser - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MeetingInviteStatus struct { - Id string `json:"id,omitempty"` - UserType int `json:"user_type,omitempty"` - Status int `json:"status,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MeetingInviteStatus) MarshalJSON() ([]byte, error) { - type cp MeetingInviteStatus - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MeetingParticipant struct { - Id string `json:"id,omitempty"` - UserType int `json:"user_type,omitempty"` - IsHost bool `json:"is_host,omitempty"` - IsCohost bool `json:"is_cohost,omitempty"` - IsExternal bool `json:"is_external,omitempty"` - Status int `json:"status,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MeetingParticipant) MarshalJSON() ([]byte, error) { - type cp MeetingParticipant - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MeetingUser struct { - Id string `json:"id,omitempty"` - UserType int `json:"user_type,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MeetingUser) MarshalJSON() ([]byte, error) { - type cp MeetingUser - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type RecordingPermissionObject struct { - Id string `json:"id,omitempty"` - Type int `json:"type,omitempty"` - Permission int `json:"permission,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *RecordingPermissionObject) MarshalJSON() ([]byte, error) { - type cp RecordingPermissionObject - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Report struct { - TotalMeetingCount int64 `json:"total_meeting_count,omitempty,string"` - TotalMeetingDuration int64 `json:"total_meeting_duration,omitempty,string"` - TotalParticipantCount int64 `json:"total_participant_count,omitempty,string"` - DailyReport []*ReportMeetingDaily `json:"daily_report,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Report) MarshalJSON() ([]byte, error) { - type cp Report - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ReportMeetingDaily struct { - Date int64 `json:"date,omitempty,string"` - MeetingCount int64 `json:"meeting_count,omitempty,string"` - MeetingDuration int64 `json:"meeting_duration,omitempty,string"` - ParticipantCount int64 `json:"participant_count,omitempty,string"` - ForceSendFields []string `json:"-"` -} - -func (s *ReportMeetingDaily) MarshalJSON() ([]byte, error) { - type cp ReportMeetingDaily - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ReportTopUser struct { - Id int64 `json:"id,omitempty,string"` - Name string `json:"name,omitempty"` - UserType int `json:"user_type,omitempty"` - MeetingCount int64 `json:"meeting_count,omitempty,string"` - MeetingDuration int64 `json:"meeting_duration,omitempty,string"` - ForceSendFields []string `json:"-"` -} - -func (s *ReportTopUser) MarshalJSON() ([]byte, error) { - type cp ReportTopUser - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ReserveActionPermission struct { - Permission int `json:"permission,omitempty"` - PermissionCheckers []*ReservePermissionChecker `json:"permission_checkers,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ReserveActionPermission) MarshalJSON() ([]byte, error) { - type cp ReserveActionPermission - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ReserveCallSetting struct { - Callee *ReserveCallee `json:"callee,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ReserveCallSetting) MarshalJSON() ([]byte, error) { - type cp ReserveCallSetting - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ReserveCallee struct { - Id string `json:"id,omitempty"` - UserType int `json:"user_type,omitempty"` - PstnSipInfo *PstnSipInfo `json:"pstn_sip_info,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ReserveCallee) MarshalJSON() ([]byte, error) { - type cp ReserveCallee - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ReserveMeetingSetting struct { - Topic string `json:"topic,omitempty"` - ActionPermissions []*ReserveActionPermission `json:"action_permissions,omitempty"` - MeetingInitialType int `json:"meeting_initial_type,omitempty"` - CallSetting *ReserveCallSetting `json:"call_setting,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ReserveMeetingSetting) MarshalJSON() ([]byte, error) { - type cp ReserveMeetingSetting - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ReservePermissionChecker struct { - CheckField int `json:"check_field,omitempty"` - CheckMode int `json:"check_mode,omitempty"` - CheckList []string `json:"check_list,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ReservePermissionChecker) MarshalJSON() ([]byte, error) { - type cp ReservePermissionChecker - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type RoomConfig struct { - RoomBackground string `json:"room_background,omitempty"` - DisplayBackground string `json:"display_background,omitempty"` - DigitalSignage *RoomDigitalSignage `json:"digital_signage,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *RoomConfig) MarshalJSON() ([]byte, error) { - type cp RoomConfig - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type RoomDigitalSignage struct { - Enable bool `json:"enable,omitempty"` - Mute bool `json:"mute,omitempty"` - StartDisplay int `json:"start_display,omitempty"` - StopDisplay int `json:"stop_display,omitempty"` - Materials []*RoomDigitalSignageMaterial `json:"materials,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *RoomDigitalSignage) MarshalJSON() ([]byte, error) { - type cp RoomDigitalSignage - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type RoomDigitalSignageMaterial struct { - Id string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - MaterialType int `json:"material_type,omitempty"` - Url string `json:"url,omitempty"` - Duration int `json:"duration,omitempty"` - Cover string `json:"cover,omitempty"` - Md5 string `json:"md5,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *RoomDigitalSignageMaterial) MarshalJSON() ([]byte, error) { - type cp RoomDigitalSignageMaterial - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Material struct { - Name string `json:"name,omitempty"` - FileToken string `json:"file_token,omitempty"` - FileSize int `json:"file_size,omitempty"` - DeviceType int `json:"device_type,omitempty"` - MaterialType int `json:"material_type,omitempty"` - ReviewResult int `json:"review_result,omitempty"` - MaterialSource int `json:"material_source,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Material) MarshalJSON() ([]byte, error) { - type cp Material - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MaterialDeleteResult struct { - FileToken string `json:"file_token,omitempty"` - Result int `json:"result,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MaterialDeleteResult) MarshalJSON() ([]byte, error) { - type cp MaterialDeleteResult - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MaterialReviewResult struct { - FileToken string `json:"file_token,omitempty"` - Result int `json:"result,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MaterialReviewResult) MarshalJSON() ([]byte, error) { - type cp MaterialReviewResult - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MaterialUploadResult struct { - FileToken string `json:"file_token,omitempty"` - Result int `json:"result,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MaterialUploadResult) MarshalJSON() ([]byte, error) { - type cp MaterialUploadResult - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MeetingParticipantResult struct { - Id string `json:"id,omitempty"` - UserType int `json:"user_type,omitempty"` - Result int `json:"result,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MeetingParticipantResult) MarshalJSON() ([]byte, error) { - type cp MeetingParticipantResult - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type PstnSipInfo struct { - Nickname string `json:"nickname,omitempty"` - MainAddress string `json:"main_address,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *PstnSipInfo) MarshalJSON() ([]byte, error) { - type cp PstnSipInfo - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type Reserve struct { - Id int64 `json:"id,omitempty,string"` - MeetingNo string `json:"meeting_no,omitempty"` - Url string `json:"url,omitempty"` - AppLink string `json:"app_link,omitempty"` - LiveLink string `json:"live_link,omitempty"` - EndTime int64 `json:"end_time,omitempty,string"` - ExpireStatus int `json:"expire_status,omitempty"` - ReserveUserId string `json:"reserve_user_id,omitempty"` - MeetingSettings *ReserveMeetingSetting `json:"meeting_settings,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *Reserve) MarshalJSON() ([]byte, error) { - type cp Reserve - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MeetingInviteReqBody struct { - Invitees []*MeetingUser `json:"invitees,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MeetingInviteReqBody) MarshalJSON() ([]byte, error) { - type cp MeetingInviteReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MeetingInviteResult struct { - InviteResults []*MeetingInviteStatus `json:"invite_results,omitempty"` -} - -type ReportGetTopUserResult struct { - TopUserReport []*ReportTopUser `json:"top_user_report,omitempty"` -} - -type MeetingSetHostReqBody struct { - HostUser *MeetingUser `json:"host_user,omitempty"` - OldHostUser *MeetingUser `json:"old_host_user,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MeetingSetHostReqBody) MarshalJSON() ([]byte, error) { - type cp MeetingSetHostReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MeetingSetHostResult struct { - HostUser *MeetingUser `json:"host_user,omitempty"` -} - -type MeetingRecordingGetResult struct { - Recording *MeetingRecording `json:"recording,omitempty"` -} - -type ReportGetDailyResult struct { - MeetingReport *Report `json:"meeting_report,omitempty"` -} - -type MeetingGetResult struct { - Meeting *Meeting `json:"meeting,omitempty"` -} - -type RoomConfigSetReqBody struct { - Scope int `json:"scope,omitempty"` - CountryId int64 `json:"country_id,omitempty,string"` - DistrictId int64 `json:"district_id,omitempty,string"` - BuildingId int64 `json:"building_id,omitempty,string"` - FloorName string `json:"floor_name,omitempty"` - RoomId int64 `json:"room_id,omitempty,string"` - RoomConfig *RoomConfig `json:"room_config,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *RoomConfigSetReqBody) MarshalJSON() ([]byte, error) { - type cp RoomConfigSetReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MeetingRecordingSetPermissionReqBody struct { - PermissionObjects []*RecordingPermissionObject `json:"permission_objects,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MeetingRecordingSetPermissionReqBody) MarshalJSON() ([]byte, error) { - type cp MeetingRecordingSetPermissionReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MeetingRecordingStartReqBody struct { - Timezone int `json:"timezone,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MeetingRecordingStartReqBody) MarshalJSON() ([]byte, error) { - type cp MeetingRecordingStartReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ReserveUpdateReqBody struct { - EndTime int64 `json:"end_time,omitempty,string"` - MeetingSettings *ReserveMeetingSetting `json:"meeting_settings,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ReserveUpdateReqBody) MarshalJSON() ([]byte, error) { - type cp ReserveUpdateReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ReserveUpdateResult struct { - Reserve *Reserve `json:"reserve,omitempty"` -} - -type ReserveApplyReqBody struct { - EndTime int64 `json:"end_time,omitempty,string"` - MeetingSettings *ReserveMeetingSetting `json:"meeting_settings,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *ReserveApplyReqBody) MarshalJSON() ([]byte, error) { - type cp ReserveApplyReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type ReserveApplyResult struct { - Reserve *Reserve `json:"reserve,omitempty"` -} - -type ReserveGetResult struct { - Reserve *Reserve `json:"reserve,omitempty"` -} - -type ReserveGetActiveMeetingResult struct { - Meeting *Meeting `json:"meeting,omitempty"` -} - -type MeetingKickoutReqBody struct { - KickoutUsers []*MeetingUser `json:"kickout_users,omitempty"` - ForceSendFields []string `json:"-"` -} - -func (s *MeetingKickoutReqBody) MarshalJSON() ([]byte, error) { - type cp MeetingKickoutReqBody - raw := cp(*s) - return tools.MarshalJSON(raw, s.ForceSendFields) -} - -type MeetingKickoutResult struct { - KickoutResults []*MeetingParticipantResult `json:"kickout_results,omitempty"` -} - -type MeetingLeaveMeetingEventData struct { - Meeting *MeetingEventMeeting `json:"meeting,omitempty"` - Operator *MeetingEventUser `json:"operator,omitempty"` - LeaveReason int `json:"leave_reason,omitempty"` -} - -type MeetingLeaveMeetingEvent struct { - *model.BaseEventV2 - Event *MeetingLeaveMeetingEventData `json:"event"` -} - -type MeetingMeetingEndedEventData struct { - Meeting *MeetingEventMeeting `json:"meeting,omitempty"` - Operator *MeetingEventUser `json:"operator,omitempty"` -} - -type MeetingMeetingEndedEvent struct { - *model.BaseEventV2 - Event *MeetingMeetingEndedEventData `json:"event"` -} - -type MeetingMeetingStartedEventData struct { - Meeting *MeetingEventMeeting `json:"meeting,omitempty"` - Operator *MeetingEventUser `json:"operator,omitempty"` -} - -type MeetingMeetingStartedEvent struct { - *model.BaseEventV2 - Event *MeetingMeetingStartedEventData `json:"event"` -} - -type MeetingRecordingEndedEventData struct { - Meeting *MeetingEventMeeting `json:"meeting,omitempty"` - Operator *MeetingEventUser `json:"operator,omitempty"` -} - -type MeetingRecordingEndedEvent struct { - *model.BaseEventV2 - Event *MeetingRecordingEndedEventData `json:"event"` -} - -type MeetingShareEndedEventData struct { - Meeting *MeetingEventMeeting `json:"meeting,omitempty"` - Operator *MeetingEventUser `json:"operator,omitempty"` -} - -type MeetingShareEndedEvent struct { - *model.BaseEventV2 - Event *MeetingShareEndedEventData `json:"event"` -} - -type MeetingJoinMeetingEventData struct { - Meeting *MeetingEventMeeting `json:"meeting,omitempty"` - Operator *MeetingEventUser `json:"operator,omitempty"` -} - -type MeetingJoinMeetingEvent struct { - *model.BaseEventV2 - Event *MeetingJoinMeetingEventData `json:"event"` -} - -type MeetingRecordingStartedEventData struct { - Meeting *MeetingEventMeeting `json:"meeting,omitempty"` - Operator *MeetingEventUser `json:"operator,omitempty"` -} - -type MeetingRecordingStartedEvent struct { - *model.BaseEventV2 - Event *MeetingRecordingStartedEventData `json:"event"` -} - -type MeetingShareStartedEventData struct { - Meeting *MeetingEventMeeting `json:"meeting,omitempty"` - Operator *MeetingEventUser `json:"operator,omitempty"` -} - -type MeetingShareStartedEvent struct { - *model.BaseEventV2 - Event *MeetingShareStartedEventData `json:"event"` -} - -type MeetingRecordingReadyEventData struct { - Meeting *MeetingEventMeeting `json:"meeting,omitempty"` - Url string `json:"url,omitempty"` - Duration int64 `json:"duration,omitempty,string"` -} - -type MeetingRecordingReadyEvent struct { - *model.BaseEventV2 - Event *MeetingRecordingReadyEventData `json:"event"` -} diff --git a/test.pdf b/test.pdf deleted file mode 100644 index 1d2cfc63..00000000 Binary files a/test.pdf and /dev/null differ diff --git a/test.png b/test.png deleted file mode 100644 index bea74ce5..00000000 Binary files a/test.png and /dev/null differ diff --git a/test_download.pdf b/test_download.pdf deleted file mode 100755 index 1d2cfc63..00000000 Binary files a/test_download.pdf and /dev/null differ diff --git a/test_download.png b/test_download.png deleted file mode 100644 index bea74ce5..00000000 Binary files a/test_download.png and /dev/null differ diff --git a/v2/api.go b/v2/api.go new file mode 100644 index 00000000..a39cd66f --- /dev/null +++ b/v2/api.go @@ -0,0 +1,725 @@ +package lark + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "mime/multipart" + "net/http" + "net/url" + "reflect" + "strings" + "time" +) + +var ( + ErrAppTicketIsEmpty = errors.New("app ticket is empty") +) + +func (app *App) SendRequest(ctx context.Context, httpMethod string, httpPath string, + accessTokenType AccessTokenType, input interface{}, options ...RequestOptionFunc) (*RawResponse, error) { + return app.SendRequestWithAccessTokenTypes(ctx, httpMethod, httpPath, []AccessTokenType{accessTokenType}, input, options...) +} + +func (app *App) SendRequestWithAccessTokenTypes(ctx context.Context, httpMethod string, httpPath string, + accessTokenTypes []AccessTokenType, input interface{}, options ...RequestOptionFunc) (*RawResponse, error) { + option := &requestOption{} + for _, optionFunc := range options { + optionFunc(option) + } + accessibleTokenTypeSet := make(map[AccessTokenType]struct{}) + accessTokenType := accessTokenTypes[0] + for _, t := range accessTokenTypes { + if t == AccessTokenTypeTenant { + accessTokenType = t // default + } + accessibleTokenTypeSet[t] = struct{}{} + } + if option.tenantKey != "" { + if _, ok := accessibleTokenTypeSet[AccessTokenTypeTenant]; ok { + accessTokenType = AccessTokenTypeTenant + } + } + if option.userAccessToken != "" { + if _, ok := accessibleTokenTypeSet[AccessTokenTypeUser]; ok { + accessTokenType = AccessTokenTypeUser + } + } + paths, queries, body := parseInput(input, option) + if _, ok := body.(*Formdata); ok { + option.fileUpload = true + } + contentType, rawBody, err := payload(body) + if err != nil { + return nil, err + } + fullURL, err := jointURL(app.domain, httpPath, paths, queries) + if err != nil { + return nil, err + } + req := &request{ + method: httpMethod, + url: fullURL, + contentType: contentType, + body: rawBody, + accessTokenType: accessTokenType, + option: option, + } + return req.do(ctx, app) +} + +type RequestOptionFunc func(option *requestOption) + +func WithNeedHelpDeskAuth() RequestOptionFunc { + return func(option *requestOption) { + option.needHelpDeskAuth = true + } +} + +func WithTenantKey(tenantKey string) RequestOptionFunc { + return func(option *requestOption) { + option.tenantKey = tenantKey + } +} + +func WithFileUpload() RequestOptionFunc { + return func(option *requestOption) { + option.fileUpload = true + } +} + +func WithFileDownload() RequestOptionFunc { + return func(option *requestOption) { + option.fileDownload = true + } +} + +func WithHTTPHeader(header http.Header) RequestOptionFunc { + return func(option *requestOption) { + option.header = header + } +} + +func WithUserAccessToken(userAccessToken string) RequestOptionFunc { + return func(option *requestOption) { + option.userAccessToken = userAccessToken + } +} + +func parseInput(input interface{}, option *requestOption) (map[string]interface{}, map[string]interface{}, interface{}) { + if input == nil { + return nil, nil, nil + } + if _, ok := input.(*Formdata); ok { + return nil, nil, input + } + var hasHTTPTag bool + paths, queries := map[string]interface{}{}, map[string]interface{}{} + vv := reflect.ValueOf(input) + vt := reflect.TypeOf(input) + if vt.Kind() == reflect.Ptr { + vv = vv.Elem() + vt = vt.Elem() + } + if vt.Kind() != reflect.Struct { + return nil, nil, input + } + var body interface{} + for i := 0; i < vt.NumField(); i++ { + fieldValue := vv.Field(i) + fieldType := vt.Field(i) + if path, ok := fieldType.Tag.Lookup("path"); ok { + hasHTTPTag = true + if path != "" && !isEmptyValue(fieldValue) { + paths[path] = reflect.Indirect(fieldValue).Interface() + } + continue + } + if query, ok := fieldType.Tag.Lookup("query"); ok { + hasHTTPTag = true + if query != "" && !isEmptyValue(fieldValue) { + queries[query] = reflect.Indirect(fieldValue).Interface() + } + continue + } + if _, ok := fieldType.Tag.Lookup("body"); ok { + hasHTTPTag = true + body = fieldValue.Interface() + } + } + if !hasHTTPTag { + body = input + if option.fileUpload { + body = toFormdata(input) + } + return nil, nil, body + } + if body != nil { + if option.fileUpload { + body = toFormdata(body) + } + } + return paths, queries, body +} + +func toFormdata(body interface{}) *Formdata { + formdata := &Formdata{} + v := reflect.ValueOf(body) + t := reflect.TypeOf(body) + if t.Kind() == reflect.Ptr { + v = v.Elem() + t = t.Elem() + } + for i := 0; i < t.NumField(); i++ { + fieldValue := v.Field(i) + fieldType := t.Field(i) + if isEmptyValue(fieldValue) { + continue + } + if fieldName := fieldType.Tag.Get("json"); fieldName != "" { + fieldName = strings.TrimSuffix(fieldName, ",omitempty") + formdata.AddField(fieldName, reflect.Indirect(fieldValue).Interface()) + } + } + return formdata +} + +func jointURL(domain Domain, httpPath string, paths, queries map[string]interface{}) (string, error) { + // path + var pathSegs []string + for _, p := range strings.Split(httpPath, "/") { + if strings.Index(p, ":") == 0 { + varName := p[1:] + v, ok := paths[varName] + if !ok { + return "", fmt.Errorf("http path:%s, name: %s, not found value", httpPath, varName) + } + val := fmt.Sprint(v) + if val == "" { + return "", fmt.Errorf("http path:%s, name: %s, value is empty", httpPath, varName) + } + pathSegs = append(pathSegs, val) + continue + } + pathSegs = append(pathSegs, p) + } + newPath := strings.Join(pathSegs, "/") + if strings.Index(newPath, "http") != 0 { + if strings.Index(newPath, "/open-apis") == 0 { + newPath = fmt.Sprintf("%s%s", domain, newPath) + } else { + newPath = fmt.Sprintf("%s/open-apis/%s", domain, newPath) + } + } + // query + query := make(url.Values) + for k, v := range queries { + sv := reflect.ValueOf(v) + if sv.Kind() == reflect.Slice || sv.Kind() == reflect.Array { + for i := 0; i < sv.Len(); i++ { + query.Add(k, fmt.Sprint(sv.Index(i))) + } + } else { + query.Set(k, fmt.Sprint(v)) + } + } + if len(query) > 0 { + newPath = fmt.Sprintf("%s?%s", newPath, query.Encode()) + } + return newPath, nil +} + +func payload(body interface{}) (string, []byte, error) { + if fd, ok := body.(*Formdata); ok { + return fd.content() + } + contentType := defaultContentType + if body == nil { + return contentType, nil, nil + } + bs, err := json.Marshal(body) + return contentType, bs, err +} + +type requestOption struct { + tenantKey string + userAccessToken string + needHelpDeskAuth bool + fileUpload bool + fileDownload bool + header http.Header +} + +type request struct { + method string + url string + contentType string + body []byte + accessTokenType AccessTokenType + option *requestOption + retryCount int +} + +func (r *request) do(ctx context.Context, app *App) (*RawResponse, error) { + err := r.validate(app) + if err != nil { + return nil, err + } + rawResp, code, err := r.send(ctx, app) + if code == errCodeAppTicketInvalid || err == ErrAppTicketIsEmpty { + app.logger.Warn(ctx, "app_ticket invalid, send apply app_ticket request") + r.applyAppTicket(ctx, app) + } + return rawResp, err +} + +func (r *request) validate(app *App) error { + if app.settings.type_ == AppTypeMarketplace { + if r.accessTokenType == AccessTokenTypeTenant && r.option.tenantKey == "" { + return errors.New("tenant key is empty") + } + } + if r.accessTokenType == AccessTokenTypeUser && r.option.userAccessToken == "" { + return errors.New("user access token is empty") + } + return nil +} + +func (r *request) send(ctx context.Context, app *App) (*RawResponse, int, error) { + var rawResp *RawResponse + var code int + for r.retryCount < 2 { + app.logger.Debug(ctx, fmt.Sprintf("send request %v", r)) + httpRequest, err := r.newHTTPRequest(ctx, app) + if err != nil { + return nil, 0, err + } + rawResp, err = sendHTTPRequest(httpRequest) + if err != nil { + return nil, 0, err + } + app.logger.Debug(ctx, fmt.Sprintf("send request %v, response %v", r, rawResp)) + fileDownloadSuccess := r.option.fileDownload && rawResp.StatusCode == http.StatusOK + if fileDownloadSuccess || !strings.Contains(rawResp.Header.Get(contentTypeHeader), contentTypeJson) { + break + } + codeError := &CodeError{} + err = json.Unmarshal(rawResp.RawBody, codeError) + if err != nil { + return nil, 0, err + } + code = codeError.Code + if code != errCodeAccessTokenInvalid && code != errCodeAppAccessTokenInvalid && + code != errCodeTenantAccessTokenInvalid { + break + } + r.retryCount++ + } + return rawResp, code, nil +} + +func (r *request) newHTTPRequest(ctx context.Context, app *App) (*http.Request, error) { + httpRequest, err := http.NewRequestWithContext(ctx, r.method, r.url, bytes.NewBuffer(r.body)) + if err != nil { + return nil, err + } + for k, vs := range r.option.header { + for _, v := range vs { + httpRequest.Header.Add(k, v) + } + } + httpRequest.Header.Set(userAgentHeader, userAgent()) + if r.contentType != "" { + httpRequest.Header.Set(contentTypeHeader, r.contentType) + } + switch r.accessTokenType { + case AccessTokenTypeApp: + err = r.signAppAccessToken(ctx, httpRequest, app) + case AccessTokenTypeTenant: + err = r.signTenantAccessToken(ctx, httpRequest, app) + case AccessTokenTypeUser: + err = r.signUserAccessToken(httpRequest) + } + if err != nil { + return nil, err + } + err = r.signHelpdeskAuthToken(httpRequest, app) + if err != nil { + return nil, err + } + return httpRequest, nil +} + +func (r *request) applyAppTicket(ctx context.Context, app *App) { + rawResp, err := app.SendRequest(ctx, http.MethodPost, applyAppTicketPath, accessTokenTypeNone, &applyAppTicketReq{ + AppID: app.settings.id, + AppSecret: app.settings.secret, + }) + if err != nil { + app.logger.Error(ctx, fmt.Sprintf("apply app_ticket, error: %v", err)) + return + } + if !strings.Contains(rawResp.Header.Get(contentTypeHeader), contentTypeJson) { + app.logger.Error(ctx, fmt.Sprintf("apply app_ticket, response content-type not json, response: %v", rawResp)) + return + } + codeError := &CodeError{} + err = json.Unmarshal(rawResp.RawBody, codeError) + if err != nil { + app.logger.Error(ctx, fmt.Sprintf("apply app_ticket, json unmarshal error: %v", err)) + return + } + if codeError.Code != 0 { + app.logger.Error(ctx, fmt.Sprintf("apply app_ticket, response error: %v", codeError)) + return + } +} + +func (r *request) String() string { + bodyStr := "" + if r.option.fileUpload { + bodyStr = fmt.Sprintf(" len %d", len(r.body)) + } else { + bodyStr = string(r.body) + } + return fmt.Sprintf("%s %s, body: %s", r.method, r.url, bodyStr) +} + +const expiryDelta = 3 * time.Minute + +// internal app access token +func (r *request) customAppAccessToken(ctx context.Context, app *App) (string, error) { + rawResp, err := app.SendRequest(ctx, http.MethodPost, appAccessTokenInternalUrlPath, accessTokenTypeNone, &internalAccessTokenReq{ + AppID: app.settings.id, + AppSecret: app.settings.secret, + }) + if err != nil { + return "", err + } + appAccessTokenResp := &appAccessTokenResp{} + err = json.Unmarshal(rawResp.RawBody, appAccessTokenResp) + if err != nil { + return "", err + } + if appAccessTokenResp.Code != 0 { + return "", appAccessTokenResp.CodeError + } + expire := time.Duration(appAccessTokenResp.Expire)*time.Second - expiryDelta + err = app.store.Put(ctx, appAccessTokenKey(app.settings.id), appAccessTokenResp.AppAccessToken, expire) + if err != nil { + app.logger.Warn(ctx, fmt.Sprintf("custom app appAccessToken store, err:%v", err)) + } + return appAccessTokenResp.AppAccessToken, err +} + +// get internal tenant access token +func (r *request) customTenantAccessToken(ctx context.Context, app *App) (string, error) { + rawResp, err := app.SendRequest(ctx, http.MethodPost, tenantAccessTokenInternalUrlPath, accessTokenTypeNone, &internalAccessTokenReq{ + AppID: app.settings.id, + AppSecret: app.settings.secret, + }) + if err != nil { + return "", err + } + tenantAccessTokenResp := &tenantAccessTokenResp{} + err = json.Unmarshal(rawResp.RawBody, tenantAccessTokenResp) + if err != nil { + return "", err + } + if tenantAccessTokenResp.Code != 0 { + return "", tenantAccessTokenResp.CodeError + } + expire := time.Duration(tenantAccessTokenResp.Expire)*time.Second - expiryDelta + err = app.store.Put(ctx, tenantAccessTokenKey(app.settings.id, r.option.tenantKey), tenantAccessTokenResp.TenantAccessToken, expire) + if err != nil { + app.logger.Warn(ctx, fmt.Sprintf("custom app tenantAccessToken store, err:%v", err)) + } + return tenantAccessTokenResp.TenantAccessToken, err +} + +// get marketplace app access token +func (r *request) marketplaceAppAccessToken(ctx context.Context, app *App) (string, error) { + appTicket, err := r.appTicket(ctx, app) + if err != nil { + return "", err + } + if appTicket == "" { + return "", ErrAppTicketIsEmpty + } + rawResp, err := app.SendRequest(ctx, http.MethodPost, appAccessTokenUrlPath, accessTokenTypeNone, &marketplaceAppAccessTokenReq{ + AppID: app.settings.id, + AppSecret: app.settings.secret, + AppTicket: appTicket, + }) + if err != nil { + return "", err + } + appAccessTokenResp := &appAccessTokenResp{} + err = json.Unmarshal(rawResp.RawBody, appAccessTokenResp) + if err != nil { + return "", err + } + if appAccessTokenResp.Code != 0 { + return "", appAccessTokenResp.CodeError + } + expire := time.Duration(appAccessTokenResp.Expire)*time.Second - expiryDelta + err = app.store.Put(ctx, appAccessTokenKey(app.settings.id), appAccessTokenResp.AppAccessToken, expire) + if err != nil { + app.logger.Warn(ctx, fmt.Sprintf("marketplace app appAccessToken store, err:%v", err)) + } + return appAccessTokenResp.AppAccessToken, err +} + +// get marketplace tenant access token +func (r *request) marketplaceTenantAccessToken(ctx context.Context, app *App) (string, error) { + appAccessToken, err := r.marketplaceAppAccessToken(ctx, app) + if err != nil { + return "", err + } + rawResp, err := app.SendRequest(ctx, http.MethodPost, tenantAccessTokenUrlPath, accessTokenTypeNone, &marketplaceTenantAccessTokenReq{ + AppAccessToken: appAccessToken, + TenantKey: r.option.tenantKey, + }) + if err != nil { + return "", err + } + tenantAccessTokenResp := &tenantAccessTokenResp{} + err = json.Unmarshal(rawResp.RawBody, tenantAccessTokenResp) + if err != nil { + return "", err + } + if tenantAccessTokenResp.Code != 0 { + return "", tenantAccessTokenResp.CodeError + } + expire := time.Duration(tenantAccessTokenResp.Expire)*time.Second - expiryDelta + err = app.store.Put(ctx, tenantAccessTokenKey(app.settings.id, r.option.tenantKey), tenantAccessTokenResp.TenantAccessToken, expire) + if err != nil { + app.logger.Warn(ctx, fmt.Sprintf("custom app tenantAccessToken store, err:%v", err)) + } + return tenantAccessTokenResp.TenantAccessToken, err +} + +func (r *request) authorizationToHeader(req *http.Request, token string) { + req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token)) +} + +func (r *request) appTicket(ctx context.Context, app *App) (string, error) { + return app.store.Get(ctx, appTicketKey(app.settings.id)) +} + +func (r *request) signAppAccessToken(ctx context.Context, httpRequest *http.Request, app *App) error { + // from store get app access token + if r.retryCount == 0 { + tok, err := app.store.Get(ctx, appAccessTokenKey(app.settings.id)) + if err != nil { + return err + } + if tok != "" { + r.authorizationToHeader(httpRequest, tok) + return nil + } + } + // from api get app access token + var appAccessToken string + var err error + if app.settings.type_ == AppTypeCustom { + appAccessToken, err = r.customAppAccessToken(ctx, app) + } else { + appAccessToken, err = r.marketplaceAppAccessToken(ctx, app) + } + if err != nil { + return err + } + r.authorizationToHeader(httpRequest, appAccessToken) + return nil +} + +func (r *request) signTenantAccessToken(ctx context.Context, httpRequest *http.Request, app *App) error { + // from store get tenant access token + if r.retryCount == 0 { + tok, err := app.store.Get(ctx, tenantAccessTokenKey(app.settings.id, r.option.tenantKey)) + if err != nil { + return err + } + if tok != "" { + r.authorizationToHeader(httpRequest, tok) + return nil + } + } + // from api get tenant access token + var tenantAccessToken string + var err error + if app.settings.type_ == AppTypeCustom { + tenantAccessToken, err = r.customTenantAccessToken(ctx, app) + } else { + tenantAccessToken, err = r.marketplaceTenantAccessToken(ctx, app) + } + if err != nil { + return err + } + r.authorizationToHeader(httpRequest, tenantAccessToken) + return nil +} + +func (r *request) signUserAccessToken(httpRequest *http.Request) error { + r.authorizationToHeader(httpRequest, r.option.userAccessToken) + return nil +} + +func (r *request) signHelpdeskAuthToken(rawRequest *http.Request, app *App) error { + if r.option.needHelpDeskAuth { + if app.settings.helpdeskAuthToken == "" { + return errors.New("help desk API, please set the helpdesk information of lark.App") + } + rawRequest.Header.Set("X-Lark-Helpdesk-Authorization", app.settings.helpdeskAuthToken) + } + return nil +} + +type tenantAccessTokenResp struct { + CodeError + Expire int `json:"expire"` + TenantAccessToken string `json:"tenant_access_token"` +} + +type internalAccessTokenReq struct { + AppID string `json:"app_id"` + AppSecret string `json:"app_secret"` +} + +type marketplaceAppAccessTokenReq struct { + AppID string `json:"app_id"` + AppSecret string `json:"app_secret"` + AppTicket string `json:"app_ticket"` +} + +type marketplaceTenantAccessTokenReq struct { + AppAccessToken string `json:"app_access_token"` + TenantKey string `json:"tenant_key"` +} + +type appAccessTokenResp struct { + CodeError + Expire int `json:"expire"` + AppAccessToken string `json:"app_access_token"` +} + +type applyAppTicketReq struct { + AppID string `json:"app_id"` + AppSecret string `json:"app_secret"` +} + +const ( + appTicketKeyPrefix = "app_ticket" + appAccessTokenKeyPrefix = "app_access_token" + tenantAccessTokenKeyPrefix = "tenant_access_token" +) + +func appTicketKey(appID string) string { + return fmt.Sprintf("%s-%s", appTicketKeyPrefix, appID) +} + +func appAccessTokenKey(appID string) string { + return fmt.Sprintf("%s-%s", appAccessTokenKeyPrefix, appID) +} + +func tenantAccessTokenKey(appID, tenantKey string) string { + return fmt.Sprintf("%s-%s-%s", tenantAccessTokenKeyPrefix, appID, tenantKey) +} + +type Formdata struct { + fields map[string]interface{} + data *struct { + content []byte + contentType string + } +} + +func NewFormdata() *Formdata { + return &Formdata{} +} + +func (fd *Formdata) AddField(field string, val interface{}) *Formdata { + if fd.fields == nil { + fd.fields = map[string]interface{}{} + } + fd.fields[field] = val + return fd +} + +func (fd *Formdata) AddFile(field string, r io.Reader) *Formdata { + return fd.AddField(field, r) +} + +func (fd *Formdata) content() (string, []byte, error) { + if fd.data != nil { + return fd.data.contentType, fd.data.content, nil + } + buf := &bytes.Buffer{} + writer := multipart.NewWriter(buf) + for key, val := range fd.fields { + if r, ok := val.(io.Reader); ok { + part, err := writer.CreateFormFile(key, "unknown-file") + if err != nil { + return "", nil, err + } + _, err = io.Copy(part, r) + if err != nil { + return "", nil, err + } + continue + } + err := writer.WriteField(key, fmt.Sprint(val)) + if err != nil { + return "", nil, err + } + } + contentType := writer.FormDataContentType() + err := writer.Close() + if err != nil { + return "", nil, err + } + fd.data = &struct { + content []byte + contentType string + }{content: buf.Bytes(), contentType: contentType} + return fd.data.contentType, fd.data.content, nil +} + +type CodeError struct { + Code int `json:"code"` + Msg string `json:"msg"` + Err *struct { + Details []*CodeErrorDetail `json:"details,omitempty"` + PermissionViolations []*CodeErrorPermissionViolation `json:"permission_violations,omitempty"` + FieldViolations []*CodeErrorFieldViolation `json:"field_violations,omitempty"` + } `json:"error"` +} + +func (ce CodeError) Error() string { + return ce.String() +} + +func (ce CodeError) String() string { + return Prettify(ce) +} + +type CodeErrorDetail struct { + Key string `json:"key,omitempty"` + Value string `json:"value,omitempty"` +} + +type CodeErrorPermissionViolation struct { + Type string `json:"type,omitempty"` + Subject string `json:"subject,omitempty"` + Description string `json:"description,omitempty"` +} + +type CodeErrorFieldViolation struct { + Field string `json:"field,omitempty"` + Value string `json:"value,omitempty"` + Description string `json:"description,omitempty"` +} diff --git a/v2/card.go b/v2/card.go new file mode 100644 index 00000000..0273f4ff --- /dev/null +++ b/v2/card.go @@ -0,0 +1,154 @@ +package lark + +import ( + "context" + "crypto/sha1" + "encoding/json" + "errors" + "fmt" + "net/http" + "strings" +) + +type cardActionHandler func(context.Context, *RawRequest, *CardAction) (interface{}, error) + +func (wh *webhook) CardActionHandle(ctx context.Context, req *RawRequest) *RawResponse { + card := httpCard{ + request: req, + response: &RawResponse{}, + } + card.do(ctx, wh) + return card.response +} + +func (wh *webhook) CardActionHandler(handler cardActionHandler) { + wh.actionHandler = handler +} + +type httpCard struct { + request *RawRequest + response *RawResponse +} + +func (c httpCard) do(ctx context.Context, wh *webhook) { + var err error + var type_ webhookType + var challenge string + var resultBS []byte + var result interface{} + defer func() { + c.response.StatusCode = http.StatusOK + c.response.Header = map[string][]string{} + c.response.Header.Set(contentTypeHeader, defaultContentType) + if err != nil { + if err == notFoundCardHandlerErr { + c.response.RawBody = []byte(fmt.Sprintf(webhookResponseFormat, err.Error())) + return + } + wh.app.logger.Error(ctx, fmt.Sprintf("card action handle err: %v", err)) + c.response.StatusCode = http.StatusInternalServerError + c.response.RawBody = []byte(fmt.Sprintf(webhookResponseFormat, err.Error())) + return + } + if type_ == webhookTypeChallenge { + c.response.RawBody = []byte(fmt.Sprintf(challengeResponseFormat, challenge)) + return + } + if len(resultBS) > 0 { + c.response.RawBody = resultBS + return + } + c.response.RawBody = []byte(fmt.Sprintf(webhookResponseFormat, "success")) + }() + wh.app.logger.Debug(ctx, fmt.Sprintf("card action: %v", c.request)) + out := &cardChallenge{} + err = json.Unmarshal(c.request.RawBody, out) + if err != nil { + return + } + type_ = webhookType(out.Type) + challenge = out.Challenge + if type_ == webhookTypeChallenge { + if wh.app.settings.verificationToken != out.Token { + err = errors.New("card challenge token not equal app settings token") + return + } + return + } + err = c.verify(wh.app) + if err != nil { + return + } + h := wh.actionHandler + if h == nil { + err = notFoundCardHandlerErr + return + } + cardAction := &CardAction{} + err = json.Unmarshal(c.request.RawBody, cardAction) + if err != nil { + return + } + result, err = h(ctx, c.request, cardAction) + if err != nil { + return + } + if result == nil { + return + } + switch r := result.(type) { + case string: + resultBS = []byte(r) + default: + resultBS, err = json.Marshal(result) + } +} + +func (c httpCard) verify(app *App) error { + if app.settings.verificationToken == "" { + return nil + } + targetSig := c.signature(c.request.Header.Get(larkRequestNonce), c.request.Header.Get(larkRequestTimestamp), + string(c.request.RawBody), app.settings.verificationToken) + if c.request.Header.Get(larkSignature) == targetSig { + return nil + } + return errors.New("signature error") +} + +func (c httpCard) signature(nonce string, timestamp string, body string, token string) string { + var b strings.Builder + b.WriteString(timestamp) + b.WriteString(nonce) + b.WriteString(token) + b.WriteString(body) + bs := []byte(b.String()) + h := sha1.New() + _, _ = h.Write(bs) + bs = h.Sum(nil) + return fmt.Sprintf("%x", bs) +} + +type CardAction struct { + OpenID string `json:"open_id"` + UserID string `json:"user_id"` + OpenMessageID string `json:"open_message_id"` + TenantKey string `json:"tenant_key"` + Token string `json:"token"` + Timezone string `json:"timezone"` + + Action *struct { + Value map[string]interface{} `json:"value"` + Tag string `json:"tag"` + Option string `json:"option"` + Timezone string `json:"timezone"` + } `json:"action"` +} + +type cardChallenge struct { + Challenge string `json:"challenge"` + Token string `json:"token"` + Type string `json:"type"` +} + +var notFoundCardHandlerErr = errors.New("card not found handler") diff --git a/v2/constants.go b/v2/constants.go new file mode 100644 index 00000000..c806ed01 --- /dev/null +++ b/v2/constants.go @@ -0,0 +1,64 @@ +package lark + +const userAgentHeader = "User-Agent" +const contentTypeHeader = "Content-Type" +const contentTypeJson = "application/json" +const defaultContentType = contentTypeJson + "; charset=utf-8" + +const ( + httpHeaderKeyRequestId = "X-Request-Id" + httpHeaderKeyLogId = "X-Tt-Logid" +) + +type AppType string + +const ( + AppTypeCustom AppType = "Custom App" + AppTypeMarketplace AppType = "Marketplace App" +) + +type Domain string + +const ( + DomainFeiShu Domain = "https://open.feishu.cn" + DomainLarkSuite Domain = "https://open.larksuite.com" +) + +type webhookType string + +const ( + webhookTypeChallenge webhookType = "url_verification" +) + +type AccessTokenType string + +const ( + accessTokenTypeNone AccessTokenType = "none_access_token" + AccessTokenTypeApp AccessTokenType = "app_access_token" + AccessTokenTypeTenant AccessTokenType = "tenant_access_token" + AccessTokenTypeUser AccessTokenType = "user_access_token" +) + +const ( + appAccessTokenInternalUrlPath string = "/open-apis/auth/v3/app_access_token/internal" + appAccessTokenUrlPath string = "/open-apis/auth/v3/app_access_token" + tenantAccessTokenInternalUrlPath string = "/open-apis/auth/v3/tenant_access_token/internal" + tenantAccessTokenUrlPath string = "/open-apis/auth/v3/tenant_access_token" + applyAppTicketPath string = "/open-apis/auth/v3/app_ticket/resend" +) + +const ( + errCodeAppTicketInvalid = 10012 + errCodeAccessTokenInvalid = 99991671 + errCodeAppAccessTokenInvalid = 99991664 + errCodeTenantAccessTokenInvalid = 99991663 +) + +const ( + larkRequestNonce = "X-Lark-Request-Nonce" + larkRequestTimestamp = "X-Lark-Request-Timestamp" + larkSignature = "X-Lark-Signature" +) + +const webhookResponseFormat = `{"msg":"%s"}` +const challengeResponseFormat = `{"challenge":"%s"}` diff --git a/v2/customer_bot.go b/v2/customer_bot.go new file mode 100644 index 00000000..e2a481ae --- /dev/null +++ b/v2/customer_bot.go @@ -0,0 +1,98 @@ +package lark + +import ( + "bytes" + "context" + "crypto/hmac" + "crypto/sha256" + "encoding/base64" + "encoding/json" + "fmt" + "net/http" + "strconv" + "time" +) + +type CustomerBot struct { + webhook string + secret string +} + +func NewCustomerBot(webhook string, secret string) *CustomerBot { + return &CustomerBot{ + webhook: webhook, + secret: secret, + } +} + +func (c *CustomerBot) SendMessage(ctx context.Context, msgType string, content interface{}) (*CustomerBotSendMessageResp, error) { + req, err := c.newSendMessageReq(msgType, content) + if err != nil { + return nil, err + } + reqBs, err := json.Marshal(req) + if err != nil { + return nil, err + } + httpRequest, err := http.NewRequestWithContext(ctx, http.MethodPost, c.webhook, bytes.NewBuffer(reqBs)) + if err != nil { + return nil, err + } + httpRequest.Header.Set(userAgentHeader, userAgent()) + httpRequest.Header.Set(contentTypeHeader, defaultContentType) + rawResp, err := sendHTTPRequest(httpRequest) + if err != nil { + return nil, err + } + codeError := CodeError{} + err = json.Unmarshal(rawResp.RawBody, &codeError) + if err != nil { + return nil, err + } + return &CustomerBotSendMessageResp{ + RawResponse: rawResp, + CodeError: codeError, + }, nil +} + +type CustomerBotSendMessageResp struct { + *RawResponse `json:"-"` + CodeError +} + +type customerBotSendMessageReq struct { + Timestamp string `json:"timestamp,omitempty"` + Sign string `json:"sign,omitempty"` + MsgType string `json:"msg_type,omitempty"` + Content interface{} `json:"content"` +} + +func (c *CustomerBot) sign(timestamp string) (string, error) { + sign := fmt.Sprintf("%s\n%s", timestamp, c.secret) + var data []byte + h := hmac.New(sha256.New, []byte(sign)) + _, err := h.Write(data) + if err != nil { + return "", err + } + signature := base64.StdEncoding.EncodeToString(h.Sum(nil)) + return signature, nil +} + +func (c *CustomerBot) newSendMessageReq(msgType string, content interface{}) (*customerBotSendMessageReq, error) { + timestamp, sign := "", "" + if c.secret != "" { + var err error + timestamp = strconv.FormatInt(time.Now().Unix(), 10) + sign, err = c.sign(timestamp) + if err != nil { + return nil, err + } + } + return &customerBotSendMessageReq{ + Timestamp: timestamp, + Sign: sign, + MsgType: msgType, + Content: content, + }, nil +} diff --git a/v2/event.go b/v2/event.go new file mode 100644 index 00000000..b785ecb0 --- /dev/null +++ b/v2/event.go @@ -0,0 +1,278 @@ +package lark + +import ( + "context" + "crypto/aes" + "crypto/cipher" + "crypto/sha256" + "encoding/base64" + "encoding/json" + "errors" + "fmt" + "net/http" + "strings" + "sync" + "time" +) + +var once sync.Once + +func (wh *webhook) EventCommandHandle(ctx context.Context, req *RawRequest) *RawResponse { + once.Do(func() { + if wh.app.settings.type_ == AppTypeMarketplace { + wh.EventHandler("app_ticket", &appTicketEventHandler{app: wh.app}) + } + }) + httpEvent := &httpEvent{ + request: req, + response: &RawResponse{}, + } + httpEvent.do(ctx, wh) + return httpEvent.response +} + +func (wh *webhook) EventHandler(eventType string, handler eventHandler) { + wh.eventType2EventHandler[eventType] = handler +} + +func (wh *webhook) EventHandleFunc(eventType string, handler func(context.Context, *RawRequest) error) { + wh.EventHandler(eventType, &defaultHandler{handler: handler}) +} + +type eventHandler interface { + Event() interface{} + Handle(context.Context, *RawRequest, interface{}) error +} + +type defaultHandler struct { + handler func(context.Context, *RawRequest) error +} + +func (h *defaultHandler) Event() interface{} { + return nil +} + +func (h *defaultHandler) Handle(ctx context.Context, req *RawRequest, event interface{}) error { + return h.handler(ctx, req) +} + +type httpEvent struct { + request *RawRequest + response *RawResponse +} + +func (e *httpEvent) do(ctx context.Context, wh *webhook) { + var type_ webhookType + var token string + var eventType string + var challenge string + var err error + defer func() { + e.response.StatusCode = http.StatusOK + e.response.Header = map[string][]string{} + e.response.Header.Set(contentTypeHeader, defaultContentType) + if err != nil { + if _, ok := err.(*notFoundEventHandlerErr); ok { + wh.app.logger.Debug(ctx, fmt.Sprintf("%v", err)) + e.response.RawBody = []byte(fmt.Sprintf(webhookResponseFormat, err.Error())) + return + } + wh.app.logger.Error(ctx, fmt.Sprintf("event handle err: %v", err)) + e.response.StatusCode = http.StatusInternalServerError + e.response.RawBody = []byte(fmt.Sprintf(webhookResponseFormat, err.Error())) + return + } + if type_ == webhookTypeChallenge { + e.response.RawBody = []byte(fmt.Sprintf(challengeResponseFormat, challenge)) + return + } + e.response.RawBody = []byte(fmt.Sprintf(webhookResponseFormat, "success")) + }() + var body = e.request.RawBody + wh.app.logger.Debug(ctx, fmt.Sprintf("event request: %v", e.request)) + if wh.app.settings.eventEncryptKey != "" { + var encrypt eventAESMsg + err = json.Unmarshal(e.request.RawBody, &encrypt) + if err != nil { + err = fmt.Errorf("event json unmarshal, err:%v", err) + return + } + body, err = eventDecrypt(encrypt.Encrypt, wh.app.settings.eventEncryptKey) + if err != nil { + err = fmt.Errorf("event decrypt, err:%v", err) + return + } + wh.app.logger.Debug(ctx, fmt.Sprintf("event decrypt: %s", string(body))) + } + fuzzy := &eventFuzzy{} + err = json.Unmarshal(body, fuzzy) + if err != nil { + err = fmt.Errorf("event json unmarshal, err: %v", err) + return + } + type_ = webhookType(fuzzy.Type) + token = fuzzy.Token + challenge = fuzzy.Challenge + if fuzzy.Event != nil { + if et, ok := fuzzy.Event.Type.(string); ok { + eventType = et + } + } + if fuzzy.Header != nil { + token = fuzzy.Header.Token + eventType = fuzzy.Header.EventType + } + if type_ == webhookTypeChallenge { + if token != wh.app.settings.verificationToken { + err = errors.New("event token not equal app settings token") + return + } + return + } + err = e.verify(wh.app) + if err != nil { + return + } + handler := wh.eventType2EventHandler[eventType] + if handler == nil { + err = ¬FoundEventHandlerErr{eventType: eventType} + return + } + event := handler.Event() + if _, ok := handler.(*defaultHandler); !ok { + err = json.Unmarshal(body, event) + if err != nil { + return + } + } + err = handler.Handle(ctx, e.request, event) +} + +func (e httpEvent) verify(app *App) error { + if app.settings.eventEncryptKey == "" { + return nil + } + targetSig := e.signature(e.request.Header.Get(larkRequestTimestamp), e.request.Header.Get(larkRequestNonce), + app.settings.eventEncryptKey, string(e.request.RawBody)) + if e.request.Header.Get(larkSignature) == targetSig { + return nil + } + return errors.New("signature error") +} + +func (e httpEvent) signature(timestamp string, nonce string, eventEncryptKey string, body string) string { + var b strings.Builder + b.WriteString(timestamp) + b.WriteString(nonce) + b.WriteString(eventEncryptKey) + b.WriteString(body) + bs := []byte(b.String()) + h := sha256.New() + _, _ = h.Write(bs) + bs = h.Sum(nil) + return fmt.Sprintf("%x", bs) +} + +// eventDecrypt returns decrypt bytes +func eventDecrypt(encrypt string, secret string) ([]byte, error) { + buf, err := base64.StdEncoding.DecodeString(encrypt) + if err != nil { + return nil, newDecryptErr(fmt.Sprintf("base64 decode error: %v", err)) + } + if len(buf) < aes.BlockSize { + return nil, newDecryptErr("cipher too short") + } + key := sha256.Sum256([]byte(secret)) + block, err := aes.NewCipher(key[:sha256.Size]) + if err != nil { + return nil, newDecryptErr(fmt.Sprintf("AES new cipher error %v", err)) + } + iv := buf[:aes.BlockSize] + buf = buf[aes.BlockSize:] + // CBC mode always works in whole blocks. + if len(buf)%aes.BlockSize != 0 { + return nil, newDecryptErr("ciphertext is not a multiple of the block size") + } + mode := cipher.NewCBCDecrypter(block, iv) + mode.CryptBlocks(buf, buf) + n := strings.Index(string(buf), "{") + if n == -1 { + n = 0 + } + m := strings.LastIndex(string(buf), "}") + if m == -1 { + m = len(buf) - 1 + } + return buf[n : m+1], nil +} + +type EventBase struct { + Ts string `json:"ts"` + UUID string `json:"uuid"` + Token string `json:"token"` + Type string `json:"type"` +} + +type eventFuzzy struct { + Schema string `json:"schema"` + Token string `json:"token"` + Type string `json:"type"` + Challenge string `json:"challenge"` + Header *EventHeader `json:"header"` + Event *struct { + Type interface{} `json:"type"` + } `json:"event"` +} + +type EventHeader struct { + EventID string `json:"event_id"` + EventType string `json:"event_type"` + AppID string `json:"app_id"` + TenantKey string `json:"tenant_key"` + CreateTime string `json:"create_time"` + Token string `json:"token"` +} + +type EventV2Base struct { + Schema string `json:"schema"` + Header *EventHeader `json:"header"` +} + +type eventAESMsg struct { + Encrypt string `json:"encrypt"` +} + +type notFoundEventHandlerErr struct { + eventType string +} + +func (e notFoundEventHandlerErr) Error() string { + return fmt.Sprintf("event type: %s, not found handler", e.eventType) +} + +type appTicketEventData struct { + AppId string `json:"app_id"` + Type string `json:"type"` + AppTicket string `json:"app_ticket"` +} + +type appTicketEvent struct { + *EventBase + Event *appTicketEventData `json:"event"` +} + +type appTicketEventHandler struct { + app *App + event *appTicketEvent +} + +func (h *appTicketEventHandler) Event() interface{} { + h.event = &appTicketEvent{} + return h.event +} + +func (h *appTicketEventHandler) Handle(ctx context.Context, req *RawRequest, event interface{}) error { + appTicketEvent := event.(*appTicketEvent) + return h.app.store.Put(ctx, fmt.Sprintf("%s-%s", appTicketKeyPrefix, appTicketEvent.Event.AppId), + appTicketEvent.Event.AppTicket, time.Hour*12) +} diff --git a/v2/go.mod b/v2/go.mod new file mode 100644 index 00000000..1de9409b --- /dev/null +++ b/v2/go.mod @@ -0,0 +1,9 @@ +module github.com/larksuite/oapi-sdk-go/v2 + +go 1.13 + +require ( + github.com/go-redis/redis/v8 v8.11.3 + github.com/sirupsen/logrus v1.8.1 + github.com/stretchr/testify v1.6.1 // indirect +) diff --git a/go.sum b/v2/go.sum similarity index 55% rename from go.sum rename to v2/go.sum index f8b018f7..96161b63 100644 --- a/go.sum +++ b/v2/go.sum @@ -8,102 +8,96 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cu github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= -github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= -github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= -github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= -github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= -github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= -github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= -github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= -github.com/go-redis/redis/v8 v8.2.2 h1:A1tQgdeVF23Ojc1TIRpVuVfOadUdIM0vFVURigoPEMM= -github.com/go-redis/redis/v8 v8.2.2/go.mod h1:ysgGY09J/QeDYbu3HikWEIPCwaeOkuNoTgKayTEaEOw= +github.com/go-redis/redis/v8 v8.11.3 h1:GCjoYp8c+yQTJfc0n69iwSiHjvuAdruxl7elnZCxgt8= +github.com/go-redis/redis/v8 v8.11.3/go.mod h1:xNJ9xDG09FsIPwh3bWdk+0oDWHbtF9rPN0F/oD9XeKc= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1 h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= -github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= -github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.14.1 h1:jMU0WaQrP0a/YAEq8eJmJKjBoMs+pClEr1vDMlM/Do4= -github.com/onsi/ginkgo v1.14.1/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= +github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.10.2 h1:aY/nuoWlKJud2J6U0E3NWsjlg+0GtwXxgEqthRdzlcs= -github.com/onsi/gomega v1.10.2/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.15.0 h1:WjP/FQ/sk43MRmnEcT+MlDw2TFvkrXlprrPST/IudjU= +github.com/onsi/gomega v1.15.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= -github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= -github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= -github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -go.opentelemetry.io/otel v0.11.0 h1:IN2tzQa9Gc4ZVKnTaMbPVcHjvzOdg5n9QfnmlqiET7E= -go.opentelemetry.io/otel v0.11.0/go.mod h1:G8UCk+KooF2HLkgo8RHX9epABH/aRGYET7gQOqBVdB0= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7 h1:AeiKBIuRw3UomYXSbLy0Mc2dDLfdtbT/IVn4keq83P0= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 h1:DzZ89McO9/gWPsQXS/FVKAlG02ZjaQ6AlZRBimEYOd0= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 h1:DYfZAGf2WMFjMxbgTjaC+2HC7NkNAQs+6Q8b9WEB/F4= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -111,8 +105,8 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/v2/lark.go b/v2/lark.go new file mode 100644 index 00000000..579175fd --- /dev/null +++ b/v2/lark.go @@ -0,0 +1,99 @@ +package lark + +import ( + "encoding/base64" + "fmt" +) + +func NewApp(domain Domain, appID, appSecret string, options ...AppOptionFunc) *App { + app := &App{ + domain: domain, + settings: &appSettings{type_: AppTypeCustom}, + logger: newLoggerProxy(LogLevelError, nil), + store: &defaultStore{}, + } + options = append(options, withAppCredential(appID, appSecret)) + for _, optionFunc := range options { + optionFunc(app) + } + app.Webhook = newWebhook(app) + return app +} + +func withAppCredential(appID, appSecret string) AppOptionFunc { + return func(app *App) { + app.settings.id = appID + app.settings.secret = appSecret + } +} + +func WithAppEventVerify(verificationToken, encryptKey string) AppOptionFunc { + return func(app *App) { + app.settings.verificationToken = verificationToken + app.settings.eventEncryptKey = encryptKey + } +} + +func WithAppHelpdeskCredential(helpdeskID, helpdeskToken string) AppOptionFunc { + return func(app *App) { + app.settings.helpDeskID = helpdeskID + app.settings.helpDeskToken = helpdeskToken + if helpdeskID != "" && helpdeskToken != "" { + app.settings.helpdeskAuthToken = base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", helpdeskID, helpdeskToken))) + } + } +} + +func WithLogger(logger logger, level LogLevel) AppOptionFunc { + return func(lark *App) { + lark.logger = newLoggerProxy(level, logger) + } +} + +func WithAppType(appType AppType) AppOptionFunc { + return func(app *App) { + app.settings.type_ = appType + } +} + +func WithStore(store store) AppOptionFunc { + return func(app *App) { + app.store = store + } +} + +type AppOptionFunc func(*App) + +type App struct { + domain Domain + settings *appSettings + logger logger + store store + Webhook *webhook +} + +type appSettings struct { + type_ AppType + id string + secret string + + verificationToken string + eventEncryptKey string + + helpDeskID string + helpDeskToken string + helpdeskAuthToken string +} + +type webhook struct { + app *App + actionHandler cardActionHandler + eventType2EventHandler map[string]eventHandler +} + +func newWebhook(app *App) *webhook { + return &webhook{ + app: app, + eventType2EventHandler: map[string]eventHandler{}, + } +} diff --git a/core/log/log.go b/v2/log.go similarity index 55% rename from core/log/log.go rename to v2/log.go index 15083426..3c2278c3 100644 --- a/core/log/log.go +++ b/v2/log.go @@ -1,4 +1,4 @@ -package log +package lark import ( "context" @@ -6,59 +6,59 @@ import ( "os" ) -type Level int +type LogLevel int const ( - LevelDebug Level = 1 - LevelInfo Level = 2 - LevelWarn Level = 3 - LevelError Level = 4 + LogLevelDebug LogLevel = 1 + LogLevelInfo LogLevel = 2 + LogLevelWarn LogLevel = 3 + LogLevelError LogLevel = 4 ) -type LoggerProxy struct { - LogLevel Level - Logger Logger +type loggerProxy struct { + LogLevel LogLevel + Logger logger } -func NewLoggerProxy(logLevel Level, logger Logger) *LoggerProxy { - return &LoggerProxy{ +func newLoggerProxy(logLevel LogLevel, logger logger) *loggerProxy { + return &loggerProxy{ LogLevel: logLevel, Logger: logger, } } -func (p *LoggerProxy) Debug(ctx context.Context, args ...interface{}) { - if p.LogLevel <= LevelDebug { +func (p *loggerProxy) Debug(ctx context.Context, args ...interface{}) { + if p.Logger != nil && p.LogLevel <= LogLevelDebug { p.Logger.Debug(ctx, args...) } } -func (p *LoggerProxy) Info(ctx context.Context, args ...interface{}) { - if p.LogLevel <= LevelInfo { +func (p *loggerProxy) Info(ctx context.Context, args ...interface{}) { + if p.Logger != nil && p.LogLevel <= LogLevelInfo { p.Logger.Info(ctx, args...) } } -func (p *LoggerProxy) Warn(ctx context.Context, args ...interface{}) { - if p.LogLevel <= LevelWarn { +func (p *loggerProxy) Warn(ctx context.Context, args ...interface{}) { + if p.Logger != nil && p.LogLevel <= LogLevelWarn { p.Logger.Warn(ctx, args...) } } -func (p *LoggerProxy) Error(ctx context.Context, args ...interface{}) { - if p.LogLevel <= LevelError { +func (p *loggerProxy) Error(ctx context.Context, args ...interface{}) { + if p.Logger != nil && p.LogLevel <= LogLevelError { p.Logger.Error(ctx, args...) } } -type Logger interface { +type logger interface { Debug(context.Context, ...interface{}) Info(context.Context, ...interface{}) Warn(context.Context, ...interface{}) Error(context.Context, ...interface{}) } -func NewDefaultLogger() Logger { +func NewDefaultLogger() logger { return &defaultLogger{ logger: log.New(os.Stdout, "", log.LstdFlags), } diff --git a/v2/message_model.go b/v2/message_model.go new file mode 100644 index 00000000..995ad17a --- /dev/null +++ b/v2/message_model.go @@ -0,0 +1,600 @@ +package lark + +import "encoding/json" + +type LanguageType string + +const ( + LanguageTypeZhCN LanguageType = "zh_cn" + LanguageTypeEnUS LanguageType = "en_us" + LanguageTypeJaJP LanguageType = "ja_jp" +) + +type MessageText struct { + Text string `json:"text"` +} + +func (m *MessageText) JSON() (string, error) { + bs, err := json.Marshal(m) + if err != nil { + return "", err + } + return string(bs), nil +} + +type MessagePost map[LanguageType]*MessagePostContent + +type MessagePostContent struct { + Title string `json:"title,omitempty"` + Content [][]MessagePostElement `json:"content,omitempty"` +} + +func (m *MessagePost) JSON() (string, error) { + bs, err := json.Marshal(m) + if err != nil { + return "", err + } + return string(bs), nil +} + +type MessagePostElement interface { + Tag() string + IsPost() + MarshalJSON() ([]byte, error) +} + +func messagePostElementJson(e MessagePostElement) ([]byte, error) { + data, err := structToMap(e) + if err != nil { + return nil, err + } + data["tag"] = e.Tag() + return json.Marshal(data) +} + +type MessagePostText struct { + Text string `json:"text,omitempty"` + UnEscape bool `json:"un_escape,omitempty"` +} + +func (m *MessagePostText) Tag() string { + return "text" +} + +func (m *MessagePostText) IsPost() { +} + +func (m *MessagePostText) MarshalJSON() ([]byte, error) { + return messagePostElementJson(m) +} + +type MessagePostA struct { + Text string `json:"text,omitempty"` + Href string `json:"href,omitempty"` + UnEscape bool `json:"un_escape,omitempty"` +} + +func (m *MessagePostA) Tag() string { + return "a" +} + +func (m *MessagePostA) IsPost() { +} + +func (m *MessagePostA) MarshalJSON() ([]byte, error) { + return messagePostElementJson(m) +} + +type MessagePostAt struct { + UserId string `json:"user_id,omitempty"` +} + +func (m *MessagePostAt) Tag() string { + return "at" +} + +func (m *MessagePostAt) IsPost() { +} + +func (m *MessagePostAt) MarshalJSON() ([]byte, error) { + return messagePostElementJson(m) +} + +type MessagePostImg struct { + ImageKey string `json:"image_key,omitempty"` + Width int `json:"width,omitempty"` + Height int `json:"height,omitempty"` +} + +func (m *MessagePostImg) Tag() string { + return "img" +} + +func (m *MessagePostImg) IsPost() { +} + +func (m *MessagePostImg) MarshalJSON() ([]byte, error) { + return messagePostElementJson(m) +} + +type MessageShareUser struct { + UserId string `json:"user_id,omitempty"` +} + +func (m *MessageShareUser) JSON() (string, error) { + bs, err := json.Marshal(m) + if err != nil { + return "", err + } + return string(bs), nil +} + +type MessageShareChat struct { + ChatId string `json:"chat_id,omitempty"` +} + +func (m *MessageShareChat) JSON() (string, error) { + bs, err := json.Marshal(m) + if err != nil { + return "", err + } + return string(bs), nil +} + +type MessageImage struct { + ImageKey string `json:"image_key,omitempty"` +} + +func (m *MessageImage) JSON() (string, error) { + bs, err := json.Marshal(m) + if err != nil { + return "", err + } + return string(bs), nil +} + +type MessageAudio struct { + FileKey string `json:"file_key,omitempty"` +} + +func (m *MessageAudio) JSON() (string, error) { + bs, err := json.Marshal(m) + if err != nil { + return "", err + } + return string(bs), nil +} + +type MessageVideo struct { + FileKey string `json:"file_key,omitempty"` + ImageKey string `json:"image_key,omitempty"` +} + +func (m *MessageVideo) JSON() (string, error) { + bs, err := json.Marshal(m) + if err != nil { + return "", err + } + return string(bs), nil +} + +type MessageFile struct { + FileKey string `json:"file_key,omitempty"` +} + +func (m *MessageFile) JSON() (string, error) { + bs, err := json.Marshal(m) + if err != nil { + return "", err + } + return string(bs), nil +} + +type MessageSticker struct { + FileKey string `json:"file_key,omitempty"` +} + +func (m *MessageSticker) JSON() (string, error) { + bs, err := json.Marshal(m) + if err != nil { + return "", err + } + return string(bs), nil +} + +type MessageCard struct { + Config *MessageCardConfig `json:"config,omitempty"` + Header *MessageCardHeader `json:"header,omitempty"` + Elements []MessageCardElement `json:"elements,omitempty"` + I18nElements map[LanguageType]MessageCardElement `json:"i18n_elements,omitempty"` + CardLink *MessageCardURL `json:"card_link,omitempty"` +} + +func (m *MessageCard) JSON() (string, error) { + bs, err := json.Marshal(m) + if err != nil { + return "", err + } + return string(bs), nil +} + +func messageCardElementJson(e MessageCardElement) ([]byte, error) { + data, err := structToMap(e) + if err != nil { + return nil, err + } + data["tag"] = e.Tag() + return json.Marshal(data) +} + +type MessageCardElement interface { + Tag() string + MarshalJSON() ([]byte, error) +} + +type MessageCardActionElement interface { + MessageCardElement + IsAction() +} + +type MessageCardExtraElement interface { + MessageCardElement + IsExtra() +} + +type MessageCardNoteElement interface { + MessageCardElement + IsNote() +} + +type MessageCardHr struct { +} + +func (m *MessageCardHr) Tag() string { + return "hr" +} + +func (m *MessageCardHr) MarshalJSON() ([]byte, error) { + return messageCardElementJson(m) +} + +type MessageCardMarkdown struct { + Content string `json:"content,omitempty"` + Href map[string]*MessageCardURL `json:"href,omitempty"` +} + +func (m *MessageCardMarkdown) Tag() string { + return "markdown" +} + +func (m *MessageCardMarkdown) MarshalJSON() ([]byte, error) { + return messageCardElementJson(m) +} + +type MessageCardDiv struct { + Text MessageCardText `json:"text,omitempty"` + Fields []*MessageCardField `json:"fields,omitempty"` + Extra MessageCardExtraElement `json:"extra,omitempty"` +} + +func (m *MessageCardDiv) Tag() string { + return "div" +} + +func (m *MessageCardDiv) MarshalJSON() ([]byte, error) { + return messageCardElementJson(m) +} + +type MessageCardText interface { + MessageCardElement + Text() string +} + +type MessageCardPlainText struct { + Content string `json:"content,omitempty"` + Lines *int `json:"lines,omitempty"` +} + +func (m *MessageCardPlainText) Tag() string { + return "plain_text" +} + +func (m *MessageCardPlainText) MarshalJSON() ([]byte, error) { + return messageCardElementJson(m) +} + +func (m *MessageCardPlainText) Text() string { + return m.Content +} + +func (m *MessageCardPlainText) IsExtra() { +} + +func (m *MessageCardPlainText) IsNote() { +} + +type MessageCardLarkMd struct { + Content string `json:"content,omitempty"` +} + +func (m *MessageCardLarkMd) Tag() string { + return "lark_md" +} + +func (m *MessageCardLarkMd) MarshalJSON() ([]byte, error) { + return messageCardElementJson(m) +} + +func (m *MessageCardLarkMd) Text() string { + return m.Content +} + +func (m *MessageCardLarkMd) IsExtra() { +} + +func (m *MessageCardLarkMd) IsNote() { +} + +type MessageCardImageModel string + +const ( + MessageCardImageModelFitHorizontal MessageCardImageModel = "fit_horizontal" + MessageCardImageModelCropCenter MessageCardImageModel = "crop_center" +) + +func (m MessageCardImageModel) Ptr() *MessageCardImageModel { + return &m +} + +type MessageCardImage struct { + Alt *MessageCardPlainText `json:"alt,omitempty"` + Title MessageCardText `json:"title,omitempty"` + ImgKey string `json:"img_key,omitempty"` + CustomWidth *int `json:"custom_width,omitempty"` + CompactWidth *bool `json:"compact_width,omitempty"` + Mode *MessageCardImageModel `json:"mode,omitempty"` + Preview *bool `json:"preview,omitempty"` +} + +func (m *MessageCardImage) Tag() string { + return "img" +} + +func (m *MessageCardImage) MarshalJSON() ([]byte, error) { + return messageCardElementJson(m) +} + +type MessageCardNote struct { + Elements []MessageCardNoteElement `json:"elements,omitempty"` +} + +func (m *MessageCardNote) Tag() string { + return "note" +} + +func (m *MessageCardNote) MarshalJSON() ([]byte, error) { + return messageCardElementJson(m) +} + +type MessageCardButtonType string + +const ( + MessageCardButtonTypeDefault MessageCardButtonType = "default" + MessageCardButtonTypePrimary MessageCardButtonType = "primary" + MessageCardButtonTypeDanger MessageCardButtonType = "danger" +) + +func (bt MessageCardButtonType) Ptr() *MessageCardButtonType { + return &bt +} + +type MessageCardActionConfirm struct { + Title *MessageCardPlainText `json:"title,omitempty"` + Text *MessageCardPlainText `json:"text,omitempty"` +} + +type MessageCardEmbedImage struct { + Alt *MessageCardPlainText `json:"alt,omitempty"` + ImgKey string `json:"img_key,omitempty"` + Mode *MessageCardImageModel `json:"mode,omitempty"` + Preview *bool `json:"preview,omitempty"` +} + +func (m *MessageCardEmbedImage) Tag() string { + return "img" +} + +func (m *MessageCardEmbedImage) IsExtra() { +} + +func (m *MessageCardEmbedImage) IsNote() { +} + +type MessageCardEmbedButton struct { + Text MessageCardText `json:"text,omitempty"` + URL *string `json:"url,omitempty"` + MultiURL *MessageCardURL `json:"multi_url,omitempty"` + Type *MessageCardButtonType `json:"type,omitempty"` + Value map[string]interface{} `json:"value,omitempty"` + Confirm *MessageCardActionConfirm `json:"confirm,omitempty"` +} + +func (m *MessageCardEmbedButton) Tag() string { + return "button" +} + +func (m *MessageCardEmbedButton) MarshalJSON() ([]byte, error) { + return messageCardElementJson(m) +} + +func (m *MessageCardEmbedButton) IsAction() { +} + +func (m *MessageCardEmbedButton) IsExtra() { +} + +type MessageCardEmbedDatePickerBase struct { + InitialDate *string `json:"initial_date,omitempty"` + InitialTime *string `json:"initial_time,omitempty"` + InitialDatetime *string `json:"initial_datetime,omitempty"` + Placeholder *MessageCardPlainText `json:"placeholder,omitempty"` + Value map[string]interface{} `json:"value,omitempty"` + Confirm *MessageCardActionConfirm `json:"confirm,omitempty"` +} + +func (m *MessageCardEmbedDatePickerBase) IsAction() { +} + +func (m *MessageCardEmbedDatePickerBase) IsExtra() { +} + +type MessageCardEmbedDatePicker struct { + *MessageCardEmbedDatePickerBase +} + +func (m *MessageCardEmbedDatePicker) Tag() string { + return "date_picker" +} + +func (m *MessageCardEmbedDatePicker) MarshalJSON() ([]byte, error) { + return messageCardElementJson(m) +} + +type MessageCardEmbedPickerTime struct { + *MessageCardEmbedDatePickerBase +} + +func (m *MessageCardEmbedPickerTime) Tag() string { + return "picker_time" +} + +func (m *MessageCardEmbedPickerTime) MarshalJSON() ([]byte, error) { + return messageCardElementJson(m) +} + +type MessageCardEmbedPickerDatetime struct { + *MessageCardEmbedDatePickerBase +} + +func (m *MessageCardEmbedPickerDatetime) Tag() string { + return "picker_datetime" +} + +func (m *MessageCardEmbedPickerDatetime) MarshalJSON() ([]byte, error) { + return messageCardElementJson(m) +} + +type MessageCardEmbedSelectOption struct { + Text *MessageCardPlainText `json:"text,omitempty"` + Value string `json:"value,omitempty"` + URL *string `json:"url,omitempty"` + MultiURL *MessageCardURL `json:"multi_url,omitempty"` + Type *MessageCardButtonType `json:"type,omitempty"` +} + +type MessageCardEmbedOverflow struct { + Options []*MessageCardEmbedSelectOption `json:"options,omitempty"` + Value map[string]interface { + } `json:"value,omitempty"` + Confirm *MessageCardActionConfirm `json:"confirm,omitempty"` +} + +func (m *MessageCardEmbedOverflow) Tag() string { + return "overflow" +} + +func (m *MessageCardEmbedOverflow) MarshalJSON() ([]byte, error) { + return messageCardElementJson(m) +} + +func (m *MessageCardEmbedOverflow) IsAction() { +} + +func (m *MessageCardEmbedOverflow) IsExtra() { +} + +type MessageCardEmbedSelectMenuBase struct { + Placeholder *MessageCardPlainText `json:"placeholder,omitempty"` + InitialOption string `json:"initial_option,omitempty"` + Options []*MessageCardEmbedSelectOption `json:"options,omitempty"` + Value map[string]interface { + } `json:"value"` + Confirm *MessageCardActionConfirm `json:"confirm,omitempty"` +} + +func (m *MessageCardEmbedSelectMenuBase) IsAction() { +} + +func (m *MessageCardEmbedSelectMenuBase) IsExtra() { +} + +type MessageCardEmbedSelectMenuStatic struct { + *MessageCardEmbedSelectMenuBase +} + +func (m *MessageCardEmbedSelectMenuStatic) Tag() string { + return "select_static" +} + +func (m *MessageCardEmbedSelectMenuStatic) MarshalJSON() ([]byte, error) { + return messageCardElementJson(m) +} + +type MessageCardEmbedSelectMenuPerson struct { + *MessageCardEmbedSelectMenuBase +} + +func (m *MessageCardEmbedSelectMenuPerson) Tag() string { + return "select_person" +} + +func (m *MessageCardEmbedSelectMenuPerson) MarshalJSON() ([]byte, error) { + return messageCardElementJson(m) +} + +type MessageCardActionLayout string + +const ( + MessageCardActionLayoutDisected MessageCardActionLayout = "bisected" + MessageCardActionLayoutTrisection MessageCardActionLayout = "trisection" + MessageCardActionLayoutFlow MessageCardActionLayout = "flow" +) + +func (al MessageCardActionLayout) Ptr() *MessageCardActionLayout { + return &al +} + +type MessageCardAction struct { + Actions []MessageCardActionElement `json:"actions,omitempty"` + Layout *MessageCardActionLayout `json:"layout,omitempty"` +} + +func (m *MessageCardAction) Tag() string { + return "action" +} + +func (m *MessageCardAction) MarshalJSON() ([]byte, error) { + return messageCardElementJson(m) +} + +type MessageCardConfig struct { + EnableForward *bool `json:"enable_forward,omitempty"` + WideScreenMode *bool `json:"wide_screen_mode,omitempty"` +} + +type MessageCardHeader struct { + Template *string `json:"template,omitempty"` + Title *MessageCardPlainText `json:"title,omitempty"` +} + +type MessageCardURL struct { + URL string `json:"url,omitempty"` + AndroidURL string `json:"android_url,omitempty"` + IOSURL string `json:"ios_url,omitempty"` + PCURL string `json:"pc_url,omitempty"` +} + +type MessageCardField struct { + IsShort bool `json:"is_short,omitempty"` + Text MessageCardText `json:"text,omitempty"` +} diff --git a/v2/model.go b/v2/model.go new file mode 100644 index 00000000..002f1a8b --- /dev/null +++ b/v2/model.go @@ -0,0 +1,88 @@ +package lark + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "strings" +) + +type RawRequest struct { + Header http.Header + RawBody []byte +} + +func NewRawRequest(req *http.Request) (*RawRequest, error) { + rawBody, err := ioutil.ReadAll(req.Body) + if err != nil { + return nil, err + } + return &RawRequest{ + Header: req.Header, + RawBody: rawBody, + }, nil +} + +func (req RawRequest) RequestId() string { + logID := req.Header.Get(httpHeaderKeyLogId) + if logID != "" { + return logID + } + return req.Header.Get(httpHeaderKeyRequestId) +} + +func (req RawRequest) JSONUnmarshalBody(val interface{}) error { + if !strings.Contains(req.Header.Get(contentTypeHeader), contentTypeJson) { + return fmt.Errorf("req content-type not json, req: %v", req) + } + return json.Unmarshal(req.RawBody, val) +} + +func (req RawRequest) String() string { + return fmt.Sprintf("Header:%v, Content-Type: %s, Body: %v", + req.Header, req.Header.Get(contentTypeHeader), string(req.RawBody)) +} + +type RawResponse struct { + StatusCode int `json:"-"` + Header http.Header `json:"-"` + RawBody []byte `json:"-"` +} + +func (resp RawResponse) Write(writer http.ResponseWriter) { + writer.WriteHeader(resp.StatusCode) + for k, vs := range resp.Header { + for _, v := range vs { + writer.Header().Add(k, v) + } + } + if _, err := writer.Write(resp.RawBody); err != nil { + panic(err) + } +} + +func (resp RawResponse) JSONUnmarshalBody(val interface{}) error { + if !strings.Contains(resp.Header.Get(contentTypeHeader), contentTypeJson) { + return fmt.Errorf("response content-type not json, response: %v", resp) + } + return json.Unmarshal(resp.RawBody, val) +} + +func (resp RawResponse) RequestId() string { + logID := resp.Header.Get(httpHeaderKeyLogId) + if logID != "" { + return logID + } + return resp.Header.Get(httpHeaderKeyRequestId) +} + +func (resp RawResponse) String() string { + contentType := resp.Header.Get(contentTypeHeader) + body := fmt.Sprintf(" len %d", len(resp.RawBody)) + if strings.Contains(contentType, "json") || strings.Contains(contentType, "text") { + body = string(resp.RawBody) + } + return fmt.Sprintf("StatusCode: %d, Header:%v, Content-Type: %s, Body: %v", resp.StatusCode, + resp.Header, resp.Header.Get(contentTypeHeader), body) +} diff --git a/v2/sample/api/api.go b/v2/sample/api/api.go new file mode 100644 index 00000000..41f5de98 --- /dev/null +++ b/v2/sample/api/api.go @@ -0,0 +1,76 @@ +package main + +import ( + "context" + "fmt" + "github.com/larksuite/oapi-sdk-go/v2" + "io/ioutil" + "net/http" + "os" +) + +func main() { + var appID, appSecret = os.Getenv("APP_ID"), os.Getenv("APP_SECRET") + larkApp := lark.NewApp(lark.DomainFeiShu, appID, appSecret, + lark.WithLogger(lark.NewDefaultLogger(), lark.LogLevelDebug)) + + ctx := context.Background() + sendMessage(ctx, larkApp) + uploadImage(ctx, larkApp) + downloadImage(ctx, larkApp) +} + +func sendMessage(ctx context.Context, larkApp *lark.App) { + resp, err := larkApp.SendRequest(ctx, http.MethodGet, "/open-apis/message/v4/send", lark.AccessTokenTypeTenant, map[string]interface{}{ + "user_id": "77bbc392", + "msg_type": "text", + "content": &lark.MessageText{Text: "test"}, + }) + if err != nil { + fmt.Println(err) + return + } + fmt.Printf("request id: %s \n", resp.RequestId()) + fmt.Println(resp) + fmt.Println() + fmt.Println() +} + +func uploadImage(ctx context.Context, larkApp *lark.App) { + img, err := os.Open("test.png") + if err != nil { + fmt.Println(err) + return + } + defer img.Close() + resp, err := larkApp.SendRequest(ctx, http.MethodPost, "/open-apis/image/v4/put", + lark.AccessTokenTypeTenant, lark.NewFormdata().AddField("image_type", "message").AddFile("image", img)) + if err != nil { + fmt.Println(err) + return + } + fmt.Printf("request id: %s \n", resp.RequestId()) + fmt.Println(resp) + fmt.Println() + fmt.Println() +} + +func downloadImage(ctx context.Context, larkApp *lark.App) { + resp, err := larkApp.SendRequest(ctx, http.MethodGet, "/open-apis/image/v4/get?image_key=img_v2_b49b2df3-f277-467b-a650-d352839f4b6g", + lark.AccessTokenTypeTenant, nil, lark.WithFileDownload()) + if err != nil { + fmt.Println(err) + return + } + if resp.StatusCode != http.StatusOK { + fmt.Println(resp) + return + } + err = ioutil.WriteFile("test_download_v2.png", resp.RawBody, 0666) + if err != nil { + fmt.Println(err) + return + } + fmt.Printf("request id: %s \n", resp.RequestId()) + fmt.Println(resp) +} diff --git a/v2/sample/api/helpdesk.go b/v2/sample/api/helpdesk.go new file mode 100644 index 00000000..493e14d2 --- /dev/null +++ b/v2/sample/api/helpdesk.go @@ -0,0 +1,26 @@ +package main + +import ( + "context" + "fmt" + "github.com/larksuite/oapi-sdk-go/v2" + "os" +) + +func main() { + appID, appSecret, helpDeskID, helpDeskToken := os.Getenv("HD_APP_ID"), os.Getenv("HD_APP_SECRET"), + os.Getenv("HD_HELP_DESK_ID"), os.Getenv("HD_HELP_DESK_TOKEN") + larkApp := lark.NewApp("https://open.feishu.cn", appID, appSecret, + lark.WithAppHelpdeskCredential(helpDeskID, helpDeskToken), + lark.WithLogger(lark.NewDefaultLogger(), lark.LogLevelDebug)) + + resp, err := larkApp.SendRequest(context.TODO(), "GET", "/open-apis/helpdesk/v1/tickets/6971250929135779860", + lark.AccessTokenTypeTenant, nil, lark.WithNeedHelpDeskAuth()) + if err != nil { + fmt.Println(err) + return + } + fmt.Println(resp) + fmt.Println() + fmt.Println() +} diff --git a/v2/sample/api/im.go b/v2/sample/api/im.go new file mode 100644 index 00000000..735ef382 --- /dev/null +++ b/v2/sample/api/im.go @@ -0,0 +1,106 @@ +package main + +import ( + "context" + "fmt" + "github.com/larksuite/oapi-sdk-go/v2" + "github.com/larksuite/oapi-sdk-go/v2/service/im/v1" + "io/ioutil" + "os" +) + +func main() { + var appID, appSecret = os.Getenv("APP_ID"), os.Getenv("APP_SECRET") + larkApp := lark.NewApp(lark.DomainFeiShu, appID, appSecret, + lark.WithLogger(lark.NewDefaultLogger(), lark.LogLevelDebug)) + + ctx := context.Background() + messageCreate(ctx, larkApp) + //fileCreate(ctx, larkApp) + //fileDownload(ctx, larkApp) +} + +func messageCreate(ctx context.Context, larkApp *lark.App) { + messageText := &lark.MessageText{Text: "Tom test content"} + content, err := messageText.JSON() + if err != nil { + fmt.Println(err) + return + } + messageCreateResp, err := im.New(larkApp).Messages.Create(ctx, &im.MessageCreateReq{ + ReceiveIdType: lark.StringPtr("user_id"), + Body: &im.MessageCreateReqBody{ + ReceiveId: lark.StringPtr("77bbc392"), + MsgType: lark.StringPtr("text"), + Content: lark.StringPtr(content), + }, + }) + if err != nil { + fmt.Println(err) + return + } + fmt.Printf("request id: %s \n", messageCreateResp.RequestId()) + if messageCreateResp.Code != 0 { + fmt.Println(messageCreateResp.CodeError) + return + } + fmt.Println(lark.Prettify(messageCreateResp.Data)) + fmt.Println() + fmt.Println() +} + +func fileCreate(ctx context.Context, larkApp *lark.App) { + pdf, err := os.Open("test.pdf") + if err != nil { + fmt.Println(err) + return + } + defer pdf.Close() + + fileCreateResp, err := im.New(larkApp).Files.Create(ctx, &im.FileCreateReq{ + Body: &im.FileCreateReqBody{ + FileType: lark.StringPtr("pdf"), + FileName: lark.StringPtr("测试.pdf"), + File: pdf, + }, + }) + if err != nil { + fmt.Println(err) + return + } + fmt.Printf("request id: %s \n", fileCreateResp.RequestId()) + if fileCreateResp.Code != 0 { + fmt.Println(fileCreateResp.CodeError) + return + } + fmt.Println(lark.Prettify(fileCreateResp)) + fmt.Println() + fmt.Println() +} + +func fileDownload(ctx context.Context, larkApp *lark.App) { + fileGetResp, err := im.New(larkApp).Files.Get(ctx, &im.FileGetReq{ + FileKey: "file_v2_d0f706c9-9d6a-4f1d-8bdc-c577e23d94fg", + }) + if err != nil { + fmt.Println(err) + return + } + fmt.Printf("request id: %s \n", fileGetResp.RequestId()) + if fileGetResp.Code != 0 { + fmt.Println(fileGetResp.CodeError) + return + } + fmt.Printf("file name:%s \n", fileGetResp.FileName) + + bs, err := ioutil.ReadAll(fileGetResp.File) + if err != nil { + fmt.Println(err) + return + } + err = ioutil.WriteFile("test_download_v2.pdf", bs, 0666) + if err != nil { + fmt.Println(err) + return + } +} diff --git a/v2/sample/api/marketplace_app.go b/v2/sample/api/marketplace_app.go new file mode 100644 index 00000000..ca3ed554 --- /dev/null +++ b/v2/sample/api/marketplace_app.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "fmt" + lark "github.com/larksuite/oapi-sdk-go/v2" + "github.com/larksuite/oapi-sdk-go/v2/sample" + "github.com/larksuite/oapi-sdk-go/v2/service/im/v1" + "net/http" + "os" +) + +func main() { + appID, appSecret, verificationToken, encryptKey := os.Getenv("BOE_ISV_APP_ID"), os.Getenv("BOE_ISV_APP_SECRET"), + os.Getenv("BOE_ISV_VERIFICATION_TOKEN"), os.Getenv("BOE_ISV_ENCRYPT_KEY") + // BOE env + larkApp := lark.NewApp(lark.DomainFeiShu, appID, appSecret, + lark.WithAppEventVerify(verificationToken, encryptKey), + lark.WithAppType(lark.AppTypeMarketplace), // marketplace app(ISV app) + lark.WithLogger(sample.Logrus{}, lark.LogLevelDebug), // use logrus print log + lark.WithStore(sample.NewRedisStore()), // use redis store + ) + + marketplaceAppSendMessage(context.Background(), larkApp) + + // http server handle func + // obtain app ticket + http.HandleFunc("/webhook/event", func(writer http.ResponseWriter, request *http.Request) { + rawRequest, err := lark.NewRawRequest(request) + if err != nil { + writer.WriteHeader(http.StatusInternalServerError) + writer.Write([]byte(err.Error())) + return + } + larkApp.Webhook.EventCommandHandle(context.Background(), rawRequest).Write(writer) + }) + // startup http server + err := http.ListenAndServe(":8089", nil) + if err != nil { + panic(err) + } +} + +func marketplaceAppSendMessage(ctx context.Context, larkApp *lark.App) { + messageText := &lark.MessageText{Text: "Tom test content"} + content, err := messageText.JSON() + if err != nil { + fmt.Println(err) + return + } + messageCreateResp, err := im.New(larkApp).Messages.Create(ctx, &im.MessageCreateReq{ + ReceiveIdType: lark.StringPtr("user_id"), + Body: &im.MessageCreateReqBody{ + ReceiveId: lark.StringPtr("beb9d1cc"), + MsgType: lark.StringPtr("text"), + Content: lark.StringPtr(content), + }, + }, lark.WithTenantKey("13586be5aacf1748")) // setting TenantKey + if err != nil { + fmt.Println(err) + return + } + fmt.Printf("request id: %s \n", messageCreateResp.RequestId()) + if messageCreateResp.Code != 0 { + fmt.Println(messageCreateResp.CodeError) + return + } + fmt.Println(lark.Prettify(messageCreateResp.Data)) + fmt.Println() + fmt.Println() +} diff --git a/v2/sample/api/message_model.go b/v2/sample/api/message_model.go new file mode 100644 index 00000000..46dacb60 --- /dev/null +++ b/v2/sample/api/message_model.go @@ -0,0 +1,212 @@ +package main + +import ( + "fmt" + "github.com/larksuite/oapi-sdk-go/v2" +) + +func main() { + printMessageText() + printMessagePost() + printMessageCard() + printMessageImage() + printMessageShareChat() + printMessageShareUser() + printMessageAudio() + printMessageVideo() + printMessageFile() + printMessageSticker() +} + +func printMessageText() { + text := &lark.MessageText{Text: "Text"} + s, err := text.JSON() + if err != nil { + panic(err) + } + fmt.Println(s) +} + +func printMessagePost() { + post := make(lark.MessagePost) + post[lark.LanguageTypeZhCN] = &lark.MessagePostContent{ + Title: "Title", + Content: [][]lark.MessagePostElement{ + { + &lark.MessagePostText{ + Text: "Text", + UnEscape: false, + }, + &lark.MessagePostA{ + Text: "Fei Shu", + Href: "https://www.feishu.com", + UnEscape: false, + }, + }, + { + &lark.MessagePostA{ + Text: "Fei Shu", + Href: "https://www.feishu.com", + UnEscape: false, + }, + }, + }, + } + s, err := post.JSON() + if err != nil { + panic(err) + } + fmt.Println(s) +} + +func printMessageCard() { + card := &lark.MessageCard{ + CardLink: &lark.MessageCardURL{ + URL: "https://www.feishu.cn", + AndroidURL: "https://www.feishu.cn", + IOSURL: "https://www.feishu.cn", + PCURL: "https://www.feishu.cn", + }, + Config: &lark.MessageCardConfig{EnableForward: lark.BoolPtr(true)}, + Header: &lark.MessageCardHeader{ + Template: lark.StringPtr("blue"), + Title: &lark.MessageCardPlainText{ + Content: "Header title", + }, + }, + Elements: []lark.MessageCardElement{ + &lark.MessageCardImage{ + Alt: &lark.MessageCardPlainText{ + Content: "img_v2_9221f258-db3e-4a40-b9cb-24decddee2bg", + Lines: nil, + }, + Title: &lark.MessageCardPlainText{ + Content: "img_v2_9221f258-db3e-4a40-b9cb-24decddee2bg", + }, + ImgKey: "img_v2_9221f258-db3e-4a40-b9cb-24decddee2bg", + CustomWidth: lark.IntPtr(300), + CompactWidth: lark.BoolPtr(false), + }, + &lark.MessageCardAction{ + Actions: []lark.MessageCardActionElement{ + &lark.MessageCardEmbedButton{ + Text: &lark.MessageCardPlainText{ + Content: "button", + }, + Type: lark.MessageCardButtonTypeDanger.Ptr(), + Value: map[string]interface{}{"value": "1"}, + Confirm: &lark.MessageCardActionConfirm{ + Title: &lark.MessageCardPlainText{ + Content: "Title", + }, + Text: &lark.MessageCardPlainText{ + Content: "Text", + }, + }, + }, + }, + Layout: lark.MessageCardActionLayoutFlow.Ptr(), + }, + &lark.MessageCardMarkdown{ + Content: "**Markdown**", + }, + &lark.MessageCardDiv{ + Text: &lark.MessageCardPlainText{ + Content: "text", + }, + Extra: &lark.MessageCardEmbedButton{ + Text: &lark.MessageCardPlainText{ + Content: "button", + }, + Type: lark.MessageCardButtonTypeDanger.Ptr(), + Value: map[string]interface{}{"value": "1"}, + Confirm: &lark.MessageCardActionConfirm{ + Title: &lark.MessageCardPlainText{ + Content: "Title", + }, + Text: &lark.MessageCardPlainText{ + Content: "Text", + }, + }, + }, + }, + }, + } + s, err := card.JSON() + if err != nil { + panic(err) + } + fmt.Println(s) +} + +func printMessageImage() { + image := &lark.MessageImage{ImageKey: "img_v2_9221f258-db3e-4a40-b9cb-24decddee2bg"} + s, err := image.JSON() + if err != nil { + panic(err) + } + fmt.Println(s) +} + +func printMessageShareChat() { + shareChat := &lark.MessageShareChat{ChatId: "oc_xxxxxxxxxxxx"} + s, err := shareChat.JSON() + if err != nil { + panic(err) + } + fmt.Println(s) +} + +func printMessageShareUser() { + shareUser := &lark.MessageShareUser{UserId: "ou-xxxxxxxxxxxxxx"} + s, err := shareUser.JSON() + if err != nil { + panic(err) + } + fmt.Println(s) +} + +func printMessageAudio() { + audio := &lark.MessageAudio{ + FileKey: "file-xxxxxxxxxx", + } + s, err := audio.JSON() + if err != nil { + panic(err) + } + fmt.Println(s) +} + +func printMessageVideo() { + audio := &lark.MessageVideo{ + FileKey: "file-xxxxxxxxxx", + ImageKey: "img-xxxxxxxxx", + } + s, err := audio.JSON() + if err != nil { + panic(err) + } + fmt.Println(s) +} + +func printMessageFile() { + file := &lark.MessageFile{ + FileKey: "file-xxxxxxxxxx", + } + s, err := file.JSON() + if err != nil { + panic(err) + } + fmt.Println(s) +} + +func printMessageSticker() { + sticker := &lark.MessageSticker{ + FileKey: "file-xxxxxxxxxx", + } + s, err := sticker.JSON() + if err != nil { + panic(err) + } + fmt.Println(s) +} diff --git a/v2/sample/card/card.go b/v2/sample/card/card.go new file mode 100644 index 00000000..47d565ea --- /dev/null +++ b/v2/sample/card/card.go @@ -0,0 +1,49 @@ +package main + +import ( + "context" + "fmt" + "github.com/larksuite/oapi-sdk-go/v2" + "net/http" + "os" +) + +func main() { + appID, appSecret, verificationToken, encryptKey := os.Getenv("APP_ID"), os.Getenv("APP_SECRET"), + os.Getenv("VERIFICATION_TOKEN"), os.Getenv("ENCRYPT_KEY") + larkApp := lark.NewApp(lark.DomainFeiShu, appID, appSecret, + lark.WithAppEventVerify(verificationToken, encryptKey), + lark.WithLogger(lark.NewDefaultLogger(), lark.LogLevelDebug)) + + // card action handler + // return new card + larkApp.Webhook.CardActionHandler(func(ctx context.Context, request *lark.RawRequest, + action *lark.CardAction) (interface{}, error) { + fmt.Println(request) + fmt.Println(lark.Prettify(action)) + + card := &lark.MessageCard{ + Config: &lark.MessageCardConfig{WideScreenMode: lark.BoolPtr(true)}, + Elements: []lark.MessageCardElement{&lark.MessageCardMarkdown{ + Content: "**test**", + }}, + } + return card, nil + }) + + // http server handle func + http.HandleFunc("/webhook/card", func(writer http.ResponseWriter, request *http.Request) { + rawRequest, err := lark.NewRawRequest(request) + if err != nil { + writer.WriteHeader(http.StatusInternalServerError) + _, _ = writer.Write([]byte(err.Error())) + return + } + larkApp.Webhook.CardActionHandle(context.Background(), rawRequest).Write(writer) + }) + // startup http server + err := http.ListenAndServe(":8089", nil) + if err != nil { + panic(err) + } +} diff --git a/v2/sample/customer_bot/customer_bot.go b/v2/sample/customer_bot/customer_bot.go new file mode 100644 index 00000000..046dc700 --- /dev/null +++ b/v2/sample/customer_bot/customer_bot.go @@ -0,0 +1,17 @@ +package main + +import ( + "context" + "fmt" + lark "github.com/larksuite/oapi-sdk-go/v2" +) + +func main() { + customerBot := lark.NewCustomerBot("https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxxxxxxxxxxxxx", "u8TfAYQYZWvWRubw6EKQUe") + resp, err := customerBot.SendMessage(context.TODO(), "text", &lark.MessageText{Text: "test"}) + if err != nil { + panic(err) + } + fmt.Printf("request id: %s \n", resp.RequestId()) + fmt.Println(lark.Prettify(resp)) +} diff --git a/v2/sample/event/event.go b/v2/sample/event/event.go new file mode 100644 index 00000000..9048eaea --- /dev/null +++ b/v2/sample/event/event.go @@ -0,0 +1,41 @@ +package main + +import ( + "context" + "fmt" + "github.com/larksuite/oapi-sdk-go/v2" + "net/http" + "os" +) + +func main() { + appID, appSecret, verificationToken, encryptKey := os.Getenv("APP_ID"), os.Getenv("APP_SECRET"), + os.Getenv("VERIFICATION_TOKEN"), os.Getenv("ENCRYPT_KEY") + + larkApp := lark.NewApp(lark.DomainFeiShu, appID, appSecret, + lark.WithAppEventVerify(verificationToken, encryptKey), + lark.WithLogger(lark.NewDefaultLogger(), lark.LogLevelDebug)) + + // @robot message handle + larkApp.Webhook.EventHandleFunc("im.message.receive_v1", func(ctx context.Context, req *lark.RawRequest) error { + fmt.Println(req.RequestId()) + fmt.Println(req) + return nil + }) + + // http server handle func + http.HandleFunc("/webhook/event", func(writer http.ResponseWriter, request *http.Request) { + rawRequest, err := lark.NewRawRequest(request) + if err != nil { + writer.WriteHeader(http.StatusInternalServerError) + writer.Write([]byte(err.Error())) + return + } + larkApp.Webhook.EventCommandHandle(context.Background(), rawRequest).Write(writer) + }) + // startup http server + err := http.ListenAndServe(":8089", nil) + if err != nil { + panic(err) + } +} diff --git a/v2/sample/event/im.go b/v2/sample/event/im.go new file mode 100644 index 00000000..9318475f --- /dev/null +++ b/v2/sample/event/im.go @@ -0,0 +1,42 @@ +package main + +import ( + "context" + "fmt" + "github.com/larksuite/oapi-sdk-go/v2" + "github.com/larksuite/oapi-sdk-go/v2/service/im/v1" + "net/http" + "os" +) + +func main() { + appID, appSecret, verificationToken, encryptKey := os.Getenv("APP_ID"), os.Getenv("APP_SECRET"), + os.Getenv("VERIFICATION_TOKEN"), os.Getenv("ENCRYPT_KEY") + + larkApp := lark.NewApp(lark.DomainFeiShu, appID, appSecret, + lark.WithAppEventVerify(verificationToken, encryptKey), + lark.WithLogger(lark.NewDefaultLogger(), lark.LogLevelDebug)) + + // @robot message handle + im.New(larkApp).Messages.ReceiveEventHandler(func(ctx context.Context, req *lark.RawRequest, event *im.MessageReceiveEvent) error { + fmt.Println(req) + fmt.Println(lark.Prettify(event)) + return nil + }) + + // http server handle func + http.HandleFunc("/webhook/event", func(writer http.ResponseWriter, request *http.Request) { + rawRequest, err := lark.NewRawRequest(request) + if err != nil { + writer.WriteHeader(http.StatusInternalServerError) + writer.Write([]byte(err.Error())) + return + } + larkApp.Webhook.EventCommandHandle(context.Background(), rawRequest).Write(writer) + }) + // startup http server + err := http.ListenAndServe(":8089", nil) + if err != nil { + panic(err) + } +} diff --git a/sample/configs/logrus.go b/v2/sample/logrus.go similarity index 91% rename from sample/configs/logrus.go rename to v2/sample/logrus.go index cedfa1d4..8f629f13 100644 --- a/sample/configs/logrus.go +++ b/v2/sample/logrus.go @@ -1,4 +1,4 @@ -package configs +package sample import ( "context" @@ -6,7 +6,7 @@ import ( "os" ) -// use logrus implement log.Logger +// Logrus use logrus implement lark.logger type Logrus struct { } diff --git a/sample/configs/redis_store.go b/v2/sample/redis_store.go similarity index 94% rename from sample/configs/redis_store.go rename to v2/sample/redis_store.go index 3ddf9bfb..87ca4479 100644 --- a/sample/configs/redis_store.go +++ b/v2/sample/redis_store.go @@ -1,4 +1,4 @@ -package configs +package sample import ( "context" @@ -6,7 +6,7 @@ import ( "time" ) -// use redis implement store.Store +// RedisStore use redis implement lark.store type RedisStore struct { client *redis.Client } diff --git a/v2/sample/utils/file_download.go b/v2/sample/utils/file_download.go new file mode 100644 index 00000000..11a46712 --- /dev/null +++ b/v2/sample/utils/file_download.go @@ -0,0 +1,21 @@ +package main + +import ( + "context" + "fmt" + "github.com/larksuite/oapi-sdk-go/v2" + "io/ioutil" +) + +func main() { + bs, err := lark.DownloadFile(context.Background(), "https://sf1-ttcdn-tos.pstatp.com/obj/open-platform-opendoc/b7f456f542e8811e82657e577f126bce_WfFUj8sO1i.png") + if err != nil { + fmt.Println(err) + return + } + err = ioutil.WriteFile("test_file_download.png", bs, 0666) + if err != nil { + fmt.Println(err) + return + } +} diff --git a/v2/service/acs/v1/api.go b/v2/service/acs/v1/api.go new file mode 100644 index 00000000..914df718 --- /dev/null +++ b/v2/service/acs/v1/api.go @@ -0,0 +1,162 @@ +// Package acs code generated by lark suite oapi sdk gen +package acs + +import ( + "bytes" + "context" + "net/http" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type AcsService struct { + AccessRecords *accessRecords + Users *users + Devices *devices + AccessRecordAccessPhoto *accessRecordAccessPhoto + UserFace *userFace +} + +func New(app *lark.App) *AcsService { + a := &AcsService{} + a.AccessRecords = &accessRecords{app: app} + a.Users = &users{app: app} + a.Devices = &devices{app: app} + a.AccessRecordAccessPhoto = &accessRecordAccessPhoto{app: app} + a.UserFace = &userFace{app: app} + return a +} + +type accessRecords struct { + app *lark.App +} +type users struct { + app *lark.App +} +type devices struct { + app *lark.App +} +type accessRecordAccessPhoto struct { + app *lark.App +} +type userFace struct { + app *lark.App +} + +func (a *accessRecords) List(ctx context.Context, req *AccessRecordListReq, options ...lark.RequestOptionFunc) (*AccessRecordListResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/acs/v1/access_records", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AccessRecordListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *accessRecordAccessPhoto) Get(ctx context.Context, req *AccessRecordAccessPhotoGetReq, options ...lark.RequestOptionFunc) (*AccessRecordAccessPhotoGetResp, error) { + options = append(options, lark.WithFileDownload()) + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/acs/v1/access_records/:access_record_id/access_photo", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AccessRecordAccessPhotoGetResp{RawResponse: rawResp} + if rawResp.StatusCode == http.StatusOK { + resp.File = bytes.NewBuffer(rawResp.RawBody) + resp.FileName = lark.FileNameByHeader(rawResp.Header) + return resp, err + } + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (d *devices) List(ctx context.Context, options ...lark.RequestOptionFunc) (*DeviceListResp, error) { + rawResp, err := d.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/acs/v1/devices", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, nil, options...) + if err != nil { + return nil, err + } + resp := &DeviceListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (u *users) Patch(ctx context.Context, req *UserPatchReq, options ...lark.RequestOptionFunc) (*UserPatchResp, error) { + rawResp, err := u.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPatch, + "/open-apis/acs/v1/users/:user_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &UserPatchResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (u *users) Get(ctx context.Context, req *UserGetReq, options ...lark.RequestOptionFunc) (*UserGetResp, error) { + rawResp, err := u.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/acs/v1/users/:user_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &UserGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (u *users) List(ctx context.Context, req *UserListReq, options ...lark.RequestOptionFunc) (*UserListResp, error) { + rawResp, err := u.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/acs/v1/users", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &UserListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (u *userFace) Get(ctx context.Context, req *UserFaceGetReq, options ...lark.RequestOptionFunc) (*UserFaceGetResp, error) { + options = append(options, lark.WithFileDownload()) + rawResp, err := u.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/acs/v1/users/:user_id/face", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &UserFaceGetResp{RawResponse: rawResp} + if rawResp.StatusCode == http.StatusOK { + resp.File = bytes.NewBuffer(rawResp.RawBody) + resp.FileName = lark.FileNameByHeader(rawResp.Header) + return resp, err + } + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (u *userFace) Update(ctx context.Context, req *UserFaceUpdateReq, options ...lark.RequestOptionFunc) (*UserFaceUpdateResp, error) { + options = append(options, lark.WithFileUpload()) + rawResp, err := u.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPut, + "/open-apis/acs/v1/users/:user_id/face", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &UserFaceUpdateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} diff --git a/v2/service/acs/v1/event.go b/v2/service/acs/v1/event.go new file mode 100644 index 00000000..d893e2a0 --- /dev/null +++ b/v2/service/acs/v1/event.go @@ -0,0 +1,39 @@ +// Package acs code generated by lark suite oapi sdk gen +package acs + +import ( + "context" + "github.com/larksuite/oapi-sdk-go/v2" +) + +type accessRecordCreatedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *AccessRecordCreatedEvent) error +} + +func (h *accessRecordCreatedEventHandler) Event() interface{} { + return &AccessRecordCreatedEvent{} +} + +func (h *accessRecordCreatedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*AccessRecordCreatedEvent)) +} + +func (a *accessRecords) CreatedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *AccessRecordCreatedEvent) error) { + a.app.Webhook.EventHandler("created", &accessRecordCreatedEventHandler{handler: handler}) +} + +type userUpdatedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *UserUpdatedEvent) error +} + +func (h *userUpdatedEventHandler) Event() interface{} { + return &UserUpdatedEvent{} +} + +func (h *userUpdatedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*UserUpdatedEvent)) +} + +func (u *users) UpdatedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *UserUpdatedEvent) error) { + u.app.Webhook.EventHandler("updated", &userUpdatedEventHandler{handler: handler}) +} diff --git a/v2/service/acs/v1/model.go b/v2/service/acs/v1/model.go new file mode 100644 index 00000000..8e0ed191 --- /dev/null +++ b/v2/service/acs/v1/model.go @@ -0,0 +1,182 @@ +// Package acs code generated by lark suite oapi sdk gen +package acs + +import ( + "io" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type UserId struct { + UserId *string `json:"user_id,omitempty"` + OpenId *string `json:"open_id,omitempty"` + UnionId *string `json:"union_id,omitempty"` +} + +type Device struct { + DeviceId *int64 `json:"device_id,omitempty,string"` + DeviceName *string `json:"device_name,omitempty"` + DeviceSn *string `json:"device_sn,omitempty"` +} + +type AccessRecord struct { + AccessRecordId *int64 `json:"access_record_id,omitempty,string"` + UserId *string `json:"user_id,omitempty"` + DeviceId *int64 `json:"device_id,omitempty,string"` + IsClockIn *bool `json:"is_clock_in,omitempty"` + AccessTime *int64 `json:"access_time,omitempty,string"` + AccessType *string `json:"access_type,omitempty"` + AccessData *string `json:"access_data,omitempty"` + IsDoorOpen *bool `json:"is_door_open,omitempty"` +} + +type Feature struct { + Card *int `json:"card,omitempty"` + FaceUploaded *bool `json:"face_uploaded,omitempty"` +} + +type File struct { + Files io.Reader `json:"files,omitempty"` + FileType *string `json:"file_type,omitempty"` + FileName *string `json:"file_name,omitempty"` +} + +type User struct { + Feature *Feature `json:"feature,omitempty"` + UserId *string `json:"user_id,omitempty"` +} + +type AccessRecordListReq struct { + PageSize *int `query:"page_size"` + PageToken *string `query:"page_token"` + From *int `query:"from"` + To *int `query:"to"` + DeviceId *int64 `query:"device_id"` + UserIdType *string `query:"user_id_type"` +} + +type AccessRecordListRespData struct { + Items []*AccessRecord `json:"items,omitempty"` + PageToken *string `json:"page_token,omitempty"` + HasMore *bool `json:"has_more,omitempty"` +} + +type AccessRecordListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *AccessRecordListRespData `json:"data"` +} + +type AccessRecordAccessPhotoGetReq struct { + AccessRecordId string `path:"access_record_id"` +} + +type AccessRecordAccessPhotoGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + File io.Reader `json:"-"` + FileName string `json:"-"` +} + +type DeviceListRespData struct { + Items []*Device `json:"items,omitempty"` +} + +type DeviceListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *DeviceListRespData `json:"data"` +} + +type UserPatchReq struct { + UserId string `path:"user_id"` + UserIdType *string `query:"user_id_type"` + User *User `body:""` +} + +type UserPatchResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type UserGetReq struct { + UserId string `path:"user_id"` + UserIdType *string `query:"user_id_type"` +} + +type UserGetRespData struct { + User *User `json:"user,omitempty"` +} + +type UserGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *UserGetRespData `json:"data"` +} + +type UserListReq struct { + PageSize *int `query:"page_size"` + PageToken *string `query:"page_token"` + UserIdType *string `query:"user_id_type"` +} + +type UserListRespData struct { + Items []*User `json:"items,omitempty"` + PageToken *string `json:"page_token,omitempty"` + HasMore *bool `json:"has_more,omitempty"` +} + +type UserListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *UserListRespData `json:"data"` +} + +type UserFaceGetReq struct { + UserId string `path:"user_id"` + IsCropped *bool `query:"is_cropped"` + UserIdType *string `query:"user_id_type"` +} + +type UserFaceGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + File io.Reader `json:"-"` + FileName string `json:"-"` +} + +type UserFaceUpdateReq struct { + UserId string `path:"user_id"` + UserIdType *string `query:"user_id_type"` + File *File `body:""` +} + +type UserFaceUpdateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type AccessRecordCreatedEventData struct { + AccessRecordId *string `json:"access_record_id,omitempty"` + UserId *UserId `json:"user_id,omitempty"` + DeviceId *string `json:"device_id,omitempty"` + IsClockIn *bool `json:"is_clock_in,omitempty"` + IsDoorOpen *bool `json:"is_door_open,omitempty"` + AccessTime *string `json:"access_time,omitempty"` +} + +type AccessRecordCreatedEvent struct { + *lark.EventV2Base + Event *AccessRecordCreatedEventData `json:"event"` +} + +type UserUpdatedEventData struct { + UserId *UserId `json:"user_id,omitempty"` + Card *int `json:"card,omitempty"` + FaceUploaded *bool `json:"face_uploaded,omitempty"` +} + +type UserUpdatedEvent struct { + *lark.EventV2Base + Event *UserUpdatedEventData `json:"event"` +} diff --git a/v2/service/admin/v1/api.go b/v2/service/admin/v1/api.go new file mode 100644 index 00000000..442eb277 --- /dev/null +++ b/v2/service/admin/v1/api.go @@ -0,0 +1,55 @@ +// Package admin code generated by lark suite oapi sdk gen +package admin + +import ( + "context" + "net/http" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type AdminService struct { + AdminDeptStats *adminDeptStats + AdminUserStats *adminUserStats +} + +func New(app *lark.App) *AdminService { + a := &AdminService{} + a.AdminDeptStats = &adminDeptStats{app: app} + a.AdminUserStats = &adminUserStats{app: app} + return a +} + +type adminDeptStats struct { + app *lark.App +} +type adminUserStats struct { + app *lark.App +} + +func (a *adminDeptStats) List(ctx context.Context, req *AdminDeptStatListReq, options ...lark.RequestOptionFunc) (*AdminDeptStatListResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/admin/v1/admin_dept_stats", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AdminDeptStatListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *adminUserStats) List(ctx context.Context, req *AdminUserStatListReq, options ...lark.RequestOptionFunc) (*AdminUserStatListResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/admin/v1/admin_user_stats", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AdminUserStatListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} diff --git a/v2/service/admin/v1/model.go b/v2/service/admin/v1/model.go new file mode 100644 index 00000000..5aa745d5 --- /dev/null +++ b/v2/service/admin/v1/model.go @@ -0,0 +1,240 @@ +// Package admin code generated by lark suite oapi sdk gen +package admin + +import ( + "github.com/larksuite/oapi-sdk-go/v2" +) + +type AdminDeptStat struct { + Date *string `json:"date,omitempty"` + DepartmentId *string `json:"department_id,omitempty"` + DepartmentName *string `json:"department_name,omitempty"` + DepartmentPath *string `json:"department_path,omitempty"` + TotalUserNum *int `json:"total_user_num,omitempty"` + ActiveUserNum *int `json:"active_user_num,omitempty"` + ActiveUserRate *string `json:"active_user_rate,omitempty"` + SuiteDau *int `json:"suite_dau,omitempty"` + SuiteActiveRate *string `json:"suite_active_rate,omitempty"` + NewUserNum *int `json:"new_user_num,omitempty"` + NewActiveNum *int `json:"new_active_num,omitempty"` + ResignUserNum *int `json:"resign_user_num,omitempty"` + ImDau *int `json:"im_dau,omitempty"` + SendMessengerUserNum *int `json:"send_messenger_user_num,omitempty"` + SendMessengerNum *int `json:"send_messenger_num,omitempty"` + AvgSendMessengerNum *string `json:"avg_send_messenger_num,omitempty"` + DocsDau *int `json:"docs_dau,omitempty"` + CreateDocsUserNum *int `json:"create_docs_user_num,omitempty"` + CreateDocsNum *int `json:"create_docs_num,omitempty"` + AvgCreateDocsNum *string `json:"avg_create_docs_num,omitempty"` + CalDau *int `json:"cal_dau,omitempty"` + CreateCalUserNum *int `json:"create_cal_user_num,omitempty"` + CreateCalNum *int `json:"create_cal_num,omitempty"` + AvgCreateCalNum *string `json:"avg_create_cal_num,omitempty"` + VcDau *int `json:"vc_dau,omitempty"` + VcDuration *int `json:"vc_duration,omitempty"` + AvgVcDuration *string `json:"avg_vc_duration,omitempty"` +} + +type AdminUserStat struct { + Date *string `json:"date,omitempty"` + UserId *string `json:"user_id,omitempty"` + UserName *string `json:"user_name,omitempty"` + DepartmentName *string `json:"department_name,omitempty"` + DepartmentPath *string `json:"department_path,omitempty"` + CreateTime *string `json:"create_time,omitempty"` + UserActiveFlag *int `json:"user_active_flag,omitempty"` + RegisterTime *string `json:"register_time,omitempty"` + SuiteActiveFlag *int `json:"suite_active_flag,omitempty"` + LastActiveTime *string `json:"last_active_time,omitempty"` + ImActiveFlag *int `json:"im_active_flag,omitempty"` + SendMessengerNum *int `json:"send_messenger_num,omitempty"` + DocsActiveFlag *int `json:"docs_active_flag,omitempty"` + CreateDocsNum *int `json:"create_docs_num,omitempty"` + CalActiveFlag *int `json:"cal_active_flag,omitempty"` + CreateCalNum *int `json:"create_cal_num,omitempty"` + VcActiveFlag *int `json:"vc_active_flag,omitempty"` + VcDuration *int `json:"vc_duration,omitempty"` + ActiveOs *string `json:"active_os,omitempty"` +} + +type AuditAndroidContext struct { + Udid *string `json:"udid,omitempty"` + Did *string `json:"did,omitempty"` + AppVer *string `json:"app_ver,omitempty"` + Ver *string `json:"ver,omitempty"` + Region *string `json:"region,omitempty"` + IdI *string `json:"id_i,omitempty"` + IdR *string `json:"id_r,omitempty"` + HwBrand *string `json:"hw_brand,omitempty"` + HwManuf *string `json:"hw_manuf,omitempty"` + Wifip *string `json:"wifip,omitempty"` + RouteIip *string `json:"route_iip,omitempty"` + RouteGip *string `json:"route_gip,omitempty"` + EnvSu *string `json:"env_su,omitempty"` + EnvTz *string `json:"env_tz,omitempty"` + EnvMl *string `json:"env_ml,omitempty"` + Location *string `json:"location,omitempty"` + ActiveIp *string `json:"active_ip,omitempty"` + ActiveIpDetail *string `json:"active_ip_detail,omitempty"` + CellBaseStation *string `json:"cell_base_station,omitempty"` + IP *string `json:"IP,omitempty"` +} + +type AuditContext struct { + TerminalType *int `json:"terminal_type,omitempty"` + IosContext *AuditIosContext `json:"ios_context,omitempty"` + PcContext *AuditPcContext `json:"pc_context,omitempty"` + WebContext *AuditWebContext `json:"web_context,omitempty"` + AndroidContext *AuditAndroidContext `json:"android_context,omitempty"` +} + +type AuditEventExtend struct { + CommentType *string `json:"comment_type,omitempty"` + AppDetail *string `json:"app_detail,omitempty"` + TwoStepValidation *bool `json:"two_step_validation,omitempty"` + LoginMethod *string `json:"login_method,omitempty"` + NewPeopleNumInVideo *int `json:"new_people_num_in_video,omitempty"` + ExternalPeopleNumInVideo *int `json:"external_people_num_in_video,omitempty"` + ExternalPeopleNumInChat *int `json:"external_people_num_in_chat,omitempty"` + JoinGroup *int `json:"join_group,omitempty"` + QuitGroup *int `json:"quit_group,omitempty"` + ExternalPeopleNumInDocShare *int `json:"external_people_num_in_doc_share,omitempty"` +} + +type AuditInfo struct { + EventId *string `json:"event_id,omitempty"` + EventName *string `json:"event_name,omitempty"` + DepartmentIds []string `json:"department_ids,omitempty"` + EventModule *int `json:"event_module,omitempty"` + OperatorType *int `json:"operator_type,omitempty"` + OperatorValue *string `json:"operator_value,omitempty"` + Objects []*AuditObjectEntity `json:"objects,omitempty"` + Recipients []*AuditRecipientEntity `json:"recipients,omitempty"` + EventTime *int `json:"event_time,omitempty"` + Ip *string `json:"ip,omitempty"` + OperatorApp *string `json:"operator_app,omitempty"` + AuditContext *AuditContext `json:"audit_context,omitempty"` + Extend *AuditEventExtend `json:"extend,omitempty"` + OperatorAppName *string `json:"operator_app_name,omitempty"` +} + +type AuditIosContext struct { + Udid *string `json:"udid,omitempty"` + Did *string `json:"did,omitempty"` + AppVer *string `json:"app_ver,omitempty"` + Ver *string `json:"ver,omitempty"` + Os *string `json:"os,omitempty"` + STZone *string `json:"STZone,omitempty"` + ML *string `json:"ML,omitempty"` + Sjd *string `json:"sjd,omitempty"` + Proxyip *string `json:"proxyip,omitempty"` + Wifip *string `json:"wifip,omitempty"` + Location *string `json:"location,omitempty"` + ActiveIp *string `json:"active_ip,omitempty"` + ActiveIpDetail *string `json:"active_ip_detail,omitempty"` + CellBaseStation *string `json:"cell_base_station,omitempty"` + IP *string `json:"IP,omitempty"` +} + +type AuditObjectDetail struct { + CloneSource *string `json:"clone_source,omitempty"` + TextDetail *string `json:"text_detail,omitempty"` + FileName *string `json:"file_name,omitempty"` + ThirdPartyAppID *string `json:"third_party_appID,omitempty"` + ContainFileNum *int `json:"contain_file_num,omitempty"` + PermissionSettingType *string `json:"permission_setting_type,omitempty"` + PermissionExternalAccessType *bool `json:"permission_external_access_Type,omitempty"` + PermissionShareType *string `json:"permission_share_type,omitempty"` + FileServiceSource *string `json:"file_service_source,omitempty"` + OkrDownloadContent *string `json:"okr_download_content,omitempty"` +} + +type AuditObjectEntity struct { + ObjectType *string `json:"object_type,omitempty"` + ObjectValue *string `json:"object_value,omitempty"` + ObjectName *string `json:"object_name,omitempty"` + ObjectOwner *string `json:"object_owner,omitempty"` + ObjectDetail *AuditObjectDetail `json:"object_detail,omitempty"` +} + +type AuditPcContext struct { + Udid *string `json:"udid,omitempty"` + Did *string `json:"did,omitempty"` + AppVer *string `json:"app_ver,omitempty"` + Ver *string `json:"ver,omitempty"` + Os *string `json:"os,omitempty"` + Wifip *string `json:"wifip,omitempty"` + Region *string `json:"region,omitempty"` + IP *string `json:"IP,omitempty"` +} + +type AuditRecipientDetail struct { + PermissionActionType *string `json:"permission_action_type,omitempty"` +} + +type AuditRecipientEntity struct { + RecipientType *string `json:"recipient_type,omitempty"` + RecipientValue *string `json:"recipient_value,omitempty"` + RecipientDetail *AuditRecipientDetail `json:"recipient_detail,omitempty"` +} + +type AuditWebContext struct { + UserAgent *string `json:"user_agent,omitempty"` + IP *string `json:"IP,omitempty"` +} + +type SplashPageStat struct { + Date *string `json:"date,omitempty"` + SplashId *string `json:"splash_id,omitempty"` + ImpressionCount *int `json:"impression_count,omitempty"` + ClickCount *int `json:"click_count,omitempty"` + SkipCount *int `json:"skip_count,omitempty"` + ImpressionCountAccumulate *int `json:"impression_count_accumulate,omitempty"` + ClickCountAccumulate *int `json:"click_count_accumulate,omitempty"` + SkipCountAccumulate *int `json:"skip_count_accumulate,omitempty"` +} + +type AdminDeptStatListReq struct { + DepartmentIdType *string `query:"department_id_type"` + StartDate *string `query:"start_date"` + EndDate *string `query:"end_date"` + DepartmentId *string `query:"department_id"` + ContainsChildDept *bool `query:"contains_child_dept"` + PageSize *int `query:"page_size"` + PageToken *string `query:"page_token"` +} + +type AdminDeptStatListRespData struct { + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` + Items []*AdminDeptStat `json:"items,omitempty"` +} + +type AdminDeptStatListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *AdminDeptStatListRespData `json:"data"` +} + +type AdminUserStatListReq struct { + UserIdType *string `query:"user_id_type"` + DepartmentIdType *string `query:"department_id_type"` + StartDate *string `query:"start_date"` + EndDate *string `query:"end_date"` + DepartmentId *string `query:"department_id"` + UserId *string `query:"user_id"` + PageSize *int `query:"page_size"` + PageToken *string `query:"page_token"` +} + +type AdminUserStatListRespData struct { + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` + Items []*AdminUserStat `json:"items,omitempty"` +} + +type AdminUserStatListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *AdminUserStatListRespData `json:"data"` +} diff --git a/v2/service/application/v1/api.go b/v2/service/application/v1/api.go new file mode 100644 index 00000000..0f29440d --- /dev/null +++ b/v2/service/application/v1/api.go @@ -0,0 +1,20 @@ +// Package application code generated by lark suite oapi sdk gen +package application + +import ( + "github.com/larksuite/oapi-sdk-go/v2" +) + +type ApplicationService struct { + Application *application +} + +func New(app *lark.App) *ApplicationService { + a := &ApplicationService{} + a.Application = &application{app: app} + return a +} + +type application struct { + app *lark.App +} diff --git a/v2/service/application/v1/event.go b/v2/service/application/v1/event.go new file mode 100644 index 00000000..ce7e8763 --- /dev/null +++ b/v2/service/application/v1/event.go @@ -0,0 +1,71 @@ +// Package application code generated by lark suite oapi sdk gen +package application + +import ( + "context" + "github.com/larksuite/oapi-sdk-go/v2" +) + +type applicationAppOpenEventHandler struct { + handler func(context.Context, *lark.RawRequest, *ApplicationAppOpenEvent) error +} + +func (h *applicationAppOpenEventHandler) Event() interface{} { + return &ApplicationAppOpenEvent{} +} + +func (h *applicationAppOpenEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*ApplicationAppOpenEvent)) +} + +func (a *application) AppOpenEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *ApplicationAppOpenEvent) error) { + a.app.Webhook.EventHandler("app_open", &applicationAppOpenEventHandler{handler: handler}) +} + +type applicationAppStatusChangeEventHandler struct { + handler func(context.Context, *lark.RawRequest, *ApplicationAppStatusChangeEvent) error +} + +func (h *applicationAppStatusChangeEventHandler) Event() interface{} { + return &ApplicationAppStatusChangeEvent{} +} + +func (h *applicationAppStatusChangeEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*ApplicationAppStatusChangeEvent)) +} + +func (a *application) AppStatusChangeEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *ApplicationAppStatusChangeEvent) error) { + a.app.Webhook.EventHandler("app_status_change", &applicationAppStatusChangeEventHandler{handler: handler}) +} + +type applicationAppUninstalledEventHandler struct { + handler func(context.Context, *lark.RawRequest, *ApplicationAppUninstalledEvent) error +} + +func (h *applicationAppUninstalledEventHandler) Event() interface{} { + return &ApplicationAppUninstalledEvent{} +} + +func (h *applicationAppUninstalledEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*ApplicationAppUninstalledEvent)) +} + +func (a *application) AppUninstalledEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *ApplicationAppUninstalledEvent) error) { + a.app.Webhook.EventHandler("app_uninstalled", &applicationAppUninstalledEventHandler{handler: handler}) +} + +type applicationOrderPaidEventHandler struct { + handler func(context.Context, *lark.RawRequest, *ApplicationOrderPaidEvent) error +} + +func (h *applicationOrderPaidEventHandler) Event() interface{} { + return &ApplicationOrderPaidEvent{} +} + +func (h *applicationOrderPaidEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*ApplicationOrderPaidEvent)) +} + +func (a *application) OrderPaidEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *ApplicationOrderPaidEvent) error) { + a.app.Webhook.EventHandler("order_paid", &applicationOrderPaidEventHandler{handler: handler}) +} diff --git a/v2/service/application/v1/model.go b/v2/service/application/v1/model.go new file mode 100644 index 00000000..2ae50aec --- /dev/null +++ b/v2/service/application/v1/model.go @@ -0,0 +1,70 @@ +// Package application code generated by lark suite oapi sdk gen +package application + +import ( + "github.com/larksuite/oapi-sdk-go/v2" +) + +type UserId struct { + OpenId *string `json:"open_id,omitempty"` + UserId *string `json:"user_id,omitempty"` +} + +type ApplicationAppOpenEventData struct { + AppId *string `json:"app_id,omitempty"` + TenantKey *string `json:"tenant_key,omitempty"` + Type *string `json:"type,omitempty"` + Applicants []*UserId `json:"applicants,omitempty"` + Installer *UserId `json:"installer,omitempty"` + InstallerEmployee *UserId `json:"installer_employee,omitempty"` +} + +type ApplicationAppOpenEvent struct { + *lark.EventV2Base + Event *ApplicationAppOpenEventData `json:"event"` +} + +type ApplicationAppStatusChangeEventData struct { + AppId *string `json:"app_id,omitempty"` + TenantKey *string `json:"tenant_key,omitempty"` + Type *string `json:"type,omitempty"` + Status *string `json:"status,omitempty"` + Operator *UserId `json:"operator,omitempty"` +} + +type ApplicationAppStatusChangeEvent struct { + *lark.EventV2Base + Event *ApplicationAppStatusChangeEventData `json:"event"` +} + +type ApplicationAppUninstalledEventData struct { + AppId *string `json:"app_id,omitempty"` + TenantKey *string `json:"tenant_key,omitempty"` + Type *string `json:"type,omitempty"` +} + +type ApplicationAppUninstalledEvent struct { + *lark.EventV2Base + Event *ApplicationAppUninstalledEventData `json:"event"` +} + +type ApplicationOrderPaidEventData struct { + AppId *string `json:"app_id,omitempty"` + TenantKey *string `json:"tenant_key,omitempty"` + Type *string `json:"type,omitempty"` + OrderId *string `json:"order_id,omitempty"` + PricePlanId *string `json:"price_plan_id,omitempty"` + PricePlanType *string `json:"price_plan_type,omitempty"` + Seats *int `json:"seats,omitempty"` + BuyCount *int `json:"buy_count,omitempty"` + CreateTime *string `json:"create_time,omitempty"` + PayTime *string `json:"pay_time,omitempty"` + BuyType *string `json:"buy_type,omitempty"` + SrcOrderId *string `json:"src_order_id,omitempty"` + OrderPayPrice *int `json:"order_pay_price,omitempty"` +} + +type ApplicationOrderPaidEvent struct { + *lark.EventV2Base + Event *ApplicationOrderPaidEventData `json:"event"` +} diff --git a/v2/service/authen/v1/api.go b/v2/service/authen/v1/api.go new file mode 100644 index 00000000..983a0642 --- /dev/null +++ b/v2/service/authen/v1/api.go @@ -0,0 +1,63 @@ +// Package authen code generated by lark suite oapi sdk gen +package authen + +import ( + "context" + "net/http" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type AuthenService struct { + Authen *authen +} + +func New(app *lark.App) *AuthenService { + a := &AuthenService{} + a.Authen = &authen{app: app} + return a +} + +type authen struct { + app *lark.App +} + +func (a *authen) AccessToken(ctx context.Context, req *AuthenAccessTokenReq, options ...lark.RequestOptionFunc) (*AuthenAccessTokenResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/authen/v1/access_token", []lark.AccessTokenType{lark.AccessTokenTypeApp}, req, options...) + if err != nil { + return nil, err + } + resp := &AuthenAccessTokenResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *authen) RefreshAccessToken(ctx context.Context, req *AuthenRefreshAccessTokenReq, options ...lark.RequestOptionFunc) (*AuthenRefreshAccessTokenResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/authen/v1/refresh_access_token", []lark.AccessTokenType{lark.AccessTokenTypeApp}, req, options...) + if err != nil { + return nil, err + } + resp := &AuthenRefreshAccessTokenResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *authen) UserInfo(ctx context.Context, options ...lark.RequestOptionFunc) (*AuthenUserInfoResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/authen/v1/user_info", []lark.AccessTokenType{lark.AccessTokenTypeUser}, nil, options...) + if err != nil { + return nil, err + } + resp := &AuthenUserInfoResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} diff --git a/v2/service/authen/v1/model.go b/v2/service/authen/v1/model.go new file mode 100644 index 00000000..a6f0c64d --- /dev/null +++ b/v2/service/authen/v1/model.go @@ -0,0 +1,77 @@ +// Package authen code generated by lark suite oapi sdk gen +package authen + +import ( + "github.com/larksuite/oapi-sdk-go/v2" +) + +type UserAccessTokenInfo struct { + AccessToken *string `json:"access_token,omitempty"` + TokenType *string `json:"token_type,omitempty"` + ExpiresIn *int `json:"expires_in,omitempty"` + Name *string `json:"name,omitempty"` + EnName *string `json:"en_name,omitempty"` + AvatarUrl *string `json:"avatar_url,omitempty"` + AvatarThumb *string `json:"avatar_thumb,omitempty"` + AvatarMiddle *string `json:"avatar_middle,omitempty"` + AvatarBig *string `json:"avatar_big,omitempty"` + OpenId *string `json:"open_id,omitempty"` + UnionId *string `json:"union_id,omitempty"` + Email *string `json:"email,omitempty"` + UserId *string `json:"user_id,omitempty"` + Mobile *string `json:"mobile,omitempty"` + TenantKey *string `json:"tenant_key,omitempty"` + RefreshExpiresIn *int `json:"refresh_expires_in,omitempty"` + RefreshToken *string `json:"refresh_token,omitempty"` +} + +type UserInfo struct { + Name *string `json:"name,omitempty"` + EnName *string `json:"en_name,omitempty"` + AvatarUrl *string `json:"avatar_url,omitempty"` + AvatarThumb *string `json:"avatar_thumb,omitempty"` + AvatarMiddle *string `json:"avatar_middle,omitempty"` + AvatarBig *string `json:"avatar_big,omitempty"` + OpenId *string `json:"open_id,omitempty"` + UnionId *string `json:"union_id,omitempty"` + Email *string `json:"email,omitempty"` + UserId *string `json:"user_id,omitempty"` + Mobile *string `json:"mobile,omitempty"` + TenantKey *string `json:"tenant_key,omitempty"` +} + +type AuthenAccessTokenReqBody struct { + GrantType *string `json:"grant_type,omitempty"` + Code *string `json:"code,omitempty"` +} + +type AuthenAccessTokenReq struct { + Body *AuthenAccessTokenReqBody `body:""` +} + +type AuthenAccessTokenResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *UserAccessTokenInfo `json:"data"` +} + +type AuthenRefreshAccessTokenReqBody struct { + GrantType *string `json:"grant_type,omitempty"` + RefreshToken *string `json:"refresh_token,omitempty"` +} + +type AuthenRefreshAccessTokenReq struct { + Body *AuthenRefreshAccessTokenReqBody `body:""` +} + +type AuthenRefreshAccessTokenResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *UserAccessTokenInfo `json:"data"` +} + +type AuthenUserInfoResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *UserInfo `json:"data"` +} diff --git a/v2/service/bitable/v1/api.go b/v2/service/bitable/v1/api.go new file mode 100644 index 00000000..28f598e0 --- /dev/null +++ b/v2/service/bitable/v1/api.go @@ -0,0 +1,317 @@ +// Package bitable code generated by lark suite oapi sdk gen +package bitable + +import ( + "context" + "net/http" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type BitableService struct { + Apps *apps + AppTables *appTables + AppTableFields *appTableFields + AppTableRecords *appTableRecords + AppTableViews *appTableViews +} + +func New(app *lark.App) *BitableService { + b := &BitableService{} + b.Apps = &apps{app: app} + b.AppTables = &appTables{app: app} + b.AppTableFields = &appTableFields{app: app} + b.AppTableRecords = &appTableRecords{app: app} + b.AppTableViews = &appTableViews{app: app} + return b +} + +type apps struct { + app *lark.App +} +type appTables struct { + app *lark.App +} +type appTableFields struct { + app *lark.App +} +type appTableRecords struct { + app *lark.App +} +type appTableViews struct { + app *lark.App +} + +func (a *apps) Get(ctx context.Context, req *AppGetReq, options ...lark.RequestOptionFunc) (*AppGetResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/bitable/v1/apps/:app_token", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *appTables) List(ctx context.Context, req *AppTableListReq, options ...lark.RequestOptionFunc) (*AppTableListResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/bitable/v1/apps/:app_token/tables", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppTableListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *appTables) BatchCreate(ctx context.Context, req *AppTableBatchCreateReq, options ...lark.RequestOptionFunc) (*AppTableBatchCreateResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/bitable/v1/apps/:app_token/tables/batch_create", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppTableBatchCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *appTables) Create(ctx context.Context, req *AppTableCreateReq, options ...lark.RequestOptionFunc) (*AppTableCreateResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/bitable/v1/apps/:app_token/tables", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppTableCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *appTables) Delete(ctx context.Context, req *AppTableDeleteReq, options ...lark.RequestOptionFunc) (*AppTableDeleteResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/bitable/v1/apps/:app_token/tables/:table_id", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppTableDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *appTables) BatchDelete(ctx context.Context, req *AppTableBatchDeleteReq, options ...lark.RequestOptionFunc) (*AppTableBatchDeleteResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/bitable/v1/apps/:app_token/tables/batch_delete", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppTableBatchDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *appTableFields) List(ctx context.Context, req *AppTableFieldListReq, options ...lark.RequestOptionFunc) (*AppTableFieldListResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/bitable/v1/apps/:app_token/tables/:table_id/fields", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppTableFieldListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *appTableFields) Create(ctx context.Context, req *AppTableFieldCreateReq, options ...lark.RequestOptionFunc) (*AppTableFieldCreateResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/bitable/v1/apps/:app_token/tables/:table_id/fields", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppTableFieldCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *appTableFields) Delete(ctx context.Context, req *AppTableFieldDeleteReq, options ...lark.RequestOptionFunc) (*AppTableFieldDeleteResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/bitable/v1/apps/:app_token/tables/:table_id/fields/:field_id", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppTableFieldDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *appTableFields) Update(ctx context.Context, req *AppTableFieldUpdateReq, options ...lark.RequestOptionFunc) (*AppTableFieldUpdateResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPut, + "/open-apis/bitable/v1/apps/:app_token/tables/:table_id/fields/:field_id", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppTableFieldUpdateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *appTableRecords) BatchDelete(ctx context.Context, req *AppTableRecordBatchDeleteReq, options ...lark.RequestOptionFunc) (*AppTableRecordBatchDeleteResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records/batch_delete", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppTableRecordBatchDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *appTableRecords) BatchCreate(ctx context.Context, req *AppTableRecordBatchCreateReq, options ...lark.RequestOptionFunc) (*AppTableRecordBatchCreateResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records/batch_create", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppTableRecordBatchCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *appTableRecords) Get(ctx context.Context, req *AppTableRecordGetReq, options ...lark.RequestOptionFunc) (*AppTableRecordGetResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records/:record_id", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppTableRecordGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *appTableRecords) Update(ctx context.Context, req *AppTableRecordUpdateReq, options ...lark.RequestOptionFunc) (*AppTableRecordUpdateResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPut, + "/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records/:record_id", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppTableRecordUpdateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *appTableRecords) Delete(ctx context.Context, req *AppTableRecordDeleteReq, options ...lark.RequestOptionFunc) (*AppTableRecordDeleteResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records/:record_id", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppTableRecordDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *appTableRecords) List(ctx context.Context, req *AppTableRecordListReq, options ...lark.RequestOptionFunc) (*AppTableRecordListResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppTableRecordListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *appTableRecords) BatchUpdate(ctx context.Context, req *AppTableRecordBatchUpdateReq, options ...lark.RequestOptionFunc) (*AppTableRecordBatchUpdateResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records/batch_update", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppTableRecordBatchUpdateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *appTableRecords) Create(ctx context.Context, req *AppTableRecordCreateReq, options ...lark.RequestOptionFunc) (*AppTableRecordCreateResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/bitable/v1/apps/:app_token/tables/:table_id/records", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppTableRecordCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *appTableViews) Create(ctx context.Context, req *AppTableViewCreateReq, options ...lark.RequestOptionFunc) (*AppTableViewCreateResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/bitable/v1/apps/:app_token/tables/:table_id/views", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppTableViewCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *appTableViews) Delete(ctx context.Context, req *AppTableViewDeleteReq, options ...lark.RequestOptionFunc) (*AppTableViewDeleteResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/bitable/v1/apps/:app_token/tables/:table_id/views/:view_id", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppTableViewDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (a *appTableViews) List(ctx context.Context, req *AppTableViewListReq, options ...lark.RequestOptionFunc) (*AppTableViewListResp, error) { + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/bitable/v1/apps/:app_token/tables/:table_id/views", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AppTableViewListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} diff --git a/v2/service/bitable/v1/model.go b/v2/service/bitable/v1/model.go new file mode 100644 index 00000000..b8bbfc0c --- /dev/null +++ b/v2/service/bitable/v1/model.go @@ -0,0 +1,450 @@ +// Package bitable code generated by lark suite oapi sdk gen +package bitable + +import ( + "github.com/larksuite/oapi-sdk-go/v2" +) + +type AppTable struct { + TableId *string `json:"table_id,omitempty"` + Revision *int `json:"revision,omitempty"` + Name *string `json:"name,omitempty"` +} + +type DeleteRecord struct { + Deleted *bool `json:"deleted,omitempty"` + RecordId *string `json:"record_id,omitempty"` +} + +type Person struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + EnName *string `json:"en_name,omitempty"` + Email *string `json:"email,omitempty"` +} + +type App struct { + AppToken *string `json:"app_token,omitempty"` + Name *string `json:"name,omitempty"` + Revision *int `json:"revision,omitempty"` +} + +type AppTableField struct { + FieldId *string `json:"field_id,omitempty"` + FieldName *string `json:"field_name,omitempty"` + Type *int `json:"type,omitempty"` + Property *AppTableFieldProperty `json:"property,omitempty"` +} + +type AppTableFieldProperty struct { + Options []*AppTableFieldPropertyOption `json:"options,omitempty"` + Formatter *string `json:"formatter,omitempty"` + DateFormat *string `json:"date_format,omitempty"` + TimeFormat *string `json:"time_format,omitempty"` + AutoFill *bool `json:"auto_fill,omitempty"` + Multiple *bool `json:"multiple,omitempty"` + TableId *string `json:"table_id,omitempty"` + ViewId *string `json:"view_id,omitempty"` + Fields []string `json:"fields,omitempty"` +} + +type AppTableFieldPropertyOption struct { + Name *string `json:"name,omitempty"` + Id *string `json:"id,omitempty"` +} + +type AppTableRecord struct { + RecordId *string `json:"record_id,omitempty"` + Fields map[string]interface{} `json:"fields,omitempty"` +} + +type AppTableView struct { + ViewId *string `json:"view_id,omitempty"` + ViewName *string `json:"view_name,omitempty"` + ViewType *string `json:"view_type,omitempty"` +} + +type Attachment struct { + FileToken *string `json:"file_token,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Size *int `json:"size,omitempty"` + Url *string `json:"url,omitempty"` + TmpUrl *string `json:"tmp_url,omitempty"` +} + +type ReqTable struct { + Name *string `json:"name,omitempty"` +} + +type Url struct { + Text *string `json:"text,omitempty"` + Link *string `json:"link,omitempty"` +} + +type AppGetReq struct { + AppToken string `path:"app_token"` +} + +type AppGetRespData struct { + App *App `json:"app,omitempty"` +} + +type AppGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *AppGetRespData `json:"data"` +} + +type AppTableListReq struct { + AppToken string `path:"app_token"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type AppTableListRespData struct { + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` + Total *int `json:"total,omitempty"` + Items []*AppTable `json:"items,omitempty"` +} + +type AppTableListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *AppTableListRespData `json:"data"` +} + +type AppTableBatchCreateReqBody struct { + Tables []*ReqTable `json:"tables,omitempty"` +} + +type AppTableBatchCreateReq struct { + AppToken string `path:"app_token"` + UserIdType *string `query:"user_id_type"` + Body *AppTableBatchCreateReqBody `body:""` +} + +type AppTableBatchCreateRespData struct { + TableIds []string `json:"table_ids,omitempty"` +} + +type AppTableBatchCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *AppTableBatchCreateRespData `json:"data"` +} + +type AppTableCreateReqBody struct { + Table *ReqTable `json:"table,omitempty"` +} + +type AppTableCreateReq struct { + AppToken string `path:"app_token"` + UserIdType *string `query:"user_id_type"` + Body *AppTableCreateReqBody `body:""` +} + +type AppTableCreateRespData struct { + TableId *string `json:"table_id,omitempty"` +} + +type AppTableCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *AppTableCreateRespData `json:"data"` +} + +type AppTableDeleteReq struct { + AppToken string `path:"app_token"` + TableId string `path:"table_id"` +} + +type AppTableDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type AppTableBatchDeleteReqBody struct { + TableIds []string `json:"table_ids,omitempty"` +} + +type AppTableBatchDeleteReq struct { + AppToken string `path:"app_token"` + Body *AppTableBatchDeleteReqBody `body:""` +} + +type AppTableBatchDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type AppTableFieldListReq struct { + AppToken string `path:"app_token"` + TableId string `path:"table_id"` + ViewId *string `query:"view_id"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type AppTableFieldListRespData struct { + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` + Total *int `json:"total,omitempty"` + Items []*AppTableField `json:"items,omitempty"` +} + +type AppTableFieldListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *AppTableFieldListRespData `json:"data"` +} + +type AppTableFieldCreateReq struct { + AppToken string `path:"app_token"` + TableId string `path:"table_id"` + UserIdType *string `query:"user_id_type"` + AppTableField *AppTableField `body:""` +} + +type AppTableFieldCreateRespData struct { + Field *AppTableField `json:"field,omitempty"` +} + +type AppTableFieldCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *AppTableFieldCreateRespData `json:"data"` +} + +type AppTableFieldDeleteReq struct { + AppToken string `path:"app_token"` + TableId string `path:"table_id"` + FieldId string `path:"field_id"` +} + +type AppTableFieldDeleteRespData struct { + FieldId *string `json:"field_id,omitempty"` + Deleted *bool `json:"deleted,omitempty"` +} + +type AppTableFieldDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *AppTableFieldDeleteRespData `json:"data"` +} + +type AppTableFieldUpdateReq struct { + AppToken string `path:"app_token"` + TableId string `path:"table_id"` + FieldId string `path:"field_id"` + AppTableField *AppTableField `body:""` +} + +type AppTableFieldUpdateRespData struct { + Field *AppTableField `json:"field,omitempty"` +} + +type AppTableFieldUpdateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *AppTableFieldUpdateRespData `json:"data"` +} + +type AppTableRecordBatchDeleteReqBody struct { + Records []string `json:"records,omitempty"` +} + +type AppTableRecordBatchDeleteReq struct { + AppToken string `path:"app_token"` + TableId string `path:"table_id"` + Body *AppTableRecordBatchDeleteReqBody `body:""` +} + +type AppTableRecordBatchDeleteRespData struct { + Records []*DeleteRecord `json:"records,omitempty"` +} + +type AppTableRecordBatchDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *AppTableRecordBatchDeleteRespData `json:"data"` +} + +type AppTableRecordBatchCreateReqBody struct { + Records []*AppTableRecord `json:"records,omitempty"` +} + +type AppTableRecordBatchCreateReq struct { + AppToken string `path:"app_token"` + TableId string `path:"table_id"` + UserIdType *string `query:"user_id_type"` + Body *AppTableRecordBatchCreateReqBody `body:""` +} + +type AppTableRecordBatchCreateRespData struct { + Records []*AppTableRecord `json:"records,omitempty"` +} + +type AppTableRecordBatchCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *AppTableRecordBatchCreateRespData `json:"data"` +} + +type AppTableRecordGetReq struct { + AppToken string `path:"app_token"` + TableId string `path:"table_id"` + RecordId string `path:"record_id"` + UserIdType *string `query:"user_id_type"` +} + +type AppTableRecordGetRespData struct { + Record *AppTableRecord `json:"record,omitempty"` +} + +type AppTableRecordGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *AppTableRecordGetRespData `json:"data"` +} + +type AppTableRecordUpdateReq struct { + AppToken string `path:"app_token"` + TableId string `path:"table_id"` + RecordId string `path:"record_id"` + UserIdType *string `query:"user_id_type"` + AppTableRecord *AppTableRecord `body:""` +} + +type AppTableRecordUpdateRespData struct { + Record *AppTableRecord `json:"record,omitempty"` +} + +type AppTableRecordUpdateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *AppTableRecordUpdateRespData `json:"data"` +} + +type AppTableRecordDeleteReq struct { + AppToken string `path:"app_token"` + TableId string `path:"table_id"` + RecordId string `path:"record_id"` +} + +type AppTableRecordDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *DeleteRecord `json:"data"` +} + +type AppTableRecordListReq struct { + AppToken string `path:"app_token"` + TableId string `path:"table_id"` + ViewId *string `query:"view_id"` + Filter *string `query:"filter"` + Sort *string `query:"sort"` + FieldNames *string `query:"field_names"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` + UserIdType *string `query:"user_id_type"` +} + +type AppTableRecordListRespData struct { + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` + Total *int `json:"total,omitempty"` + Items []*AppTableRecord `json:"items,omitempty"` +} + +type AppTableRecordListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *AppTableRecordListRespData `json:"data"` +} + +type AppTableRecordBatchUpdateReqBody struct { + Records []*AppTableRecord `json:"records,omitempty"` +} + +type AppTableRecordBatchUpdateReq struct { + AppToken string `path:"app_token"` + TableId string `path:"table_id"` + UserIdType *string `query:"user_id_type"` + Body *AppTableRecordBatchUpdateReqBody `body:""` +} + +type AppTableRecordBatchUpdateRespData struct { + Records []*AppTableRecord `json:"records,omitempty"` +} + +type AppTableRecordBatchUpdateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *AppTableRecordBatchUpdateRespData `json:"data"` +} + +type AppTableRecordCreateReq struct { + AppToken string `path:"app_token"` + TableId string `path:"table_id"` + UserIdType *string `query:"user_id_type"` + AppTableRecord *AppTableRecord `body:""` +} + +type AppTableRecordCreateRespData struct { + Record *AppTableRecord `json:"record,omitempty"` +} + +type AppTableRecordCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *AppTableRecordCreateRespData `json:"data"` +} + +type AppTableViewCreateReq struct { + AppToken string `path:"app_token"` + TableId string `path:"table_id"` + AppTableView *AppTableView `body:""` +} + +type AppTableViewCreateRespData struct { + AppTableView *AppTableView `json:"app.table.view,omitempty"` +} + +type AppTableViewCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *AppTableViewCreateRespData `json:"data"` +} + +type AppTableViewDeleteReq struct { + AppToken string `path:"app_token"` + TableId string `path:"table_id"` + ViewId string `path:"view_id"` +} + +type AppTableViewDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type AppTableViewListReq struct { + AppToken string `path:"app_token"` + TableId string `path:"table_id"` + PageSize *int `query:"page_size"` + PageToken *string `query:"page_token"` +} + +type AppTableViewListRespData struct { + Items []*AppTableView `json:"items,omitempty"` + PageToken *string `json:"page_token,omitempty"` + HasMore *bool `json:"has_more,omitempty"` + Total *int `json:"total,omitempty"` +} + +type AppTableViewListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *AppTableViewListRespData `json:"data"` +} diff --git a/v2/service/calendar/v4/api.go b/v2/service/calendar/v4/api.go new file mode 100644 index 00000000..ddccdb78 --- /dev/null +++ b/v2/service/calendar/v4/api.go @@ -0,0 +1,423 @@ +// Package calendar code generated by lark suite oapi sdk gen +package calendar + +import ( + "context" + "net/http" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type CalendarService struct { + Calendars *calendars + CalendarAcls *calendarAcls + CalendarEvents *calendarEvents + CalendarEventAttendees *calendarEventAttendees + CalendarEventAttendeeChatMembers *calendarEventAttendeeChatMembers + Freebusy *freebusy + Settings *settings + TimeoffEvents *timeoffEvents +} + +func New(app *lark.App) *CalendarService { + c := &CalendarService{} + c.Calendars = &calendars{app: app} + c.CalendarAcls = &calendarAcls{app: app} + c.CalendarEvents = &calendarEvents{app: app} + c.CalendarEventAttendees = &calendarEventAttendees{app: app} + c.CalendarEventAttendeeChatMembers = &calendarEventAttendeeChatMembers{app: app} + c.Freebusy = &freebusy{app: app} + c.Settings = &settings{app: app} + c.TimeoffEvents = &timeoffEvents{app: app} + return c +} + +type calendars struct { + app *lark.App +} +type calendarAcls struct { + app *lark.App +} +type calendarEvents struct { + app *lark.App +} +type calendarEventAttendees struct { + app *lark.App +} +type calendarEventAttendeeChatMembers struct { + app *lark.App +} +type freebusy struct { + app *lark.App +} +type settings struct { + app *lark.App +} +type timeoffEvents struct { + app *lark.App +} + +func (c *calendars) Create(ctx context.Context, req *CalendarCreateReq, options ...lark.RequestOptionFunc) (*CalendarCreateResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/calendar/v4/calendars", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendars) Patch(ctx context.Context, req *CalendarPatchReq, options ...lark.RequestOptionFunc) (*CalendarPatchResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPatch, + "/open-apis/calendar/v4/calendars/:calendar_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarPatchResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendars) Delete(ctx context.Context, req *CalendarDeleteReq, options ...lark.RequestOptionFunc) (*CalendarDeleteResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/calendar/v4/calendars/:calendar_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendars) List(ctx context.Context, req *CalendarListReq, options ...lark.RequestOptionFunc) (*CalendarListResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/calendar/v4/calendars", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendars) Get(ctx context.Context, req *CalendarGetReq, options ...lark.RequestOptionFunc) (*CalendarGetResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/calendar/v4/calendars/:calendar_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendars) Search(ctx context.Context, req *CalendarSearchReq, options ...lark.RequestOptionFunc) (*CalendarSearchResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/calendar/v4/calendars/search", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarSearchResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendars) Unsubscribe(ctx context.Context, req *CalendarUnsubscribeReq, options ...lark.RequestOptionFunc) (*CalendarUnsubscribeResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/calendar/v4/calendars/:calendar_id/unsubscribe", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarUnsubscribeResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendars) Subscribe(ctx context.Context, req *CalendarSubscribeReq, options ...lark.RequestOptionFunc) (*CalendarSubscribeResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/calendar/v4/calendars/:calendar_id/subscribe", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarSubscribeResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendars) Subscription(ctx context.Context, options ...lark.RequestOptionFunc) (*CalendarSubscriptionResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/calendar/v4/calendars/subscription", []lark.AccessTokenType{lark.AccessTokenTypeUser}, nil, options...) + if err != nil { + return nil, err + } + resp := &CalendarSubscriptionResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendarAcls) List(ctx context.Context, req *CalendarAclListReq, options ...lark.RequestOptionFunc) (*CalendarAclListResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/calendar/v4/calendars/:calendar_id/acls", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarAclListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendarAcls) Delete(ctx context.Context, req *CalendarAclDeleteReq, options ...lark.RequestOptionFunc) (*CalendarAclDeleteResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/calendar/v4/calendars/:calendar_id/acls/:acl_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarAclDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendarAcls) Create(ctx context.Context, req *CalendarAclCreateReq, options ...lark.RequestOptionFunc) (*CalendarAclCreateResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/calendar/v4/calendars/:calendar_id/acls", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarAclCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendarAcls) Subscription(ctx context.Context, req *CalendarAclSubscriptionReq, options ...lark.RequestOptionFunc) (*CalendarAclSubscriptionResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/calendar/v4/calendars/:calendar_id/acls/subscription", []lark.AccessTokenType{lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarAclSubscriptionResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendarEvents) Delete(ctx context.Context, req *CalendarEventDeleteReq, options ...lark.RequestOptionFunc) (*CalendarEventDeleteResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/calendar/v4/calendars/:calendar_id/events/:event_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarEventDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendarEvents) Get(ctx context.Context, req *CalendarEventGetReq, options ...lark.RequestOptionFunc) (*CalendarEventGetResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/calendar/v4/calendars/:calendar_id/events/:event_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarEventGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendarEvents) Create(ctx context.Context, req *CalendarEventCreateReq, options ...lark.RequestOptionFunc) (*CalendarEventCreateResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/calendar/v4/calendars/:calendar_id/events", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarEventCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendarEvents) List(ctx context.Context, req *CalendarEventListReq, options ...lark.RequestOptionFunc) (*CalendarEventListResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/calendar/v4/calendars/:calendar_id/events", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarEventListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendarEvents) Patch(ctx context.Context, req *CalendarEventPatchReq, options ...lark.RequestOptionFunc) (*CalendarEventPatchResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPatch, + "/open-apis/calendar/v4/calendars/:calendar_id/events/:event_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarEventPatchResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendarEvents) Search(ctx context.Context, req *CalendarEventSearchReq, options ...lark.RequestOptionFunc) (*CalendarEventSearchResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/calendar/v4/calendars/:calendar_id/events/search", []lark.AccessTokenType{lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarEventSearchResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendarEvents) Subscription(ctx context.Context, req *CalendarEventSubscriptionReq, options ...lark.RequestOptionFunc) (*CalendarEventSubscriptionResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/calendar/v4/calendars/:calendar_id/events/subscription", []lark.AccessTokenType{lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarEventSubscriptionResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendarEventAttendees) List(ctx context.Context, req *CalendarEventAttendeeListReq, options ...lark.RequestOptionFunc) (*CalendarEventAttendeeListResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/calendar/v4/calendars/:calendar_id/events/:event_id/attendees", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarEventAttendeeListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendarEventAttendees) BatchDelete(ctx context.Context, req *CalendarEventAttendeeBatchDeleteReq, options ...lark.RequestOptionFunc) (*CalendarEventAttendeeBatchDeleteResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/calendar/v4/calendars/:calendar_id/events/:event_id/attendees/batch_delete", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarEventAttendeeBatchDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendarEventAttendees) Create(ctx context.Context, req *CalendarEventAttendeeCreateReq, options ...lark.RequestOptionFunc) (*CalendarEventAttendeeCreateResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/calendar/v4/calendars/:calendar_id/events/:event_id/attendees", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarEventAttendeeCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *calendarEventAttendeeChatMembers) List(ctx context.Context, req *CalendarEventAttendeeChatMemberListReq, options ...lark.RequestOptionFunc) (*CalendarEventAttendeeChatMemberListResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/calendar/v4/calendars/:calendar_id/events/:event_id/attendees/:attendee_id/chat_members", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &CalendarEventAttendeeChatMemberListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (f *freebusy) List(ctx context.Context, req *FreebusyListReq, options ...lark.RequestOptionFunc) (*FreebusyListResp, error) { + rawResp, err := f.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/calendar/v4/freebusy/list", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &FreebusyListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (s *settings) GenerateCaldavConf(ctx context.Context, req *SettingGenerateCaldavConfReq, options ...lark.RequestOptionFunc) (*SettingGenerateCaldavConfResp, error) { + rawResp, err := s.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/calendar/v4/settings/generate_caldav_conf", []lark.AccessTokenType{lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &SettingGenerateCaldavConfResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (t *timeoffEvents) Delete(ctx context.Context, req *TimeoffEventDeleteReq, options ...lark.RequestOptionFunc) (*TimeoffEventDeleteResp, error) { + rawResp, err := t.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/calendar/v4/timeoff_events/:timeoff_event_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TimeoffEventDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (t *timeoffEvents) Create(ctx context.Context, req *TimeoffEventCreateReq, options ...lark.RequestOptionFunc) (*TimeoffEventCreateResp, error) { + rawResp, err := t.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/calendar/v4/timeoff_events", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TimeoffEventCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} diff --git a/v2/service/calendar/v4/event.go b/v2/service/calendar/v4/event.go new file mode 100644 index 00000000..23ef03eb --- /dev/null +++ b/v2/service/calendar/v4/event.go @@ -0,0 +1,71 @@ +// Package calendar code generated by lark suite oapi sdk gen +package calendar + +import ( + "context" + "github.com/larksuite/oapi-sdk-go/v2" +) + +type calendarChangedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *CalendarChangedEvent) error +} + +func (h *calendarChangedEventHandler) Event() interface{} { + return &CalendarChangedEvent{} +} + +func (h *calendarChangedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*CalendarChangedEvent)) +} + +func (c *calendars) ChangedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *CalendarChangedEvent) error) { + c.app.Webhook.EventHandler("changed", &calendarChangedEventHandler{handler: handler}) +} + +type calendarAclCreatedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *CalendarAclCreatedEvent) error +} + +func (h *calendarAclCreatedEventHandler) Event() interface{} { + return &CalendarAclCreatedEvent{} +} + +func (h *calendarAclCreatedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*CalendarAclCreatedEvent)) +} + +func (c *calendarAcls) CreatedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *CalendarAclCreatedEvent) error) { + c.app.Webhook.EventHandler("created", &calendarAclCreatedEventHandler{handler: handler}) +} + +type calendarAclDeletedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *CalendarAclDeletedEvent) error +} + +func (h *calendarAclDeletedEventHandler) Event() interface{} { + return &CalendarAclDeletedEvent{} +} + +func (h *calendarAclDeletedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*CalendarAclDeletedEvent)) +} + +func (c *calendarAcls) DeletedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *CalendarAclDeletedEvent) error) { + c.app.Webhook.EventHandler("deleted", &calendarAclDeletedEventHandler{handler: handler}) +} + +type calendarEventChangedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *CalendarEventChangedEvent) error +} + +func (h *calendarEventChangedEventHandler) Event() interface{} { + return &CalendarEventChangedEvent{} +} + +func (h *calendarEventChangedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*CalendarEventChangedEvent)) +} + +func (c *calendarEvents) ChangedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *CalendarEventChangedEvent) error) { + c.app.Webhook.EventHandler("changed", &calendarEventChangedEventHandler{handler: handler}) +} diff --git a/v2/service/calendar/v4/model.go b/v2/service/calendar/v4/model.go new file mode 100644 index 00000000..03c10cf9 --- /dev/null +++ b/v2/service/calendar/v4/model.go @@ -0,0 +1,637 @@ +// Package calendar code generated by lark suite oapi sdk gen +package calendar + +import ( + "github.com/larksuite/oapi-sdk-go/v2" +) + +type UserId struct { + UserId *string `json:"user_id,omitempty"` + OpenId *string `json:"open_id,omitempty"` + UnionId *string `json:"union_id,omitempty"` +} + +type AclScope struct { + Type *string `json:"type,omitempty"` + UserId *string `json:"user_id,omitempty"` +} + +type AttendeeChatMember struct { + RsvpStatus *string `json:"rsvp_status,omitempty"` + IsOptional *bool `json:"is_optional,omitempty"` + DisplayName *string `json:"display_name,omitempty"` + IsOrganizer *bool `json:"is_organizer,omitempty"` + IsExternal *bool `json:"is_external,omitempty"` +} + +type Calendar struct { + CalendarId *string `json:"calendar_id,omitempty"` + Summary *string `json:"summary,omitempty"` + Description *string `json:"description,omitempty"` + Permissions *string `json:"permissions,omitempty"` + Color *int `json:"color,omitempty"` + Type *string `json:"type,omitempty"` + SummaryAlias *string `json:"summary_alias,omitempty"` + IsDeleted *bool `json:"is_deleted,omitempty"` + IsThirdParty *bool `json:"is_third_party,omitempty"` + Role *string `json:"role,omitempty"` +} + +type CalendarAcl struct { + AclId *string `json:"acl_id,omitempty"` + Role *string `json:"role,omitempty"` + Scope *AclScope `json:"scope,omitempty"` +} + +type CalendarEventAttendeeChatMember struct { + RsvpStatus *string `json:"rsvp_status,omitempty"` + IsOptional *bool `json:"is_optional,omitempty"` + DisplayName *string `json:"display_name,omitempty"` + IsOrganizer *bool `json:"is_organizer,omitempty"` + IsExternal *bool `json:"is_external,omitempty"` +} + +type EventLocation struct { + Name *string `json:"name,omitempty"` + Address *string `json:"address,omitempty"` + Latitude *float64 `json:"latitude,omitempty"` + Longitude *float64 `json:"longitude,omitempty"` +} + +type EventSearchFilter struct { + StartTime *TimeInfo `json:"start_time,omitempty"` + EndTime *TimeInfo `json:"end_time,omitempty"` + UserIds []string `json:"user_ids,omitempty"` + RoomIds []string `json:"room_ids,omitempty"` + ChatIds []string `json:"chat_ids,omitempty"` +} + +type Freebusy struct { + StartTime *string `json:"start_time,omitempty"` + EndTime *string `json:"end_time,omitempty"` +} + +type Reminder struct { + Minutes *int `json:"minutes,omitempty"` +} + +type Schema struct { + UiName *string `json:"ui_name,omitempty"` + UiStatus *string `json:"ui_status,omitempty"` + AppLink *string `json:"app_link,omitempty"` +} + +type TimeInfo struct { + Date *string `json:"date,omitempty"` + Timestamp *string `json:"timestamp,omitempty"` + Timezone *string `json:"timezone,omitempty"` +} + +type TimeoffEvent struct { + TimeoffEventId *string `json:"timeoff_event_id,omitempty"` + UserId *string `json:"user_id,omitempty"` + Timezone *string `json:"timezone,omitempty"` + StartTime *string `json:"start_time,omitempty"` + EndTime *string `json:"end_time,omitempty"` + Title *string `json:"title,omitempty"` + Description *string `json:"description,omitempty"` +} + +type AclScopeEvent struct { + Type *string `json:"type,omitempty"` + UserId *UserId `json:"user_id,omitempty"` +} + +type CalendarAclEvent struct { + AclId *string `json:"acl_id,omitempty"` + Role *string `json:"role,omitempty"` + Scope *AclScopeEvent `json:"scope,omitempty"` + UserIdList []*UserId `json:"user_id_list,omitempty"` +} + +type CalendarAttendeeResourceCustomization struct { + IndexKey *string `json:"index_key,omitempty"` + InputContent *string `json:"input_content,omitempty"` + Options []*CustomizationOption `json:"options,omitempty"` +} + +type CalendarEvent struct { + EventId *string `json:"event_id,omitempty"` + Summary *string `json:"summary,omitempty"` + Description *string `json:"description,omitempty"` + NeedNotification *bool `json:"need_notification,omitempty"` + StartTime *TimeInfo `json:"start_time,omitempty"` + EndTime *TimeInfo `json:"end_time,omitempty"` + Vchat *Vchat `json:"vchat,omitempty"` + Visibility *string `json:"visibility,omitempty"` + AttendeeAbility *string `json:"attendee_ability,omitempty"` + FreeBusyStatus *string `json:"free_busy_status,omitempty"` + Location *EventLocation `json:"location,omitempty"` + Color *int `json:"color,omitempty"` + Reminders []*Reminder `json:"reminders,omitempty"` + Recurrence *string `json:"recurrence,omitempty"` + Status *string `json:"status,omitempty"` + IsException *bool `json:"is_exception,omitempty"` + RecurringEventId *string `json:"recurring_event_id,omitempty"` + Schemas []*Schema `json:"schemas,omitempty"` +} + +type CalendarEventAttendee struct { + Type *string `json:"type,omitempty"` + AttendeeId *string `json:"attendee_id,omitempty"` + RsvpStatus *string `json:"rsvp_status,omitempty"` + IsOptional *bool `json:"is_optional,omitempty"` + IsOrganizer *bool `json:"is_organizer,omitempty"` + IsExternal *bool `json:"is_external,omitempty"` + DisplayName *string `json:"display_name,omitempty"` + ChatMembers []*AttendeeChatMember `json:"chat_members,omitempty"` + UserId *string `json:"user_id,omitempty"` + ChatId *string `json:"chat_id,omitempty"` + RoomId *string `json:"room_id,omitempty"` + ThirdPartyEmail *string `json:"third_party_email,omitempty"` + OperateId *string `json:"operate_id,omitempty"` + ResourceCustomization []*CalendarAttendeeResourceCustomization `json:"resource_customization,omitempty"` +} + +type CustomizationOption struct { + OptionKey *string `json:"option_key,omitempty"` + OthersContent *string `json:"others_content,omitempty"` +} + +type ExchangeBinding struct { + AdminAccount *string `json:"admin_account,omitempty"` + ExchangeAccount *string `json:"exchange_account,omitempty"` + UserId *string `json:"user_id,omitempty"` + Status *string `json:"status,omitempty"` + ExchangeBindingId *string `json:"exchange_binding_id,omitempty"` +} + +type Vchat struct { + VcType *string `json:"vc_type,omitempty"` + IconType *string `json:"icon_type,omitempty"` + Description *string `json:"description,omitempty"` + MeetingUrl *string `json:"meeting_url,omitempty"` +} + +type CalendarCreateReq struct { + Calendar *Calendar `body:""` +} + +type CalendarCreateRespData struct { + Calendar *Calendar `json:"calendar,omitempty"` +} + +type CalendarCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *CalendarCreateRespData `json:"data"` +} + +type CalendarPatchReq struct { + CalendarId string `path:"calendar_id"` + Calendar *Calendar `body:""` +} + +type CalendarPatchRespData struct { + Calendar *Calendar `json:"calendar,omitempty"` +} + +type CalendarPatchResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *CalendarPatchRespData `json:"data"` +} + +type CalendarDeleteReq struct { + CalendarId string `path:"calendar_id"` +} + +type CalendarDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type CalendarListReq struct { + PageSize *int `query:"page_size"` + PageToken *string `query:"page_token"` + SyncToken *string `query:"sync_token"` +} + +type CalendarListRespData struct { + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` + SyncToken *string `json:"sync_token,omitempty"` + CalendarList []*Calendar `json:"calendar_list,omitempty"` +} + +type CalendarListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *CalendarListRespData `json:"data"` +} + +type CalendarGetReq struct { + CalendarId string `path:"calendar_id"` +} + +type CalendarGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *Calendar `json:"data"` +} + +type CalendarSearchReqBody struct { + Query *string `json:"query,omitempty"` +} + +type CalendarSearchReq struct { + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` + Body *CalendarSearchReqBody `body:""` +} + +type CalendarSearchRespData struct { + Items []*Calendar `json:"items,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type CalendarSearchResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *CalendarSearchRespData `json:"data"` +} + +type CalendarUnsubscribeReq struct { + CalendarId string `path:"calendar_id"` +} + +type CalendarUnsubscribeResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type CalendarSubscribeReq struct { + CalendarId string `path:"calendar_id"` +} + +type CalendarSubscribeRespData struct { + Calendar *Calendar `json:"calendar,omitempty"` +} + +type CalendarSubscribeResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *CalendarSubscribeRespData `json:"data"` +} + +type CalendarSubscriptionResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type CalendarAclListReq struct { + CalendarId string `path:"calendar_id"` + UserIdType *string `query:"user_id_type"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type CalendarAclListRespData struct { + Acls []*CalendarAcl `json:"acls,omitempty"` + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type CalendarAclListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *CalendarAclListRespData `json:"data"` +} + +type CalendarAclDeleteReq struct { + CalendarId string `path:"calendar_id"` + AclId string `path:"acl_id"` +} + +type CalendarAclDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type CalendarAclCreateReq struct { + CalendarId string `path:"calendar_id"` + UserIdType *string `query:"user_id_type"` + CalendarAcl *CalendarAcl `body:""` +} + +type CalendarAclCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *CalendarAcl `json:"data"` +} + +type CalendarAclSubscriptionReq struct { + CalendarId string `path:"calendar_id"` +} + +type CalendarAclSubscriptionResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type CalendarEventDeleteReq struct { + CalendarId string `path:"calendar_id"` + EventId string `path:"event_id"` + NeedNotification *bool `query:"need_notification"` +} + +type CalendarEventDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type CalendarEventGetReq struct { + CalendarId string `path:"calendar_id"` + EventId string `path:"event_id"` +} + +type CalendarEventGetRespData struct { + Event *CalendarEvent `json:"event,omitempty"` +} + +type CalendarEventGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *CalendarEventGetRespData `json:"data"` +} + +type CalendarEventCreateReq struct { + CalendarId string `path:"calendar_id"` + CalendarEvent *CalendarEvent `body:""` +} + +type CalendarEventCreateRespData struct { + Event *CalendarEvent `json:"event,omitempty"` +} + +type CalendarEventCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *CalendarEventCreateRespData `json:"data"` +} + +type CalendarEventListReq struct { + CalendarId string `path:"calendar_id"` + PageSize *int `query:"page_size"` + AnchorTime *string `query:"anchor_time"` + PageToken *string `query:"page_token"` + SyncToken *string `query:"sync_token"` + StartTime *string `query:"start_time"` + EndTime *string `query:"end_time"` +} + +type CalendarEventListRespData struct { + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` + SyncToken *string `json:"sync_token,omitempty"` + Items []*CalendarEvent `json:"items,omitempty"` +} + +type CalendarEventListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *CalendarEventListRespData `json:"data"` +} + +type CalendarEventPatchReq struct { + CalendarId string `path:"calendar_id"` + EventId string `path:"event_id"` + CalendarEvent *CalendarEvent `body:""` +} + +type CalendarEventPatchRespData struct { + Event *CalendarEvent `json:"event,omitempty"` +} + +type CalendarEventPatchResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *CalendarEventPatchRespData `json:"data"` +} + +type CalendarEventSearchReqBody struct { + Query *string `json:"query,omitempty"` + Filter *EventSearchFilter `json:"filter,omitempty"` +} + +type CalendarEventSearchReq struct { + CalendarId string `path:"calendar_id"` + UserIdType *string `query:"user_id_type"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` + Body *CalendarEventSearchReqBody `body:""` +} + +type CalendarEventSearchRespData struct { + Items []*CalendarEvent `json:"items,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type CalendarEventSearchResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *CalendarEventSearchRespData `json:"data"` +} + +type CalendarEventSubscriptionReq struct { + CalendarId string `path:"calendar_id"` +} + +type CalendarEventSubscriptionResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type CalendarEventAttendeeListReq struct { + CalendarId string `path:"calendar_id"` + EventId string `path:"event_id"` + UserIdType *string `query:"user_id_type"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type CalendarEventAttendeeListRespData struct { + Items []*CalendarEventAttendee `json:"items,omitempty"` + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type CalendarEventAttendeeListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *CalendarEventAttendeeListRespData `json:"data"` +} + +type CalendarEventAttendeeBatchDeleteReqBody struct { + AttendeeIds []string `json:"attendee_ids,omitempty"` + NeedNotification *bool `json:"need_notification,omitempty"` +} + +type CalendarEventAttendeeBatchDeleteReq struct { + CalendarId string `path:"calendar_id"` + EventId string `path:"event_id"` + Body *CalendarEventAttendeeBatchDeleteReqBody `body:""` +} + +type CalendarEventAttendeeBatchDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type CalendarEventAttendeeCreateReqBody struct { + Attendees []*CalendarEventAttendee `json:"attendees,omitempty"` + NeedNotification *bool `json:"need_notification,omitempty"` +} + +type CalendarEventAttendeeCreateReq struct { + CalendarId string `path:"calendar_id"` + EventId string `path:"event_id"` + UserIdType *string `query:"user_id_type"` + Body *CalendarEventAttendeeCreateReqBody `body:""` +} + +type CalendarEventAttendeeCreateRespData struct { + Attendees []*CalendarEventAttendee `json:"attendees,omitempty"` +} + +type CalendarEventAttendeeCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *CalendarEventAttendeeCreateRespData `json:"data"` +} + +type CalendarEventAttendeeChatMemberListReq struct { + CalendarId string `path:"calendar_id"` + EventId string `path:"event_id"` + AttendeeId string `path:"attendee_id"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type CalendarEventAttendeeChatMemberListRespData struct { + Items []*CalendarEventAttendeeChatMember `json:"items,omitempty"` + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type CalendarEventAttendeeChatMemberListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *CalendarEventAttendeeChatMemberListRespData `json:"data"` +} + +type FreebusyListReqBody struct { + TimeMin *string `json:"time_min,omitempty"` + TimeMax *string `json:"time_max,omitempty"` + UserId *string `json:"user_id,omitempty"` + RoomId *string `json:"room_id,omitempty"` +} + +type FreebusyListReq struct { + UserIdType *string `query:"user_id_type"` + Body *FreebusyListReqBody `body:""` +} + +type FreebusyListRespData struct { + FreebusyList []*Freebusy `json:"freebusy_list,omitempty"` +} + +type FreebusyListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *FreebusyListRespData `json:"data"` +} + +type SettingGenerateCaldavConfReqBody struct { + DeviceName *string `json:"device_name,omitempty"` +} + +type SettingGenerateCaldavConfReq struct { + Body *SettingGenerateCaldavConfReqBody `body:""` +} + +type SettingGenerateCaldavConfRespData struct { + Password *string `json:"password,omitempty"` + UserName *string `json:"user_name,omitempty"` + ServerAddress *string `json:"server_address,omitempty"` + DeviceName *string `json:"device_name,omitempty"` +} + +type SettingGenerateCaldavConfResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *SettingGenerateCaldavConfRespData `json:"data"` +} + +type TimeoffEventDeleteReq struct { + TimeoffEventId string `path:"timeoff_event_id"` +} + +type TimeoffEventDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type TimeoffEventCreateReq struct { + UserIdType *string `query:"user_id_type"` + TimeoffEvent *TimeoffEvent `body:""` +} + +type TimeoffEventCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *TimeoffEvent `json:"data"` +} + +type CalendarChangedEventData struct { + UserIdList []*UserId `json:"user_id_list,omitempty"` +} + +type CalendarChangedEvent struct { + *lark.EventV2Base + Event *CalendarChangedEventData `json:"event"` +} + +type CalendarAclCreatedEventData struct { + AclId *string `json:"acl_id,omitempty"` + Role *string `json:"role,omitempty"` + Scope *AclScopeEvent `json:"scope,omitempty"` + UserIdList []*UserId `json:"user_id_list,omitempty"` +} + +type CalendarAclCreatedEvent struct { + *lark.EventV2Base + Event *CalendarAclCreatedEventData `json:"event"` +} + +type CalendarAclDeletedEventData struct { + AclId *string `json:"acl_id,omitempty"` + Role *string `json:"role,omitempty"` + Scope *AclScopeEvent `json:"scope,omitempty"` + UserIdList []*UserId `json:"user_id_list,omitempty"` +} + +type CalendarAclDeletedEvent struct { + *lark.EventV2Base + Event *CalendarAclDeletedEventData `json:"event"` +} + +type CalendarEventChangedEventData struct { + CalendarId *string `json:"calendar_id,omitempty"` + UserIdList []*UserId `json:"user_id_list,omitempty"` +} + +type CalendarEventChangedEvent struct { + *lark.EventV2Base + Event *CalendarEventChangedEventData `json:"event"` +} diff --git a/v2/service/contact/v3/api.go b/v2/service/contact/v3/api.go new file mode 100644 index 00000000..9bc18980 --- /dev/null +++ b/v2/service/contact/v3/api.go @@ -0,0 +1,405 @@ +// Package contact code generated by lark suite oapi sdk gen +package contact + +import ( + "context" + "net/http" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type ContactService struct { + Users *users + Departments *departments + Scopes *scopes + EmployeeTypeEnums *employeeTypeEnums + CustomAttrs *customAttrs + Group *group + GroupMember *groupMember +} + +func New(app *lark.App) *ContactService { + c := &ContactService{} + c.Users = &users{app: app} + c.Departments = &departments{app: app} + c.Scopes = &scopes{app: app} + c.EmployeeTypeEnums = &employeeTypeEnums{app: app} + c.CustomAttrs = &customAttrs{app: app} + c.Group = &group{app: app} + c.GroupMember = &groupMember{app: app} + return c +} + +type users struct { + app *lark.App +} +type departments struct { + app *lark.App +} +type scopes struct { + app *lark.App +} +type employeeTypeEnums struct { + app *lark.App +} +type customAttrs struct { + app *lark.App +} +type group struct { + app *lark.App +} +type groupMember struct { + app *lark.App +} + +func (c *customAttrs) List(ctx context.Context, req *CustomAttrListReq, options ...lark.RequestOptionFunc) (*CustomAttrListResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/contact/v3/custom_attrs", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &CustomAttrListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (d *departments) Get(ctx context.Context, req *DepartmentGetReq, options ...lark.RequestOptionFunc) (*DepartmentGetResp, error) { + rawResp, err := d.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/contact/v3/departments/:department_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &DepartmentGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (d *departments) List(ctx context.Context, req *DepartmentListReq, options ...lark.RequestOptionFunc) (*DepartmentListResp, error) { + rawResp, err := d.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/contact/v3/departments", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &DepartmentListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (d *departments) Patch(ctx context.Context, req *DepartmentPatchReq, options ...lark.RequestOptionFunc) (*DepartmentPatchResp, error) { + rawResp, err := d.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPatch, + "/open-apis/contact/v3/departments/:department_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &DepartmentPatchResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (d *departments) Create(ctx context.Context, req *DepartmentCreateReq, options ...lark.RequestOptionFunc) (*DepartmentCreateResp, error) { + rawResp, err := d.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/contact/v3/departments", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &DepartmentCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (d *departments) Delete(ctx context.Context, req *DepartmentDeleteReq, options ...lark.RequestOptionFunc) (*DepartmentDeleteResp, error) { + rawResp, err := d.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/contact/v3/departments/:department_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &DepartmentDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (d *departments) Update(ctx context.Context, req *DepartmentUpdateReq, options ...lark.RequestOptionFunc) (*DepartmentUpdateResp, error) { + rawResp, err := d.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPut, + "/open-apis/contact/v3/departments/:department_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &DepartmentUpdateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (d *departments) Parent(ctx context.Context, req *DepartmentParentReq, options ...lark.RequestOptionFunc) (*DepartmentParentResp, error) { + rawResp, err := d.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/contact/v3/departments/parent", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &DepartmentParentResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (d *departments) Search(ctx context.Context, req *DepartmentSearchReq, options ...lark.RequestOptionFunc) (*DepartmentSearchResp, error) { + rawResp, err := d.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/contact/v3/departments/search", []lark.AccessTokenType{lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &DepartmentSearchResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (e *employeeTypeEnums) List(ctx context.Context, req *EmployeeTypeEnumListReq, options ...lark.RequestOptionFunc) (*EmployeeTypeEnumListResp, error) { + rawResp, err := e.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/contact/v3/employee_type_enums", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &EmployeeTypeEnumListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (e *employeeTypeEnums) Create(ctx context.Context, req *EmployeeTypeEnumCreateReq, options ...lark.RequestOptionFunc) (*EmployeeTypeEnumCreateResp, error) { + rawResp, err := e.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/contact/v3/employee_type_enums", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &EmployeeTypeEnumCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (e *employeeTypeEnums) Delete(ctx context.Context, req *EmployeeTypeEnumDeleteReq, options ...lark.RequestOptionFunc) (*EmployeeTypeEnumDeleteResp, error) { + rawResp, err := e.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/contact/v3/employee_type_enums/:enum_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &EmployeeTypeEnumDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (e *employeeTypeEnums) Update(ctx context.Context, req *EmployeeTypeEnumUpdateReq, options ...lark.RequestOptionFunc) (*EmployeeTypeEnumUpdateResp, error) { + rawResp, err := e.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPut, + "/open-apis/contact/v3/employee_type_enums/:enum_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &EmployeeTypeEnumUpdateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (g *group) Create(ctx context.Context, req *GroupCreateReq, options ...lark.RequestOptionFunc) (*GroupCreateResp, error) { + rawResp, err := g.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/contact/v3/group", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &GroupCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (g *group) Simplelist(ctx context.Context, req *GroupSimplelistReq, options ...lark.RequestOptionFunc) (*GroupSimplelistResp, error) { + rawResp, err := g.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/contact/v3/group/simplelist", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &GroupSimplelistResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (g *group) Delete(ctx context.Context, req *GroupDeleteReq, options ...lark.RequestOptionFunc) (*GroupDeleteResp, error) { + rawResp, err := g.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/contact/v3/group/:group_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &GroupDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (g *group) Get(ctx context.Context, req *GroupGetReq, options ...lark.RequestOptionFunc) (*GroupGetResp, error) { + rawResp, err := g.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/contact/v3/group/:group_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &GroupGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (g *group) Patch(ctx context.Context, req *GroupPatchReq, options ...lark.RequestOptionFunc) (*GroupPatchResp, error) { + rawResp, err := g.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPatch, + "/open-apis/contact/v3/group/:group_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &GroupPatchResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (g *groupMember) Simplelist(ctx context.Context, req *GroupMemberSimplelistReq, options ...lark.RequestOptionFunc) (*GroupMemberSimplelistResp, error) { + rawResp, err := g.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/contact/v3/group/:group_id/member/simplelist", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &GroupMemberSimplelistResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (g *groupMember) Add(ctx context.Context, req *GroupMemberAddReq, options ...lark.RequestOptionFunc) (*GroupMemberAddResp, error) { + rawResp, err := g.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/contact/v3/group/:group_id/member/add", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &GroupMemberAddResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (g *groupMember) Remove(ctx context.Context, req *GroupMemberRemoveReq, options ...lark.RequestOptionFunc) (*GroupMemberRemoveResp, error) { + rawResp, err := g.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/contact/v3/group/:group_id/member/remove", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &GroupMemberRemoveResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (u *users) Delete(ctx context.Context, req *UserDeleteReq, options ...lark.RequestOptionFunc) (*UserDeleteResp, error) { + rawResp, err := u.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/contact/v3/users/:user_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &UserDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (u *users) Update(ctx context.Context, req *UserUpdateReq, options ...lark.RequestOptionFunc) (*UserUpdateResp, error) { + rawResp, err := u.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPut, + "/open-apis/contact/v3/users/:user_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &UserUpdateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (u *users) Create(ctx context.Context, req *UserCreateReq, options ...lark.RequestOptionFunc) (*UserCreateResp, error) { + rawResp, err := u.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/contact/v3/users", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &UserCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (u *users) Patch(ctx context.Context, req *UserPatchReq, options ...lark.RequestOptionFunc) (*UserPatchResp, error) { + rawResp, err := u.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPatch, + "/open-apis/contact/v3/users/:user_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &UserPatchResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (u *users) Get(ctx context.Context, req *UserGetReq, options ...lark.RequestOptionFunc) (*UserGetResp, error) { + rawResp, err := u.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/contact/v3/users/:user_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &UserGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (u *users) List(ctx context.Context, req *UserListReq, options ...lark.RequestOptionFunc) (*UserListResp, error) { + rawResp, err := u.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/contact/v3/users", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &UserListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} diff --git a/v2/service/contact/v3/event.go b/v2/service/contact/v3/event.go new file mode 100644 index 00000000..b4aa98f8 --- /dev/null +++ b/v2/service/contact/v3/event.go @@ -0,0 +1,199 @@ +// Package contact code generated by lark suite oapi sdk gen +package contact + +import ( + "context" + "github.com/larksuite/oapi-sdk-go/v2" +) + +type departmentCreatedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *DepartmentCreatedEvent) error +} + +func (h *departmentCreatedEventHandler) Event() interface{} { + return &DepartmentCreatedEvent{} +} + +func (h *departmentCreatedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*DepartmentCreatedEvent)) +} + +func (d *departments) CreatedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *DepartmentCreatedEvent) error) { + d.app.Webhook.EventHandler("created", &departmentCreatedEventHandler{handler: handler}) +} + +type departmentDeletedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *DepartmentDeletedEvent) error +} + +func (h *departmentDeletedEventHandler) Event() interface{} { + return &DepartmentDeletedEvent{} +} + +func (h *departmentDeletedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*DepartmentDeletedEvent)) +} + +func (d *departments) DeletedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *DepartmentDeletedEvent) error) { + d.app.Webhook.EventHandler("deleted", &departmentDeletedEventHandler{handler: handler}) +} + +type departmentUpdatedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *DepartmentUpdatedEvent) error +} + +func (h *departmentUpdatedEventHandler) Event() interface{} { + return &DepartmentUpdatedEvent{} +} + +func (h *departmentUpdatedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*DepartmentUpdatedEvent)) +} + +func (d *departments) UpdatedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *DepartmentUpdatedEvent) error) { + d.app.Webhook.EventHandler("updated", &departmentUpdatedEventHandler{handler: handler}) +} + +type employeeTypeEnumActivedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *EmployeeTypeEnumActivedEvent) error +} + +func (h *employeeTypeEnumActivedEventHandler) Event() interface{} { + return &EmployeeTypeEnumActivedEvent{} +} + +func (h *employeeTypeEnumActivedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*EmployeeTypeEnumActivedEvent)) +} + +func (e *employeeTypeEnums) ActivedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *EmployeeTypeEnumActivedEvent) error) { + e.app.Webhook.EventHandler("actived", &employeeTypeEnumActivedEventHandler{handler: handler}) +} + +type employeeTypeEnumCreatedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *EmployeeTypeEnumCreatedEvent) error +} + +func (h *employeeTypeEnumCreatedEventHandler) Event() interface{} { + return &EmployeeTypeEnumCreatedEvent{} +} + +func (h *employeeTypeEnumCreatedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*EmployeeTypeEnumCreatedEvent)) +} + +func (e *employeeTypeEnums) CreatedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *EmployeeTypeEnumCreatedEvent) error) { + e.app.Webhook.EventHandler("created", &employeeTypeEnumCreatedEventHandler{handler: handler}) +} + +type employeeTypeEnumDeactivatedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *EmployeeTypeEnumDeactivatedEvent) error +} + +func (h *employeeTypeEnumDeactivatedEventHandler) Event() interface{} { + return &EmployeeTypeEnumDeactivatedEvent{} +} + +func (h *employeeTypeEnumDeactivatedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*EmployeeTypeEnumDeactivatedEvent)) +} + +func (e *employeeTypeEnums) DeactivatedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *EmployeeTypeEnumDeactivatedEvent) error) { + e.app.Webhook.EventHandler("deactivated", &employeeTypeEnumDeactivatedEventHandler{handler: handler}) +} + +type employeeTypeEnumDeletedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *EmployeeTypeEnumDeletedEvent) error +} + +func (h *employeeTypeEnumDeletedEventHandler) Event() interface{} { + return &EmployeeTypeEnumDeletedEvent{} +} + +func (h *employeeTypeEnumDeletedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*EmployeeTypeEnumDeletedEvent)) +} + +func (e *employeeTypeEnums) DeletedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *EmployeeTypeEnumDeletedEvent) error) { + e.app.Webhook.EventHandler("deleted", &employeeTypeEnumDeletedEventHandler{handler: handler}) +} + +type employeeTypeEnumUpdatedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *EmployeeTypeEnumUpdatedEvent) error +} + +func (h *employeeTypeEnumUpdatedEventHandler) Event() interface{} { + return &EmployeeTypeEnumUpdatedEvent{} +} + +func (h *employeeTypeEnumUpdatedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*EmployeeTypeEnumUpdatedEvent)) +} + +func (e *employeeTypeEnums) UpdatedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *EmployeeTypeEnumUpdatedEvent) error) { + e.app.Webhook.EventHandler("updated", &employeeTypeEnumUpdatedEventHandler{handler: handler}) +} + +type scopeUpdatedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *ScopeUpdatedEvent) error +} + +func (h *scopeUpdatedEventHandler) Event() interface{} { + return &ScopeUpdatedEvent{} +} + +func (h *scopeUpdatedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*ScopeUpdatedEvent)) +} + +func (s *scopes) UpdatedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *ScopeUpdatedEvent) error) { + s.app.Webhook.EventHandler("updated", &scopeUpdatedEventHandler{handler: handler}) +} + +type userCreatedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *UserCreatedEvent) error +} + +func (h *userCreatedEventHandler) Event() interface{} { + return &UserCreatedEvent{} +} + +func (h *userCreatedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*UserCreatedEvent)) +} + +func (u *users) CreatedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *UserCreatedEvent) error) { + u.app.Webhook.EventHandler("created", &userCreatedEventHandler{handler: handler}) +} + +type userDeletedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *UserDeletedEvent) error +} + +func (h *userDeletedEventHandler) Event() interface{} { + return &UserDeletedEvent{} +} + +func (h *userDeletedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*UserDeletedEvent)) +} + +func (u *users) DeletedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *UserDeletedEvent) error) { + u.app.Webhook.EventHandler("deleted", &userDeletedEventHandler{handler: handler}) +} + +type userUpdatedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *UserUpdatedEvent) error +} + +func (h *userUpdatedEventHandler) Event() interface{} { + return &UserUpdatedEvent{} +} + +func (h *userUpdatedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*UserUpdatedEvent)) +} + +func (u *users) UpdatedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *UserUpdatedEvent) error) { + u.app.Webhook.EventHandler("updated", &userUpdatedEventHandler{handler: handler}) +} diff --git a/v2/service/contact/v3/model.go b/v2/service/contact/v3/model.go new file mode 100644 index 00000000..ed7eb393 --- /dev/null +++ b/v2/service/contact/v3/model.go @@ -0,0 +1,824 @@ +// Package contact code generated by lark suite oapi sdk gen +package contact + +import ( + "github.com/larksuite/oapi-sdk-go/v2" +) + +type AvatarInfo struct { + Avatar72 *string `json:"avatar_72,omitempty"` + Avatar240 *string `json:"avatar_240,omitempty"` + Avatar640 *string `json:"avatar_640,omitempty"` + AvatarOrigin *string `json:"avatar_origin,omitempty"` +} + +type CustomAttrEvent struct { + ContactFieldKey *string `json:"contact_field_key,omitempty"` + FieldValueTypes *string `json:"field_value_types,omitempty"` + I18nFieldNames *string `json:"i18n_field_names,omitempty"` + AllowOpenQuery *string `json:"allow_open_query,omitempty"` +} + +type DepartmentI18nName struct { + ZhCn *string `json:"zh_cn,omitempty"` + JaJp *string `json:"ja_jp,omitempty"` + EnUs *string `json:"en_us,omitempty"` +} + +type DepartmentStatus struct { + IsDeleted *bool `json:"is_deleted,omitempty"` +} + +type DepartmentUnit struct { + UnitId *string `json:"unit_id,omitempty"` + UnitType *string `json:"unit_type,omitempty"` + UnitName *string `json:"unit_name,omitempty"` +} + +type GroupEvent struct { + UserGroupId *string `json:"user_group_id,omitempty"` + Name *string `json:"name,omitempty"` +} + +type I18nContent struct { + Locale *string `json:"locale,omitempty"` + Value *string `json:"value,omitempty"` +} + +type NotificationOption struct { + Channels []string `json:"channels,omitempty"` + Language *string `json:"language,omitempty"` +} + +type Scope struct { + Departments []*Department `json:"departments,omitempty"` + Users []*User `json:"users,omitempty"` + UserGroups []*UserGroup `json:"user_groups,omitempty"` +} + +type UserCustomAttr struct { + Type *string `json:"type,omitempty"` + Id *string `json:"id,omitempty"` + Value *UserCustomAttrValue `json:"value,omitempty"` +} + +type UserGroup struct { + UserGroupId *string `json:"user_group_id,omitempty"` + Name *string `json:"name,omitempty"` + Type *int `json:"type,omitempty"` + MemberCount *int `json:"member_count,omitempty"` + Status *int `json:"status,omitempty"` +} + +type UserOrder struct { + DepartmentId *string `json:"department_id,omitempty"` + UserOrder *int `json:"user_order,omitempty"` + DepartmentOrder *int `json:"department_order,omitempty"` +} + +type UserPosition struct { + PositionCode *string `json:"position_code,omitempty"` + PositionName *string `json:"position_name,omitempty"` + DepartmentId *string `json:"department_id,omitempty"` + LeaderUserId *string `json:"leader_user_id,omitempty"` + LeaderPositionCode *string `json:"leader_position_code,omitempty"` + IsMajor *bool `json:"is_major,omitempty"` +} + +type UserStatus struct { + IsFrozen *bool `json:"is_frozen,omitempty"` + IsResigned *bool `json:"is_resigned,omitempty"` + IsActivated *bool `json:"is_activated,omitempty"` +} + +type CustomAttr struct { + Id *string `json:"id,omitempty"` + Type *string `json:"type,omitempty"` + Options *CustomAttrOptions `json:"options,omitempty"` + I18nName []*I18nContent `json:"i18n_name,omitempty"` +} + +type CustomAttrGenericUser struct { + Id *string `json:"id,omitempty"` + Type *int `json:"type,omitempty"` +} + +type CustomAttrOption struct { + Id *string `json:"id,omitempty"` + Value *string `json:"value,omitempty"` + Name *string `json:"name,omitempty"` +} + +type CustomAttrOptions struct { + DefaultOptionId *string `json:"default_option_id,omitempty"` + OptionType *string `json:"option_type,omitempty"` + Options []*CustomAttrOption `json:"options,omitempty"` +} + +type Department struct { + Name *string `json:"name,omitempty"` + I18nName *DepartmentI18nName `json:"i18n_name,omitempty"` + ParentDepartmentId *string `json:"parent_department_id,omitempty"` + DepartmentId *string `json:"department_id,omitempty"` + OpenDepartmentId *string `json:"open_department_id,omitempty"` + LeaderUserId *string `json:"leader_user_id,omitempty"` + ChatId *string `json:"chat_id,omitempty"` + Order *int64 `json:"order,omitempty,string"` + UnitIds []string `json:"unit_ids,omitempty"` + MemberCount *int `json:"member_count,omitempty"` + Status *DepartmentStatus `json:"status,omitempty"` + CreateGroupChat *bool `json:"create_group_chat,omitempty"` +} + +type DepartmentCount struct { + DepartmentId *string `json:"department_id,omitempty"` + DirectDepartmentCount *int `json:"direct_department_count,omitempty"` + DirectUserCount *int `json:"direct_user_count,omitempty"` + DepartmentCount *int `json:"department_count,omitempty"` + UserCount *int `json:"user_count,omitempty"` +} + +type DepartmentEvent struct { + Name *string `json:"name,omitempty"` + ParentDepartmentId *string `json:"parent_department_id,omitempty"` + DepartmentId *string `json:"department_id,omitempty"` + OpenDepartmentId *string `json:"open_department_id,omitempty"` + LeaderUserId *string `json:"leader_user_id,omitempty"` + ChatId *string `json:"chat_id,omitempty"` + Order *int `json:"order,omitempty"` + + Status *DepartmentStatus `json:"status,omitempty"` +} + +type DepartmentParent struct { + DepartmentId *string `json:"department_id,omitempty"` + ParentIds []string `json:"parent_ids,omitempty"` +} + +type EmployeeTypeEnum struct { + EnumId *string `json:"enum_id,omitempty"` + EnumValue *int64 `json:"enum_value,omitempty,string"` + Content *string `json:"content,omitempty"` + EnumType *int `json:"enum_type,omitempty"` + EnumStatus *int `json:"enum_status,omitempty"` + I18nContent []*I18nContent `json:"i18n_content,omitempty"` +} + +type OldDepartmentObject struct { + Status *DepartmentStatus `json:"status,omitempty"` + OpenDepartmentId *string `json:"open_department_id,omitempty"` +} + +type OldUserObject struct { + DepartmentIds []string `json:"department_ids,omitempty"` + OpenId *string `json:"open_id,omitempty"` +} + +type UserCustomAttrValue struct { + Text *string `json:"text,omitempty"` + Url *string `json:"url,omitempty"` + PcUrl *string `json:"pc_url,omitempty"` + OptionId *string `json:"option_id,omitempty"` + OptionValue *string `json:"option_value,omitempty"` + Name *string `json:"name,omitempty"` + PictureUrl *string `json:"picture_url,omitempty"` + GenericUser *CustomAttrGenericUser `json:"generic_user,omitempty"` +} + +type UserEvent struct { + OpenId *string `json:"open_id,omitempty"` + UserId *string `json:"user_id,omitempty"` + Name *string `json:"name,omitempty"` + EnName *string `json:"en_name,omitempty"` + Email *string `json:"email,omitempty"` + Mobile *string `json:"mobile,omitempty"` + + Gender *int `json:"gender,omitempty"` + Avatar *AvatarInfo `json:"avatar,omitempty"` + Status *UserStatus `json:"status,omitempty"` + DepartmentIds []string `json:"department_ids,omitempty"` + LeaderUserId *string `json:"leader_user_id,omitempty"` + City *string `json:"city,omitempty"` + Country *string `json:"country,omitempty"` + WorkStation *string `json:"work_station,omitempty"` + JoinTime *int `json:"join_time,omitempty"` + + EmployeeNo *string `json:"employee_no,omitempty"` + EmployeeType *int `json:"employee_type,omitempty"` + + Orders []*UserOrder `json:"orders,omitempty"` + + CustomAttrs []*UserCustomAttr `json:"custom_attrs,omitempty"` +} + +type Group struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + MemberUserCount *int `json:"member_user_count,omitempty"` + MemberDepartmentCount *int `json:"member_department_count,omitempty"` +} + +type Memberlist struct { + MemberId *string `json:"member_id,omitempty"` + MemberType *string `json:"member_type,omitempty"` +} + +type User struct { + UnionId *string `json:"union_id,omitempty"` + UserId *string `json:"user_id,omitempty"` + OpenId *string `json:"open_id,omitempty"` + Name *string `json:"name,omitempty"` + EnName *string `json:"en_name,omitempty"` + Email *string `json:"email,omitempty"` + Mobile *string `json:"mobile,omitempty"` + MobileVisible *bool `json:"mobile_visible,omitempty"` + Gender *int `json:"gender,omitempty"` + AvatarKey *string `json:"avatar_key,omitempty"` + Avatar *AvatarInfo `json:"avatar,omitempty"` + Status *UserStatus `json:"status,omitempty"` + DepartmentIds []string `json:"department_ids,omitempty"` + LeaderUserId *string `json:"leader_user_id,omitempty"` + City *string `json:"city,omitempty"` + Country *string `json:"country,omitempty"` + WorkStation *string `json:"work_station,omitempty"` + JoinTime *int `json:"join_time,omitempty"` + IsTenantManager *bool `json:"is_tenant_manager,omitempty"` + EmployeeNo *string `json:"employee_no,omitempty"` + EmployeeType *int `json:"employee_type,omitempty"` + + Orders []*UserOrder `json:"orders,omitempty"` + CustomAttrs []*UserCustomAttr `json:"custom_attrs,omitempty"` + EnterpriseEmail *string `json:"enterprise_email,omitempty"` + + JobTitle *string `json:"job_title,omitempty"` + NeedSendNotification *bool `json:"need_send_notification,omitempty"` + NotificationOption *NotificationOption `json:"notification_option,omitempty"` + IsFrozen *bool `json:"is_frozen,omitempty"` +} + +type CustomAttrListReq struct { + PageSize *int `query:"page_size"` + PageToken *string `query:"page_token"` +} + +type CustomAttrListRespData struct { + Items []*CustomAttr `json:"items,omitempty"` + PageToken *string `json:"page_token,omitempty"` + HasMore *bool `json:"has_more,omitempty"` +} + +type CustomAttrListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *CustomAttrListRespData `json:"data"` +} + +type DepartmentGetReq struct { + DepartmentId string `path:"department_id"` + UserIdType *string `query:"user_id_type"` + DepartmentIdType *string `query:"department_id_type"` +} + +type DepartmentGetRespData struct { + Department *Department `json:"department,omitempty"` +} + +type DepartmentGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *DepartmentGetRespData `json:"data"` +} + +type DepartmentListReq struct { + UserIdType *string `query:"user_id_type"` + DepartmentIdType *string `query:"department_id_type"` + ParentDepartmentId *string `query:"parent_department_id"` + FetchChild *bool `query:"fetch_child"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type DepartmentListRespData struct { + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` + Items []*Department `json:"items,omitempty"` +} + +type DepartmentListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *DepartmentListRespData `json:"data"` +} + +type DepartmentPatchReq struct { + DepartmentId string `path:"department_id"` + UserIdType *string `query:"user_id_type"` + DepartmentIdType *string `query:"department_id_type"` + Department *Department `body:""` +} + +type DepartmentPatchRespData struct { + Department *Department `json:"department,omitempty"` +} + +type DepartmentPatchResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *DepartmentPatchRespData `json:"data"` +} + +type DepartmentCreateReq struct { + UserIdType *string `query:"user_id_type"` + DepartmentIdType *string `query:"department_id_type"` + ClientToken *string `query:"client_token"` + Department *Department `body:""` +} + +type DepartmentCreateRespData struct { + Department *Department `json:"department,omitempty"` +} + +type DepartmentCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *DepartmentCreateRespData `json:"data"` +} + +type DepartmentDeleteReq struct { + DepartmentId string `path:"department_id"` + DepartmentIdType *string `query:"department_id_type"` +} + +type DepartmentDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type DepartmentUpdateReq struct { + DepartmentId string `path:"department_id"` + UserIdType *string `query:"user_id_type"` + DepartmentIdType *string `query:"department_id_type"` + Department *Department `body:""` +} + +type DepartmentUpdateRespData struct { + Department *Department `json:"department,omitempty"` +} + +type DepartmentUpdateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *DepartmentUpdateRespData `json:"data"` +} + +type DepartmentParentReq struct { + UserIdType *string `query:"user_id_type"` + DepartmentIdType *string `query:"department_id_type"` + DepartmentId *string `query:"department_id"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type DepartmentParentRespData struct { + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` + Items []*Department `json:"items,omitempty"` +} + +type DepartmentParentResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *DepartmentParentRespData `json:"data"` +} + +type DepartmentSearchReqBody struct { + Query *string `json:"query,omitempty"` +} + +type DepartmentSearchReq struct { + UserIdType *string `query:"user_id_type"` + DepartmentIdType *string `query:"department_id_type"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` + Body *DepartmentSearchReqBody `body:""` +} + +type DepartmentSearchRespData struct { + Items []*Department `json:"items,omitempty"` + PageToken *string `json:"page_token,omitempty"` + HasMore *bool `json:"has_more,omitempty"` +} + +type DepartmentSearchResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *DepartmentSearchRespData `json:"data"` +} + +type EmployeeTypeEnumListReq struct { + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type EmployeeTypeEnumListRespData struct { + Items []*EmployeeTypeEnum `json:"items,omitempty"` + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type EmployeeTypeEnumListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *EmployeeTypeEnumListRespData `json:"data"` +} + +type EmployeeTypeEnumCreateReq struct { + EmployeeTypeEnum *EmployeeTypeEnum `body:""` +} + +type EmployeeTypeEnumCreateRespData struct { + EmployeeTypeEnum *EmployeeTypeEnum `json:"employee_type_enum,omitempty"` +} + +type EmployeeTypeEnumCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *EmployeeTypeEnumCreateRespData `json:"data"` +} + +type EmployeeTypeEnumDeleteReq struct { + EnumId string `path:"enum_id"` +} + +type EmployeeTypeEnumDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type EmployeeTypeEnumUpdateReq struct { + EnumId string `path:"enum_id"` + EmployeeTypeEnum *EmployeeTypeEnum `body:""` +} + +type EmployeeTypeEnumUpdateRespData struct { + EmployeeTypeEnum *EmployeeTypeEnum `json:"employee_type_enum,omitempty"` +} + +type EmployeeTypeEnumUpdateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *EmployeeTypeEnumUpdateRespData `json:"data"` +} + +type GroupCreateReqBody struct { + GroupId *string `json:"group_id,omitempty"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + Type *int `json:"type,omitempty"` +} + +type GroupCreateReq struct { + Body *GroupCreateReqBody `body:""` +} + +type GroupCreateRespData struct { + GroupId *string `json:"group_id,omitempty"` +} + +type GroupCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *GroupCreateRespData `json:"data"` +} + +type GroupSimplelistReq struct { + PageSize *int `query:"page_size"` + PageToken *string `query:"page_token"` + Type *int `query:"type"` +} + +type GroupSimplelistRespData struct { + Grouplist []*Group `json:"grouplist,omitempty"` + PageToken *string `json:"page_token,omitempty"` + HasMore *bool `json:"has_more,omitempty"` +} + +type GroupSimplelistResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *GroupSimplelistRespData `json:"data"` +} + +type GroupDeleteReq struct { + GroupId string `path:"group_id"` +} + +type GroupDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type GroupGetReq struct { + GroupId string `path:"group_id"` +} + +type GroupGetRespData struct { + Group *Group `json:"group,omitempty"` +} + +type GroupGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *GroupGetRespData `json:"data"` +} + +type GroupPatchReqBody struct { + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` +} + +type GroupPatchReq struct { + GroupId string `path:"group_id"` + Body *GroupPatchReqBody `body:""` +} + +type GroupPatchResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type GroupMemberSimplelistReq struct { + GroupId string `path:"group_id"` + PageSize *int `query:"page_size"` + PageToken *string `query:"page_token"` + MemberIdType *string `query:"member_id_type"` + MemberType *string `query:"member_type"` +} + +type GroupMemberSimplelistRespData struct { + Memberlist []*Memberlist `json:"memberlist,omitempty"` + PageToken *string `json:"page_token,omitempty"` + HasMore *bool `json:"has_more,omitempty"` +} + +type GroupMemberSimplelistResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *GroupMemberSimplelistRespData `json:"data"` +} + +type GroupMemberAddReqBody struct { + MemberType *string `json:"member_type,omitempty"` + MemberIdType *string `json:"member_id_type,omitempty"` + MemberId *string `json:"member_id,omitempty"` +} + +type GroupMemberAddReq struct { + GroupId string `path:"group_id"` + Body *GroupMemberAddReqBody `body:""` +} + +type GroupMemberAddResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type GroupMemberRemoveReqBody struct { + MemberType *string `json:"member_type,omitempty"` + MemberId *string `json:"member_id,omitempty"` + MemberIdType *string `json:"member_id_type,omitempty"` +} + +type GroupMemberRemoveReq struct { + GroupId string `path:"group_id"` + Body *GroupMemberRemoveReqBody `body:""` +} + +type GroupMemberRemoveResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type UserDeleteReqBody struct { + DepartmentChatAcceptorUserId *string `json:"department_chat_acceptor_user_id,omitempty"` + ExternalChatAcceptorUserId *string `json:"external_chat_acceptor_user_id,omitempty"` + DocsAcceptorUserId *string `json:"docs_acceptor_user_id,omitempty"` + CalendarAcceptorUserId *string `json:"calendar_acceptor_user_id,omitempty"` + ApplicationAcceptorUserId *string `json:"application_acceptor_user_id,omitempty"` + HelpdeskAcceptorUserId *string `json:"helpdesk_acceptor_user_id,omitempty"` +} + +type UserDeleteReq struct { + UserId string `path:"user_id"` + UserIdType *string `query:"user_id_type"` + Body *UserDeleteReqBody `body:""` +} + +type UserDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type UserUpdateReq struct { + UserId string `path:"user_id"` + UserIdType *string `query:"user_id_type"` + DepartmentIdType *string `query:"department_id_type"` + User *User `body:""` +} + +type UserUpdateRespData struct { + User *User `json:"user,omitempty"` +} + +type UserUpdateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *UserUpdateRespData `json:"data"` +} + +type UserCreateReq struct { + UserIdType *string `query:"user_id_type"` + DepartmentIdType *string `query:"department_id_type"` + ClientToken *string `query:"client_token"` + User *User `body:""` +} + +type UserCreateRespData struct { + User *User `json:"user,omitempty"` +} + +type UserCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *UserCreateRespData `json:"data"` +} + +type UserPatchReq struct { + UserId string `path:"user_id"` + UserIdType *string `query:"user_id_type"` + DepartmentIdType *string `query:"department_id_type"` + User *User `body:""` +} + +type UserPatchRespData struct { + User *User `json:"user,omitempty"` +} + +type UserPatchResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *UserPatchRespData `json:"data"` +} + +type UserGetReq struct { + UserId string `path:"user_id"` + UserIdType *string `query:"user_id_type"` + DepartmentIdType *string `query:"department_id_type"` +} + +type UserGetRespData struct { + User *User `json:"user,omitempty"` +} + +type UserGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *UserGetRespData `json:"data"` +} + +type UserListReq struct { + UserIdType *string `query:"user_id_type"` + DepartmentIdType *string `query:"department_id_type"` + DepartmentId *string `query:"department_id"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type UserListRespData struct { + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` + Items []*User `json:"items,omitempty"` +} + +type UserListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *UserListRespData `json:"data"` +} + +type DepartmentCreatedEventData struct { + Object *DepartmentEvent `json:"object,omitempty"` +} + +type DepartmentCreatedEvent struct { + *lark.EventV2Base + Event *DepartmentCreatedEventData `json:"event"` +} + +type DepartmentDeletedEventData struct { + Object *DepartmentEvent `json:"object,omitempty"` + OldObject *OldDepartmentObject `json:"old_object,omitempty"` +} + +type DepartmentDeletedEvent struct { + *lark.EventV2Base + Event *DepartmentDeletedEventData `json:"event"` +} + +type DepartmentUpdatedEventData struct { + Object *DepartmentEvent `json:"object,omitempty"` + OldObject *DepartmentEvent `json:"old_object,omitempty"` +} + +type DepartmentUpdatedEvent struct { + *lark.EventV2Base + Event *DepartmentUpdatedEventData `json:"event"` +} + +type EmployeeTypeEnumActivedEventData struct { + OldEnum *EmployeeTypeEnum `json:"old_enum,omitempty"` + NewEnum *EmployeeTypeEnum `json:"new_enum,omitempty"` +} + +type EmployeeTypeEnumActivedEvent struct { + *lark.EventV2Base + Event *EmployeeTypeEnumActivedEventData `json:"event"` +} + +type EmployeeTypeEnumCreatedEventData struct { + NewEnum *EmployeeTypeEnum `json:"new_enum,omitempty"` +} + +type EmployeeTypeEnumCreatedEvent struct { + *lark.EventV2Base + Event *EmployeeTypeEnumCreatedEventData `json:"event"` +} + +type EmployeeTypeEnumDeactivatedEventData struct { + OldEnum *EmployeeTypeEnum `json:"old_enum,omitempty"` + NewEnum *EmployeeTypeEnum `json:"new_enum,omitempty"` +} + +type EmployeeTypeEnumDeactivatedEvent struct { + *lark.EventV2Base + Event *EmployeeTypeEnumDeactivatedEventData `json:"event"` +} + +type EmployeeTypeEnumDeletedEventData struct { + OldEnum *EmployeeTypeEnum `json:"old_enum,omitempty"` +} + +type EmployeeTypeEnumDeletedEvent struct { + *lark.EventV2Base + Event *EmployeeTypeEnumDeletedEventData `json:"event"` +} + +type EmployeeTypeEnumUpdatedEventData struct { + OldEnum *EmployeeTypeEnum `json:"old_enum,omitempty"` + NewEnum *EmployeeTypeEnum `json:"new_enum,omitempty"` +} + +type EmployeeTypeEnumUpdatedEvent struct { + *lark.EventV2Base + Event *EmployeeTypeEnumUpdatedEventData `json:"event"` +} + +type ScopeUpdatedEventData struct { + Added *Scope `json:"added,omitempty"` + Removed *Scope `json:"removed,omitempty"` +} + +type ScopeUpdatedEvent struct { + *lark.EventV2Base + Event *ScopeUpdatedEventData `json:"event"` +} + +type UserCreatedEventData struct { + Object *UserEvent `json:"object,omitempty"` +} + +type UserCreatedEvent struct { + *lark.EventV2Base + Event *UserCreatedEventData `json:"event"` +} + +type UserDeletedEventData struct { + Object *UserEvent `json:"object,omitempty"` + OldObject *OldUserObject `json:"old_object,omitempty"` +} + +type UserDeletedEvent struct { + *lark.EventV2Base + Event *UserDeletedEventData `json:"event"` +} + +type UserUpdatedEventData struct { + Object *UserEvent `json:"object,omitempty"` + OldObject *UserEvent `json:"old_object,omitempty"` +} + +type UserUpdatedEvent struct { + *lark.EventV2Base + Event *UserUpdatedEventData `json:"event"` +} diff --git a/v2/service/ehr/v1/api.go b/v2/service/ehr/v1/api.go new file mode 100644 index 00000000..c1b5c863 --- /dev/null +++ b/v2/service/ehr/v1/api.go @@ -0,0 +1,62 @@ +// Package ehr code generated by lark suite oapi sdk gen +package ehr + +import ( + "bytes" + "context" + "net/http" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type EhrService struct { + Attachments *attachments + Employees *employees +} + +func New(app *lark.App) *EhrService { + e := &EhrService{} + e.Attachments = &attachments{app: app} + e.Employees = &employees{app: app} + return e +} + +type attachments struct { + app *lark.App +} +type employees struct { + app *lark.App +} + +func (a *attachments) Get(ctx context.Context, req *AttachmentGetReq, options ...lark.RequestOptionFunc) (*AttachmentGetResp, error) { + options = append(options, lark.WithFileDownload()) + rawResp, err := a.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/ehr/v1/attachments/:token", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &AttachmentGetResp{RawResponse: rawResp} + if rawResp.StatusCode == http.StatusOK { + resp.File = bytes.NewBuffer(rawResp.RawBody) + resp.FileName = lark.FileNameByHeader(rawResp.Header) + return resp, err + } + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (e *employees) List(ctx context.Context, req *EmployeeListReq, options ...lark.RequestOptionFunc) (*EmployeeListResp, error) { + rawResp, err := e.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/ehr/v1/employees", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &EmployeeListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} diff --git a/v2/service/ehr/v1/model.go b/v2/service/ehr/v1/model.go new file mode 100644 index 00000000..f4d13eb4 --- /dev/null +++ b/v2/service/ehr/v1/model.go @@ -0,0 +1,182 @@ +// Package ehr code generated by lark suite oapi sdk gen +package ehr + +import ( + "io" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type Attachment struct { + Id *string `json:"id,omitempty"` + MimeType *string `json:"mime_type,omitempty"` + Name *string `json:"name,omitempty"` + Size *int64 `json:"size,omitempty"` +} + +type ContractCompany struct { + Id *int64 `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + +type CustomFields struct { + Key *string `json:"key,omitempty"` + Label *string `json:"label,omitempty"` + Type *string `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} + +type Education struct { + Level *int `json:"level,omitempty"` + School *string `json:"school,omitempty"` + Major *string `json:"major,omitempty"` + Degree *int `json:"degree,omitempty"` + Start *string `json:"start,omitempty"` + End *string `json:"end,omitempty"` +} + +type EmergencyContact struct { + Name *string `json:"name,omitempty"` + Relationship *int `json:"relationship,omitempty"` + Mobile *string `json:"mobile,omitempty"` +} + +type Employee struct { + UserId *string `json:"user_id,omitempty"` + SystemFields *SystemFields `json:"system_fields,omitempty"` + CustomFields []*CustomFields `json:"custom_fields,omitempty"` +} + +type Job struct { + Id *int64 `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + +type JobLevel struct { + Id *int64 `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + +type Manager struct { + UserId *string `json:"user_id,omitempty"` + Name *string `json:"name,omitempty"` + EnName *string `json:"en_name,omitempty"` +} + +type NativeRegion struct { + IsoCode *string `json:"iso_code,omitempty"` + Name *string `json:"name,omitempty"` +} + +type SystemFields struct { + Name *string `json:"name,omitempty"` + EnName *string `json:"en_name,omitempty"` + Email *string `json:"email,omitempty"` + Mobile *string `json:"mobile,omitempty"` + DepartmentId *string `json:"department_id,omitempty"` + Manager *Manager `json:"manager,omitempty"` + Job *Job `json:"job,omitempty"` + JobLevel *JobLevel `json:"job_level,omitempty"` + WorkLocation *WorkLocation `json:"work_location,omitempty"` + Gender *int `json:"gender,omitempty"` + Birthday *string `json:"birthday,omitempty"` + NativeRegion *NativeRegion `json:"native_region,omitempty"` + Ethnicity *int `json:"ethnicity,omitempty"` + MaritalStatus *int `json:"marital_status,omitempty"` + PoliticalStatus *int `json:"political_status,omitempty"` + EnteredWorkforceDate *string `json:"entered_workforce_date,omitempty"` + IdType *int `json:"id_type,omitempty"` + IdNumber *string `json:"id_number,omitempty"` + HukouType *int `json:"hukou_type,omitempty"` + HukouLocation *string `json:"hukou_location,omitempty"` + BankAccountNumber *string `json:"bank_account_number,omitempty"` + BankName *string `json:"bank_name,omitempty"` + SocialSecurityAccount *string `json:"social_security_account,omitempty"` + ProvidentFundAccount *string `json:"provident_fund_account,omitempty"` + EmployeeNo *string `json:"employee_no,omitempty"` + EmployeeType *int `json:"employee_type,omitempty"` + Status *int `json:"status,omitempty"` + HireDate *string `json:"hire_date,omitempty"` + ProbationMonths *float64 `json:"probation_months,omitempty"` + ConversionDate *string `json:"conversion_date,omitempty"` + Application *int `json:"application,omitempty"` + ApplicationStatus *int `json:"application_status,omitempty"` + LastDay *string `json:"last_day,omitempty"` + DepartureType *int `json:"departure_type,omitempty"` + DepartureReason *int `json:"departure_reason,omitempty"` + DepartureNotes *string `json:"departure_notes,omitempty"` + ContractCompany *ContractCompany `json:"contract_company,omitempty"` + ContractType *int `json:"contract_type,omitempty"` + ContractStartDate *string `json:"contract_start_date,omitempty"` + ContractExpirationDate *string `json:"contract_expiration_date,omitempty"` + ContractSignTimes *int `json:"contract_sign_times,omitempty"` + PersonalEmail *string `json:"personal_email,omitempty"` + FamilyAddress *string `json:"family_address,omitempty"` + PrimaryEmergencyContact *EmergencyContact `json:"primary_emergency_contact,omitempty"` + EmergencyContact []*EmergencyContact `json:"emergency_contact,omitempty"` + HighestLevelOfEdu *Education `json:"highest_level_of_edu,omitempty"` + Education []*Education `json:"education,omitempty"` + FormerWorkExp *WorkExperience `json:"former_work_exp,omitempty"` + WorkExp []*WorkExperience `json:"work_exp,omitempty"` + IdPhotoPoSide []*Attachment `json:"id_photo_po_side,omitempty"` + IdPhotoEmSide []*Attachment `json:"id_photo_em_side,omitempty"` + IdPhoto []*Attachment `json:"id_photo,omitempty"` + DiplomaPhoto []*Attachment `json:"diploma_photo,omitempty"` + GraduationCert []*Attachment `json:"graduation_cert,omitempty"` + CertOfMerit []*Attachment `json:"cert_of_merit,omitempty"` + OffboardingFile []*Attachment `json:"offboarding_file,omitempty"` + CancelOnboardingReason *int `json:"cancel_onboarding_reason,omitempty"` + CancelOnboardingNotes *string `json:"cancel_onboarding_notes,omitempty"` + EmployeeFormStatus *int `json:"employee_form_status,omitempty"` + CreateTime *int64 `json:"create_time,omitempty"` + UpdateTime *int64 `json:"update_time,omitempty"` +} + +type WorkExperience struct { + Company *string `json:"company,omitempty"` + Department *string `json:"department,omitempty"` + Job *string `json:"job,omitempty"` + Start *string `json:"start,omitempty"` + End *string `json:"end,omitempty"` + Description *string `json:"description,omitempty"` +} + +type WorkLocation struct { + Id *int64 `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + +type AttachmentGetReq struct { + Token string `path:"token"` +} + +type AttachmentGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + File io.Reader `json:"-"` + FileName string `json:"-"` +} + +type EmployeeListReq struct { + View *string `query:"view"` + Status []int `query:"status"` + Type []int `query:"type"` + StartTime *int64 `query:"start_time"` + EndTime *int64 `query:"end_time"` + UserIdType *string `query:"user_id_type"` + UserIds []string `query:"user_ids"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type EmployeeListRespData struct { + Items []*Employee `json:"items,omitempty"` + PageToken *string `json:"page_token,omitempty"` + HasMore *bool `json:"has_more,omitempty"` +} + +type EmployeeListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *EmployeeListRespData `json:"data"` +} diff --git a/v2/service/face_verify/v1/api.go b/v2/service/face_verify/v1/api.go new file mode 100644 index 00000000..1d027058 --- /dev/null +++ b/v2/service/face_verify/v1/api.go @@ -0,0 +1,65 @@ +// Package face_verify code generated by lark suite oapi sdk gen +package face_verify + +import ( + "context" + "net/http" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type FaceVerifyService struct { + FaceVerify *faceVerify +} + +func New(app *lark.App) *FaceVerifyService { + f := &FaceVerifyService{} + f.FaceVerify = &faceVerify{app: app} + return f +} + +type faceVerify struct { + app *lark.App +} + +func (f *faceVerify) CropFaceImage(ctx context.Context, req *FaceVerifyCropFaceImageReq, options ...lark.RequestOptionFunc) (*FaceVerifyCropFaceImageResp, error) { + options = append(options, lark.WithFileUpload()) + rawResp, err := f.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/face_verify/v1/crop_face_image", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &FaceVerifyCropFaceImageResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (f *faceVerify) QueryAuthResult(ctx context.Context, req *FaceVerifyQueryAuthResultReq, options ...lark.RequestOptionFunc) (*FaceVerifyQueryAuthResultResp, error) { + rawResp, err := f.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/face_verify/v1/query_auth_result", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &FaceVerifyQueryAuthResultResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (f *faceVerify) UploadFaceImage(ctx context.Context, req *FaceVerifyUploadFaceImageReq, options ...lark.RequestOptionFunc) (*FaceVerifyUploadFaceImageResp, error) { + options = append(options, lark.WithFileUpload()) + rawResp, err := f.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/face_verify/v1/upload_face_image", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &FaceVerifyUploadFaceImageResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} diff --git a/v2/service/face_verify/v1/model.go b/v2/service/face_verify/v1/model.go new file mode 100644 index 00000000..6b0c8cb3 --- /dev/null +++ b/v2/service/face_verify/v1/model.go @@ -0,0 +1,63 @@ +// Package face_verify code generated by lark suite oapi sdk gen +package face_verify + +import ( + "io" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type FaceVerifyCropFaceImageReqBody struct { + RawImage io.Reader `json:"raw_image,omitempty"` +} + +type FaceVerifyCropFaceImageReq struct { + Body *FaceVerifyCropFaceImageReqBody `body:""` +} + +type FaceVerifyCropFaceImageRespData struct { + FaceImage *string `json:"face_image,omitempty"` +} + +type FaceVerifyCropFaceImageResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *FaceVerifyCropFaceImageRespData `json:"data"` +} + +type FaceVerifyQueryAuthResultReq struct { + ReqOrderNo *string `query:"req_order_no"` + OpenId *string `query:"open_id"` + EmployeeId *string `query:"employee_id"` +} + +type FaceVerifyQueryAuthResultRespData struct { + AuthState *int `json:"auth_state,omitempty"` + AuthTimpstamp *int `json:"auth_timpstamp,omitempty"` +} + +type FaceVerifyQueryAuthResultResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *FaceVerifyQueryAuthResultRespData `json:"data"` +} + +type FaceVerifyUploadFaceImageReqBody struct { + Image io.Reader `json:"image,omitempty"` +} + +type FaceVerifyUploadFaceImageReq struct { + OpenId *string `query:"open_id"` + EmployeeId *string `query:"employee_id"` + Body *FaceVerifyUploadFaceImageReqBody `body:""` +} + +type FaceVerifyUploadFaceImageRespData struct { + FaceUid *string `json:"face_uid,omitempty"` +} + +type FaceVerifyUploadFaceImageResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *FaceVerifyUploadFaceImageRespData `json:"data"` +} diff --git a/v2/service/human_authentication/v1/api.go b/v2/service/human_authentication/v1/api.go new file mode 100644 index 00000000..e4c46cc2 --- /dev/null +++ b/v2/service/human_authentication/v1/api.go @@ -0,0 +1,37 @@ +// Package human_authentication code generated by lark suite oapi sdk gen +package human_authentication + +import ( + "context" + "net/http" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type HumanAuthenticationService struct { + Identities *identities +} + +func New(app *lark.App) *HumanAuthenticationService { + h := &HumanAuthenticationService{} + h.Identities = &identities{app: app} + return h +} + +type identities struct { + app *lark.App +} + +func (i *identities) Create(ctx context.Context, req *IdentityCreateReq, options ...lark.RequestOptionFunc) (*IdentityCreateResp, error) { + rawResp, err := i.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/human_authentication/v1/identities", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &IdentityCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} diff --git a/v2/service/human_authentication/v1/model.go b/v2/service/human_authentication/v1/model.go new file mode 100644 index 00000000..f7572c25 --- /dev/null +++ b/v2/service/human_authentication/v1/model.go @@ -0,0 +1,34 @@ +// Package human_authentication code generated by lark suite oapi sdk gen +package human_authentication + +import ( + "github.com/larksuite/oapi-sdk-go/v2" +) + +type Identity struct { + IdentityName *string `json:"identity_name,omitempty"` + IdentityCode *string `json:"identity_code,omitempty"` + Mobile *string `json:"mobile,omitempty"` +} + +type IdentityCreateReqBody struct { + IdentityName *string `json:"identity_name,omitempty"` + IdentityCode *string `json:"identity_code,omitempty"` + Mobile *string `json:"mobile,omitempty"` +} + +type IdentityCreateReq struct { + UserId *string `query:"user_id"` + UserIdType *string `query:"user_id_type"` + Body *IdentityCreateReqBody `body:""` +} + +type IdentityCreateRespData struct { + VerifyUid *string `json:"verify_uid,omitempty"` +} + +type IdentityCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *IdentityCreateRespData `json:"data"` +} diff --git a/v2/service/im/v1/api.go b/v2/service/im/v1/api.go new file mode 100644 index 00000000..8bbc2ce8 --- /dev/null +++ b/v2/service/im/v1/api.go @@ -0,0 +1,410 @@ +// Package im code generated by lark suite oapi sdk gen +package im + +import ( + "bytes" + "context" + "net/http" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type ImService struct { + Messages *messages + Chats *chats + ChatMemberUsers *chatMemberUsers + ChatMemberBots *chatMemberBots + ChatAnnouncement *chatAnnouncement + ChatMembers *chatMembers + Files *files + Images *images + Resources *resources +} + +func New(app *lark.App) *ImService { + i := &ImService{} + i.Messages = &messages{app: app} + i.Chats = &chats{app: app} + i.ChatMemberUsers = &chatMemberUsers{app: app} + i.ChatMemberBots = &chatMemberBots{app: app} + i.ChatAnnouncement = &chatAnnouncement{app: app} + i.ChatMembers = &chatMembers{app: app} + i.Files = &files{app: app} + i.Images = &images{app: app} + i.Resources = &resources{app: app} + return i +} + +type messages struct { + app *lark.App +} +type chats struct { + app *lark.App +} +type chatMemberUsers struct { + app *lark.App +} +type chatMemberBots struct { + app *lark.App +} +type chatAnnouncement struct { + app *lark.App +} +type chatMembers struct { + app *lark.App +} +type files struct { + app *lark.App +} +type images struct { + app *lark.App +} +type resources struct { + app *lark.App +} + +func (c *chats) Update(ctx context.Context, req *ChatUpdateReq, options ...lark.RequestOptionFunc) (*ChatUpdateResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPut, + "/open-apis/im/v1/chats/:chat_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &ChatUpdateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *chats) List(ctx context.Context, req *ChatListReq, options ...lark.RequestOptionFunc) (*ChatListResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/im/v1/chats", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &ChatListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *chats) Delete(ctx context.Context, req *ChatDeleteReq, options ...lark.RequestOptionFunc) (*ChatDeleteResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/im/v1/chats/:chat_id", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &ChatDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *chats) Get(ctx context.Context, req *ChatGetReq, options ...lark.RequestOptionFunc) (*ChatGetResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/im/v1/chats/:chat_id", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &ChatGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *chats) Create(ctx context.Context, req *ChatCreateReq, options ...lark.RequestOptionFunc) (*ChatCreateResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/im/v1/chats", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &ChatCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *chats) Search(ctx context.Context, req *ChatSearchReq, options ...lark.RequestOptionFunc) (*ChatSearchResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/im/v1/chats/search", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &ChatSearchResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *chatAnnouncement) Get(ctx context.Context, req *ChatAnnouncementGetReq, options ...lark.RequestOptionFunc) (*ChatAnnouncementGetResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/im/v1/chats/:chat_id/announcement", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &ChatAnnouncementGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *chatAnnouncement) Patch(ctx context.Context, req *ChatAnnouncementPatchReq, options ...lark.RequestOptionFunc) (*ChatAnnouncementPatchResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPatch, + "/open-apis/im/v1/chats/:chat_id/announcement", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &ChatAnnouncementPatchResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *chatMembers) Create(ctx context.Context, req *ChatMembersCreateReq, options ...lark.RequestOptionFunc) (*ChatMembersCreateResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/im/v1/chats/:chat_id/members", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &ChatMembersCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *chatMembers) Delete(ctx context.Context, req *ChatMembersDeleteReq, options ...lark.RequestOptionFunc) (*ChatMembersDeleteResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/im/v1/chats/:chat_id/members", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &ChatMembersDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *chatMembers) Get(ctx context.Context, req *ChatMembersGetReq, options ...lark.RequestOptionFunc) (*ChatMembersGetResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/im/v1/chats/:chat_id/members", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &ChatMembersGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *chatMembers) IsInChat(ctx context.Context, req *ChatMembersIsInChatReq, options ...lark.RequestOptionFunc) (*ChatMembersIsInChatResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/im/v1/chats/:chat_id/members/is_in_chat", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &ChatMembersIsInChatResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *chatMembers) MeJoin(ctx context.Context, req *ChatMembersMeJoinReq, options ...lark.RequestOptionFunc) (*ChatMembersMeJoinResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPatch, + "/open-apis/im/v1/chats/:chat_id/members/me_join", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &ChatMembersMeJoinResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (f *files) Create(ctx context.Context, req *FileCreateReq, options ...lark.RequestOptionFunc) (*FileCreateResp, error) { + options = append(options, lark.WithFileUpload()) + rawResp, err := f.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/im/v1/files", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &FileCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (f *files) Get(ctx context.Context, req *FileGetReq, options ...lark.RequestOptionFunc) (*FileGetResp, error) { + options = append(options, lark.WithFileDownload()) + rawResp, err := f.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/im/v1/files/:file_key", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &FileGetResp{RawResponse: rawResp} + if rawResp.StatusCode == http.StatusOK { + resp.File = bytes.NewBuffer(rawResp.RawBody) + resp.FileName = lark.FileNameByHeader(rawResp.Header) + return resp, err + } + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (i *images) Create(ctx context.Context, req *ImageCreateReq, options ...lark.RequestOptionFunc) (*ImageCreateResp, error) { + options = append(options, lark.WithFileUpload()) + rawResp, err := i.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/im/v1/images", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &ImageCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (i *images) Get(ctx context.Context, req *ImageGetReq, options ...lark.RequestOptionFunc) (*ImageGetResp, error) { + options = append(options, lark.WithFileDownload()) + rawResp, err := i.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/im/v1/images/:image_key", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &ImageGetResp{RawResponse: rawResp} + if rawResp.StatusCode == http.StatusOK { + resp.File = bytes.NewBuffer(rawResp.RawBody) + resp.FileName = lark.FileNameByHeader(rawResp.Header) + return resp, err + } + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *messages) List(ctx context.Context, req *MessageListReq, options ...lark.RequestOptionFunc) (*MessageListResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/im/v1/messages", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MessageListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *messages) Patch(ctx context.Context, req *MessagePatchReq, options ...lark.RequestOptionFunc) (*MessagePatchResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPatch, + "/open-apis/im/v1/messages/:message_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &MessagePatchResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *messages) Reply(ctx context.Context, req *MessageReplyReq, options ...lark.RequestOptionFunc) (*MessageReplyResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/im/v1/messages/:message_id/reply", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MessageReplyResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *messages) Create(ctx context.Context, req *MessageCreateReq, options ...lark.RequestOptionFunc) (*MessageCreateResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/im/v1/messages", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MessageCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *messages) Delete(ctx context.Context, req *MessageDeleteReq, options ...lark.RequestOptionFunc) (*MessageDeleteResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/im/v1/messages/:message_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant, lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &MessageDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *messages) ReadUsers(ctx context.Context, req *MessageReadUsersReq, options ...lark.RequestOptionFunc) (*MessageReadUsersResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/im/v1/messages/:message_id/read_users", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MessageReadUsersResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *messages) Get(ctx context.Context, req *MessageGetReq, options ...lark.RequestOptionFunc) (*MessageGetResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/im/v1/messages/:message_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MessageGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (r *resources) Get(ctx context.Context, req *MessageResourceGetReq, options ...lark.RequestOptionFunc) (*MessageResourceGetResp, error) { + options = append(options, lark.WithFileDownload()) + rawResp, err := r.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/im/v1/messages/:message_id/resources/:file_key", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MessageResourceGetResp{RawResponse: rawResp} + if rawResp.StatusCode == http.StatusOK { + resp.File = bytes.NewBuffer(rawResp.RawBody) + resp.FileName = lark.FileNameByHeader(rawResp.Header) + return resp, err + } + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} diff --git a/v2/service/im/v1/event.go b/v2/service/im/v1/event.go new file mode 100644 index 00000000..1bf2e774 --- /dev/null +++ b/v2/service/im/v1/event.go @@ -0,0 +1,151 @@ +// Package im code generated by lark suite oapi sdk gen +package im + +import ( + "context" + "github.com/larksuite/oapi-sdk-go/v2" +) + +type chatUpdatedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *ChatUpdatedEvent) error +} + +func (h *chatUpdatedEventHandler) Event() interface{} { + return &ChatUpdatedEvent{} +} + +func (h *chatUpdatedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*ChatUpdatedEvent)) +} + +func (c *chats) UpdatedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *ChatUpdatedEvent) error) { + c.app.Webhook.EventHandler("updated", &chatUpdatedEventHandler{handler: handler}) +} + +type chatDisbandedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *ChatDisbandedEvent) error +} + +func (h *chatDisbandedEventHandler) Event() interface{} { + return &ChatDisbandedEvent{} +} + +func (h *chatDisbandedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*ChatDisbandedEvent)) +} + +func (c *chats) DisbandedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *ChatDisbandedEvent) error) { + c.app.Webhook.EventHandler("disbanded", &chatDisbandedEventHandler{handler: handler}) +} + +type chatMemberBotAddedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *ChatMemberBotAddedEvent) error +} + +func (h *chatMemberBotAddedEventHandler) Event() interface{} { + return &ChatMemberBotAddedEvent{} +} + +func (h *chatMemberBotAddedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*ChatMemberBotAddedEvent)) +} + +func (c *chatMemberBots) AddedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *ChatMemberBotAddedEvent) error) { + c.app.Webhook.EventHandler("added", &chatMemberBotAddedEventHandler{handler: handler}) +} + +type chatMemberBotDeletedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *ChatMemberBotDeletedEvent) error +} + +func (h *chatMemberBotDeletedEventHandler) Event() interface{} { + return &ChatMemberBotDeletedEvent{} +} + +func (h *chatMemberBotDeletedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*ChatMemberBotDeletedEvent)) +} + +func (c *chatMemberBots) DeletedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *ChatMemberBotDeletedEvent) error) { + c.app.Webhook.EventHandler("deleted", &chatMemberBotDeletedEventHandler{handler: handler}) +} + +type chatMemberUserAddedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *ChatMemberUserAddedEvent) error +} + +func (h *chatMemberUserAddedEventHandler) Event() interface{} { + return &ChatMemberUserAddedEvent{} +} + +func (h *chatMemberUserAddedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*ChatMemberUserAddedEvent)) +} + +func (c *chatMemberUsers) AddedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *ChatMemberUserAddedEvent) error) { + c.app.Webhook.EventHandler("added", &chatMemberUserAddedEventHandler{handler: handler}) +} + +type chatMemberUserWithdrawnEventHandler struct { + handler func(context.Context, *lark.RawRequest, *ChatMemberUserWithdrawnEvent) error +} + +func (h *chatMemberUserWithdrawnEventHandler) Event() interface{} { + return &ChatMemberUserWithdrawnEvent{} +} + +func (h *chatMemberUserWithdrawnEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*ChatMemberUserWithdrawnEvent)) +} + +func (c *chatMemberUsers) WithdrawnEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *ChatMemberUserWithdrawnEvent) error) { + c.app.Webhook.EventHandler("withdrawn", &chatMemberUserWithdrawnEventHandler{handler: handler}) +} + +type chatMemberUserDeletedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *ChatMemberUserDeletedEvent) error +} + +func (h *chatMemberUserDeletedEventHandler) Event() interface{} { + return &ChatMemberUserDeletedEvent{} +} + +func (h *chatMemberUserDeletedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*ChatMemberUserDeletedEvent)) +} + +func (c *chatMemberUsers) DeletedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *ChatMemberUserDeletedEvent) error) { + c.app.Webhook.EventHandler("deleted", &chatMemberUserDeletedEventHandler{handler: handler}) +} + +type messageReceiveEventHandler struct { + handler func(context.Context, *lark.RawRequest, *MessageReceiveEvent) error +} + +func (h *messageReceiveEventHandler) Event() interface{} { + return &MessageReceiveEvent{} +} + +func (h *messageReceiveEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*MessageReceiveEvent)) +} + +func (m *messages) ReceiveEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *MessageReceiveEvent) error) { + m.app.Webhook.EventHandler("receive", &messageReceiveEventHandler{handler: handler}) +} + +type messageMessageReadEventHandler struct { + handler func(context.Context, *lark.RawRequest, *MessageMessageReadEvent) error +} + +func (h *messageMessageReadEventHandler) Event() interface{} { + return &MessageMessageReadEvent{} +} + +func (h *messageMessageReadEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*MessageMessageReadEvent)) +} + +func (m *messages) MessageReadEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *MessageMessageReadEvent) error) { + m.app.Webhook.EventHandler("message_read", &messageMessageReadEventHandler{handler: handler}) +} diff --git a/v2/service/im/v1/model.go b/v2/service/im/v1/model.go new file mode 100644 index 00000000..2a63e55a --- /dev/null +++ b/v2/service/im/v1/model.go @@ -0,0 +1,767 @@ +// Package im code generated by lark suite oapi sdk gen +package im + +import ( + "io" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type UserId struct { + UserId *string `json:"user_id,omitempty"` + OpenId *string `json:"open_id,omitempty"` + UnionId *string `json:"union_id,omitempty"` +} + +type Chat struct { + ChatId *string `json:"chat_id,omitempty"` + Avatar *string `json:"avatar,omitempty"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + I18nNames *I18nNames `json:"i18n_names,omitempty"` + OnlyOwnerAdd *bool `json:"only_owner_add,omitempty"` + ShareAllowed *bool `json:"share_allowed,omitempty"` + OnlyOwnerAtAll *bool `json:"only_owner_at_all,omitempty"` + OnlyOwnerEdit *bool `json:"only_owner_edit,omitempty"` + OwnerUserId *string `json:"owner_user_id,omitempty"` + Type *string `json:"type,omitempty"` +} + +type ChatMember struct { + UserId *string `json:"user_id,omitempty"` +} + +type ChatMemberBot struct { + BotId *string `json:"bot_id,omitempty"` +} + +type ChatMemberUser struct { + Name *string `json:"name,omitempty"` + TenantKey *string `json:"tenant_key,omitempty"` + UserId *UserId `json:"user_id,omitempty"` +} + +type ChatMembers struct { + UserId *string `json:"user_id,omitempty"` +} + +type ChatChange struct { + Avatar *string `json:"avatar,omitempty"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + I18nNames *I18nNames `json:"i18n_names,omitempty"` + AddMemberPermission *string `json:"add_member_permission,omitempty"` + ShareCardPermission *string `json:"share_card_permission,omitempty"` + AtAllPermission *string `json:"at_all_permission,omitempty"` + EditPermission *string `json:"edit_permission,omitempty"` + MembershipApproval *string `json:"membership_approval,omitempty"` + JoinMessageVisibility *string `json:"join_message_visibility,omitempty"` + LeaveMessageVisibility *string `json:"leave_message_visibility,omitempty"` + ModerationPermission *string `json:"moderation_permission,omitempty"` + OwnerId *UserId `json:"owner_id,omitempty"` +} + +type Emoji struct { + EmojiType *string `json:"emoji_type,omitempty"` +} + +type EventMessage struct { + MessageId *string `json:"message_id,omitempty"` + RootId *string `json:"root_id,omitempty"` + ParentId *string `json:"parent_id,omitempty"` + CreateTime *int64 `json:"create_time,omitempty,string"` + ChatId *string `json:"chat_id,omitempty"` + ChatType *string `json:"chat_type,omitempty"` + MessageType *string `json:"message_type,omitempty"` + Content *string `json:"content,omitempty"` + Mentions []*MentionEvent `json:"mentions,omitempty"` +} + +type EventMessageReader struct { + ReaderId *UserId `json:"reader_id,omitempty"` + ReadTime *string `json:"read_time,omitempty"` + TenantKey *string `json:"tenant_key,omitempty"` +} + +type EventSender struct { + SenderId *UserId `json:"sender_id,omitempty"` + SenderType *string `json:"sender_type,omitempty"` + TenantKey *string `json:"tenant_key,omitempty"` +} + +type I18nNames struct { + ZhCn *string `json:"zh_cn,omitempty"` + EnUs *string `json:"en_us,omitempty"` + JaJp *string `json:"ja_jp,omitempty"` +} + +type ListChat struct { + ChatId *string `json:"chat_id,omitempty"` + Avatar *string `json:"avatar,omitempty"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + OwnerId *string `json:"owner_id,omitempty"` + OwnerIdType *string `json:"owner_id_type,omitempty"` + External *bool `json:"external,omitempty"` + TenantKey *string `json:"tenant_key,omitempty"` +} + +type ListEventModerator struct { + TenantKey *string `json:"tenant_key,omitempty"` + UserId *UserId `json:"user_id,omitempty"` +} + +type ListMember struct { + MemberIdType *string `json:"member_id_type,omitempty"` + MemberId *string `json:"member_id,omitempty"` + Name *string `json:"name,omitempty"` + TenantKey *string `json:"tenant_key,omitempty"` +} + +type ListModerator struct { + UserIdType *string `json:"user_id_type,omitempty"` + UserId *string `json:"user_id,omitempty"` + TenantKey *string `json:"tenant_key,omitempty"` +} + +type Mention struct { + Key *string `json:"key,omitempty"` + Id *string `json:"id,omitempty"` + IdType *string `json:"id_type,omitempty"` + Name *string `json:"name,omitempty"` + TenantKey *string `json:"tenant_key,omitempty"` +} + +type MentionEvent struct { + Key *string `json:"key,omitempty"` + Id *UserId `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + TenantKey *string `json:"tenant_key,omitempty"` +} + +type Message struct { + MessageId *string `json:"message_id,omitempty"` + RootId *string `json:"root_id,omitempty"` + ParentId *string `json:"parent_id,omitempty"` + MsgType *string `json:"msg_type,omitempty"` + CreateTime *int64 `json:"create_time,omitempty,string"` + UpdateTime *int64 `json:"update_time,omitempty,string"` + Deleted *bool `json:"deleted,omitempty"` + Updated *bool `json:"updated,omitempty"` + ChatId *string `json:"chat_id,omitempty"` + Sender *Sender `json:"sender,omitempty"` + Body *MessageBody `json:"body,omitempty"` + Mentions []*Mention `json:"mentions,omitempty"` + UpperMessageId *string `json:"upper_message_id,omitempty"` +} + +type MessageBody struct { + Content *string `json:"content,omitempty"` +} + +type ModeratorList struct { + AddedMemberList []*ListEventModerator `json:"added_member_list,omitempty"` + RemovedMemberList []*ListEventModerator `json:"removed_member_list,omitempty"` +} + +type Operator struct { + OperatorId *string `json:"operator_id,omitempty"` + OperatorType *string `json:"operator_type,omitempty"` +} + +type ReadUser struct { + UserIdType *string `json:"user_id_type,omitempty"` + UserId *string `json:"user_id,omitempty"` + Timestamp *string `json:"timestamp,omitempty"` + TenantKey *string `json:"tenant_key,omitempty"` +} + +type Sender struct { + Id *string `json:"id,omitempty"` + IdType *string `json:"id_type,omitempty"` + SenderType *string `json:"sender_type,omitempty"` + TenantKey *string `json:"tenant_key,omitempty"` +} + +type UrgentReceivers struct { + UserIdList []string `json:"user_id_list,omitempty"` +} + +type ChatManagers struct { + ManagerId *int64 `json:"manager_id,omitempty,string"` +} + +type MessageReaction struct { + ReactionId *string `json:"reaction_id,omitempty"` + Operator *Operator `json:"operator,omitempty"` + ActionTime *int64 `json:"action_time,omitempty,string"` + ReactionType *Emoji `json:"reaction_type,omitempty"` +} + +type ChatUpdateReqBody struct { + Avatar *string `json:"avatar,omitempty"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + I18nNames *I18nNames `json:"i18n_names,omitempty"` + AddMemberPermission *string `json:"add_member_permission,omitempty"` + ShareCardPermission *string `json:"share_card_permission,omitempty"` + AtAllPermission *string `json:"at_all_permission,omitempty"` + EditPermission *string `json:"edit_permission,omitempty"` + OwnerId *string `json:"owner_id,omitempty"` + JoinMessageVisibility *string `json:"join_message_visibility,omitempty"` + LeaveMessageVisibility *string `json:"leave_message_visibility,omitempty"` + MembershipApproval *string `json:"membership_approval,omitempty"` +} + +type ChatUpdateReq struct { + ChatId string `path:"chat_id"` + UserIdType *string `query:"user_id_type"` + Body *ChatUpdateReqBody `body:""` +} + +type ChatUpdateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type ChatListReq struct { + UserIdType *string `query:"user_id_type"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type ChatListRespData struct { + Items []*ListChat `json:"items,omitempty"` + PageToken *string `json:"page_token,omitempty"` + HasMore *bool `json:"has_more,omitempty"` +} + +type ChatListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *ChatListRespData `json:"data"` +} + +type ChatDeleteReq struct { + ChatId string `path:"chat_id"` +} + +type ChatDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type ChatGetReq struct { + ChatId string `path:"chat_id"` + UserIdType *string `query:"user_id_type"` +} + +type ChatGetRespData struct { + Avatar *string `json:"avatar,omitempty"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + I18nNames *I18nNames `json:"i18n_names,omitempty"` + AddMemberPermission *string `json:"add_member_permission,omitempty"` + ShareCardPermission *string `json:"share_card_permission,omitempty"` + AtAllPermission *string `json:"at_all_permission,omitempty"` + EditPermission *string `json:"edit_permission,omitempty"` + OwnerIdType *string `json:"owner_id_type,omitempty"` + OwnerId *string `json:"owner_id,omitempty"` + ChatMode *string `json:"chat_mode,omitempty"` + ChatType *string `json:"chat_type,omitempty"` + ChatTag *string `json:"chat_tag,omitempty"` + JoinMessageVisibility *string `json:"join_message_visibility,omitempty"` + LeaveMessageVisibility *string `json:"leave_message_visibility,omitempty"` + MembershipApproval *string `json:"membership_approval,omitempty"` + ModerationPermission *string `json:"moderation_permission,omitempty"` + External *bool `json:"external,omitempty"` + TenantKey *string `json:"tenant_key,omitempty"` +} + +type ChatGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *ChatGetRespData `json:"data"` +} + +type ChatCreateReqBody struct { + Avatar *string `json:"avatar,omitempty"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + I18nNames *I18nNames `json:"i18n_names,omitempty"` + OwnerId *string `json:"owner_id,omitempty"` + ChatMode *string `json:"chat_mode,omitempty"` + ChatType *string `json:"chat_type,omitempty"` + External *bool `json:"external,omitempty"` + JoinMessageVisibility *string `json:"join_message_visibility,omitempty"` + LeaveMessageVisibility *string `json:"leave_message_visibility,omitempty"` + MembershipApproval *string `json:"membership_approval,omitempty"` +} + +type ChatCreateReq struct { + UserIdType *string `query:"user_id_type"` + Body *ChatCreateReqBody `body:""` +} + +type ChatCreateRespData struct { + ChatId *string `json:"chat_id,omitempty"` + Avatar *string `json:"avatar,omitempty"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + I18nNames *I18nNames `json:"i18n_names,omitempty"` + OwnerId *string `json:"owner_id,omitempty"` + OwnerIdType *string `json:"owner_id_type,omitempty"` + AddMemberPermission *string `json:"add_member_permission,omitempty"` + ShareCardPermission *string `json:"share_card_permission,omitempty"` + AtAllPermission *string `json:"at_all_permission,omitempty"` + EditPermission *string `json:"edit_permission,omitempty"` + ChatMode *string `json:"chat_mode,omitempty"` + ChatType *string `json:"chat_type,omitempty"` + ChatTag *string `json:"chat_tag,omitempty"` + External *bool `json:"external,omitempty"` + TenantKey *string `json:"tenant_key,omitempty"` + JoinMessageVisibility *string `json:"join_message_visibility,omitempty"` + LeaveMessageVisibility *string `json:"leave_message_visibility,omitempty"` + MembershipApproval *string `json:"membership_approval,omitempty"` + ModerationPermission *string `json:"moderation_permission,omitempty"` +} + +type ChatCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *ChatCreateRespData `json:"data"` +} + +type ChatSearchReq struct { + UserIdType *string `query:"user_id_type"` + Query *string `query:"query"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type ChatSearchRespData struct { + Items []*ListChat `json:"items,omitempty"` + PageToken *string `json:"page_token,omitempty"` + HasMore *bool `json:"has_more,omitempty"` +} + +type ChatSearchResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *ChatSearchRespData `json:"data"` +} + +type ChatAnnouncementGetReq struct { + ChatId string `path:"chat_id"` + UserIdType *string `query:"user_id_type"` +} + +type ChatAnnouncementGetRespData struct { + Content *string `json:"content,omitempty"` + Revision *string `json:"revision,omitempty"` + CreateTime *string `json:"create_time,omitempty"` + UpdateTime *string `json:"update_time,omitempty"` + OwnerIdType *string `json:"owner_id_type,omitempty"` + OwnerId *string `json:"owner_id,omitempty"` + ModifierIdType *string `json:"modifier_id_type,omitempty"` + ModifierId *string `json:"modifier_id,omitempty"` +} + +type ChatAnnouncementGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *ChatAnnouncementGetRespData `json:"data"` +} + +type ChatAnnouncementPatchReqBody struct { + Revision *string `json:"revision,omitempty"` + Requests []string `json:"requests,omitempty"` +} + +type ChatAnnouncementPatchReq struct { + ChatId string `path:"chat_id"` + Body *ChatAnnouncementPatchReqBody `body:""` +} + +type ChatAnnouncementPatchResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type ChatMembersCreateReqBody struct { + IdList []string `json:"id_list,omitempty"` +} + +type ChatMembersCreateReq struct { + ChatId string `path:"chat_id"` + MemberIdType *string `query:"member_id_type"` + Body *ChatMembersCreateReqBody `body:""` +} + +type ChatMembersCreateRespData struct { + InvalidIdList []string `json:"invalid_id_list,omitempty"` +} + +type ChatMembersCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *ChatMembersCreateRespData `json:"data"` +} + +type ChatMembersDeleteReqBody struct { + IdList []string `json:"id_list,omitempty"` +} + +type ChatMembersDeleteReq struct { + ChatId string `path:"chat_id"` + MemberIdType *string `query:"member_id_type"` + Body *ChatMembersDeleteReqBody `body:""` +} + +type ChatMembersDeleteRespData struct { + InvalidIdList []string `json:"invalid_id_list,omitempty"` +} + +type ChatMembersDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *ChatMembersDeleteRespData `json:"data"` +} + +type ChatMembersGetReq struct { + ChatId string `path:"chat_id"` + MemberIdType *string `query:"member_id_type"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type ChatMembersGetRespData struct { + Items []*ListMember `json:"items,omitempty"` + PageToken *string `json:"page_token,omitempty"` + HasMore *bool `json:"has_more,omitempty"` + MemberTotal *int `json:"member_total,omitempty"` +} + +type ChatMembersGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *ChatMembersGetRespData `json:"data"` +} + +type ChatMembersIsInChatReq struct { + ChatId string `path:"chat_id"` +} + +type ChatMembersIsInChatRespData struct { + IsInChat *bool `json:"is_in_chat,omitempty"` +} + +type ChatMembersIsInChatResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *ChatMembersIsInChatRespData `json:"data"` +} + +type ChatMembersMeJoinReq struct { + ChatId string `path:"chat_id"` +} + +type ChatMembersMeJoinResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type FileCreateReqBody struct { + FileType *string `json:"file_type,omitempty"` + FileName *string `json:"file_name,omitempty"` + Duration *int `json:"duration,omitempty"` + File io.Reader `json:"file,omitempty"` +} + +type FileCreateReq struct { + Body *FileCreateReqBody `body:""` +} + +type FileCreateRespData struct { + FileKey *string `json:"file_key,omitempty"` +} + +type FileCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *FileCreateRespData `json:"data"` +} + +type FileGetReq struct { + FileKey string `path:"file_key"` +} + +type FileGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + File io.Reader `json:"-"` + FileName string `json:"-"` +} + +type ImageCreateReqBody struct { + ImageType *string `json:"image_type,omitempty"` + Image io.Reader `json:"image,omitempty"` +} + +type ImageCreateReq struct { + Body *ImageCreateReqBody `body:""` +} + +type ImageCreateRespData struct { + ImageKey *string `json:"image_key,omitempty"` +} + +type ImageCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *ImageCreateRespData `json:"data"` +} + +type ImageGetReq struct { + ImageKey string `path:"image_key"` +} + +type ImageGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + File io.Reader `json:"-"` + FileName string `json:"-"` +} + +type MessageListReq struct { + ContainerIdType *string `query:"container_id_type"` + ContainerId *string `query:"container_id"` + StartTime *string `query:"start_time"` + EndTime *string `query:"end_time"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type MessageListRespData struct { + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` + Items []*Message `json:"items,omitempty"` +} + +type MessageListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *MessageListRespData `json:"data"` +} + +type MessagePatchReqBody struct { + Content *string `json:"content,omitempty"` +} + +type MessagePatchReq struct { + MessageId string `path:"message_id"` + Body *MessagePatchReqBody `body:""` +} + +type MessagePatchResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type MessageReplyReqBody struct { + Content *string `json:"content,omitempty"` + MsgType *string `json:"msg_type,omitempty"` +} + +type MessageReplyReq struct { + MessageId string `path:"message_id"` + Body *MessageReplyReqBody `body:""` +} + +type MessageReplyResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *Message `json:"data"` +} + +type MessageCreateReqBody struct { + ReceiveId *string `json:"receive_id,omitempty"` + Content *string `json:"content,omitempty"` + MsgType *string `json:"msg_type,omitempty"` +} + +type MessageCreateReq struct { + ReceiveIdType *string `query:"receive_id_type"` + Body *MessageCreateReqBody `body:""` +} + +type MessageCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *Message `json:"data"` +} + +type MessageDeleteReq struct { + MessageId string `path:"message_id"` +} + +type MessageDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type MessageReadUsersReq struct { + MessageId string `path:"message_id"` + UserIdType *string `query:"user_id_type"` + PageSize *int `query:"page_size"` + PageToken *string `query:"page_token"` +} + +type MessageReadUsersRespData struct { + Items []*ReadUser `json:"items,omitempty"` + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type MessageReadUsersResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *MessageReadUsersRespData `json:"data"` +} + +type MessageGetReq struct { + MessageId string `path:"message_id"` +} + +type MessageGetRespData struct { + Items []*Message `json:"items,omitempty"` +} + +type MessageGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *MessageGetRespData `json:"data"` +} + +type MessageResourceGetReq struct { + MessageId string `path:"message_id"` + FileKey string `path:"file_key"` + Type *string `query:"type"` +} + +type MessageResourceGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + File io.Reader `json:"-"` + FileName string `json:"-"` +} + +type ChatUpdatedEventData struct { + ChatId *string `json:"chat_id,omitempty"` + OperatorId *UserId `json:"operator_id,omitempty"` + External *bool `json:"external,omitempty"` + OperatorTenantKey *string `json:"operator_tenant_key,omitempty"` + AfterChange *ChatChange `json:"after_change,omitempty"` + BeforeChange *ChatChange `json:"before_change,omitempty"` + ModeratorList *ModeratorList `json:"moderator_list,omitempty"` +} + +type ChatUpdatedEvent struct { + *lark.EventV2Base + Event *ChatUpdatedEventData `json:"event"` +} + +type ChatDisbandedEventData struct { + ChatId *string `json:"chat_id,omitempty"` + OperatorId *UserId `json:"operator_id,omitempty"` + External *bool `json:"external,omitempty"` + OperatorTenantKey *string `json:"operator_tenant_key,omitempty"` +} + +type ChatDisbandedEvent struct { + *lark.EventV2Base + Event *ChatDisbandedEventData `json:"event"` +} + +type ChatMemberBotAddedEventData struct { + ChatId *string `json:"chat_id,omitempty"` + OperatorId *UserId `json:"operator_id,omitempty"` + External *bool `json:"external,omitempty"` + OperatorTenantKey *string `json:"operator_tenant_key,omitempty"` +} + +type ChatMemberBotAddedEvent struct { + *lark.EventV2Base + Event *ChatMemberBotAddedEventData `json:"event"` +} + +type ChatMemberBotDeletedEventData struct { + ChatId *string `json:"chat_id,omitempty"` + OperatorId *UserId `json:"operator_id,omitempty"` + External *bool `json:"external,omitempty"` + OperatorTenantKey *string `json:"operator_tenant_key,omitempty"` +} + +type ChatMemberBotDeletedEvent struct { + *lark.EventV2Base + Event *ChatMemberBotDeletedEventData `json:"event"` +} + +type ChatMemberUserAddedEventData struct { + ChatId *string `json:"chat_id,omitempty"` + OperatorId *UserId `json:"operator_id,omitempty"` + External *bool `json:"external,omitempty"` + OperatorTenantKey *string `json:"operator_tenant_key,omitempty"` + Users []*ChatMemberUser `json:"users,omitempty"` +} + +type ChatMemberUserAddedEvent struct { + *lark.EventV2Base + Event *ChatMemberUserAddedEventData `json:"event"` +} + +type ChatMemberUserWithdrawnEventData struct { + ChatId *string `json:"chat_id,omitempty"` + OperatorId *UserId `json:"operator_id,omitempty"` + External *bool `json:"external,omitempty"` + OperatorTenantKey *string `json:"operator_tenant_key,omitempty"` + Users []*ChatMemberUser `json:"users,omitempty"` +} + +type ChatMemberUserWithdrawnEvent struct { + *lark.EventV2Base + Event *ChatMemberUserWithdrawnEventData `json:"event"` +} + +type ChatMemberUserDeletedEventData struct { + ChatId *string `json:"chat_id,omitempty"` + OperatorId *UserId `json:"operator_id,omitempty"` + External *bool `json:"external,omitempty"` + OperatorTenantKey *string `json:"operator_tenant_key,omitempty"` + Users []*ChatMemberUser `json:"users,omitempty"` +} + +type ChatMemberUserDeletedEvent struct { + *lark.EventV2Base + Event *ChatMemberUserDeletedEventData `json:"event"` +} + +type MessageReceiveEventData struct { + Sender *EventSender `json:"sender,omitempty"` + Message *EventMessage `json:"message,omitempty"` +} + +type MessageReceiveEvent struct { + *lark.EventV2Base + Event *MessageReceiveEventData `json:"event"` +} + +type MessageMessageReadEventData struct { + Reader *EventMessageReader `json:"reader,omitempty"` + MessageIdList []string `json:"message_id_list,omitempty"` +} + +type MessageMessageReadEvent struct { + *lark.EventV2Base + Event *MessageMessageReadEventData `json:"event"` +} diff --git a/v2/service/image/v4/api.go b/v2/service/image/v4/api.go new file mode 100644 index 00000000..568be120 --- /dev/null +++ b/v2/service/image/v4/api.go @@ -0,0 +1,58 @@ +// Package image code generated by lark suite oapi sdk gen +package image + +import ( + "bytes" + "context" + "net/http" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type ImageService struct { + Images *images +} + +func New(app *lark.App) *ImageService { + i := &ImageService{} + i.Images = &images{app: app} + return i +} + +type images struct { + app *lark.App +} + +func (i *images) Get(ctx context.Context, req *ImageGetReq, options ...lark.RequestOptionFunc) (*ImageGetResp, error) { + options = append(options, lark.WithFileDownload()) + rawResp, err := i.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/image/v4/get", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &ImageGetResp{RawResponse: rawResp} + if rawResp.StatusCode == http.StatusOK { + resp.File = bytes.NewBuffer(rawResp.RawBody) + resp.FileName = lark.FileNameByHeader(rawResp.Header) + return resp, err + } + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (i *images) Put(ctx context.Context, req *ImagePutReq, options ...lark.RequestOptionFunc) (*ImagePutResp, error) { + options = append(options, lark.WithFileUpload()) + rawResp, err := i.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/image/v4/put", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &ImagePutResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} diff --git a/v2/service/image/v4/model.go b/v2/service/image/v4/model.go new file mode 100644 index 00000000..fb0a9616 --- /dev/null +++ b/v2/service/image/v4/model.go @@ -0,0 +1,38 @@ +// Package image code generated by lark suite oapi sdk gen +package image + +import ( + "io" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type Image struct { + ImageKey *string `json:"image_key,omitempty"` +} + +type ImageGetReq struct { + ImageKey *string `query:"image_key"` +} + +type ImageGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + File io.Reader `json:"-"` + FileName string `json:"-"` +} + +type ImagePutReqBody struct { + Image io.Reader `json:"image,omitempty"` + ImageType *string `json:"image_type,omitempty"` +} + +type ImagePutReq struct { + Body *ImagePutReqBody `body:""` +} + +type ImagePutResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *Image `json:"data"` +} diff --git a/v2/service/mail/v1/api.go b/v2/service/mail/v1/api.go new file mode 100644 index 00000000..15aaedcd --- /dev/null +++ b/v2/service/mail/v1/api.go @@ -0,0 +1,356 @@ +// Package mail code generated by lark suite oapi sdk gen +package mail + +import ( + "context" + "net/http" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type MailService struct { + MailgroupMembers *mailgroupMembers + MailgroupPermissionMembers *mailgroupPermissionMembers + PublicMailboxes *publicMailboxes + PublicMailboxMembers *publicMailboxMembers + Mailgroups *mailgroups +} + +func New(app *lark.App) *MailService { + m := &MailService{} + m.MailgroupMembers = &mailgroupMembers{app: app} + m.MailgroupPermissionMembers = &mailgroupPermissionMembers{app: app} + m.PublicMailboxes = &publicMailboxes{app: app} + m.PublicMailboxMembers = &publicMailboxMembers{app: app} + m.Mailgroups = &mailgroups{app: app} + return m +} + +type mailgroupMembers struct { + app *lark.App +} +type mailgroupPermissionMembers struct { + app *lark.App +} +type publicMailboxes struct { + app *lark.App +} +type publicMailboxMembers struct { + app *lark.App +} +type mailgroups struct { + app *lark.App +} + +func (m *mailgroups) Get(ctx context.Context, req *MailgroupGetReq, options ...lark.RequestOptionFunc) (*MailgroupGetResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/mail/v1/mailgroups/:mailgroup_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MailgroupGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *mailgroups) Update(ctx context.Context, req *MailgroupUpdateReq, options ...lark.RequestOptionFunc) (*MailgroupUpdateResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPut, + "/open-apis/mail/v1/mailgroups/:mailgroup_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MailgroupUpdateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *mailgroups) Delete(ctx context.Context, req *MailgroupDeleteReq, options ...lark.RequestOptionFunc) (*MailgroupDeleteResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/mail/v1/mailgroups/:mailgroup_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MailgroupDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *mailgroups) Create(ctx context.Context, req *MailgroupCreateReq, options ...lark.RequestOptionFunc) (*MailgroupCreateResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/mail/v1/mailgroups", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MailgroupCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *mailgroups) List(ctx context.Context, req *MailgroupListReq, options ...lark.RequestOptionFunc) (*MailgroupListResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/mail/v1/mailgroups", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MailgroupListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *mailgroups) Patch(ctx context.Context, req *MailgroupPatchReq, options ...lark.RequestOptionFunc) (*MailgroupPatchResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPatch, + "/open-apis/mail/v1/mailgroups/:mailgroup_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MailgroupPatchResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *mailgroupMembers) List(ctx context.Context, req *MailgroupMemberListReq, options ...lark.RequestOptionFunc) (*MailgroupMemberListResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/mail/v1/mailgroups/:mailgroup_id/members", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MailgroupMemberListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *mailgroupMembers) Get(ctx context.Context, req *MailgroupMemberGetReq, options ...lark.RequestOptionFunc) (*MailgroupMemberGetResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/mail/v1/mailgroups/:mailgroup_id/members/:member_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MailgroupMemberGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *mailgroupMembers) Create(ctx context.Context, req *MailgroupMemberCreateReq, options ...lark.RequestOptionFunc) (*MailgroupMemberCreateResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/mail/v1/mailgroups/:mailgroup_id/members", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MailgroupMemberCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *mailgroupMembers) Delete(ctx context.Context, req *MailgroupMemberDeleteReq, options ...lark.RequestOptionFunc) (*MailgroupMemberDeleteResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/mail/v1/mailgroups/:mailgroup_id/members/:member_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MailgroupMemberDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *mailgroupPermissionMembers) Delete(ctx context.Context, req *MailgroupPermissionMemberDeleteReq, options ...lark.RequestOptionFunc) (*MailgroupPermissionMemberDeleteResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/mail/v1/mailgroups/:mailgroup_id/permission_members/:permission_member_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MailgroupPermissionMemberDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *mailgroupPermissionMembers) Get(ctx context.Context, req *MailgroupPermissionMemberGetReq, options ...lark.RequestOptionFunc) (*MailgroupPermissionMemberGetResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/mail/v1/mailgroups/:mailgroup_id/permission_members/:permission_member_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MailgroupPermissionMemberGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *mailgroupPermissionMembers) List(ctx context.Context, req *MailgroupPermissionMemberListReq, options ...lark.RequestOptionFunc) (*MailgroupPermissionMemberListResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/mail/v1/mailgroups/:mailgroup_id/permission_members", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MailgroupPermissionMemberListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *mailgroupPermissionMembers) Create(ctx context.Context, req *MailgroupPermissionMemberCreateReq, options ...lark.RequestOptionFunc) (*MailgroupPermissionMemberCreateResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/mail/v1/mailgroups/:mailgroup_id/permission_members", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MailgroupPermissionMemberCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (p *publicMailboxes) Update(ctx context.Context, req *PublicMailboxUpdateReq, options ...lark.RequestOptionFunc) (*PublicMailboxUpdateResp, error) { + rawResp, err := p.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPut, + "/open-apis/mail/v1/public_mailboxes/:public_mailbox_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &PublicMailboxUpdateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (p *publicMailboxes) List(ctx context.Context, req *PublicMailboxListReq, options ...lark.RequestOptionFunc) (*PublicMailboxListResp, error) { + rawResp, err := p.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/mail/v1/public_mailboxes", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &PublicMailboxListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (p *publicMailboxes) Create(ctx context.Context, req *PublicMailboxCreateReq, options ...lark.RequestOptionFunc) (*PublicMailboxCreateResp, error) { + rawResp, err := p.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/mail/v1/public_mailboxes", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &PublicMailboxCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (p *publicMailboxes) Get(ctx context.Context, req *PublicMailboxGetReq, options ...lark.RequestOptionFunc) (*PublicMailboxGetResp, error) { + rawResp, err := p.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/mail/v1/public_mailboxes/:public_mailbox_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &PublicMailboxGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (p *publicMailboxes) Patch(ctx context.Context, req *PublicMailboxPatchReq, options ...lark.RequestOptionFunc) (*PublicMailboxPatchResp, error) { + rawResp, err := p.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPatch, + "/open-apis/mail/v1/public_mailboxes/:public_mailbox_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &PublicMailboxPatchResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (p *publicMailboxMembers) Get(ctx context.Context, req *PublicMailboxMemberGetReq, options ...lark.RequestOptionFunc) (*PublicMailboxMemberGetResp, error) { + rawResp, err := p.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/mail/v1/public_mailboxes/:public_mailbox_id/members/:member_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &PublicMailboxMemberGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (p *publicMailboxMembers) Delete(ctx context.Context, req *PublicMailboxMemberDeleteReq, options ...lark.RequestOptionFunc) (*PublicMailboxMemberDeleteResp, error) { + rawResp, err := p.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/mail/v1/public_mailboxes/:public_mailbox_id/members/:member_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &PublicMailboxMemberDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (p *publicMailboxMembers) Clear(ctx context.Context, req *PublicMailboxMemberClearReq, options ...lark.RequestOptionFunc) (*PublicMailboxMemberClearResp, error) { + rawResp, err := p.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/mail/v1/public_mailboxes/:public_mailbox_id/members/clear", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &PublicMailboxMemberClearResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (p *publicMailboxMembers) List(ctx context.Context, req *PublicMailboxMemberListReq, options ...lark.RequestOptionFunc) (*PublicMailboxMemberListResp, error) { + rawResp, err := p.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/mail/v1/public_mailboxes/:public_mailbox_id/members", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &PublicMailboxMemberListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (p *publicMailboxMembers) Create(ctx context.Context, req *PublicMailboxMemberCreateReq, options ...lark.RequestOptionFunc) (*PublicMailboxMemberCreateResp, error) { + rawResp, err := p.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/mail/v1/public_mailboxes/:public_mailbox_id/members", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &PublicMailboxMemberCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} diff --git a/v2/service/mail/v1/model.go b/v2/service/mail/v1/model.go new file mode 100644 index 00000000..622db976 --- /dev/null +++ b/v2/service/mail/v1/model.go @@ -0,0 +1,345 @@ +// Package mail code generated by lark suite oapi sdk gen +package mail + +import ( + "github.com/larksuite/oapi-sdk-go/v2" +) + +type Mailgroup struct { + MailgroupId *string `json:"mailgroup_id,omitempty"` + Email *string `json:"email,omitempty"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + DirectMembersCount *string `json:"direct_members_count,omitempty"` + IncludeExternalMember *bool `json:"include_external_member,omitempty"` + IncludeAllCompanyMember *bool `json:"include_all_company_member,omitempty"` + WhoCanSendMail *string `json:"who_can_send_mail,omitempty"` +} + +type MailgroupMember struct { + MemberId *string `json:"member_id,omitempty"` + Email *string `json:"email,omitempty"` + UserId *string `json:"user_id,omitempty"` + DepartmentId *string `json:"department_id,omitempty"` + Type *string `json:"type,omitempty"` +} + +type MailgroupPermissionMember struct { + PermissionMemberId *string `json:"permission_member_id,omitempty"` + UserId *string `json:"user_id,omitempty"` + DepartmentId *string `json:"department_id,omitempty"` + Type *string `json:"type,omitempty"` +} + +type PublicMailbox struct { + PublicMailboxId *string `json:"public_mailbox_id,omitempty"` + Email *string `json:"email,omitempty"` + Name *string `json:"name,omitempty"` +} + +type PublicMailboxMember struct { + MemberId *string `json:"member_id,omitempty"` + UserId *string `json:"user_id,omitempty"` + Type *string `json:"type,omitempty"` +} + +type MailgroupGetReq struct { + MailgroupId string `path:"mailgroup_id"` +} + +type MailgroupGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *Mailgroup `json:"data"` +} + +type MailgroupUpdateReq struct { + MailgroupId string `path:"mailgroup_id"` + Mailgroup *Mailgroup `body:""` +} + +type MailgroupUpdateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *Mailgroup `json:"data"` +} + +type MailgroupDeleteReq struct { + MailgroupId string `path:"mailgroup_id"` +} + +type MailgroupDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type MailgroupCreateReq struct { + Mailgroup *Mailgroup `body:""` +} + +type MailgroupCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *Mailgroup `json:"data"` +} + +type MailgroupListReq struct { + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type MailgroupListRespData struct { + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` + Items []*Mailgroup `json:"items,omitempty"` +} + +type MailgroupListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *MailgroupListRespData `json:"data"` +} + +type MailgroupPatchReq struct { + MailgroupId string `path:"mailgroup_id"` + Mailgroup *Mailgroup `body:""` +} + +type MailgroupPatchResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *Mailgroup `json:"data"` +} + +type MailgroupMemberListReq struct { + MailgroupId string `path:"mailgroup_id"` + UserIdType *string `query:"user_id_type"` + DepartmentIdType *string `query:"department_id_type"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type MailgroupMemberListRespData struct { + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` + Items []*MailgroupMember `json:"items,omitempty"` +} + +type MailgroupMemberListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *MailgroupMemberListRespData `json:"data"` +} + +type MailgroupMemberGetReq struct { + MailgroupId string `path:"mailgroup_id"` + MemberId string `path:"member_id"` + UserIdType *string `query:"user_id_type"` + DepartmentIdType *string `query:"department_id_type"` +} + +type MailgroupMemberGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *MailgroupMember `json:"data"` +} + +type MailgroupMemberCreateReq struct { + MailgroupId string `path:"mailgroup_id"` + UserIdType *string `query:"user_id_type"` + DepartmentIdType *string `query:"department_id_type"` + MailgroupMember *MailgroupMember `body:""` +} + +type MailgroupMemberCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *MailgroupMember `json:"data"` +} + +type MailgroupMemberDeleteReq struct { + MailgroupId string `path:"mailgroup_id"` + MemberId string `path:"member_id"` +} + +type MailgroupMemberDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type MailgroupPermissionMemberDeleteReq struct { + MailgroupId string `path:"mailgroup_id"` + PermissionMemberId string `path:"permission_member_id"` +} + +type MailgroupPermissionMemberDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type MailgroupPermissionMemberGetReq struct { + MailgroupId string `path:"mailgroup_id"` + PermissionMemberId string `path:"permission_member_id"` + UserIdType *string `query:"user_id_type"` + DepartmentIdType *string `query:"department_id_type"` +} + +type MailgroupPermissionMemberGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *MailgroupPermissionMember `json:"data"` +} + +type MailgroupPermissionMemberListReq struct { + MailgroupId string `path:"mailgroup_id"` + UserIdType *string `query:"user_id_type"` + DepartmentIdType *string `query:"department_id_type"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type MailgroupPermissionMemberListRespData struct { + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` + Items []*MailgroupPermissionMember `json:"items,omitempty"` +} + +type MailgroupPermissionMemberListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *MailgroupPermissionMemberListRespData `json:"data"` +} + +type MailgroupPermissionMemberCreateReq struct { + MailgroupId string `path:"mailgroup_id"` + UserIdType *string `query:"user_id_type"` + DepartmentIdType *string `query:"department_id_type"` + MailgroupPermissionMember *MailgroupPermissionMember `body:""` +} + +type MailgroupPermissionMemberCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *MailgroupPermissionMember `json:"data"` +} + +type PublicMailboxUpdateReq struct { + PublicMailboxId string `path:"public_mailbox_id"` + PublicMailbox *PublicMailbox `body:""` +} + +type PublicMailboxUpdateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *PublicMailbox `json:"data"` +} + +type PublicMailboxListReq struct { + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type PublicMailboxListRespData struct { + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` + Items []*PublicMailbox `json:"items,omitempty"` +} + +type PublicMailboxListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *PublicMailboxListRespData `json:"data"` +} + +type PublicMailboxCreateReq struct { + PublicMailbox *PublicMailbox `body:""` +} + +type PublicMailboxCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *PublicMailbox `json:"data"` +} + +type PublicMailboxGetReq struct { + PublicMailboxId string `path:"public_mailbox_id"` +} + +type PublicMailboxGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *PublicMailbox `json:"data"` +} + +type PublicMailboxPatchReq struct { + PublicMailboxId string `path:"public_mailbox_id"` + PublicMailbox *PublicMailbox `body:""` +} + +type PublicMailboxPatchResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *PublicMailbox `json:"data"` +} + +type PublicMailboxMemberGetReq struct { + PublicMailboxId string `path:"public_mailbox_id"` + MemberId string `path:"member_id"` + UserIdType *string `query:"user_id_type"` +} + +type PublicMailboxMemberGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *PublicMailboxMember `json:"data"` +} + +type PublicMailboxMemberDeleteReq struct { + PublicMailboxId string `path:"public_mailbox_id"` + MemberId string `path:"member_id"` +} + +type PublicMailboxMemberDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type PublicMailboxMemberClearReq struct { + PublicMailboxId string `path:"public_mailbox_id"` +} + +type PublicMailboxMemberClearResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type PublicMailboxMemberListReq struct { + PublicMailboxId string `path:"public_mailbox_id"` + UserIdType *string `query:"user_id_type"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type PublicMailboxMemberListRespData struct { + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` + Items []*PublicMailboxMember `json:"items,omitempty"` +} + +type PublicMailboxMemberListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *PublicMailboxMemberListRespData `json:"data"` +} + +type PublicMailboxMemberCreateReq struct { + PublicMailboxId string `path:"public_mailbox_id"` + UserIdType *string `query:"user_id_type"` + PublicMailboxMember *PublicMailboxMember `body:""` +} + +type PublicMailboxMemberCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *PublicMailboxMember `json:"data"` +} diff --git a/v2/service/meeting_room/v1/api.go b/v2/service/meeting_room/v1/api.go new file mode 100644 index 00000000..804364d7 --- /dev/null +++ b/v2/service/meeting_room/v1/api.go @@ -0,0 +1,280 @@ +// Package meeting_room code generated by lark suite oapi sdk gen +package meeting_room + +import ( + "context" + "net/http" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type MeetingRoomService struct { + Building *building + Country *country + District *district + Freebusy *freebusy + Instance *instance + Room *room + Summary *summary + MeetingRooms *meetingRooms +} + +func New(app *lark.App) *MeetingRoomService { + m := &MeetingRoomService{} + m.Building = &building{app: app} + m.Country = &country{app: app} + m.District = &district{app: app} + m.Freebusy = &freebusy{app: app} + m.Instance = &instance{app: app} + m.Room = &room{app: app} + m.Summary = &summary{app: app} + m.MeetingRooms = &meetingRooms{app: app} + return m +} + +type building struct { + app *lark.App +} +type country struct { + app *lark.App +} +type district struct { + app *lark.App +} +type freebusy struct { + app *lark.App +} +type instance struct { + app *lark.App +} +type room struct { + app *lark.App +} +type summary struct { + app *lark.App +} +type meetingRooms struct { + app *lark.App +} + +func (b *building) BatchGet(ctx context.Context, req *BuildingBatchGetReq, options ...lark.RequestOptionFunc) (*BuildingBatchGetResp, error) { + rawResp, err := b.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/meeting_room/building/batch_get", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &BuildingBatchGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (b *building) BatchGetId(ctx context.Context, req *BuildingBatchGetIdReq, options ...lark.RequestOptionFunc) (*BuildingBatchGetIdResp, error) { + rawResp, err := b.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/meeting_room/building/batch_get_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &BuildingBatchGetIdResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (b *building) Create(ctx context.Context, req *BuildingCreateReq, options ...lark.RequestOptionFunc) (*BuildingCreateResp, error) { + rawResp, err := b.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/meeting_room/building/create", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &BuildingCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (b *building) Delete(ctx context.Context, req *BuildingDeleteReq, options ...lark.RequestOptionFunc) (*BuildingDeleteResp, error) { + rawResp, err := b.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/meeting_room/building/delete", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &BuildingDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (b *building) List(ctx context.Context, req *BuildingListReq, options ...lark.RequestOptionFunc) (*BuildingListResp, error) { + rawResp, err := b.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/meeting_room/building/list", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &BuildingListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (b *building) Update(ctx context.Context, req *BuildingUpdateReq, options ...lark.RequestOptionFunc) (*BuildingUpdateResp, error) { + rawResp, err := b.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/meeting_room/building/update", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &BuildingUpdateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *country) List(ctx context.Context, options ...lark.RequestOptionFunc) (*CountryListResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/meeting_room/country/list", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, nil, options...) + if err != nil { + return nil, err + } + resp := &CountryListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (d *district) List(ctx context.Context, req *DistrictListReq, options ...lark.RequestOptionFunc) (*DistrictListResp, error) { + rawResp, err := d.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/meeting_room/district/list", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &DistrictListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (f *freebusy) BatchGet(ctx context.Context, req *FreebusyBatchGetReq, options ...lark.RequestOptionFunc) (*FreebusyBatchGetResp, error) { + rawResp, err := f.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/meeting_room/freebusy/batch_get", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &FreebusyBatchGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (i *instance) Reply(ctx context.Context, req *InstanceReplyReq, options ...lark.RequestOptionFunc) (*InstanceReplyResp, error) { + rawResp, err := i.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/meeting_room/instance/reply", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &InstanceReplyResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (r *room) BatchGet(ctx context.Context, req *RoomBatchGetReq, options ...lark.RequestOptionFunc) (*RoomBatchGetResp, error) { + rawResp, err := r.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/meeting_room/room/batch_get", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &RoomBatchGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (r *room) BatchGetId(ctx context.Context, req *RoomBatchGetIdReq, options ...lark.RequestOptionFunc) (*RoomBatchGetIdResp, error) { + rawResp, err := r.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/meeting_room/room/batch_get_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &RoomBatchGetIdResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (r *room) Create(ctx context.Context, req *RoomCreateReq, options ...lark.RequestOptionFunc) (*RoomCreateResp, error) { + rawResp, err := r.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/meeting_room/room/create", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &RoomCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (r *room) Delete(ctx context.Context, req *RoomDeleteReq, options ...lark.RequestOptionFunc) (*RoomDeleteResp, error) { + rawResp, err := r.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/meeting_room/room/delete", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &RoomDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (r *room) List(ctx context.Context, req *RoomListReq, options ...lark.RequestOptionFunc) (*RoomListResp, error) { + rawResp, err := r.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/meeting_room/room/list", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &RoomListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (r *room) Update(ctx context.Context, req *RoomUpdateReq, options ...lark.RequestOptionFunc) (*RoomUpdateResp, error) { + rawResp, err := r.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/meeting_room/room/update", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &RoomUpdateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (s *summary) BatchGet(ctx context.Context, req *SummaryBatchGetReq, options ...lark.RequestOptionFunc) (*SummaryBatchGetResp, error) { + rawResp, err := s.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/meeting_room/summary/batch_get", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &SummaryBatchGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} diff --git a/v2/service/meeting_room/v1/event.go b/v2/service/meeting_room/v1/event.go new file mode 100644 index 00000000..c9c1769a --- /dev/null +++ b/v2/service/meeting_room/v1/event.go @@ -0,0 +1,135 @@ +// Package meeting_room code generated by lark suite oapi sdk gen +package meeting_room + +import ( + "context" + "github.com/larksuite/oapi-sdk-go/v2" +) + +type meetingRoomStatusChangedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *MeetingRoomStatusChangedEvent) error +} + +func (h *meetingRoomStatusChangedEventHandler) Event() interface{} { + return &MeetingRoomStatusChangedEvent{} +} + +func (h *meetingRoomStatusChangedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*MeetingRoomStatusChangedEvent)) +} + +func (m *meetingRooms) StatusChangedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *MeetingRoomStatusChangedEvent) error) { + m.app.Webhook.EventHandler("status_changed", &meetingRoomStatusChangedEventHandler{handler: handler}) +} + +type meetingRoomCreatedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *MeetingRoomCreatedEvent) error +} + +func (h *meetingRoomCreatedEventHandler) Event() interface{} { + return &MeetingRoomCreatedEvent{} +} + +func (h *meetingRoomCreatedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*MeetingRoomCreatedEvent)) +} + +func (m *meetingRooms) CreatedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *MeetingRoomCreatedEvent) error) { + m.app.Webhook.EventHandler("created", &meetingRoomCreatedEventHandler{handler: handler}) +} + +type meetingRoomDeletedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *MeetingRoomDeletedEvent) error +} + +func (h *meetingRoomDeletedEventHandler) Event() interface{} { + return &MeetingRoomDeletedEvent{} +} + +func (h *meetingRoomDeletedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*MeetingRoomDeletedEvent)) +} + +func (m *meetingRooms) DeletedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *MeetingRoomDeletedEvent) error) { + m.app.Webhook.EventHandler("deleted", &meetingRoomDeletedEventHandler{handler: handler}) +} + +type meetingRoomUpdatedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *MeetingRoomUpdatedEvent) error +} + +func (h *meetingRoomUpdatedEventHandler) Event() interface{} { + return &MeetingRoomUpdatedEvent{} +} + +func (h *meetingRoomUpdatedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*MeetingRoomUpdatedEvent)) +} + +func (m *meetingRooms) UpdatedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *MeetingRoomUpdatedEvent) error) { + m.app.Webhook.EventHandler("updated", &meetingRoomUpdatedEventHandler{handler: handler}) +} + +type roomCreatedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *RoomCreatedEvent) error +} + +func (h *roomCreatedEventHandler) Event() interface{} { + return &RoomCreatedEvent{} +} + +func (h *roomCreatedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*RoomCreatedEvent)) +} + +func (r *room) CreatedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *RoomCreatedEvent) error) { + r.app.Webhook.EventHandler("created", &roomCreatedEventHandler{handler: handler}) +} + +type roomDeletedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *RoomDeletedEvent) error +} + +func (h *roomDeletedEventHandler) Event() interface{} { + return &RoomDeletedEvent{} +} + +func (h *roomDeletedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*RoomDeletedEvent)) +} + +func (r *room) DeletedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *RoomDeletedEvent) error) { + r.app.Webhook.EventHandler("deleted", &roomDeletedEventHandler{handler: handler}) +} + +type roomStatusChangedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *RoomStatusChangedEvent) error +} + +func (h *roomStatusChangedEventHandler) Event() interface{} { + return &RoomStatusChangedEvent{} +} + +func (h *roomStatusChangedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*RoomStatusChangedEvent)) +} + +func (r *room) StatusChangedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *RoomStatusChangedEvent) error) { + r.app.Webhook.EventHandler("status_changed", &roomStatusChangedEventHandler{handler: handler}) +} + +type roomUpdatedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *RoomUpdatedEvent) error +} + +func (h *roomUpdatedEventHandler) Event() interface{} { + return &RoomUpdatedEvent{} +} + +func (h *roomUpdatedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*RoomUpdatedEvent)) +} + +func (r *room) UpdatedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *RoomUpdatedEvent) error) { + r.app.Webhook.EventHandler("updated", &roomUpdatedEventHandler{handler: handler}) +} diff --git a/v2/service/meeting_room/v1/model.go b/v2/service/meeting_room/v1/model.go new file mode 100644 index 00000000..d7bf5843 --- /dev/null +++ b/v2/service/meeting_room/v1/model.go @@ -0,0 +1,439 @@ +// Package meeting_room code generated by lark suite oapi sdk gen +package meeting_room + +import ( + "github.com/larksuite/oapi-sdk-go/v2" +) + +type Building struct { + BuildingId *string `json:"building_id,omitempty"` + Description *string `json:"description,omitempty"` + Floors []string `json:"floors,omitempty"` + Name *string `json:"name,omitempty"` +} + +type BuildingId struct { + BuildingId *string `json:"building_id,omitempty"` + CustomBuildingId *string `json:"custom_building_id,omitempty"` +} + +type Country struct { + CountryId *string `json:"country_id,omitempty"` + Name *string `json:"name,omitempty"` +} + +type District struct { + DistrictId *string `json:"district_id,omitempty"` + Name *string `json:"name,omitempty"` +} + +type ErrorEventUid struct { + Uid *string `json:"uid,omitempty"` + OriginalTime *int `json:"original_time,omitempty"` + ErrorMsg *string `json:"error_msg,omitempty"` +} + +type EventInfo struct { + Uid *string `json:"uid,omitempty"` + OriginalTime *int `json:"original_time,omitempty"` + Summary *string `json:"summary,omitempty"` +} + +type EventUid struct { + Uid *string `json:"uid,omitempty"` + OriginalTime *int `json:"original_time,omitempty"` +} + +type OrganizerInfo struct { + Name *string `json:"name,omitempty"` + OpenId *string `json:"open_id,omitempty"` +} + +type Room struct { + RoomId *string `json:"room_id,omitempty"` + BuildingId *string `json:"building_id,omitempty"` + BuildingName *string `json:"building_name,omitempty"` + Capacity *int `json:"capacity,omitempty"` + Description *string `json:"description,omitempty"` + DisplayId *string `json:"display_id,omitempty"` + FloorName *string `json:"floor_name,omitempty"` + IsDisabled *bool `json:"is_disabled,omitempty"` + Name *string `json:"name,omitempty"` +} + +type RoomFreeBusy struct { + StartTime *string `json:"start_time,omitempty"` + EndTime *string `json:"end_time,omitempty"` + Uid *string `json:"uid,omitempty"` + OriginalTime *int `json:"original_time,omitempty"` + OrganizerInfo *OrganizerInfo `json:"organizer_info,omitempty"` +} + +type RoomId struct { + RoomId *string `json:"room_id,omitempty"` + CustomRoomId *string `json:"custom_room_id,omitempty"` +} + +type MeetingRoom struct { + RoomId *int `json:"room_id,omitempty"` +} + +type BuildingBatchGetReq struct { + BuildingIds []string `query:"building_ids"` + Fields *string `query:"fields"` +} + +type BuildingBatchGetRespData struct { + Buildings []*Building `json:"buildings,omitempty"` +} + +type BuildingBatchGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *BuildingBatchGetRespData `json:"data"` +} + +type BuildingBatchGetIdReq struct { + CustomBuildingIds []string `query:"custom_building_ids"` +} + +type BuildingBatchGetIdRespData struct { + Buildings []*BuildingId `json:"buildings,omitempty"` +} + +type BuildingBatchGetIdResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *BuildingBatchGetIdRespData `json:"data"` +} + +type BuildingCreateReqBody struct { + Name *string `json:"name,omitempty"` + Floors []string `json:"floors,omitempty"` + CountryId *string `json:"country_id,omitempty"` + DistrictId *string `json:"district_id,omitempty"` + CustomBuildingId *string `json:"custom_building_id,omitempty"` +} + +type BuildingCreateReq struct { + Body *BuildingCreateReqBody `body:""` +} + +type BuildingCreateRespData struct { + BuildingId *string `json:"building_id,omitempty"` +} + +type BuildingCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *BuildingCreateRespData `json:"data"` +} + +type BuildingDeleteReqBody struct { + BuildingId *string `json:"building_id,omitempty"` +} + +type BuildingDeleteReq struct { + Body *BuildingDeleteReqBody `body:""` +} + +type BuildingDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type BuildingListReq struct { + OrderBy *string `query:"order_by"` + Fields *string `query:"fields"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type BuildingListRespData struct { + PageToken *string `json:"page_token,omitempty"` + HasMore *bool `json:"has_more,omitempty"` + Buildings []*Building `json:"buildings,omitempty"` +} + +type BuildingListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *BuildingListRespData `json:"data"` +} + +type BuildingUpdateReqBody struct { + BuildingId *string `json:"building_id,omitempty"` + Name *string `json:"name,omitempty"` + Floors []string `json:"floors,omitempty"` + CountryId *string `json:"country_id,omitempty"` + DistrictId *string `json:"district_id,omitempty"` + CustomBuildingId *string `json:"custom_building_id,omitempty"` +} + +type BuildingUpdateReq struct { + Body *BuildingUpdateReqBody `body:""` +} + +type BuildingUpdateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type CountryListRespData struct { + Countries []*Country `json:"countries,omitempty"` +} + +type CountryListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *CountryListRespData `json:"data"` +} + +type DistrictListReq struct { + CountryId *int `query:"country_id"` +} + +type DistrictListRespData struct { + Districts []*District `json:"districts,omitempty"` +} + +type DistrictListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *DistrictListRespData `json:"data"` +} + +type FreebusyBatchGetReq struct { + RoomIds []string `query:"room_ids"` + TimeMin *string `query:"time_min"` + TimeMax *string `query:"time_max"` +} + +type FreebusyBatchGetRespData struct { + TimeMin *string `json:"time_min,omitempty"` + TimeMax *string `json:"time_max,omitempty"` + FreeBusy map[string][]*RoomFreeBusy `json:"free_busy,omitempty"` +} + +type FreebusyBatchGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *FreebusyBatchGetRespData `json:"data"` +} + +type InstanceReplyReqBody struct { + RoomId *string `json:"room_id,omitempty"` + Uid *string `json:"uid,omitempty"` + OriginalTime *int `json:"original_time,omitempty"` + Status *string `json:"status,omitempty"` +} + +type InstanceReplyReq struct { + Body *InstanceReplyReqBody `body:""` +} + +type InstanceReplyResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type RoomBatchGetReq struct { + RoomIds []string `query:"room_ids"` + Fields *string `query:"fields"` +} + +type RoomBatchGetRespData struct { + Rooms []*Room `json:"rooms,omitempty"` +} + +type RoomBatchGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *RoomBatchGetRespData `json:"data"` +} + +type RoomBatchGetIdReq struct { + CustomRoomIds []string `query:"custom_room_ids"` +} + +type RoomBatchGetIdRespData struct { + Rooms []*RoomId `json:"rooms,omitempty"` +} + +type RoomBatchGetIdResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *RoomBatchGetIdRespData `json:"data"` +} + +type RoomCreateReqBody struct { + BuildingId *string `json:"building_id,omitempty"` + Floor *string `json:"floor,omitempty"` + Name *string `json:"name,omitempty"` + Capacity *int `json:"capacity,omitempty"` + IsDisabled *bool `json:"is_disabled,omitempty"` + CustomRoomId *string `json:"custom_room_id,omitempty"` +} + +type RoomCreateReq struct { + Body *RoomCreateReqBody `body:""` +} + +type RoomCreateRespData struct { + RoomId *string `json:"room_id,omitempty"` +} + +type RoomCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *RoomCreateRespData `json:"data"` +} + +type RoomDeleteReqBody struct { + RoomId *string `json:"room_id,omitempty"` +} + +type RoomDeleteReq struct { + Body *RoomDeleteReqBody `body:""` +} + +type RoomDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type RoomListReq struct { + BuildingId *string `query:"building_id"` + OrderBy *string `query:"order_by"` + Fields *string `query:"fields"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type RoomListRespData struct { + PageToken *string `json:"page_token,omitempty"` + HasMore *bool `json:"has_more,omitempty"` + Rooms []*Room `json:"rooms,omitempty"` +} + +type RoomListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *RoomListRespData `json:"data"` +} + +type RoomUpdateReqBody struct { + RoomId *string `json:"room_id,omitempty"` + Name *string `json:"name,omitempty"` + Capacity *int `json:"capacity,omitempty"` + IsDisabled *bool `json:"is_disabled,omitempty"` + CustomRoomId *string `json:"custom_room_id,omitempty"` +} + +type RoomUpdateReq struct { + Body *RoomUpdateReqBody `body:""` +} + +type RoomUpdateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type SummaryBatchGetReqBody struct { + EventUids []*EventUid `json:"EventUids,omitempty"` +} + +type SummaryBatchGetReq struct { + Body *SummaryBatchGetReqBody `body:""` +} + +type SummaryBatchGetRespData struct { + EventInfos []*EventInfo `json:"EventInfos,omitempty"` + ErrorEventUids []*ErrorEventUid `json:"ErrorEventUids,omitempty"` +} + +type SummaryBatchGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *SummaryBatchGetRespData `json:"data"` +} + +type MeetingRoomStatusChangedEventData struct { + RoomName *string `json:"room_name,omitempty"` + RoomId *string `json:"room_id,omitempty"` +} + +type MeetingRoomStatusChangedEvent struct { + *lark.EventV2Base + Event *MeetingRoomStatusChangedEventData `json:"event"` +} + +type MeetingRoomCreatedEventData struct { + RoomName *string `json:"room_name,omitempty"` + RoomId *string `json:"room_id,omitempty"` +} + +type MeetingRoomCreatedEvent struct { + *lark.EventV2Base + Event *MeetingRoomCreatedEventData `json:"event"` +} + +type MeetingRoomDeletedEventData struct { + RoomName *string `json:"room_name,omitempty"` + RoomId *string `json:"room_id,omitempty"` +} + +type MeetingRoomDeletedEvent struct { + *lark.EventV2Base + Event *MeetingRoomDeletedEventData `json:"event"` +} + +type MeetingRoomUpdatedEventData struct { + RoomName *string `json:"room_name,omitempty"` + RoomId *string `json:"room_id,omitempty"` +} + +type MeetingRoomUpdatedEvent struct { + *lark.EventV2Base + Event *MeetingRoomUpdatedEventData `json:"event"` +} + +type RoomCreatedEventData struct { + RoomId *string `json:"room_id,omitempty"` + RoomName *string `json:"room_name,omitempty"` +} + +type RoomCreatedEvent struct { + *lark.EventV2Base + Event *RoomCreatedEventData `json:"event"` +} + +type RoomDeletedEventData struct { + RoomId *string `json:"room_id,omitempty"` + RoomName *string `json:"room_name,omitempty"` +} + +type RoomDeletedEvent struct { + *lark.EventV2Base + Event *RoomDeletedEventData `json:"event"` +} + +type RoomStatusChangedEventData struct { + RoomId *string `json:"room_id,omitempty"` + RoomName *string `json:"room_name,omitempty"` +} + +type RoomStatusChangedEvent struct { + *lark.EventV2Base + Event *RoomStatusChangedEventData `json:"event"` +} + +type RoomUpdatedEventData struct { + RoomId *string `json:"room_id,omitempty"` + RoomName *string `json:"room_name,omitempty"` +} + +type RoomUpdatedEvent struct { + *lark.EventV2Base + Event *RoomUpdatedEventData `json:"event"` +} diff --git a/v2/service/optical_char_recognition/v1/api.go b/v2/service/optical_char_recognition/v1/api.go new file mode 100644 index 00000000..4507aefd --- /dev/null +++ b/v2/service/optical_char_recognition/v1/api.go @@ -0,0 +1,37 @@ +// Package optical_char_recognition code generated by lark suite oapi sdk gen +package optical_char_recognition + +import ( + "context" + "net/http" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type OpticalCharRecognitionService struct { + Image *image +} + +func New(app *lark.App) *OpticalCharRecognitionService { + o := &OpticalCharRecognitionService{} + o.Image = &image{app: app} + return o +} + +type image struct { + app *lark.App +} + +func (i *image) BasicRecognize(ctx context.Context, req *ImageBasicRecognizeReq, options ...lark.RequestOptionFunc) (*ImageBasicRecognizeResp, error) { + rawResp, err := i.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/optical_char_recognition/v1/image/basic_recognize", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &ImageBasicRecognizeResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} diff --git a/v2/service/optical_char_recognition/v1/model.go b/v2/service/optical_char_recognition/v1/model.go new file mode 100644 index 00000000..f37a30a5 --- /dev/null +++ b/v2/service/optical_char_recognition/v1/model.go @@ -0,0 +1,24 @@ +// Package optical_char_recognition code generated by lark suite oapi sdk gen +package optical_char_recognition + +import ( + "github.com/larksuite/oapi-sdk-go/v2" +) + +type ImageBasicRecognizeReqBody struct { + Image *string `json:"image,omitempty"` +} + +type ImageBasicRecognizeReq struct { + Body *ImageBasicRecognizeReqBody `body:""` +} + +type ImageBasicRecognizeRespData struct { + TextList []string `json:"text_list,omitempty"` +} + +type ImageBasicRecognizeResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *ImageBasicRecognizeRespData `json:"data"` +} diff --git a/v2/service/search/v2/api.go b/v2/service/search/v2/api.go new file mode 100644 index 00000000..b3765ea4 --- /dev/null +++ b/v2/service/search/v2/api.go @@ -0,0 +1,133 @@ +// Package search code generated by lark suite oapi sdk gen +package search + +import ( + "context" + "net/http" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type SearchService struct { + DataSources *dataSources + Items *items +} + +func New(app *lark.App) *SearchService { + s := &SearchService{} + s.DataSources = &dataSources{app: app} + s.Items = &items{app: app} + return s +} + +type dataSources struct { + app *lark.App +} +type items struct { + app *lark.App +} + +func (d *dataSources) Create(ctx context.Context, req *DataSourceCreateReq, options ...lark.RequestOptionFunc) (*DataSourceCreateResp, error) { + rawResp, err := d.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/search/v2/data_sources", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &DataSourceCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (d *dataSources) Delete(ctx context.Context, req *DataSourceDeleteReq, options ...lark.RequestOptionFunc) (*DataSourceDeleteResp, error) { + rawResp, err := d.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/search/v2/data_sources/:data_source_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &DataSourceDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (d *dataSources) Get(ctx context.Context, req *DataSourceGetReq, options ...lark.RequestOptionFunc) (*DataSourceGetResp, error) { + rawResp, err := d.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/search/v2/data_sources/:data_source_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &DataSourceGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (d *dataSources) List(ctx context.Context, req *DataSourceListReq, options ...lark.RequestOptionFunc) (*DataSourceListResp, error) { + rawResp, err := d.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/search/v2/data_sources", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &DataSourceListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (d *dataSources) Patch(ctx context.Context, req *DataSourcePatchReq, options ...lark.RequestOptionFunc) (*DataSourcePatchResp, error) { + rawResp, err := d.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPatch, + "/open-apis/search/v2/data_sources/:data_source_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &DataSourcePatchResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (i *items) Create(ctx context.Context, req *DataSourceItemCreateReq, options ...lark.RequestOptionFunc) (*DataSourceItemCreateResp, error) { + rawResp, err := i.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/search/v2/data_sources/:data_source_id/items", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &DataSourceItemCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (i *items) Delete(ctx context.Context, req *DataSourceItemDeleteReq, options ...lark.RequestOptionFunc) (*DataSourceItemDeleteResp, error) { + rawResp, err := i.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/search/v2/data_sources/:data_source_id/items/:item_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &DataSourceItemDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (i *items) Get(ctx context.Context, req *DataSourceItemGetReq, options ...lark.RequestOptionFunc) (*DataSourceItemGetResp, error) { + rawResp, err := i.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/search/v2/data_sources/:data_source_id/items/:item_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &DataSourceItemGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} diff --git a/v2/service/search/v2/model.go b/v2/service/search/v2/model.go new file mode 100644 index 00000000..1feb2212 --- /dev/null +++ b/v2/service/search/v2/model.go @@ -0,0 +1,188 @@ +// Package search code generated by lark suite oapi sdk gen +package search + +import ( + "github.com/larksuite/oapi-sdk-go/v2" +) + +type Acl struct { + Access *string `json:"access,omitempty"` + Value *string `json:"value,omitempty"` + Type *string `json:"type,omitempty"` +} + +type ConnectDataSource struct { + ServiceUrl *string `json:"service_url,omitempty"` + ProjectName *string `json:"project_name,omitempty"` + DisplayName *string `json:"display_name,omitempty"` + Description *string `json:"description,omitempty"` + IconUrl *string `json:"icon_url,omitempty"` + ProjectDescription *string `json:"project_description,omitempty"` + ContactEmail *string `json:"contact_email,omitempty"` + TenantName *string `json:"tenant_name,omitempty"` +} + +type DataSource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + State *int `json:"state,omitempty"` + Description *string `json:"description,omitempty"` + CreateTime *string `json:"create_time,omitempty"` + UpdateTime *string `json:"update_time,omitempty"` + IsExceedQuota *bool `json:"is_exceed_quota,omitempty"` + IconUrl *string `json:"icon_url,omitempty"` + Template *string `json:"template,omitempty"` +} + +type Item struct { + Id *string `json:"id,omitempty"` + Acl []*Acl `json:"acl,omitempty"` + Metadata *ItemMetadata `json:"metadata,omitempty"` + StructuredData *string `json:"structured_data,omitempty"` + Content *ItemContent `json:"content,omitempty"` + FieldAcl *string `json:"field_acl,omitempty"` +} + +type ItemContent struct { + Format *string `json:"format,omitempty"` + ContentData *string `json:"content_data,omitempty"` +} + +type ItemMetadata struct { + Title *string `json:"title,omitempty"` + SourceUrl *string `json:"source_url,omitempty"` + CreateTime *int `json:"create_time,omitempty"` + UpdateTime *int `json:"update_time,omitempty"` +} + +type Schema struct { + PropertyDefinitions []*SchemaPropertyDefinition `json:"property_definitions,omitempty"` + Id *string `json:"id,omitempty"` +} + +type SchemaDisplayOption struct { + DisplayLabel *string `json:"display_label,omitempty"` + DisplayType *string `json:"display_type,omitempty"` +} + +type SchemaPropertyDefinition struct { + Name *string `json:"name,omitempty"` + IsReturnable *bool `json:"is_returnable,omitempty"` + IsRepeatable *bool `json:"is_repeatable,omitempty"` + IsSortable *bool `json:"is_sortable,omitempty"` + IsFacetable *bool `json:"is_facetable,omitempty"` + IsWildcardSearchable *bool `json:"is_wildcard_searchable,omitempty"` + Type *string `json:"type,omitempty"` + DisplayOptions *SchemaDisplayOption `json:"display_options,omitempty"` +} + +type DataSourceCreateReq struct { + DataSource *DataSource `body:""` +} + +type DataSourceCreateRespData struct { + DataSource *DataSource `json:"data_source,omitempty"` +} + +type DataSourceCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *DataSourceCreateRespData `json:"data"` +} + +type DataSourceDeleteReq struct { + DataSourceId string `path:"data_source_id"` +} + +type DataSourceDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type DataSourceGetReq struct { + DataSourceId string `path:"data_source_id"` +} + +type DataSourceGetRespData struct { + DataSource *DataSource `json:"data_source,omitempty"` +} + +type DataSourceGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *DataSourceGetRespData `json:"data"` +} + +type DataSourceListReq struct { + View *int `query:"view"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type DataSourceListRespData struct { + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` + Items []*DataSource `json:"items,omitempty"` +} + +type DataSourceListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *DataSourceListRespData `json:"data"` +} + +type DataSourcePatchReqBody struct { + Name *string `json:"name,omitempty"` + State *int `json:"state,omitempty"` + Description *string `json:"description,omitempty"` +} + +type DataSourcePatchReq struct { + DataSourceId string `path:"data_source_id"` + Body *DataSourcePatchReqBody `body:""` +} + +type DataSourcePatchRespData struct { + DataSource *DataSource `json:"data_source,omitempty"` +} + +type DataSourcePatchResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *DataSourcePatchRespData `json:"data"` +} + +type DataSourceItemCreateReq struct { + DataSourceId string `path:"data_source_id"` + Item *Item `body:""` +} + +type DataSourceItemCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type DataSourceItemDeleteReq struct { + DataSourceId string `path:"data_source_id"` + ItemId string `path:"item_id"` +} + +type DataSourceItemDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type DataSourceItemGetReq struct { + DataSourceId string `path:"data_source_id"` + ItemId string `path:"item_id"` +} + +type DataSourceItemGetRespData struct { + Item *Item `json:"item,omitempty"` +} + +type DataSourceItemGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *DataSourceItemGetRespData `json:"data"` +} diff --git a/v2/service/speech_to_text/v1/api.go b/v2/service/speech_to_text/v1/api.go new file mode 100644 index 00000000..d4b7e586 --- /dev/null +++ b/v2/service/speech_to_text/v1/api.go @@ -0,0 +1,50 @@ +// Package speech_to_text code generated by lark suite oapi sdk gen +package speech_to_text + +import ( + "context" + "net/http" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type SpeechToTextService struct { + Speech *speech +} + +func New(app *lark.App) *SpeechToTextService { + s := &SpeechToTextService{} + s.Speech = &speech{app: app} + return s +} + +type speech struct { + app *lark.App +} + +func (s *speech) FileRecognize(ctx context.Context, req *SpeechFileRecognizeReq, options ...lark.RequestOptionFunc) (*SpeechFileRecognizeResp, error) { + rawResp, err := s.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/speech_to_text/v1/speech/file_recognize", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &SpeechFileRecognizeResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (s *speech) StreamRecognize(ctx context.Context, req *SpeechStreamRecognizeReq, options ...lark.RequestOptionFunc) (*SpeechStreamRecognizeResp, error) { + rawResp, err := s.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/speech_to_text/v1/speech/stream_recognize", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &SpeechStreamRecognizeResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} diff --git a/v2/service/speech_to_text/v1/model.go b/v2/service/speech_to_text/v1/model.go new file mode 100644 index 00000000..c9a4bc25 --- /dev/null +++ b/v2/service/speech_to_text/v1/model.go @@ -0,0 +1,65 @@ +// Package speech_to_text code generated by lark suite oapi sdk gen +package speech_to_text + +import ( + "github.com/larksuite/oapi-sdk-go/v2" +) + +type FileConfig struct { + FileId *string `json:"file_id,omitempty"` + Format *string `json:"format,omitempty"` + EngineType *string `json:"engine_type,omitempty"` +} + +type Speech struct { + Speech *string `json:"speech,omitempty"` + SpeechKey *string `json:"speech_key,omitempty"` +} + +type StreamConfig struct { + StreamId *string `json:"stream_id,omitempty"` + SequenceId *int `json:"sequence_id,omitempty"` + Action *int `json:"action,omitempty"` + Format *string `json:"format,omitempty"` + EngineType *string `json:"engine_type,omitempty"` +} + +type SpeechFileRecognizeReqBody struct { + Speech *Speech `json:"speech,omitempty"` + Config *FileConfig `json:"config,omitempty"` +} + +type SpeechFileRecognizeReq struct { + Body *SpeechFileRecognizeReqBody `body:""` +} + +type SpeechFileRecognizeRespData struct { + RecognitionText *string `json:"recognition_text,omitempty"` +} + +type SpeechFileRecognizeResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *SpeechFileRecognizeRespData `json:"data"` +} + +type SpeechStreamRecognizeReqBody struct { + Speech *Speech `json:"speech,omitempty"` + Config *StreamConfig `json:"config,omitempty"` +} + +type SpeechStreamRecognizeReq struct { + Body *SpeechStreamRecognizeReqBody `body:""` +} + +type SpeechStreamRecognizeRespData struct { + StreamId *string `json:"stream_id,omitempty"` + SequenceId *int `json:"sequence_id,omitempty"` + RecognitionText *string `json:"recognition_text,omitempty"` +} + +type SpeechStreamRecognizeResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *SpeechStreamRecognizeRespData `json:"data"` +} diff --git a/v2/service/task/v1/api.go b/v2/service/task/v1/api.go new file mode 100644 index 00000000..a2a118b0 --- /dev/null +++ b/v2/service/task/v1/api.go @@ -0,0 +1,291 @@ +// Package task code generated by lark suite oapi sdk gen +package task + +import ( + "context" + "net/http" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type TaskService struct { + Tasks *tasks + Comments *comments + Collaborators *collaborators + Followers *followers + Reminders *reminders +} + +func New(app *lark.App) *TaskService { + t := &TaskService{} + t.Tasks = &tasks{app: app} + t.Comments = &comments{app: app} + t.Collaborators = &collaborators{app: app} + t.Followers = &followers{app: app} + t.Reminders = &reminders{app: app} + return t +} + +type tasks struct { + app *lark.App +} +type comments struct { + app *lark.App +} +type collaborators struct { + app *lark.App +} +type followers struct { + app *lark.App +} +type reminders struct { + app *lark.App +} + +func (t *tasks) Complete(ctx context.Context, req *TaskCompleteReq, options ...lark.RequestOptionFunc) (*TaskCompleteResp, error) { + rawResp, err := t.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/task/v1/tasks/:task_id/complete", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TaskCompleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (t *tasks) Create(ctx context.Context, req *TaskCreateReq, options ...lark.RequestOptionFunc) (*TaskCreateResp, error) { + rawResp, err := t.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/task/v1/tasks", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TaskCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (t *tasks) Delete(ctx context.Context, req *TaskDeleteReq, options ...lark.RequestOptionFunc) (*TaskDeleteResp, error) { + rawResp, err := t.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/task/v1/tasks/:task_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TaskDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (t *tasks) Get(ctx context.Context, req *TaskGetReq, options ...lark.RequestOptionFunc) (*TaskGetResp, error) { + rawResp, err := t.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/task/v1/tasks/:task_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TaskGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (t *tasks) Patch(ctx context.Context, req *TaskPatchReq, options ...lark.RequestOptionFunc) (*TaskPatchResp, error) { + rawResp, err := t.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPatch, + "/open-apis/task/v1/tasks/:task_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TaskPatchResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (t *tasks) Uncomplete(ctx context.Context, req *TaskUncompleteReq, options ...lark.RequestOptionFunc) (*TaskUncompleteResp, error) { + rawResp, err := t.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/task/v1/tasks/:task_id/uncomplete", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TaskUncompleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *collaborators) Create(ctx context.Context, req *TaskCollaboratorCreateReq, options ...lark.RequestOptionFunc) (*TaskCollaboratorCreateResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/task/v1/tasks/:task_id/collaborators", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TaskCollaboratorCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *collaborators) Delete(ctx context.Context, req *TaskCollaboratorDeleteReq, options ...lark.RequestOptionFunc) (*TaskCollaboratorDeleteResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/task/v1/tasks/:task_id/collaborators/:collaborator_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TaskCollaboratorDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *collaborators) List(ctx context.Context, req *TaskCollaboratorListReq, options ...lark.RequestOptionFunc) (*TaskCollaboratorListResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/task/v1/tasks/:task_id/collaborators", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TaskCollaboratorListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *comments) Create(ctx context.Context, req *TaskCommentCreateReq, options ...lark.RequestOptionFunc) (*TaskCommentCreateResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/task/v1/tasks/:task_id/comments", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TaskCommentCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *comments) Delete(ctx context.Context, req *TaskCommentDeleteReq, options ...lark.RequestOptionFunc) (*TaskCommentDeleteResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/task/v1/tasks/:task_id/comments/:comment_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TaskCommentDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *comments) Get(ctx context.Context, req *TaskCommentGetReq, options ...lark.RequestOptionFunc) (*TaskCommentGetResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/task/v1/tasks/:task_id/comments/:comment_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TaskCommentGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (c *comments) Update(ctx context.Context, req *TaskCommentUpdateReq, options ...lark.RequestOptionFunc) (*TaskCommentUpdateResp, error) { + rawResp, err := c.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPut, + "/open-apis/task/v1/tasks/:task_id/comments/:comment_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TaskCommentUpdateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (f *followers) Create(ctx context.Context, req *TaskFollowerCreateReq, options ...lark.RequestOptionFunc) (*TaskFollowerCreateResp, error) { + rawResp, err := f.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/task/v1/tasks/:task_id/followers", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TaskFollowerCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (f *followers) Delete(ctx context.Context, req *TaskFollowerDeleteReq, options ...lark.RequestOptionFunc) (*TaskFollowerDeleteResp, error) { + rawResp, err := f.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/task/v1/tasks/:task_id/followers/:follower_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TaskFollowerDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (f *followers) List(ctx context.Context, req *TaskFollowerListReq, options ...lark.RequestOptionFunc) (*TaskFollowerListResp, error) { + rawResp, err := f.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/task/v1/tasks/:task_id/followers", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TaskFollowerListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (r *reminders) Create(ctx context.Context, req *TaskReminderCreateReq, options ...lark.RequestOptionFunc) (*TaskReminderCreateResp, error) { + rawResp, err := r.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/task/v1/tasks/:task_id/reminders", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TaskReminderCreateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (r *reminders) Delete(ctx context.Context, req *TaskReminderDeleteReq, options ...lark.RequestOptionFunc) (*TaskReminderDeleteResp, error) { + rawResp, err := r.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/task/v1/tasks/:task_id/reminders/:reminder_id", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TaskReminderDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (r *reminders) List(ctx context.Context, req *TaskReminderListReq, options ...lark.RequestOptionFunc) (*TaskReminderListResp, error) { + rawResp, err := r.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/task/v1/tasks/:task_id/reminders", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TaskReminderListResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} diff --git a/v2/service/task/v1/event.go b/v2/service/task/v1/event.go new file mode 100644 index 00000000..550ede15 --- /dev/null +++ b/v2/service/task/v1/event.go @@ -0,0 +1,39 @@ +// Package task code generated by lark suite oapi sdk gen +package task + +import ( + "context" + "github.com/larksuite/oapi-sdk-go/v2" +) + +type taskUpdatedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *TaskUpdatedEvent) error +} + +func (h *taskUpdatedEventHandler) Event() interface{} { + return &TaskUpdatedEvent{} +} + +func (h *taskUpdatedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*TaskUpdatedEvent)) +} + +func (t *tasks) UpdatedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *TaskUpdatedEvent) error) { + t.app.Webhook.EventHandler("updated", &taskUpdatedEventHandler{handler: handler}) +} + +type taskCommentUpdatedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *TaskCommentUpdatedEvent) error +} + +func (h *taskCommentUpdatedEventHandler) Event() interface{} { + return &TaskCommentUpdatedEvent{} +} + +func (h *taskCommentUpdatedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*TaskCommentUpdatedEvent)) +} + +func (c *comments) UpdatedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *TaskCommentUpdatedEvent) error) { + c.app.Webhook.EventHandler("updated", &taskCommentUpdatedEventHandler{handler: handler}) +} diff --git a/v2/service/task/v1/model.go b/v2/service/task/v1/model.go new file mode 100644 index 00000000..15feebea --- /dev/null +++ b/v2/service/task/v1/model.go @@ -0,0 +1,349 @@ +// Package task code generated by lark suite oapi sdk gen +package task + +import ( + "github.com/larksuite/oapi-sdk-go/v2" +) + +type Collaborator struct { + Id *string `json:"id,omitempty"` +} + +type Comment struct { + Content *string `json:"content,omitempty"` + ParentId *int64 `json:"parent_id,omitempty,string"` + Id *int64 `json:"id,omitempty,string"` +} + +type Due struct { + Time *int64 `json:"time,omitempty,string"` + Timezone *string `json:"timezone,omitempty"` + IsAllDay *bool `json:"is_all_day,omitempty"` +} + +type Follower struct { + Id *string `json:"id,omitempty"` +} + +type Href struct { + Url *string `json:"url,omitempty"` + Title *string `json:"title,omitempty"` +} + +type Origin struct { + PlatformI18nName *string `json:"platform_i18n_name,omitempty"` + Href *Href `json:"href,omitempty"` +} + +type Reminder struct { + Id *int64 `json:"id,omitempty,string"` + RelativeFireMinute *int `json:"relative_fire_minute,omitempty"` +} + +type Task struct { + Id *string `json:"id,omitempty"` + Summary *string `json:"summary,omitempty"` + Description *string `json:"description,omitempty"` + CompleteTime *int64 `json:"complete_time,omitempty,string"` + CreatorId *string `json:"creator_id,omitempty"` + Extra *string `json:"extra,omitempty"` + CreateTime *int64 `json:"create_time,omitempty,string"` + UpdateTime *int64 `json:"update_time,omitempty,string"` + Due *Due `json:"due,omitempty"` + Origin *Origin `json:"origin,omitempty"` + CanEdit *bool `json:"can_edit,omitempty"` + Custom *string `json:"custom,omitempty"` +} + +type TaskCompleteReq struct { + TaskId string `path:"task_id"` +} + +type TaskCompleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type TaskCreateReq struct { + UserIdType *string `query:"user_id_type"` + Task *Task `body:""` +} + +type TaskCreateRespData struct { + Task *Task `json:"task,omitempty"` +} + +type TaskCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *TaskCreateRespData `json:"data"` +} + +type TaskDeleteReq struct { + TaskId string `path:"task_id"` +} + +type TaskDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type TaskGetReq struct { + TaskId string `path:"task_id"` + UserIdType *string `query:"user_id_type"` +} + +type TaskGetRespData struct { + Task *Task `json:"task,omitempty"` +} + +type TaskGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *TaskGetRespData `json:"data"` +} + +type TaskPatchReqBody struct { + Task *Task `json:"task,omitempty"` + UpdateFields []string `json:"update_fields,omitempty"` +} + +type TaskPatchReq struct { + TaskId string `path:"task_id"` + UserIdType *string `query:"user_id_type"` + Body *TaskPatchReqBody `body:""` +} + +type TaskPatchRespData struct { + Task *Task `json:"task,omitempty"` +} + +type TaskPatchResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *TaskPatchRespData `json:"data"` +} + +type TaskUncompleteReq struct { + TaskId string `path:"task_id"` +} + +type TaskUncompleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type TaskCollaboratorCreateReq struct { + TaskId string `path:"task_id"` + UserIdType *string `query:"user_id_type"` + Collaborator *Collaborator `body:""` +} + +type TaskCollaboratorCreateRespData struct { + Collaborator *Collaborator `json:"collaborator,omitempty"` +} + +type TaskCollaboratorCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *TaskCollaboratorCreateRespData `json:"data"` +} + +type TaskCollaboratorDeleteReq struct { + TaskId string `path:"task_id"` + CollaboratorId string `path:"collaborator_id"` +} + +type TaskCollaboratorDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type TaskCollaboratorListReq struct { + TaskId string `path:"task_id"` + PageSize *int `query:"page_size"` + PageToken *string `query:"page_token"` + UserIdType *string `query:"user_id_type"` +} + +type TaskCollaboratorListRespData struct { + Items []*Collaborator `json:"items,omitempty"` + PageToken *string `json:"page_token,omitempty"` + HasMore *bool `json:"has_more,omitempty"` +} + +type TaskCollaboratorListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *TaskCollaboratorListRespData `json:"data"` +} + +type TaskCommentCreateReq struct { + TaskId string `path:"task_id"` + Comment *Comment `body:""` +} + +type TaskCommentCreateRespData struct { + Comment *Comment `json:"comment,omitempty"` +} + +type TaskCommentCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *TaskCommentCreateRespData `json:"data"` +} + +type TaskCommentDeleteReq struct { + TaskId string `path:"task_id"` + CommentId string `path:"comment_id"` +} + +type TaskCommentDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type TaskCommentGetReq struct { + TaskId string `path:"task_id"` + CommentId string `path:"comment_id"` +} + +type TaskCommentGetRespData struct { + Comment *Comment `json:"comment,omitempty"` +} + +type TaskCommentGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *TaskCommentGetRespData `json:"data"` +} + +type TaskCommentUpdateReqBody struct { + Content *string `json:"content,omitempty"` +} + +type TaskCommentUpdateReq struct { + TaskId string `path:"task_id"` + CommentId string `path:"comment_id"` + Body *TaskCommentUpdateReqBody `body:""` +} + +type TaskCommentUpdateRespData struct { + Comment *Comment `json:"comment,omitempty"` +} + +type TaskCommentUpdateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *TaskCommentUpdateRespData `json:"data"` +} + +type TaskFollowerCreateReq struct { + TaskId string `path:"task_id"` + UserIdType *string `query:"user_id_type"` + Follower *Follower `body:""` +} + +type TaskFollowerCreateRespData struct { + Follower *Follower `json:"follower,omitempty"` +} + +type TaskFollowerCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *TaskFollowerCreateRespData `json:"data"` +} + +type TaskFollowerDeleteReq struct { + TaskId string `path:"task_id"` + FollowerId string `path:"follower_id"` +} + +type TaskFollowerDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type TaskFollowerListReq struct { + TaskId string `path:"task_id"` + PageSize *int `query:"page_size"` + PageToken *string `query:"page_token"` + UserIdType *string `query:"user_id_type"` +} + +type TaskFollowerListRespData struct { + Items []*Follower `json:"items,omitempty"` + PageToken *string `json:"page_token,omitempty"` + HasMore *bool `json:"has_more,omitempty"` +} + +type TaskFollowerListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *TaskFollowerListRespData `json:"data"` +} + +type TaskReminderCreateReq struct { + TaskId string `path:"task_id"` + Reminder *Reminder `body:""` +} + +type TaskReminderCreateRespData struct { + Reminder *Reminder `json:"reminder,omitempty"` +} + +type TaskReminderCreateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *TaskReminderCreateRespData `json:"data"` +} + +type TaskReminderDeleteReq struct { + TaskId string `path:"task_id"` + ReminderId string `path:"reminder_id"` +} + +type TaskReminderDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type TaskReminderListReq struct { + TaskId string `path:"task_id"` + PageSize *int `query:"page_size"` + PageToken *string `query:"page_token"` +} + +type TaskReminderListRespData struct { + Items []*Reminder `json:"items,omitempty"` + PageToken *string `json:"page_token,omitempty"` + HasMore *bool `json:"has_more,omitempty"` +} + +type TaskReminderListResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *TaskReminderListRespData `json:"data"` +} + +type TaskUpdatedEventData struct { + TaskId *string `json:"task_id,omitempty"` + ObjType *int `json:"obj_type,omitempty"` +} + +type TaskUpdatedEvent struct { + *lark.EventV2Base + Event *TaskUpdatedEventData `json:"event"` +} + +type TaskCommentUpdatedEventData struct { + TaskId *string `json:"task_id,omitempty"` + CommentId *string `json:"comment_id,omitempty"` + ParentId *string `json:"parent_id,omitempty"` + ObjType *int `json:"obj_type,omitempty"` +} + +type TaskCommentUpdatedEvent struct { + *lark.EventV2Base + Event *TaskCommentUpdatedEventData `json:"event"` +} diff --git a/v2/service/tenant/v2/api.go b/v2/service/tenant/v2/api.go new file mode 100644 index 00000000..04f2ed78 --- /dev/null +++ b/v2/service/tenant/v2/api.go @@ -0,0 +1,37 @@ +// Package tenant code generated by lark suite oapi sdk gen +package tenant + +import ( + "context" + "net/http" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type TenantService struct { + Tenant *tenant +} + +func New(app *lark.App) *TenantService { + t := &TenantService{} + t.Tenant = &tenant{app: app} + return t +} + +type tenant struct { + app *lark.App +} + +func (t *tenant) Query(ctx context.Context, options ...lark.RequestOptionFunc) (*TenantQueryResp, error) { + rawResp, err := t.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/tenant/v2/tenant/query", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, nil, options...) + if err != nil { + return nil, err + } + resp := &TenantQueryResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} diff --git a/v2/service/tenant/v2/model.go b/v2/service/tenant/v2/model.go new file mode 100644 index 00000000..31c8f4cf --- /dev/null +++ b/v2/service/tenant/v2/model.go @@ -0,0 +1,31 @@ +// Package tenant code generated by lark suite oapi sdk gen +package tenant + +import ( + "github.com/larksuite/oapi-sdk-go/v2" +) + +type Avatar struct { + AvatarOrigin *string `json:"avatar_origin,omitempty"` + Avatar72 *string `json:"avatar_72,omitempty"` + Avatar240 *string `json:"avatar_240,omitempty"` + Avatar640 *string `json:"avatar_640,omitempty"` +} + +type Tenant struct { + Name *string `json:"name,omitempty"` + DisplayId *string `json:"display_id,omitempty"` + TenantTag *int `json:"tenant_tag,omitempty"` + TenantKey *string `json:"tenant_key,omitempty"` + Avatar *Avatar `json:"avatar,omitempty"` +} + +type TenantQueryRespData struct { + Tenant *Tenant `json:"tenant,omitempty"` +} + +type TenantQueryResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *TenantQueryRespData `json:"data"` +} diff --git a/v2/service/translation/v1/api.go b/v2/service/translation/v1/api.go new file mode 100644 index 00000000..a0b499df --- /dev/null +++ b/v2/service/translation/v1/api.go @@ -0,0 +1,50 @@ +// Package translation code generated by lark suite oapi sdk gen +package translation + +import ( + "context" + "net/http" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type TranslationService struct { + Text *text +} + +func New(app *lark.App) *TranslationService { + t := &TranslationService{} + t.Text = &text{app: app} + return t +} + +type text struct { + app *lark.App +} + +func (t *text) Translate(ctx context.Context, req *TextTranslateReq, options ...lark.RequestOptionFunc) (*TextTranslateResp, error) { + rawResp, err := t.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/translation/v1/text/translate", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TextTranslateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (t *text) Detect(ctx context.Context, req *TextDetectReq, options ...lark.RequestOptionFunc) (*TextDetectResp, error) { + rawResp, err := t.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/translation/v1/text/detect", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &TextDetectResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} diff --git a/v2/service/translation/v1/model.go b/v2/service/translation/v1/model.go new file mode 100644 index 00000000..045132dc --- /dev/null +++ b/v2/service/translation/v1/model.go @@ -0,0 +1,50 @@ +// Package translation code generated by lark suite oapi sdk gen +package translation + +import ( + "github.com/larksuite/oapi-sdk-go/v2" +) + +type Term struct { + From *string `json:"from,omitempty"` + To *string `json:"to,omitempty"` +} + +type TextTranslateReqBody struct { + SourceLanguage *string `json:"source_language,omitempty"` + Text *string `json:"text,omitempty"` + TargetLanguage *string `json:"target_language,omitempty"` + Glossary []*Term `json:"glossary,omitempty"` +} + +type TextTranslateReq struct { + Body *TextTranslateReqBody `body:""` +} + +type TextTranslateRespData struct { + Text *string `json:"text,omitempty"` +} + +type TextTranslateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *TextTranslateRespData `json:"data"` +} + +type TextDetectReqBody struct { + Text *string `json:"text,omitempty"` +} + +type TextDetectReq struct { + Body *TextDetectReqBody `body:""` +} + +type TextDetectRespData struct { + Language *string `json:"language,omitempty"` +} + +type TextDetectResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *TextDetectRespData `json:"data"` +} diff --git a/v2/service/vc/v1/api.go b/v2/service/vc/v1/api.go new file mode 100644 index 00000000..88058994 --- /dev/null +++ b/v2/service/vc/v1/api.go @@ -0,0 +1,291 @@ +// Package vc code generated by lark suite oapi sdk gen +package vc + +import ( + "context" + "net/http" + + "github.com/larksuite/oapi-sdk-go/v2" +) + +type VcService struct { + Meetings *meetings + MeetingRecording *meetingRecording + Reports *reports + Reserves *reserves + RoomConfigs *roomConfigs +} + +func New(app *lark.App) *VcService { + v := &VcService{} + v.Meetings = &meetings{app: app} + v.MeetingRecording = &meetingRecording{app: app} + v.Reports = &reports{app: app} + v.Reserves = &reserves{app: app} + v.RoomConfigs = &roomConfigs{app: app} + return v +} + +type meetings struct { + app *lark.App +} +type meetingRecording struct { + app *lark.App +} +type reports struct { + app *lark.App +} +type reserves struct { + app *lark.App +} +type roomConfigs struct { + app *lark.App +} + +func (m *meetings) Invite(ctx context.Context, req *MeetingInviteReq, options ...lark.RequestOptionFunc) (*MeetingInviteResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPatch, + "/open-apis/vc/v1/meetings/:meeting_id/invite", []lark.AccessTokenType{lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &MeetingInviteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *meetings) SetHost(ctx context.Context, req *MeetingSetHostReq, options ...lark.RequestOptionFunc) (*MeetingSetHostResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPatch, + "/open-apis/vc/v1/meetings/:meeting_id/set_host", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MeetingSetHostResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *meetings) End(ctx context.Context, req *MeetingEndReq, options ...lark.RequestOptionFunc) (*MeetingEndResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPatch, + "/open-apis/vc/v1/meetings/:meeting_id/end", []lark.AccessTokenType{lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &MeetingEndResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *meetings) Get(ctx context.Context, req *MeetingGetReq, options ...lark.RequestOptionFunc) (*MeetingGetResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/vc/v1/meetings/:meeting_id", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MeetingGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *meetings) Kickout(ctx context.Context, req *MeetingKickoutReq, options ...lark.RequestOptionFunc) (*MeetingKickoutResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/vc/v1/meetings/:meeting_id/kickout", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MeetingKickoutResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *meetings) ListByNo(ctx context.Context, req *MeetingListByNoReq, options ...lark.RequestOptionFunc) (*MeetingListByNoResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/vc/v1/meetings/list_by_no", []lark.AccessTokenType{lark.AccessTokenTypeUser, lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &MeetingListByNoResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *meetingRecording) Get(ctx context.Context, req *MeetingRecordingGetReq, options ...lark.RequestOptionFunc) (*MeetingRecordingGetResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/vc/v1/meetings/:meeting_id/recording", []lark.AccessTokenType{lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &MeetingRecordingGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *meetingRecording) Stop(ctx context.Context, req *MeetingRecordingStopReq, options ...lark.RequestOptionFunc) (*MeetingRecordingStopResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPatch, + "/open-apis/vc/v1/meetings/:meeting_id/recording/stop", []lark.AccessTokenType{lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &MeetingRecordingStopResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *meetingRecording) SetPermission(ctx context.Context, req *MeetingRecordingSetPermissionReq, options ...lark.RequestOptionFunc) (*MeetingRecordingSetPermissionResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPatch, + "/open-apis/vc/v1/meetings/:meeting_id/recording/set_permission", []lark.AccessTokenType{lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &MeetingRecordingSetPermissionResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (m *meetingRecording) Start(ctx context.Context, req *MeetingRecordingStartReq, options ...lark.RequestOptionFunc) (*MeetingRecordingStartResp, error) { + rawResp, err := m.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPatch, + "/open-apis/vc/v1/meetings/:meeting_id/recording/start", []lark.AccessTokenType{lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &MeetingRecordingStartResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (r *reports) GetTopUser(ctx context.Context, req *ReportGetTopUserReq, options ...lark.RequestOptionFunc) (*ReportGetTopUserResp, error) { + rawResp, err := r.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/vc/v1/reports/get_top_user", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &ReportGetTopUserResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (r *reports) GetDaily(ctx context.Context, req *ReportGetDailyReq, options ...lark.RequestOptionFunc) (*ReportGetDailyResp, error) { + rawResp, err := r.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/vc/v1/reports/get_daily", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &ReportGetDailyResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (r *reserves) Update(ctx context.Context, req *ReserveUpdateReq, options ...lark.RequestOptionFunc) (*ReserveUpdateResp, error) { + rawResp, err := r.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPut, + "/open-apis/vc/v1/reserves/:reserve_id", []lark.AccessTokenType{lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &ReserveUpdateResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (r *reserves) Apply(ctx context.Context, req *ReserveApplyReq, options ...lark.RequestOptionFunc) (*ReserveApplyResp, error) { + rawResp, err := r.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/vc/v1/reserves/apply", []lark.AccessTokenType{lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &ReserveApplyResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (r *reserves) Get(ctx context.Context, req *ReserveGetReq, options ...lark.RequestOptionFunc) (*ReserveGetResp, error) { + rawResp, err := r.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/vc/v1/reserves/:reserve_id", []lark.AccessTokenType{lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &ReserveGetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (r *reserves) GetActiveMeeting(ctx context.Context, req *ReserveGetActiveMeetingReq, options ...lark.RequestOptionFunc) (*ReserveGetActiveMeetingResp, error) { + rawResp, err := r.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/vc/v1/reserves/:reserve_id/get_active_meeting", []lark.AccessTokenType{lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &ReserveGetActiveMeetingResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (r *reserves) Delete(ctx context.Context, req *ReserveDeleteReq, options ...lark.RequestOptionFunc) (*ReserveDeleteResp, error) { + rawResp, err := r.app.SendRequestWithAccessTokenTypes(ctx, http.MethodDelete, + "/open-apis/vc/v1/reserves/:reserve_id", []lark.AccessTokenType{lark.AccessTokenTypeUser}, req, options...) + if err != nil { + return nil, err + } + resp := &ReserveDeleteResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (r *roomConfigs) Query(ctx context.Context, req *RoomConfigQueryReq, options ...lark.RequestOptionFunc) (*RoomConfigQueryResp, error) { + rawResp, err := r.app.SendRequestWithAccessTokenTypes(ctx, http.MethodGet, + "/open-apis/vc/v1/room_configs/query", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &RoomConfigQueryResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} +func (r *roomConfigs) Set(ctx context.Context, req *RoomConfigSetReq, options ...lark.RequestOptionFunc) (*RoomConfigSetResp, error) { + rawResp, err := r.app.SendRequestWithAccessTokenTypes(ctx, http.MethodPost, + "/open-apis/vc/v1/room_configs/set", []lark.AccessTokenType{lark.AccessTokenTypeTenant}, req, options...) + if err != nil { + return nil, err + } + resp := &RoomConfigSetResp{RawResponse: rawResp} + err = rawResp.JSONUnmarshalBody(resp) + if err != nil { + return nil, err + } + return resp, err +} diff --git a/v2/service/vc/v1/event.go b/v2/service/vc/v1/event.go new file mode 100644 index 00000000..17c85f87 --- /dev/null +++ b/v2/service/vc/v1/event.go @@ -0,0 +1,151 @@ +// Package vc code generated by lark suite oapi sdk gen +package vc + +import ( + "context" + "github.com/larksuite/oapi-sdk-go/v2" +) + +type meetingLeaveMeetingEventHandler struct { + handler func(context.Context, *lark.RawRequest, *MeetingLeaveMeetingEvent) error +} + +func (h *meetingLeaveMeetingEventHandler) Event() interface{} { + return &MeetingLeaveMeetingEvent{} +} + +func (h *meetingLeaveMeetingEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*MeetingLeaveMeetingEvent)) +} + +func (m *meetings) LeaveMeetingEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *MeetingLeaveMeetingEvent) error) { + m.app.Webhook.EventHandler("leave_meeting", &meetingLeaveMeetingEventHandler{handler: handler}) +} + +type meetingMeetingEndedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *MeetingMeetingEndedEvent) error +} + +func (h *meetingMeetingEndedEventHandler) Event() interface{} { + return &MeetingMeetingEndedEvent{} +} + +func (h *meetingMeetingEndedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*MeetingMeetingEndedEvent)) +} + +func (m *meetings) MeetingEndedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *MeetingMeetingEndedEvent) error) { + m.app.Webhook.EventHandler("meeting_ended", &meetingMeetingEndedEventHandler{handler: handler}) +} + +type meetingMeetingStartedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *MeetingMeetingStartedEvent) error +} + +func (h *meetingMeetingStartedEventHandler) Event() interface{} { + return &MeetingMeetingStartedEvent{} +} + +func (h *meetingMeetingStartedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*MeetingMeetingStartedEvent)) +} + +func (m *meetings) MeetingStartedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *MeetingMeetingStartedEvent) error) { + m.app.Webhook.EventHandler("meeting_started", &meetingMeetingStartedEventHandler{handler: handler}) +} + +type meetingRecordingEndedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *MeetingRecordingEndedEvent) error +} + +func (h *meetingRecordingEndedEventHandler) Event() interface{} { + return &MeetingRecordingEndedEvent{} +} + +func (h *meetingRecordingEndedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*MeetingRecordingEndedEvent)) +} + +func (m *meetings) RecordingEndedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *MeetingRecordingEndedEvent) error) { + m.app.Webhook.EventHandler("recording_ended", &meetingRecordingEndedEventHandler{handler: handler}) +} + +type meetingShareEndedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *MeetingShareEndedEvent) error +} + +func (h *meetingShareEndedEventHandler) Event() interface{} { + return &MeetingShareEndedEvent{} +} + +func (h *meetingShareEndedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*MeetingShareEndedEvent)) +} + +func (m *meetings) ShareEndedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *MeetingShareEndedEvent) error) { + m.app.Webhook.EventHandler("share_ended", &meetingShareEndedEventHandler{handler: handler}) +} + +type meetingJoinMeetingEventHandler struct { + handler func(context.Context, *lark.RawRequest, *MeetingJoinMeetingEvent) error +} + +func (h *meetingJoinMeetingEventHandler) Event() interface{} { + return &MeetingJoinMeetingEvent{} +} + +func (h *meetingJoinMeetingEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*MeetingJoinMeetingEvent)) +} + +func (m *meetings) JoinMeetingEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *MeetingJoinMeetingEvent) error) { + m.app.Webhook.EventHandler("join_meeting", &meetingJoinMeetingEventHandler{handler: handler}) +} + +type meetingRecordingStartedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *MeetingRecordingStartedEvent) error +} + +func (h *meetingRecordingStartedEventHandler) Event() interface{} { + return &MeetingRecordingStartedEvent{} +} + +func (h *meetingRecordingStartedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*MeetingRecordingStartedEvent)) +} + +func (m *meetings) RecordingStartedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *MeetingRecordingStartedEvent) error) { + m.app.Webhook.EventHandler("recording_started", &meetingRecordingStartedEventHandler{handler: handler}) +} + +type meetingShareStartedEventHandler struct { + handler func(context.Context, *lark.RawRequest, *MeetingShareStartedEvent) error +} + +func (h *meetingShareStartedEventHandler) Event() interface{} { + return &MeetingShareStartedEvent{} +} + +func (h *meetingShareStartedEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*MeetingShareStartedEvent)) +} + +func (m *meetings) ShareStartedEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *MeetingShareStartedEvent) error) { + m.app.Webhook.EventHandler("share_started", &meetingShareStartedEventHandler{handler: handler}) +} + +type meetingRecordingReadyEventHandler struct { + handler func(context.Context, *lark.RawRequest, *MeetingRecordingReadyEvent) error +} + +func (h *meetingRecordingReadyEventHandler) Event() interface{} { + return &MeetingRecordingReadyEvent{} +} + +func (h *meetingRecordingReadyEventHandler) Handle(ctx context.Context, req *lark.RawRequest, event interface{}) error { + return h.handler(ctx, req, event.(*MeetingRecordingReadyEvent)) +} + +func (m *meetings) RecordingReadyEventHandler(handler func(ctx context.Context, req *lark.RawRequest, event *MeetingRecordingReadyEvent) error) { + m.app.Webhook.EventHandler("recording_ready", &meetingRecordingReadyEventHandler{handler: handler}) +} diff --git a/v2/service/vc/v1/model.go b/v2/service/vc/v1/model.go new file mode 100644 index 00000000..169ef662 --- /dev/null +++ b/v2/service/vc/v1/model.go @@ -0,0 +1,613 @@ +// Package vc code generated by lark suite oapi sdk gen +package vc + +import ( + "github.com/larksuite/oapi-sdk-go/v2" +) + +type UserId struct { + UserId *string `json:"user_id,omitempty"` + OpenId *string `json:"open_id,omitempty"` + UnionId *string `json:"union_id,omitempty"` +} + +type Material struct { + Name *string `json:"name,omitempty"` + FileToken *string `json:"file_token,omitempty"` + FileSize *int `json:"file_size,omitempty"` + DeviceType *int `json:"device_type,omitempty"` + MaterialType *int `json:"material_type,omitempty"` + ReviewResult *int `json:"review_result,omitempty"` + MaterialSource *int `json:"material_source,omitempty"` +} + +type MaterialDeleteResult struct { + FileToken *string `json:"file_token,omitempty"` + Result *int `json:"result,omitempty"` +} + +type MaterialReviewResult struct { + FileToken *string `json:"file_token,omitempty"` + Result *int `json:"result,omitempty"` +} + +type MaterialUploadResult struct { + FileToken *string `json:"file_token,omitempty"` + Result *int `json:"result,omitempty"` +} + +type MeetingRecording struct { + Id *int64 `json:"id,omitempty,string"` + MeetingId *int64 `json:"meeting_id,omitempty,string"` + Url *string `json:"url,omitempty"` + Duration *int64 `json:"duration,omitempty,string"` +} + +type MeetingAbility struct { + UseVideo *bool `json:"use_video,omitempty"` + UseAudio *bool `json:"use_audio,omitempty"` + UseShareScreen *bool `json:"use_share_screen,omitempty"` + UseFollowScreen *bool `json:"use_follow_screen,omitempty"` + UseRecording *bool `json:"use_recording,omitempty"` + UsePstn *bool `json:"use_pstn,omitempty"` +} + +type MeetingEventMeeting struct { + Id *int64 `json:"id,omitempty,string"` + Topic *string `json:"topic,omitempty"` + MeetingNo *string `json:"meeting_no,omitempty"` + StartTime *int64 `json:"start_time,omitempty,string"` + EndTime *int64 `json:"end_time,omitempty,string"` + HostUser *MeetingEventUser `json:"host_user,omitempty"` + Owner *MeetingEventUser `json:"owner,omitempty"` +} + +type MeetingEventUser struct { + Id *UserId `json:"id,omitempty"` + UserRole *int `json:"user_role,omitempty"` + UserType *int `json:"user_type,omitempty"` +} + +type MeetingInviteStatus struct { + Id *string `json:"id,omitempty"` + UserType *int `json:"user_type,omitempty"` + Status *int `json:"status,omitempty"` +} + +type MeetingUser struct { + Id *string `json:"id,omitempty"` + UserType *int `json:"user_type,omitempty"` +} + +type PstnSipInfo struct { + Nickname *string `json:"nickname,omitempty"` + MainAddress *string `json:"main_address,omitempty"` +} + +type RecordingPermissionObject struct { + Id *string `json:"id,omitempty"` + Type *int `json:"type,omitempty"` + Permission *int `json:"permission,omitempty"` +} + +type Report struct { + TotalMeetingCount *int64 `json:"total_meeting_count,omitempty,string"` + TotalMeetingDuration *int64 `json:"total_meeting_duration,omitempty,string"` + TotalParticipantCount *int64 `json:"total_participant_count,omitempty,string"` + DailyReport []*ReportMeetingDaily `json:"daily_report,omitempty"` +} + +type ReportMeetingDaily struct { + Date *int64 `json:"date,omitempty,string"` + MeetingCount *int64 `json:"meeting_count,omitempty,string"` + MeetingDuration *int64 `json:"meeting_duration,omitempty,string"` + ParticipantCount *int64 `json:"participant_count,omitempty,string"` +} + +type ReportTopUser struct { + Id *int64 `json:"id,omitempty,string"` + Name *string `json:"name,omitempty"` + UserType *int `json:"user_type,omitempty"` + MeetingCount *int64 `json:"meeting_count,omitempty,string"` + MeetingDuration *int64 `json:"meeting_duration,omitempty,string"` +} + +type ReserveActionPermission struct { + Permission *int `json:"permission,omitempty"` + PermissionCheckers []*ReservePermissionChecker `json:"permission_checkers,omitempty"` +} + +type ReserveCallSetting struct { + Callee *ReserveCallee `json:"callee,omitempty"` +} + +type ReserveCallee struct { + Id *string `json:"id,omitempty"` + UserType *int `json:"user_type,omitempty"` + PstnSipInfo *PstnSipInfo `json:"pstn_sip_info,omitempty"` +} + +type ReserveMeetingSetting struct { + Topic *string `json:"topic,omitempty"` + ActionPermissions []*ReserveActionPermission `json:"action_permissions,omitempty"` + MeetingInitialType *int `json:"meeting_initial_type,omitempty"` + CallSetting *ReserveCallSetting `json:"call_setting,omitempty"` +} + +type ReservePermissionChecker struct { + CheckField *int `json:"check_field,omitempty"` + CheckMode *int `json:"check_mode,omitempty"` + CheckList []string `json:"check_list,omitempty"` +} + +type RoomDigitalSignage struct { + Enable *bool `json:"enable,omitempty"` + Mute *bool `json:"mute,omitempty"` + StartDisplay *int `json:"start_display,omitempty"` + StopDisplay *int `json:"stop_display,omitempty"` + Materials []*RoomDigitalSignageMaterial `json:"materials,omitempty"` +} + +type Meeting struct { + Id *int64 `json:"id,omitempty,string"` + Topic *string `json:"topic,omitempty"` + Url *string `json:"url,omitempty"` + MeetingNo *string `json:"meeting_no,omitempty"` + CreateTime *int64 `json:"create_time,omitempty,string"` + StartTime *int64 `json:"start_time,omitempty,string"` + EndTime *int64 `json:"end_time,omitempty,string"` + HostUser *MeetingUser `json:"host_user,omitempty"` + Status *int `json:"status,omitempty"` + ParticipantCount *int64 `json:"participant_count,omitempty,string"` + ParticipantCountAccumulated *int64 `json:"participant_count_accumulated,omitempty,string"` + Participants []*MeetingParticipant `json:"participants,omitempty"` + Ability *MeetingAbility `json:"ability,omitempty"` +} + +type MeetingParticipant struct { + Id *string `json:"id,omitempty"` + FirstJoinTime *int64 `json:"first_join_time,omitempty,string"` + FinalLeaveTime *int64 `json:"final_leave_time,omitempty,string"` + InMeetingDuration *int64 `json:"in_meeting_duration,omitempty,string"` + UserType *int `json:"user_type,omitempty"` + IsHost *bool `json:"is_host,omitempty"` + IsCohost *bool `json:"is_cohost,omitempty"` + IsExternal *bool `json:"is_external,omitempty"` + Status *int `json:"status,omitempty"` +} + +type MeetingParticipantResult struct { + Id *string `json:"id,omitempty"` + UserType *int `json:"user_type,omitempty"` + Result *int `json:"result,omitempty"` +} + +type Reserve struct { + Id *int64 `json:"id,omitempty,string"` + MeetingNo *string `json:"meeting_no,omitempty"` + Url *string `json:"url,omitempty"` + AppLink *string `json:"app_link,omitempty"` + LiveLink *string `json:"live_link,omitempty"` + EndTime *int64 `json:"end_time,omitempty,string"` + ExpireStatus *int `json:"expire_status,omitempty"` + ReserveUserId *string `json:"reserve_user_id,omitempty"` + MeetingSettings *ReserveMeetingSetting `json:"meeting_settings,omitempty"` +} + +type RoomConfig struct { + RoomBackground *string `json:"room_background,omitempty"` + DisplayBackground *string `json:"display_background,omitempty"` + DigitalSignage *RoomDigitalSignage `json:"digital_signage,omitempty"` + RoomBoxDigitalSignage *RoomDigitalSignage `json:"room_box_digital_signage,omitempty"` +} + +type RoomDigitalSignageMaterial struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + MaterialType *int `json:"material_type,omitempty"` + Url *string `json:"url,omitempty"` + Duration *int `json:"duration,omitempty"` + Cover *string `json:"cover,omitempty"` + Md5 *string `json:"md5,omitempty"` + Vid *string `json:"vid,omitempty"` + Size *string `json:"size,omitempty"` +} + +type MeetingInviteReqBody struct { + Invitees []*MeetingUser `json:"invitees,omitempty"` +} + +type MeetingInviteReq struct { + MeetingId string `path:"meeting_id"` + UserIdType *string `query:"user_id_type"` + Body *MeetingInviteReqBody `body:""` +} + +type MeetingInviteRespData struct { + InviteResults []*MeetingInviteStatus `json:"invite_results,omitempty"` +} + +type MeetingInviteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *MeetingInviteRespData `json:"data"` +} + +type MeetingSetHostReqBody struct { + HostUser *MeetingUser `json:"host_user,omitempty"` + OldHostUser *MeetingUser `json:"old_host_user,omitempty"` +} + +type MeetingSetHostReq struct { + MeetingId string `path:"meeting_id"` + UserIdType *string `query:"user_id_type"` + Body *MeetingSetHostReqBody `body:""` +} + +type MeetingSetHostRespData struct { + HostUser *MeetingUser `json:"host_user,omitempty"` +} + +type MeetingSetHostResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *MeetingSetHostRespData `json:"data"` +} + +type MeetingEndReq struct { + MeetingId string `path:"meeting_id"` +} + +type MeetingEndResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type MeetingGetReq struct { + MeetingId string `path:"meeting_id"` + WithParticipants *bool `query:"with_participants"` + WithMeetingAbility *bool `query:"with_meeting_ability"` + UserIdType *string `query:"user_id_type"` +} + +type MeetingGetRespData struct { + Meeting *Meeting `json:"meeting,omitempty"` +} + +type MeetingGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *MeetingGetRespData `json:"data"` +} + +type MeetingKickoutReqBody struct { + KickoutUsers []*MeetingUser `json:"kickout_users,omitempty"` +} + +type MeetingKickoutReq struct { + MeetingId string `path:"meeting_id"` + UserIdType *string `query:"user_id_type"` + Body *MeetingKickoutReqBody `body:""` +} + +type MeetingKickoutRespData struct { + KickoutResults []*MeetingParticipantResult `json:"kickout_results,omitempty"` +} + +type MeetingKickoutResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *MeetingKickoutRespData `json:"data"` +} + +type MeetingListByNoReq struct { + MeetingNo *string `query:"meeting_no"` + StartTime *int64 `query:"start_time"` + EndTime *int64 `query:"end_time"` + PageToken *string `query:"page_token"` + PageSize *int `query:"page_size"` +} + +type MeetingListByNoRespData struct { + HasMore *bool `json:"has_more,omitempty"` + PageToken *string `json:"page_token,omitempty"` + MeetingBriefs []*Meeting `json:"meeting_briefs,omitempty"` +} + +type MeetingListByNoResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *MeetingListByNoRespData `json:"data"` +} + +type MeetingRecordingGetReq struct { + MeetingId string `path:"meeting_id"` +} + +type MeetingRecordingGetRespData struct { + Recording *MeetingRecording `json:"recording,omitempty"` +} + +type MeetingRecordingGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *MeetingRecordingGetRespData `json:"data"` +} + +type MeetingRecordingStopReq struct { + MeetingId string `path:"meeting_id"` +} + +type MeetingRecordingStopResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type MeetingRecordingSetPermissionReqBody struct { + PermissionObjects []*RecordingPermissionObject `json:"permission_objects,omitempty"` +} + +type MeetingRecordingSetPermissionReq struct { + MeetingId string `path:"meeting_id"` + UserIdType *string `query:"user_id_type"` + Body *MeetingRecordingSetPermissionReqBody `body:""` +} + +type MeetingRecordingSetPermissionResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type MeetingRecordingStartReqBody struct { + Timezone *int `json:"timezone,omitempty"` +} + +type MeetingRecordingStartReq struct { + MeetingId string `path:"meeting_id"` + Body *MeetingRecordingStartReqBody `body:""` +} + +type MeetingRecordingStartResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type ReportGetTopUserReq struct { + StartTime *int64 `query:"start_time"` + EndTime *int64 `query:"end_time"` + Limit *int `query:"limit"` + OrderBy *int `query:"order_by"` + UserIdType *string `query:"user_id_type"` +} + +type ReportGetTopUserRespData struct { + TopUserReport []*ReportTopUser `json:"top_user_report,omitempty"` +} + +type ReportGetTopUserResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *ReportGetTopUserRespData `json:"data"` +} + +type ReportGetDailyReq struct { + StartTime *int64 `query:"start_time"` + EndTime *int64 `query:"end_time"` +} + +type ReportGetDailyRespData struct { + MeetingReport *Report `json:"meeting_report,omitempty"` +} + +type ReportGetDailyResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *ReportGetDailyRespData `json:"data"` +} + +type ReserveUpdateReqBody struct { + EndTime *int64 `json:"end_time,omitempty,string"` + MeetingSettings *ReserveMeetingSetting `json:"meeting_settings,omitempty"` +} + +type ReserveUpdateReq struct { + ReserveId string `path:"reserve_id"` + UserIdType *string `query:"user_id_type"` + Body *ReserveUpdateReqBody `body:""` +} + +type ReserveUpdateRespData struct { + Reserve *Reserve `json:"reserve,omitempty"` +} + +type ReserveUpdateResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *ReserveUpdateRespData `json:"data"` +} + +type ReserveApplyReqBody struct { + EndTime *int64 `json:"end_time,omitempty,string"` + MeetingSettings *ReserveMeetingSetting `json:"meeting_settings,omitempty"` +} + +type ReserveApplyReq struct { + UserIdType *string `query:"user_id_type"` + Body *ReserveApplyReqBody `body:""` +} + +type ReserveApplyRespData struct { + Reserve *Reserve `json:"reserve,omitempty"` +} + +type ReserveApplyResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *ReserveApplyRespData `json:"data"` +} + +type ReserveGetReq struct { + ReserveId string `path:"reserve_id"` + UserIdType *string `query:"user_id_type"` +} + +type ReserveGetRespData struct { + Reserve *Reserve `json:"reserve,omitempty"` +} + +type ReserveGetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *ReserveGetRespData `json:"data"` +} + +type ReserveGetActiveMeetingReq struct { + ReserveId string `path:"reserve_id"` + WithParticipants *bool `query:"with_participants"` + UserIdType *string `query:"user_id_type"` +} + +type ReserveGetActiveMeetingRespData struct { + Meeting *Meeting `json:"meeting,omitempty"` +} + +type ReserveGetActiveMeetingResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *ReserveGetActiveMeetingRespData `json:"data"` +} + +type ReserveDeleteReq struct { + ReserveId string `path:"reserve_id"` +} + +type ReserveDeleteResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type RoomConfigQueryReq struct { + Scope *int `query:"scope"` + CountryId *string `query:"country_id"` + DistrictId *string `query:"district_id"` + BuildingId *string `query:"building_id"` + FloorName *string `query:"floor_name"` + RoomId *string `query:"room_id"` +} + +type RoomConfigQueryResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError + Data *RoomConfig `json:"data"` +} + +type RoomConfigSetReqBody struct { + Scope *int `json:"scope,omitempty"` + CountryId *string `json:"country_id,omitempty"` + DistrictId *string `json:"district_id,omitempty"` + BuildingId *string `json:"building_id,omitempty"` + FloorName *string `json:"floor_name,omitempty"` + RoomId *string `json:"room_id,omitempty"` + RoomConfig *RoomConfig `json:"room_config,omitempty"` +} + +type RoomConfigSetReq struct { + Body *RoomConfigSetReqBody `body:""` +} + +type RoomConfigSetResp struct { + *lark.RawResponse `json:"-"` + lark.CodeError +} + +type MeetingLeaveMeetingEventData struct { + Meeting *MeetingEventMeeting `json:"meeting,omitempty"` + Operator *MeetingEventUser `json:"operator,omitempty"` + LeaveReason *int `json:"leave_reason,omitempty"` +} + +type MeetingLeaveMeetingEvent struct { + *lark.EventV2Base + Event *MeetingLeaveMeetingEventData `json:"event"` +} + +type MeetingMeetingEndedEventData struct { + Meeting *MeetingEventMeeting `json:"meeting,omitempty"` + Operator *MeetingEventUser `json:"operator,omitempty"` +} + +type MeetingMeetingEndedEvent struct { + *lark.EventV2Base + Event *MeetingMeetingEndedEventData `json:"event"` +} + +type MeetingMeetingStartedEventData struct { + Meeting *MeetingEventMeeting `json:"meeting,omitempty"` + Operator *MeetingEventUser `json:"operator,omitempty"` +} + +type MeetingMeetingStartedEvent struct { + *lark.EventV2Base + Event *MeetingMeetingStartedEventData `json:"event"` +} + +type MeetingRecordingEndedEventData struct { + Meeting *MeetingEventMeeting `json:"meeting,omitempty"` + Operator *MeetingEventUser `json:"operator,omitempty"` +} + +type MeetingRecordingEndedEvent struct { + *lark.EventV2Base + Event *MeetingRecordingEndedEventData `json:"event"` +} + +type MeetingShareEndedEventData struct { + Meeting *MeetingEventMeeting `json:"meeting,omitempty"` + Operator *MeetingEventUser `json:"operator,omitempty"` +} + +type MeetingShareEndedEvent struct { + *lark.EventV2Base + Event *MeetingShareEndedEventData `json:"event"` +} + +type MeetingJoinMeetingEventData struct { + Meeting *MeetingEventMeeting `json:"meeting,omitempty"` + Operator *MeetingEventUser `json:"operator,omitempty"` +} + +type MeetingJoinMeetingEvent struct { + *lark.EventV2Base + Event *MeetingJoinMeetingEventData `json:"event"` +} + +type MeetingRecordingStartedEventData struct { + Meeting *MeetingEventMeeting `json:"meeting,omitempty"` + Operator *MeetingEventUser `json:"operator,omitempty"` +} + +type MeetingRecordingStartedEvent struct { + *lark.EventV2Base + Event *MeetingRecordingStartedEventData `json:"event"` +} + +type MeetingShareStartedEventData struct { + Meeting *MeetingEventMeeting `json:"meeting,omitempty"` + Operator *MeetingEventUser `json:"operator,omitempty"` +} + +type MeetingShareStartedEvent struct { + *lark.EventV2Base + Event *MeetingShareStartedEventData `json:"event"` +} + +type MeetingRecordingReadyEventData struct { + Meeting *MeetingEventMeeting `json:"meeting,omitempty"` + Url *string `json:"url,omitempty"` + Duration *int64 `json:"duration,omitempty,string"` +} + +type MeetingRecordingReadyEvent struct { + *lark.EventV2Base + Event *MeetingRecordingReadyEventData `json:"event"` +} diff --git a/v2/store.go b/v2/store.go new file mode 100644 index 00000000..5ac22789 --- /dev/null +++ b/v2/store.go @@ -0,0 +1,40 @@ +package lark + +import ( + "context" + "sync" + "time" +) + +type store interface { + Get(context.Context, string) (string, error) + Put(context.Context, string, string, time.Duration) error +} + +type defaultStore struct { + m sync.Map +} + +type Value struct { + value string + expireTime time.Time +} + +func (s *defaultStore) Get(ctx context.Context, key string) (string, error) { + if val, ok := s.m.Load(key); ok { + ev := val.(*Value) + if ev.expireTime.After(time.Now()) { + return ev.value, nil + } + } + return "", nil +} + +func (s *defaultStore) Put(ctx context.Context, key, value string, ttl time.Duration) error { + expireTime := time.Now().Add(ttl) + s.m.Store(key, &Value{ + value: value, + expireTime: expireTime, + }) + return nil +} diff --git a/v2/utils.go b/v2/utils.go new file mode 100644 index 00000000..6bd59be5 --- /dev/null +++ b/v2/utils.go @@ -0,0 +1,424 @@ +package lark + +import ( + "bytes" + "context" + "fmt" + "io" + "io/ioutil" + "mime" + "net/http" + "reflect" + "strings" +) + +import "time" + +// StringPtr returns a pointer to the string value passed in. +func StringPtr(v string) *string { + return &v +} + +// StringValue returns the value of the string pointer passed in or +// "" if the pointer is nil. +func StringValue(v *string) string { + if v != nil { + return *v + } + return "" +} + +// BoolPtr returns a pointer to the bool value passed in. +func BoolPtr(v bool) *bool { + return &v +} + +// BoolValue returns the value of the bool pointer passed in or +// false if the pointer is nil. +func BoolValue(v *bool) bool { + if v != nil { + return *v + } + return false +} + +// IntPtr returns a pointer to the int value passed in. +func IntPtr(v int) *int { + return &v +} + +// IntValue returns the value of the int pointer passed in or +// 0 if the pointer is nil. +func IntValue(v *int) int { + if v != nil { + return *v + } + return 0 +} + +// Int8Ptr returns a pointer to the int8 value passed in. +func Int8Ptr(v int8) *int8 { + return &v +} + +// Int8Value returns the value of the int8 pointer passed in or +// 0 if the pointer is nil. +func Int8Value(v *int8) int8 { + if v != nil { + return *v + } + return 0 +} + +// Int16Ptr returns a pointer to the int16 value passed in. +func Int16Ptr(v int16) *int16 { + return &v +} + +// Int16Value returns the value of the int16 pointer passed in or +// 0 if the pointer is nil. +func Int16Value(v *int16) int16 { + if v != nil { + return *v + } + return 0 +} + +// Int32Ptr returns a pointer to the int32 value passed in. +func Int32Ptr(v int32) *int32 { + return &v +} + +// Int32Value returns the value of the int32 pointer passed in or +// 0 if the pointer is nil. +func Int32Value(v *int32) int32 { + if v != nil { + return *v + } + return 0 +} + +// Int64Ptr returns a pointer to the int64 value passed in. +func Int64Ptr(v int64) *int64 { + return &v +} + +// Int64Value returns the value of the int64 pointer passed in or +// 0 if the pointer is nil. +func Int64Value(v *int64) int64 { + if v != nil { + return *v + } + return 0 +} + +// Float32Ptr returns a pointer to the float32 value passed in. +func Float32Ptr(v float32) *float32 { + return &v +} + +// Float32Value returns the value of the float32 pointer passed in or +// 0 if the pointer is nil. +func Float32Value(v *float32) float32 { + if v != nil { + return *v + } + return 0 +} + +// Float64Ptr returns a pointer to the float64 value passed in. +func Float64Ptr(v float64) *float64 { + return &v +} + +// Float64Value returns the value of the float64 pointer passed in or +// 0 if the pointer is nil. +func Float64Value(v *float64) float64 { + if v != nil { + return *v + } + return 0 +} + +// TimePtr returns a pointer to the time.Time value passed in. +func TimePtr(v time.Time) *time.Time { + return &v +} + +// TimeValue returns the value of the time.Time pointer passed in or +// time.Time{} if the pointer is nil. +func TimeValue(v *time.Time) time.Time { + if v != nil { + return *v + } + return time.Time{} +} + +// Prettify returns the string representation of a value. +func Prettify(i interface{}) string { + var buf bytes.Buffer + prettify(reflect.ValueOf(i), 0, &buf) + return buf.String() +} + +// DownloadFile returns the url of resource +func DownloadFile(ctx context.Context, url string) ([]byte, error) { + r, err := downloadFileToStream(ctx, url) + if err != nil { + return nil, err + } + defer r.Close() + return ioutil.ReadAll(r) +} + +func FileNameByHeader(header http.Header) string { + filename := "" + _, media, _ := mime.ParseMediaType(header.Get("Content-Disposition")) + if len(media) > 0 { + filename = media["filename"] + } + return filename +} + +type DecryptErr struct { + Message string +} + +func newDecryptErr(message string) *DecryptErr { + return &DecryptErr{Message: message} +} + +func (e DecryptErr) Error() string { + return e.Message +} + +func downloadFileToStream(ctx context.Context, url string) (io.ReadCloser, error) { + request, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) + if err != nil { + return nil, err + } + resp, err := http.DefaultClient.Do(request) + if err != nil { + return nil, err + } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("response status code:%d", resp.StatusCode) + } + return resp.Body, nil +} + +// prettify will recursively walk value v to build a textual +// representation of the value. +func prettify(v reflect.Value, indent int, buf *bytes.Buffer) { + for v.Kind() == reflect.Ptr { + v = v.Elem() + } + switch v.Kind() { + case reflect.Struct: + strType := v.Type().String() + if strType == "time.Time" { + fmt.Fprintf(buf, "%s", v.Interface()) + break + } else if strings.HasPrefix(strType, "io.") { + buf.WriteString("") + break + } + + buf.WriteString("{\n") + + var names []string + for i := 0; i < v.Type().NumField(); i++ { + name := v.Type().Field(i).Name + f := v.Field(i) + if name[0:1] == strings.ToLower(name[0:1]) { + continue // ignore unexported fields + } + if (f.Kind() == reflect.Ptr || f.Kind() == reflect.Slice || f.Kind() == reflect.Map) && f.IsNil() { + continue // ignore unset fields + } + names = append(names, name) + } + + for i, n := range names { + val := v.FieldByName(n) + buf.WriteString(strings.Repeat(" ", indent+2)) + buf.WriteString(n + ": ") + prettify(val, indent+2, buf) + + if i < len(names)-1 { + buf.WriteString(",\n") + } + } + + buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") + case reflect.Slice: + strType := v.Type().String() + if strType == "[]uint8" { + fmt.Fprintf(buf, " len %d", v.Len()) + break + } + + nl, id, id2 := "", "", "" + if v.Len() > 3 { + nl, id, id2 = "\n", strings.Repeat(" ", indent), strings.Repeat(" ", indent+2) + } + buf.WriteString("[" + nl) + for i := 0; i < v.Len(); i++ { + buf.WriteString(id2) + prettify(v.Index(i), indent+2, buf) + + if i < v.Len()-1 { + buf.WriteString("," + nl) + } + } + + buf.WriteString(nl + id + "]") + case reflect.Map: + buf.WriteString("{\n") + + for i, k := range v.MapKeys() { + buf.WriteString(strings.Repeat(" ", indent+2)) + buf.WriteString(k.String() + ": ") + prettify(v.MapIndex(k), indent+2, buf) + + if i < v.Len()-1 { + buf.WriteString(",\n") + } + } + + buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") + default: + if !v.IsValid() { + fmt.Fprint(buf, "") + return + } + format := "%v" + switch v.Interface().(type) { + case string: + format = "%q" + case io.ReadSeeker, io.Reader: + format = "buffer(%p)" + } + fmt.Fprintf(buf, format, v.Interface()) + } +} + +func structToMap(val interface{}) (map[string]interface{}, error) { + m := make(map[string]interface{}) + s := reflect.Indirect(reflect.ValueOf(val)) + st := s.Type() + for i := 0; i < s.NumField(); i++ { + jsonTag := st.Field(i).Tag.Get("json") + if jsonTag == "" { + continue + } + tag, err := parseJSONTag(jsonTag) + if err != nil { + return nil, err + } + if tag.ignore { + continue + } + v := s.Field(i) + f := st.Field(i) + + if f.Type.Kind() == reflect.Ptr && v.IsNil() { + continue + } + // nil maps are treated as empty maps. + if f.Type.Kind() == reflect.Map && v.IsNil() { + continue + } + if f.Type.Kind() == reflect.Slice && v.IsNil() { + continue + } + if tag.stringFormat { + m[tag.apiName] = formatAsString(v, f.Type.Kind()) + } else { + m[tag.apiName] = v.Interface() + } + } + return m, nil +} + +func formatAsString(v reflect.Value, kind reflect.Kind) string { + if kind == reflect.Ptr && !v.IsNil() { + v = v.Elem() + } + return fmt.Sprintf("%v", v.Interface()) +} + +type jsonTag struct { + apiName string + stringFormat bool + ignore bool +} + +func parseJSONTag(val string) (jsonTag, error) { + if val == "-" { + return jsonTag{ignore: true}, nil + } + var tag jsonTag + i := strings.Index(val, ",") + if i == -1 || val[:i] == "" { + return tag, fmt.Errorf("malformed json tag: %s", val) + } + tag = jsonTag{ + apiName: val[:i], + } + switch val[i+1:] { + case "omitempty": + case "omitempty,string": + tag.stringFormat = true + default: + return tag, fmt.Errorf("malformed json tag: %s", val) + } + return tag, nil +} + +func isEmptyValue(v reflect.Value) bool { + switch v.Kind() { + case reflect.Array, reflect.Map, reflect.Slice, reflect.String: + return v.Len() == 0 + case reflect.Bool: + return !v.Bool() + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return v.Int() == 0 + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return v.Uint() == 0 + case reflect.Float32, reflect.Float64: + return v.Float() == 0 + case reflect.Interface, reflect.Ptr: + return v.IsNil() + } + return false +} + +func userAgent() string { + return fmt.Sprintf("oapi-sdk-go-v2/%s", version) +} + +func sendHTTPRequest(rawRequest *http.Request) (*RawResponse, error) { + resp, err := http.DefaultClient.Do(rawRequest) + if err != nil { + return nil, err + } + body, err := readResponse(resp) + if err != nil { + return nil, err + } + return &RawResponse{ + StatusCode: resp.StatusCode, + Header: resp.Header, + RawBody: body, + }, nil +} + +func readResponse(resp *http.Response) ([]byte, error) { + defer resp.Body.Close() + respBody, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, err + } + return respBody, nil +} diff --git a/v2/version.go b/v2/version.go new file mode 100644 index 00000000..9c33b2f1 --- /dev/null +++ b/v2/version.go @@ -0,0 +1,3 @@ +package lark + +const version = "v2.0.0"