diff --git a/README.md b/README.md index 28381035..1aa6e83c 100644 --- a/README.md +++ b/README.md @@ -1,205 +1,395 @@ -[**中文**](README.zh.md) - -# larksuit open api sdk - -| Module | description | -|--------------|--------------| -| core | Application information configuration and some general methods | -| api | Request the interface of larksuite/feishu | -| event | Monitor the business data of larksuite/feishu changes and events generated | -| card | Monitor the actions of message card interaction | -| service | Generated business SDK(api&event) | -| sample | Example | - -### Module core -```shell script -$ go get -u github.com/larksuite/oapi-sdk-go +[**README of 飞书**](README.zh.md) | Lark Suite + +# 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]. + +## Run environment + +--- + +- Golang 1.5+。 + +## Install + +--- + +```shell +go get -u github.com/larksuite/oapi-sdk-go ``` -### Instructions for use -- Instructions for use - - Get application configuration - - Provide [code sample GetConfig()](sample/config/config.go) - - Use redis achieve [Store Interface](core/store/store.go), for maintenance `app_ticket`、`app_access_token`、`tenant_access_token` life cycle - - Use logrus to implement [Logger Interface](core/log/log.go) - - Instructions for the method are as follows: - ```go - // Create application configuration to prevent leakage. It is recommended to put application information in environment variables. - // Environment variable or parameter name: - // APP_ID: App ID in the application certificate - // APP_SECRET: App Secret in the application certificate - // VERIFICATION_TOKEN: Verification Token in the event subscription - // ENCRYPT_KEY: Encrypt Key in the event subscription, yes Empty, indicating that the event content is not encrypted - // The configuration of the enterprise self-built application - appSettings := config.NewInternalAppSettings("[APP_ID]", "[APP_SECRET]", "[VERIFICATION_TOKEN]", "[ENCRYPT_KEY]") - // Enterprise The configuration of self-built applications, the application configuration is obtained through environment variables - appSettings := config.GetInternalAppSettingsByEnv() - // App Store application configuration - appSettings := config.NewISVAppSettings("[APP_ID]", "[APP_SECRET]", "[VERIFICATION_TOKEN]", "[ENCRYPT_KEY]") - // App store application configuration, obtain application configuration through environment variables - appSettings := config.GetISVAppSettingsByEnv() - - - // Create Config - // domain: domain name http address: constants.DomainFeiShu/constants.DomainLarkSuite - // appSettings: application configuration - // logger: [log interface](core/log/log.go) - // loggerLevel: output log level log.LevelDebug/LevelInfo/LevelWarn/LevelError - // store: [Storage interface](core/store/store.go), used to store app_ticket/app_access_token/tenant_access_token - // used in online config - conf := config.NewConfig(domain, appSettings, logger, loggerLevel, store) - - // Config for development and testing - // logger: use the default implementation(core/log/log.go defaultLogger) - // loggerLevel: Debug level - // store: use the default implementation(core/store/store.go DefaultStore) - conf := config.NewTestConfig(domain, appSettings) - - // Create CoreContext(*core.Context) for API requests, Event callbacks, Card callbacks, etc., as function parameters - // core.Context implements the context.Context interface - coreCtx := core.WrapContext(context.Background()) - // Get the RequestID(string) of API requests, Event callbacks, and Card callbacks, used for problem feedback, open platform query related logs, you can quickly locate the problem - requestID := coreCtx.GetRequestID() - // Get response to API request Status code(int) - statusCode := coreCtx.GetHTTPStatusCode() - - ``` - -### Module api -- Processing flow - - The acquisition and life cycle maintenance of app_access_token and tenant_access_token life cycle, **developers can directly access the business interface** - ![processing flow](api_process_en.jpg) -- Business API SDK that has been generated - - | Business service | version | path | sample | - |--------------|--------------|------|------| - | Authentication | v1 | [service/authen](service/authen) | [sample/api/authen.go](sample/api/authen.go)| - | Image | v4 | [service/image](service/image)|[sample/api/image.go](sample/api/image.go)| - | Contact | v3 | [service/contact](service/contact) | [sample/api/contact.go](sample/api/contact.go) | - | Calendar | v4 | [service/calendar](service/calendar)|[sample/api/calendar.go](sample/api/calendar.go)| - | Drive | v1 | [service/drive](service/drive)|[sample/api/drive.go](sample/api/drive.go)| - - -- Instructions for use(For`No business API SDK is generated`the processing method) - - For`App Store application`, when acquiring`app_access_token`, you need `app_ticket` to start the event subscription service(`Module event`) - - [Usage example](sample/api/api.go) - - The package request is as follows: - ```go - 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/api/core/request" - "github.com/larksuite/oapi-sdk-go/api/core/response" - ) - // Create request - // httpPath:(path after `open-apis/`) API path, for example: https://{domain}/open-apis/authen/v1/user_info, the httpPath: "authen/v1/user_info" - // httpMethod: GET/POST/PUT/BATCH/DELETE - // accessTokenType: which token access is used by the API, value range: request.AccessTokenTypeApp/request.AccessTokenTypeTenant/request.AccessTokenTypeUser, for example: request.AccessTokenTypeTenant - // input : Request body(may be request.NewFormData()(for example: file upload)), if the request body is not needed(for example, some GET requests), then pass: nil - // output: response body(output := response["data" ]) - // optFns: extended function, some uncommon parameter packages, as follows: - // request.SetPathParams(map[string]interface{}{"user_id": 4}): set the URL Path parameter(with: prefix) value, When httpPath="users/:user_id", the requested URL="https://{domain}/open-apis/users/4" - // request.SetQueryParams(map[string]interface{}{"age":4,"types":[1,2]}): Set the URL qeury, 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 time: output value is Buffer type - // 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 - // req := request.NewRequestWithNative(httpPath:string, httpMethod:string, accessTokenType:AccessTokenType, input:interface, output:interface, ... optFns:OptFn [))) - // Example: - 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("message/v4/send", "POST", request.AccessTokenTypeTenant, body, &ret) - coreCtx := core.WarpContext(context.Background()) - 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)) - - ``` - - Tool - - | Tool | path | description | - |--------------|--------------|------| - | file download | [api/core/tools/file.go](api/core/tools/file.go) | For example, you can download pictures for picture upload | - -### Module event -- Processing flow - - Encapsulated - - `App Store application` The `app_ticket` event (you need to set the event handler again), store it in the Store for `Module api` use - - Decryption of event data and verification of source reliability - - Business Event SDK that has been generated - - | Business service | version | path | sample | - |--------------|--------------|------|------| - | application | v1 | [service/application](service/application) | [sample/event/application.go](sample/event/application.go) | - | contact | v3 | [service/contact](service/contact) | [sample/event/contact.go](sample/event/contact.go) | - - - Instructions for use - - Event monitoring service started - - webhook address:http://ip:8089/[APP_ID]/webhook/event - - [Start with native http server](sample/event/http_server.go) - - [Start with Gin](sample/event/gin.go) - - [Other](sample/event/go.go) - - For `No business Event SDK is generated` the treatment - - Set the event handler, for example: - ```go - import "github.com/larksuite/oapi-sdk-go/event" - - // conf: config.Config - // app_status_change: event type - // func - // coreCtx: *core.Context - // event: map[string]interface{} - // return: - // error: not nil, response status code 500 - event.SetTypeCallback(conf, "app_status_change", func(coreCtx *core.Context, event map[string]interface{}) error { - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(tools.Prettify(event)) - data := event["event"].(map[string]interface{}) - fmt.Println(tools.Prettify(data)) - return nil - }) - - ``` - -## Module card - - Encapsulated - - Verification of the validity and source reliability of card data - - Instructions for use - - Message card callback service started - - webhook address:http://ip:8089/[APP_ID]/webhook/card - - [Start with native http server](sample/card/http_server.go) - - [Start with Gin](sample/card/gin.go) - - [Other](sample/card/go.go) - - Set the message card handler, the code is as follows: - ```go - import "github.com/larksuite/oapi-sdk-go/card" - - // conf: config.Config - // func - // coreCtx: *core.Context - // card: *model.Card - // return: - // interface{}: can be string(json string of message card) or map(The map package of the message card) - // error: not nil, response status code 500 - 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 - }) - - ``` +## 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 + +- 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/config" + "github.com/larksuite/oapi-sdk-go/core/constants" + "github.com/larksuite/oapi-sdk-go/core/log" + "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) + // VerificationToken、EncryptKey:"Developer Console" -> "Event Subscriptions"(Verification Token、Encrypt Key) + appSetting := config.NewInternalAppSettings("AppID", "AppSecret", "VerificationToken", "EncryptKey") + + // Currently, you are visiting larksuite, which uses default storage and default log (debug level). More optional configurations are as follows: config.NewConfig () + conf := config.NewConfigWithDefaultStore(constants.DomainLarkSuite, appSetting, log.NewDefaultLogger(), log.LevelInfo) + + // 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("message/v4/send", "POST", request.AccessTokenTypeTenant, body, &ret) + // The context of the request + coreCtx := core.WrapContext(context.Background()) + // The context of the 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/config" + "github.com/larksuite/oapi-sdk-go/core/constants" + "github.com/larksuite/oapi-sdk-go/core/log" + "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) + // VerificationToken、EncryptKey:"Developer Console" -> "Event Subscriptions"(Verification Token、Encrypt Key) + appSetting := config.NewInternalAppSettings("AppID", "AppSecret", "VerificationToken", "EncryptKey") + + // Currently, you are visiting larksuite, which uses default storage and default log (debug level). More optional configurations are as follows: config.NewConfig () + conf := config.NewConfigWithDefaultStore(constants.DomainLarkSuite, appSetting, log.NewDefaultLogger(), log.LevelInfo) + + // 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/config" + "github.com/larksuite/oapi-sdk-go/core/constants" + "github.com/larksuite/oapi-sdk-go/core/log" + "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) + // VerificationToken、EncryptKey:"Developer Console" -> "Event Subscriptions"(Verification Token、Encrypt Key) + appSetting := config.NewInternalAppSettings("AppID", "AppSecret", "VerificationToken", "EncryptKey") + + // Currently, you are visiting larksuite, which uses default storage and default log (debug level). More optional configurations are as follows: config.NewConfig () + conf := config.NewConfigWithDefaultStore(constants.DomainLarkSuite, appSetting, log.NewDefaultLogger(), log.LevelInfo) + + // 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) + } +} +``` + +## Advanced use + +--- + +### How to build app settings(AppSettings) + +```go + +import ( + "github.com/larksuite/oapi-sdk-go/core/config" +) + +// 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) +// The configuration of `Custom App` is obtained through environment variables +appSettings := config.GetInternalAppSettingsByEnv() +// The configuration of `Marketplace App` is obtained through environment variables +appSettings := config.GetISVAppSettingsByEnv() + +// Parameter Description: +// AppID、AppSecret: "Developer Console" -> "Credentials"(App ID、App Secret) +// VerificationToken、EncryptKey:"Developer Console" -> "Event Subscriptions"(Verification Token、Encrypt Key) +// The configuration of `Custom App` +appSettings := config.NewInternalAppSettings(appID, appSecret, verificationToken, encryptKey string) +// The configuration of `Marketplace App` +appSettings := config.NewISVAppSettings(appID, appSecret, verificationToken, encryptKey string) + +``` + +### 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/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" +) + +// Method 1: it is recommended to use redis to implement the store interface, so as to reduce the times of accessing the accesstoken interface +// Parameter Description: +// domain:URL domain address, value range: constants.DomainLarkSuite / constants.FeiShu / Other domain addresses +// appSettings:App setting +// logger:[Log interface](core/log/log.go) +// loggerLevel:log level: log.LevelInfo/LevelInfo/LevelWarn/LevelError +// store: [Store interface](core/store/store.go), Used to store app_ticket/access_token +conf := config.NewConfig(domain constants.Domain, appSettings *AppSettings, logger log.Logger, logLevel log.Level, store store.Store) + +// Method 2: use the implementation of the default storage interface (store), which is suitable for light-weight use (not suitable: `Marketplace App` applies or calls the server API frequently) +// Parameter Description: +// domain:constants.DomainLarkSuite / constants.FeiShu / Other domain addresses +// appSettings:App setting +// logger:[Log interface](core/log/log.go) +// loggerLevel:log level: log.LevelInfo/LevelInfo/LevelWarn/LevelError +conf := config.NewConfig(domain constants.Domain, appSettings *AppSettings, logger log.Logger, logLevel log.Level) + +``` + +### 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(the path after `open-apis/`), for example: https://domain/open-apis/contact/v3/users/:user_id, then 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 time: output value is Buffer type + // 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 +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() +``` + +### How to send a 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/files.go](sample/tools/files.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/README.zh.md b/README.zh.md index f7ccbee6..68af0671 100644 --- a/README.zh.md +++ b/README.zh.md @@ -1,215 +1,530 @@ -[**English**](README.md) - -# larksuit open api sdk - -| 模块 | 描述 | -|--------------|--------------| -| core | 应用信息配置及一些通用的方法 | -| api | 请求larksuite/feishu的接口 | -| event | 监听larksuite/feishu的业务数据发生变化,产生的事件 | -| card | 监听消息卡片交互时的动作 | -| service | 生成的业务SDK(api&event) | -| sample | 示例 | - -### 包引入 -```shell script -$ go get -u github.com/larksuite/oapi-sdk-go +[**README of Lark suite**](README.md) | 飞书 + +# 飞书开放接口SDK + +## 概述 + +--- + +- 飞书开放平台,便于企业应用与飞书集成,让协同与管理更加高效,[概述](https://open.feishu.cn/document/uQjL04CN/ucDOz4yN4MjL3gzM) + +- 飞书开发接口SDK,便捷调用服务端API与订阅服务端事件,例如:消息&群组、通讯录、日历、视频会议、云文档、 OKR等具体可以访问 [飞书开放平台文档](https://open.feishu.cn/document/) 看看【服务端 + API】。 + +## 运行环境 + +--- + +- Golang 1.5及以上。 + +## 安装方法 + +--- + +```shell +go get -u github.com/larksuite/oapi-sdk-go ``` -### 模块core -- 使用说明 - - 获取应用配置 - - 方便开发提供了[代码样例 GetConfig方法](sample/config/config.go) - - 使用 redis 实现 [Store接口](core/store/store.go),用于维护 `app_ticket`、`app_access_token`、`tenant_access_token` 的生命周期 - - 使用 logrus 实现 [Logger接口](core/log/log.go) - - 方法使用说明,如下: - ```go - 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" - ) - - // 创建应用配置,防止泄漏,建议将应用信息放在环境变量中。 - // 环境变量或参数名: - // APP_ID:应用凭证中的App ID - // APP_SECRET:应用凭证中的App Secret - // VERIFICATION_TOKEN:事件订阅中的Verification Token - // ENCRYPT_KEY:事件订阅中的Encrypt Key,可以为空,表示事件内容不加密 - // 企业自建应用的配置 - appSettings := config.NewInternalAppSettings("[APP_ID]", "[APP_SECRET]", "[VERIFICATION_TOKEN]", "[ENCRYPT_KEY]") - // 企业自建应用的配置,通过环境变量获取应用配置 - appSettings := config.GetInternalAppSettingsByEnv() - // 应用商店应用的配置 - appSettings := config.NewISVAppSettings("[APP_ID]", "[APP_SECRET]", "[VERIFICATION_TOKEN]", "[ENCRYPT_KEY]") - // 应用商店应用的配置,通过环境变量获取应用配置 - appSettings := config.GetISVAppSettingsByEnv() - - - // 创建Config - // domain:域名http地址:constants.DomainFeiShu / constants.DomainLarkSuite - // appSettings:应用配置 - // logger:[日志接口](core/log/log.go) - // loggerLevel:输出的日志级别 log.LevelDebug/LevelInfo/LevelWarn/LevelError - // store: [存储接口](core/store/store.go),用来存储 app_ticket/app_access_token/tenant_access_token - // 用于线上的config - conf := config.NewConfig(domain, appSettings, logger, loggerLevel, store) - - // 用于开发测试的Config - // logger:使用默认实现(core/log/log.go defaultLogger) - // loggerLevel:Debug级别 - // store:使用默认实现(core/store/store.go DefaultStore) - conf := config.NewTestConfig(domain, appSettings) - - // 创建CoreContext(*core.Context),用于API请求、Event回调、Card回调等,作为函数的参数 - // core.Context实现了context.Context接口 - coreCtx := core.WrapContext(context.Background()) - // 获取 API请求、Event回调、Card回调的RequestID(string),用于问题反馈时,开放平台查询相关日志,可以快速的定位问题 - requestID := coreCtx.GetRequestID() - // 获取 API请求的响应状态码(int) - statusCode := coreCtx.GetHTTPStatusCode() - - ``` - -### 模块api -- 处理流程 - - 对app_access_token、tenant_access_token的获取及生命周期的维护做了封装,**开发者可直接访问业务接口** - ![处理流程图](api_process.jpg) -- 已经生成的业务API SDK - - | 业务服务 | 版本 | 路径 | 示例 | - |--------------|--------------|------|------| - | 身份验证 | v1 | [service/authen](service/authen) | [sample/api/authen.go](sample/api/authen.go)| - | 图片 | v4 | [service/image](service/image)|[sample/api/image.go](sample/api/image.go)| - | 通讯录 | v3 | [service/contact](service/contact)|[sample/api/contact.go](sample/api/contact.go)| - | 日历 | v4 | [service/calendar](service/calendar)|[sample/api/calendar.go](sample/api/calendar.go)| - | 云空间文件 | v1 | [service/drive](service/drive)|[sample/api/drive.go](sample/api/drive.go)| - - -- 使用说明(对于`没有生成业务API SDK`的处理方式) - - 对于`应用商店应用`,在获取`app_access_token`时,需要 `app_ticket`,需要启动事件订阅服务(`模块event`) - - [使用示例](sample/api/api.go) - - 封装请求,如下: - ```go - 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/api/core/request" - ) - // 创建请求 - // httpPath:API路径(`open-apis/`之后的路径),例如:https://{domain}/open-apis/authen/v1/user_info,则 httpPath:"authen/v1/user_info" - // httpMethod: GET/POST/PUT/BATCH/DELETE - // accessTokenType:API使用哪种token访问,取值范围:request.AccessTokenTypeApp/request.AccessTokenTypeTenant/request.AccessTokenTypeUser,例如:request.AccessTokenTypeTenant - // input:请求体(可能是request.NewFormData()(例如:文件上传)),如果不需要请求体(例如一些GET请求),则传:nil - // output:响应体(output := response["data"]) - // optFns:扩展函数,一些不常用的参数封装,如下: - // request.SetPathParams(map[string]interface{}{"user_id": 4}):设置URL Path参数(有:前缀)值,当httpPath="users/:user_id"时,请求的URL="https://{domain}/open-apis/users/4" - // request.SetQueryParams(map[string]interface{}{"age":4,"types":[1,2]}):设置 URL qeury,会在url追加?age=4&types=1&types=2 - // request.setResponseStream(),设置响应的是否是流,例如下载文件,这时:output值是Buffer类型 - // request.SetNotDataField(),设置响应的是否 没有`data`字段,业务接口都是有`data`字段,所以不需要设置 - // request.SetTenantKey("TenantKey"),以`应用商店应用`身份,表示使用`tenant_access_token`访问API,需要设置 - // request.SetUserAccessToken("UserAccessToken"),表示使用`user_access_token`访问API,需要设置 - // req := request.NewRequestWithNative(httpPath:string, httpMethod:string, accessTokenType:AccessTokenType, input:interface, output:interface, ... optFns:OptFn [))) - // Example: - 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("message/v4/send", "POST", request.AccessTokenTypeTenant, body, &ret)coreCtx := core.WarpContext(context.Background()) - 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)) - - ``` - - 工具 - - | 工具 | 路径 | 描述 | - |--------------|--------------|------| - | 文件下载 | [api/core/tools/file.go](api/core/tools/file.go) | 例如,可以下载图片,用于图片上传 | - -### 模块event -- 处理流程 - - 封装了 - - `应用商店应用`的`app_ticket`事件(需要再次设置该事件的处理者),将其存入Store,供 `模块api` 使用 - - 已封装challenge验证 - - 事件数据的解密与来源可靠性的验证 - - 已经生成的业务Event SDK +## 术语解释 +- 飞书(FeiShu):Lark在中国的称呼,主要为国内的企业提供服务,拥有独立的[域名地址](https://www.feishu.cn)。 +- LarkSuite:Lark在海外的称呼,主要为海外的企业提供服务,拥有独立的[域名地址](https://www.larksuite.com/) 。 +- 开发文档:开放平台的开放接口的参考,**开发者必看,可以使用搜索高效的查询文档**。[更多介绍说明](https://open.feishu.cn/document/) 。 +- 开发者后台:开发者开发应用的管理后台,[更多介绍说明](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) 。 - | 业务服务 | 版本 | 路径 | 示例 | - |--------------|--------------|------|------| - | 应用 | v1 | [service/application](service/application) | [sample/event/application.go](sample/event/application.go) | - | 通讯录 | v3 | [service/contact](service/contact) | [sample/event/contact.go](sample/event/contact.go) | - - - 使用说明 - - 事件监听服务启动 - - webhook地址:http://ip:8089/[APP_ID]/webhook/event - - [使用原生的http server启动](sample/event/http_server.go) - - [使用Gin启动](sample/event/gin.go) - - [其他情况使用](sample/event/go.go) - - 对于`没有生成业务Event SDK`的处理方式 - - 设置事件的处理者,样例如下: - ```go - import "github.com/larksuite/oapi-sdk-go/event" - - // conf: config.Config - // app_status_change: 事件类型 - // func - // coreCtx: *core.Context - // event: 事件数据 - // return: - // error: 不为nil,响应状态码 500 - event.SetTypeCallback(conf, "app_status_change", func(coreCtx *core.Context, event map[string]interface{}) error { - fmt.Println(coreCtx.GetRequestID()) - fmt.Println(tools.Prettify(event)) - data := event["event"].(map[string]interface{}) - fmt.Println(tools.Prettify(data)) - return nil - }) - - ``` - -## 模块card - - 封装了 - - 已封装challenge验证 - - 卡片数据的有效性、来源可靠性的验证 - - 使用说明 - - 消息卡片回调服务启动 - - webhook地址:http://ip:8089/[APP_ID]/webhook/card - - [使用原生的http server启动](sample/card/http_server.go) - - [使用Gin启动](sample/card/gin.go) - - [其他情况使用](sample/card/go.go) - - 设置卡片的处理者,代码如下: - ```go - import "github.com/larksuite/oapi-sdk-go/card" - - // conf: config.Config - // func - // coreCtx: *core.Context - // card: 卡片 - // return: - // interface{}: 可以是string(消息卡片 的json字符串),也可以是map(消息卡片 的map封装) - // error: 不为nil,响应状态码 500 - 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 - }) - - ``` - +![App type](doc/app_type.zh.png) + +## 快速使用 + +--- + +### 调用服务端API + +- **必看** [如何调用服务端API](https://open.feishu.cn/document/ukTMukTMukTM/uYTM5UjL2ETO14iNxkTN/guide-to-use-server-api) + ,了解调用服务端API的过程及注意事项。 + +#### 使用`企业自建应用`访问 发送文本消息API 示例 + +- 有些老版接口,没有直接可以使用的SDK,可以使用`原生`模式。 + +```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/config" + "github.com/larksuite/oapi-sdk-go/core/constants" + "github.com/larksuite/oapi-sdk-go/core/log" + "github.com/larksuite/oapi-sdk-go/core/tools" +) + +var conf *config.Config + +func init() { + // 企业自建应用的配置 + // AppID、AppSecret: "开发者后台" -> "凭证与基础信息" -> 应用凭证(App ID、App Secret) + // VerificationToken、EncryptKey:"开发者后台" -> "事件订阅" -> 事件订阅(Verification Token、Encrypt Key)。 + appSetting := config.NewInternalAppSettings("AppID", "AppSecret", "VerificationToken", "EncryptKey") + + // 当前访问的是飞书,使用默认存储、默认日志(Debug级别),更多可选配置,请看:README.zh.md->高级使用->如何构建整体配置(Config)。 + conf = config.NewConfigWithDefaultStore(constants.DomainFeiShu, appSetting, log.NewDefaultLogger(), log.LevelInfo) +} + +func main() { + // 发送消息的内容 + body := map[string]interface{}{ + "open_id": "user open id", + "msg_type": "text", + "content": map[string]interface{}{ + "text": "test send message", + }, + } + // 请求发送消息的结果 + ret := make(map[string]interface{}) + // 构建请求 + req := request.NewRequestWithNative("message/v4/send", "POST", request.AccessTokenTypeTenant, body, &ret) + // 请求的上下文 + 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)) +} +``` + +#### 使用`企业自建应用`访问 修改用户部分信息API 示例 + +- 该接口是新的接口,可以直接使用SDK。 + +```go +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/config" + "github.com/larksuite/oapi-sdk-go/core/constants" + "github.com/larksuite/oapi-sdk-go/core/log" + "github.com/larksuite/oapi-sdk-go/core/tools" + contact "github.com/larksuite/oapi-sdk-go/service/contact/v3" +) + +var conf *config.Config + +func init() { + // 企业自建应用的配置 + // AppID、AppSecret: "开发者后台" -> "凭证与基础信息" -> 应用凭证(App ID、App Secret) + // VerificationToken、EncryptKey:"开发者后台" -> "事件订阅" -> 事件订阅(Verification Token、Encrypt Key)。 + appSetting := config.NewInternalAppSettings("AppID", "AppSecret", "VerificationToken", "EncryptKey") + + // 当前访问的是飞书,使用默认存储、默认日志(Debug级别),更多可选配置,请看:README.zh.md->高级使用->如何构建整体配置(Config)。 + conf = config.NewConfigWithDefaultStore(constants.DomainFeiShu, appSetting, log.NewDefaultLogger(), log.LevelInfo) +} + +func main() { + service := contact.NewService(conf) + coreCtx := core.WrapContext(context.Background()) + body := &contact.User{} + body.Name = "rename" + // 由于这是一个PATCH请求,需要告之更新哪些字段 + body.ForceSendFields = append(body.ForceSendFields, "Name") + reqCall := service.Users.Patch(coreCtx, body) + reqCall.SetUserId("user id") + reqCall.SetUserIdType("user_id") + // 发送请求 + result, err := reqCall.Do() + // 打印请求的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(result)) +} +``` + +#### [使用`应用商店应用`调用 服务端API 示例](doc/ISV.APP.README.zh.md) + +### 订阅服务端事件 + +- **必看** [订阅事件概述](https://open.feishu.cn/document/ukTMukTMukTM/uUTNz4SN1MjL1UzM) ,了解订阅事件的过程及注意事项。 +- 更多使用示例,请看[sample/event](sample/event)(含:结合gin的使用) + +#### 使用`企业自建应用` 订阅 [首次启用应用事件](todo) 示例 + +- 有些老的事件,没有直接可以使用的SDK,可以使用`原生`模式 + +```go +package main + +import ( + "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/log" + "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" +) + +var conf *config.Config + +func init() { + // 企业自建应用的配置 + // AppID、AppSecret: "开发者后台" -> "凭证与基础信息" -> 应用凭证(App ID、App Secret) + // VerificationToken、EncryptKey:"开发者后台" -> "事件订阅" -> 事件订阅(Verification Token、Encrypt Key)。 + appSetting := config.NewInternalAppSettings("AppID", "AppSecret", "VerificationToken", "EncryptKey") + + // 当前访问的是飞书,使用默认存储、默认日志(Debug级别),更多可选配置,请看:README.zh.md->高级使用->如何构建整体配置(Config)。 + conf = config.NewConfigWithDefaultStore(constants.DomainFeiShu, appSetting, log.NewDefaultLogger(), log.LevelInfo) +} + +func main() { + // 设置首次启用应用事件callback + event.SetTypeCallback(conf, "app_open", func(ctx *core.Context, e map[string]interface{}) error { + // 打印请求的Request ID + fmt.Println(ctx.GetRequestID()) + // 打印事件 + fmt.Println(tools.Prettify(e)) + return nil + }) + + // 启动httpServer,开发者后台的事件订阅,请求网址:https://domain/webhook/event + eventhttpserver.Register("/webhook/event", conf) + err := http.ListenAndServe(":8089", nil) + if err != nil { + panic(err) + } +} +``` + +#### 使用`企业自建应用`订阅 [用户数据变更事件](https://open.feishu.cn/document/ukTMukTMukTM/uITNxYjLyUTM24iM1EjN#70402aa) 示例 + +- 该接口是新的事件,可以直接使用SDK + +```go +package main + +import ( + "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/log" + "github.com/larksuite/oapi-sdk-go/core/tools" + eventhttpserver "github.com/larksuite/oapi-sdk-go/event/http/native" + contact "github.com/larksuite/oapi-sdk-go/service/contact/v3" + "net/http" +) + +var conf *config.Config + +func init() { + // 企业自建应用的配置 + // AppID、AppSecret: "开发者后台" -> "凭证与基础信息" -> 应用凭证(App ID、App Secret) + // VerificationToken、EncryptKey:"开发者后台" -> "事件订阅" -> 事件订阅(Verification Token、Encrypt Key)。 + appSetting := config.NewInternalAppSettings("AppID", "AppSecret", "VerificationToken", "EncryptKey") + + // 当前访问的是飞书,使用默认存储、默认日志(Debug级别),更多可选配置,请看:README.zh.md->高级使用->如何构建整体配置(Config)。 + conf = config.NewConfigWithDefaultStore(constants.DomainFeiShu, appSetting, log.NewDefaultLogger(), log.LevelInfo) +} + +func main() { + // 设置用户数据变更事件处理者 + contact.SetUserUpdatedEventHandler(conf, func(ctx *core.Context, event *contact.UserUpdatedEvent) error { + // 打印请求的Request ID + fmt.Println(ctx.GetRequestID()) + // 打印事件 + fmt.Println(tools.Prettify(event)) + return nil + }) + + // 启动httpServer,"开发者后台" -> "事件订阅" 请求网址 URL:https://domain/webhook/event + eventhttpserver.Register("/webhook/event", conf) + err := http.ListenAndServe(":8089", nil) + if err != nil { + panic(err) + } +} +``` + +### 处理消息卡片回调 + +- **必看** [消息卡片开发流程](https://open.feishu.cn/document/ukTMukTMukTM/uAzMxEjLwMTMx4CMzETM) ,了解订阅事件的过程及注意事项 +- 更多使用示例,请看:[sample/card](sample/card) (含:结合gin的使用) + +#### 使用`企业自建应用`处理消息卡片回调示例 + +```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/config" + "github.com/larksuite/oapi-sdk-go/core/constants" + "github.com/larksuite/oapi-sdk-go/core/log" + "github.com/larksuite/oapi-sdk-go/core/tools" + "net/http" +) + +var conf *config.Config + +func init() { + // 企业自建应用的配置 + // AppID、AppSecret: "开发者后台" -> "凭证与基础信息" -> 应用凭证(App ID、App Secret) + // VerificationToken、EncryptKey:"开发者后台" -> "事件订阅" -> 事件订阅(Verification Token、Encrypt Key)。 + appSetting := config.NewInternalAppSettings("AppID", "AppSecret", "VerificationToken", "EncryptKey") + + // 当前访问的是飞书,使用默认存储、默认日志(Debug级别),更多可选配置,请看:README.zh.md->高级使用->如何构建整体配置(Config)。 + conf = config.NewConfigWithDefaultStore(constants.DomainFeiShu, appSetting, log.NewDefaultLogger(), log.LevelInfo) +} + +func main() { + // 设置消息卡片的处理者 + // 返回值:可以为nil、新的消息卡片的Json字符串 + card.SetHandler(conf, func(ctx *core.Context, c *model.Card) (interface{}, error) { + // 打印消息卡片 + fmt.Println(tools.Prettify(c)) + return "{\"config\":{\"wide_screen_mode\":true},\"i18n_elements\":{\"zh_cn\":[{\"tag\":\"div\",\"text\":{\"tag\":\"lark_md\",\"content\":\"[飞书golang](https://www.feishu.cn)整合即时沟通、日历、音视频会议、云文档、云盘、工作台等功能于一体,成就组织和个人,更高效、更愉悦。\"}}]}}", nil + }) + // 设置 "开发者后台" -> "应用功能" -> "机器人" 消息卡片请求网址:https://domain/webhook/card + cardhttpserver.Register("/webhook/card", conf) + err := http.ListenAndServe(":8089", nil) + if err != nil { + panic(err) + } +} +``` + +## 高级使用 + +--- + +### 如何构建应用配置(AppSettings) + +```go +import ( + "github.com/larksuite/oapi-sdk-go/core/config" +) + +// 防止应用信息泄漏,配置环境变量中,变量(4个)说明: +// APP_ID:开发者后台的应用凭证的 App ID +// APP_SECRET:开发者后台的应用凭证的 App Secret +// VERIFICATION_TOKEN:开发者后台的事件订阅的 Verification Token +// ENCRYPT_KEY:开发者后台的事件订阅的 Encrypt Key +// 企业自建应用的配置,通过环境变量获取应用配置 +appSettings := config.GetInternalAppSettingsByEnv() +// 应用商店应用的配置,通过环境变量获取应用配置 +appSettings := config.GetISVAppSettingsByEnv() + + +// 参数说明: +// appID、appSecret: 开发者后台的应用凭证(App ID、App Secret) +// verificationToken、encryptKey:开发者后台的事件订阅(Verification Token、Encrypt Key)。 +// 企业自建应用的配置 +appSettings := config.NewInternalAppSettings(appID, appSecret, verificationToken, encryptKey string) +// 应用商店应用的配置 +appSettings := config.NewISVAppSettings(appID, appSecret, verificationToken, encryptKey string) + +``` + +### 如何构建整体配置(Config) + +- 访问 飞书、LarkSuite或者其他 +- 应用的配置 +- 日志接口(Logger)的实现,用于输出SDK处理过程中产生的日志,便于排查问题。 + - 可以使用业务系统的日志实现,请看示例代码:[sample/config/logrus.go](sample/config/logrus.go) +- 存储接口(Store)的实现,用于保存访问凭证(app/tenant_access_token)、临时凭证(app_ticket) + - 推荐使用Redis实现,请看示例代码:[sample/config/redis_store.go](sample/config/redis_store.go) + - 减少获取 访问凭证 的次数,防止调用访问凭证 接口被限频。 + - 应用商品应用,接受开放平台下发的app_ticket,会保存到存储中,所以存储接口(Store)的实现的实现需要支持分布式存储。 + +```go +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" +) + +// 方法一,推荐使用Redis实现存储接口(Store),减少访问获取AccessToken接口的次数 +// 参数说明: +// domain:URL域名地址,值范围:constants.DomainFeiShu / constants.DomainLarkSuite / 其他URL域名地址 +// appSettings:应用配置 +// logger:[日志接口](core/log/log.go) +// loggerLevel:输出的日志级别 log.LevelInfo/LevelInfo/LevelWarn/LevelError +// store: [存储接口](core/store/store.go),用来存储 app_ticket/access_token +conf := config.NewConfig(domain constants.Domain, appSettings *AppSettings, logger log.Logger, logLevel log.Level, store store.Store) + +// 方法二,使用默认的存储接口(Store)的实现,适合轻量的使用(不合适:应用商店应用或调用服务端API次数频繁) +// 参数说明: +// domain:constants.DomainFeiShu / constants.DomainLarkSuite / 其他域名地址 +// appSettings:应用配置 +// logger:[日志接口](core/log/log.go) +// loggerLevel:输出的日志级别 log.LevelInfo/LevelInfo/LevelWarn/LevelError +conf := config.NewConfig(domain constants.Domain, appSettings *AppSettings, logger log.Logger, logLevel log.Level) + +``` + +### 如何构建请求(Request) + +- 有些老版接口,没有直接可以使用的SDK,可以使用原生模式,这时需要构建请求。 +- 更多示例,请看:[sample/api/api.go](sample/api/api.go)(含:文件的上传与下载) + +```go +import ( + "github.com/larksuite/oapi-sdk-go/api/core/request" +) + +// 参数说明: +// httpPath:API路径(`open-apis/`之后的路径),例如:https://domain/open-apis/contact/v3/users/:user_id,则 httpPath:"contact/v3/users/:user_id" +// httpMethod: GET/POST/PUT/BATCH/DELETE +// accessTokenType:API使用哪种访问凭证,取值范围:request.AccessTokenTypeApp/request.AccessTokenTypeTenant/request.AccessTokenTypeUser,例如:request.AccessTokenTypeTenant +// input:请求体(可能是request.NewFormData()(例如:文件上传)),如果不需要请求体(例如一些GET请求),则传:nil +// output:响应体(output := response["data"]) +// optFns:扩展函数,一些不常用的参数封装,如下: +// request.SetPathParams(map[string]interface{}{"user_id": 4}):设置URL Path参数(有:前缀)值,当httpPath="contact/v3/users/:user_id"时,请求的URL="https://{domain}/open-apis/contact/v3/users/4" +// request.SetQueryParams(map[string]interface{}{"age":4,"types":[1,2]}):设置 URL qeury,会在url追加?age=4&types=1&types=2 +// request.setResponseStream(),设置响应的是否是流,例如下载文件,这时:output值是Buffer类型 +// request.SetNotDataField(),设置响应的是否 没有`data`字段,业务接口都是有`data`字段,所以不需要设置 +// request.SetTenantKey("TenantKey"),以`应用商店应用`身份,表示使用`tenant_access_token`访问API,需要设置 +// request.SetUserAccessToken("UserAccessToken"),表示使用`user_access_token`访问API,需要设置 +req := request.NewRequestWithNative(httpPath, httpMethod string, accessTokenType AccessTokenType, input interface{}, output interface{}, optFns ...OptFn) + +``` + +### 如何构建请求上下文(core.Context)及常用方法 + +```go +import( + "github.com/larksuite/oapi-sdk-go/core" +) + +// 参数说明: +// c:context.Context +// 返回值说明: +// ctx: 实现了Golang的context.Context,保存请求中的一些变量 +ctx := core.WrapContext(c context.Context) + +// 获取请求的Request ID,便于排查问题 +requestId := ctx.GetRequestID() + +// 获取请求的响应状态码 +httpStatusCode = ctx.GetHTTPStatusCode() +``` + +### 如何发送请求 + +- 更多使用示例,请看:[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" +) + +// 参数说明: +// ctx:请求的上下文 +// conf:整体的配置(Config) +// req:请求(Request) +// 返回值说明: +// err:发送请求,出现的错误以及响应的错误码(response.body["code"])不等于0 +err := api.Send(ctx *core.Context, conf *config.Config, req *request.Request) + +``` + +### 下载文件工具 + +- 通过网络请求下载文件 +- 更多使用示例,请看:[sample/tools/files.go](sample/tools/files.go) + +```go +import( + "context" + "github.com/larksuite/oapi-sdk-go/core/tools" +) + +// 获取文件内容 +// 参数说明: +// ctx:context.Context +// url:文件的HTTP地址 +// 返回值说明: +// bytes:文件内容的二进制数组 +// err:错误 +bytes, err := tools.DownloadFile(ctx context.Context, url string) + +// 获取文件内容流,读取完文件内容后,需要关闭流 +// 参数说明: +// ctx:context.Context +// url:文件的HTTP地址 +// 返回值说明: +// readCloser:文件内容的二进制读取流 +// err:错误 +readCloser, err := tools.DownloadFileToStream(ctx context.Context, url string) + +``` + +## 已生成SDK的业务服务 + +--- + +|业务域|版本|路径|代码示例| +|---|---|---|----| +|[用户身份验证](https://open.feishu.cn/document/ukTMukTMukTM/uETOwYjLxkDM24SM5AjN)|v1|[service/authen](service/authen)|[sample/api/authen.go](sample/api/authen.go)| +|[图片](https://open.feishu.cn/document/ukTMukTMukTM/uEDO04SM4QjLxgDN)|v4|[service/image](service/image)|[sample/api/image.go](sample/api/image.go)| +|[通讯录](https://open.feishu.cn/document/ukTMukTMukTM/uETNz4SM1MjLxUzM/v3/introduction)|v3|[service/contact](service/contact)|[sample/api/contact.go](sample/api/contact.go)| +|[日历](https://open.feishu.cn/document/ukTMukTMukTM/uETM3YjLxEzN24SMxcjN)|v4|[service/calendar](service/calendar)|[sample/api/calendar.go](sample/api/calendar.go)| +|[云空间文件](https://open.feishu.cn/document/ukTMukTMukTM/uUjM5YjL1ITO24SNykjN)|v1|[service/drive](service/drive)|[sample/api/drive.go](sample/api/drive.go)| + +## License + +--- + +- MIT + +## 联系我们 + +--- +- 飞书:[服务端SDK](https://open.feishu.cn/document/ukTMukTMukTM/uETO1YjLxkTN24SM5UjN) 页面右上角【这篇文档是否对你有帮助?】提交反馈 diff --git a/core/test/config.go b/core/test/config.go index f8ee8107..5561fe82 100644 --- a/core/test/config.go +++ b/core/test/config.go @@ -34,8 +34,8 @@ func GetInternalConf(env string) *config.Config { } func getDomain(env string) constants.Domain { - if env != "STAGING" && env != "PRE" && env != "ONLINE" { - panic("env must in [staging, pre, online]") + if env != "BOE" && env != "PRE" && env != "ONLINE" { + panic("env must in [boe, pre, online]") } if env == "ONLINE" { return constants.DomainFeiShu diff --git a/core/tools/file.go b/core/tools/file.go new file mode 100644 index 00000000..8740e6f8 --- /dev/null +++ b/core/tools/file.go @@ -0,0 +1,36 @@ +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/doc/ISV.APP.README.zh.md b/doc/ISV.APP.README.zh.md new file mode 100644 index 00000000..ff55e78c --- /dev/null +++ b/doc/ISV.APP.README.zh.md @@ -0,0 +1,172 @@ +# 使用应用商店应用调用服务端API + +--- + +- 如何获取app_access_token,请看:[获取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。 + +### 使用`应用商店应用`访问 [发送文本消息API](https://open.feishu.cn/document/ukTMukTMukTM/uUjNz4SN2MjL1YzM) 示例 + +- 第一步:启动启动事件订阅服务,用于接收`app_ticket`。 + +```go +package main + +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" + eventhttpserver "github.com/larksuite/oapi-sdk-go/event/http/native" + "net/http" +) + +var conf *config.Config + +func init() { + // 企业自建应用的配置 + // AppID、AppSecret: "开发者后台" -> "凭证与基础信息" -> 应用凭证(App ID、App Secret) + // VerificationToken、EncryptKey:"开发者后台" -> "事件订阅" -> 事件订阅(Verification Token、Encrypt Key)。 + appSetting := config.NewISVAppSettings("AppID", "AppSecret", "VerificationToken", "EncryptKey") + + // 当前访问的是飞书,config.NewConfig()的使用,请看:README.zh.md->高级使用->如何构建整体配置(Config) + conf = config.NewConfig(constants.DomainFeiShu, appSetting, logger, log.LevelInfo, store) +} + +func main() { + // 启动httpServer,"开发者后台" -> "事件订阅" 请求网址 URL:https://domain/webhook/event + eventhttpserver.Register("/webhook/event", conf) + err := http.ListenAndServe(":8089", nil) + if err != nil { + panic(err) + } +} +``` + +- 第二步:调用服务端接口,有些老版接口,没有直接可以使用的SDK,可以使用`原生`模式。 + +```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/config" + "github.com/larksuite/oapi-sdk-go/core/constants" + "github.com/larksuite/oapi-sdk-go/core/log" + "github.com/larksuite/oapi-sdk-go/core/tools" +) + +func main() { + // 应用商店应用的配置 + // AppID、AppSecret: 开发者后台的应用凭证(App ID、App Secret) + // VerificationToken、EncryptKey:开发者后台的事件订阅(Verification Token、Encrypt Key),可以为空字符串。 + appSetting := config.NewISVAppSettings("AppID", "AppSecret", "VerificationToken", "EncryptKey") + + // 当前访问的是飞书,config.NewConfig()的使用,请看:README.zh.md->高级使用->如何构建整体配置(Config) + conf := config.NewConfig(constants.DomainFeiShu, appSetting, logger, log.LevelInfo, store) + + // 发送消息的内容 + body := map[string]interface{}{ + "open_id": "user open id", + "msg_type": "text", + "content": map[string]interface{}{ + "text": "test send message", + }, + } + // 请求发送消息的结果 + ret := make(map[string]interface{}) + // 构建请求&&设置租户标识(tenant_key) + req := request.NewRequestWithNative("message/v4/send", "POST", request.AccessTokenTypeTenant, + body, &ret, request.SetTenantKey("tenant_key")) + // 请求的上下文 + 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)) +} +``` + +## 使用`应用商店应用`访问 [修改用户部分信息API](https://open.feishu.cn/document/contact/v3/user/patch) 示例 + +- 第一步:略,同上 + +- 第二步:调用服务端接口,该接口是新的接口,可以直接使用SDK。 + +```go +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/config" + "github.com/larksuite/oapi-sdk-go/core/constants" + "github.com/larksuite/oapi-sdk-go/core/log" + "github.com/larksuite/oapi-sdk-go/core/tools" + contact "github.com/larksuite/oapi-sdk-go/service/contact/v3" +) + +var conf *config.Config + +func init() { + // 企业自建应用的配置 + // AppID、AppSecret: "开发者后台" -> "凭证与基础信息" -> 应用凭证(App ID、App Secret) + // VerificationToken、EncryptKey:"开发者后台" -> "事件订阅" -> 事件订阅(Verification Token、Encrypt Key)。 + appSetting := config.NewISVAppSettings("AppID", "AppSecret", "VerificationToken", "EncryptKey") + + // 当前访问的是飞书,config.NewConfig()的使用,请看:README.zh.md->高级使用->如何构建整体配置(Config) + conf = config.NewConfig(constants.DomainFeiShu, appSetting, logger, log.LevelInfo, store) +} + +func main() { + service := contact.NewService(conf) + coreCtx := core.WrapContext(context.Background()) + body := &contact.User{} + body.Name = "rename" + // 由于这是一个PATCH请求,需要告之更新哪些字段 + body.ForceSendFields = append(body.ForceSendFields, "Name") + // 构建请求&&设置租户标识(tenant_key) + reqCall := service.Users.Patch(coreCtx, body, request.SetTenantKey("tenant_key")) + reqCall.SetUserId("user id") + reqCall.SetUserIdType("user_id") + // 发送请求 + result, err := reqCall.Do() + // 打印请求的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(result)) +} +``` diff --git a/doc/README.old.md b/doc/README.old.md new file mode 100644 index 00000000..9f24b7c5 --- /dev/null +++ b/doc/README.old.md @@ -0,0 +1,204 @@ +# larksuit open api sdk +[中文](README.zh.md) + +| Module | description | +|--------------|--------------| +| core | Application information configuration and some general methods | +| api | Request the interface of larksuite/feishu | +| event | Monitor the business data of larksuite/feishu changes and events generated | +| card | Monitor the actions of message card interaction | +| service | Generated business SDK(api&event) | +| sample | Example | + +### Module core +```shell script +$ go get -u github.com/larksuite/oapi-sdk-go +``` + +### Instructions for use +- Instructions for use + - Get application configuration + - Provide [code sample GetConfig()](sample/config/config.go) + - Use redis achieve [Store Interface](core/store/store.go), for maintenance `app_ticket`、`app_access_token`、`tenant_access_token` life cycle + - Use logrus to implement [Logger Interface](core/log/log.go) + - Instructions for the method are as follows: + ```go + // Create application configuration to prevent leakage. It is recommended to put application information in environment variables. + // Environment variable or parameter name: + // APP_ID: App ID in the application certificate + // APP_SECRET: App Secret in the application certificate + // VERIFICATION_TOKEN: Verification Token in the event subscription + // ENCRYPT_KEY: Encrypt Key in the event subscription, yes Empty, indicating that the event content is not encrypted + // The configuration of the enterprise self-built application + appSettings := config.NewInternalAppSettings("[APP_ID]", "[APP_SECRET]", "[VERIFICATION_TOKEN]", "[ENCRYPT_KEY]") + // Enterprise The configuration of self-built applications, the application configuration is obtained through environment variables + appSettings := config.GetInternalAppSettingsByEnv() + // App Store application configuration + appSettings := config.NewISVAppSettings("[APP_ID]", "[APP_SECRET]", "[VERIFICATION_TOKEN]", "[ENCRYPT_KEY]") + // App store application configuration, obtain application configuration through environment variables + appSettings := config.GetISVAppSettingsByEnv() + + + // Create Config + // domain: domain name http address: constants.DomainFeiShu/constants.DomainLarkSuite + // appSettings: application configuration + // logger: [log interface](core/log/log.go) + // loggerLevel: output log level log.LevelDebug/LevelInfo/LevelWarn/LevelError + // store: [Storage interface](core/store/store.go), used to store app_ticket/app_access_token/tenant_access_token + // used in online config + conf := config.NewConfig(domain, appSettings, logger, loggerLevel, store) + + // Config for development and testing + // logger: use the default implementation(core/log/log.go defaultLogger) + // loggerLevel: Debug level + // store: use the default implementation(core/store/store.go DefaultStore) + conf := config.NewTestConfig(domain, appSettings) + + // Create CoreContext(*core.Context) for API requests, Event callbacks, Card callbacks, etc., as function parameters + // core.Context implements the context.Context interface + coreCtx := core.WrapContext(context.Background()) + // Get the RequestID(string) of API requests, Event callbacks, and Card callbacks, used for problem feedback, open platform query related logs, you can quickly locate the problem + requestID := coreCtx.GetRequestID() + // Get response to API request Status code(int) + statusCode := coreCtx.GetHTTPStatusCode() + + ``` + +### Module api +- Processing flow + - The acquisition and life cycle maintenance of app_access_token and tenant_access_token life cycle, **developers can directly access the business interface** + ![processing flow](api_process_en.jpg) +- Business API SDK that has been generated + + | Business service | version | path | sample | + |--------------|--------------|------|------| + | Authentication | v1 | [service/authen](service/authen) | [sample/api/authen.go](sample/api/authen.go)| + | Image | v4 | [service/image](service/image)|[sample/api/image.go](sample/api/image.go)| + | Contact | v3 | [service/contact](service/contact) | [sample/api/contact.go](sample/api/contact.go) | + | Calendar | v4 | [service/calendar](service/calendar)|[sample/api/calendar.go](sample/api/calendar.go)| + | Drive | v1 | [service/drive](service/drive)|[sample/api/drive.go](sample/api/drive.go)| + + +- Instructions for use(For`No business API SDK is generated`the processing method) + - For`App Store application`, when acquiring`app_access_token`, you need `app_ticket` to start the event subscription service(`Module event`) + - [Usage example](sample/api/api.go) + - The package request is as follows: + ```go + 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/api/core/request" + "github.com/larksuite/oapi-sdk-go/api/core/response" + ) + // Create request + // httpPath:(path after `open-apis/`) API path, for example: https://{domain}/open-apis/authen/v1/user_info, the httpPath: "authen/v1/user_info" + // httpMethod: GET/POST/PUT/BATCH/DELETE + // accessTokenType: which token access is used by the API, value range: request.AccessTokenTypeApp/request.AccessTokenTypeTenant/request.AccessTokenTypeUser, for example: request.AccessTokenTypeTenant + // input : Request body(may be request.NewFormData()(for example: file upload)), if the request body is not needed(for example, some GET requests), then pass: nil + // output: response body(output := response["data" ]) + // optFns: extended function, some uncommon parameter packages, as follows: + // request.SetPathParams(map[string]interface{}{"user_id": 4}): set the URL Path parameter(with: prefix) value, When httpPath="users/:user_id", the requested URL="https://{domain}/open-apis/users/4" + // request.SetQueryParams(map[string]interface{}{"age":4,"types":[1,2]}): Set the URL qeury, 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 time: output value is Buffer type + // 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 + // req := request.NewRequestWithNative(httpPath:string, httpMethod:string, accessTokenType:AccessTokenType, input:interface, output:interface, ... optFns:OptFn [))) + // Example: + 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("message/v4/send", "POST", request.AccessTokenTypeTenant, body, &ret) + coreCtx := core.WarpContext(context.Background()) + 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)) + + ``` + - Tool + + | Tool | path | description | + |--------------|--------------|------| + | file download | [api/core/tools/file.go](api/core/tools/file.go) | For example, you can download pictures for picture upload | + +### Module event +- Processing flow + - Encapsulated + - `App Store application` The `app_ticket` event (you need to set the event handler again), store it in the Store for `Module api` use + - Decryption of event data and verification of source reliability + - Business Event SDK that has been generated + + | Business service | version | path | sample | + |--------------|--------------|------|------| + | application | v1 | [service/application](service/application) | [sample/event/application.go](sample/event/application.go) | + | contact | v3 | [service/contact](service/contact) | [sample/event/contact.go](sample/event/contact.go) | + + - Instructions for use + - Event monitoring service started + - webhook address:http://ip:8089/[APP_ID]/webhook/event + - [Start with native http server](sample/event/http_server.go) + - [Start with Gin](sample/event/gin.go) + - [Other](sample/event/go.go) + - For `No business Event SDK is generated` the treatment + - Set the event handler, for example: + ```go + import "github.com/larksuite/oapi-sdk-go/event" + + // conf: config.Config + // app_status_change: event type + // func + // coreCtx: *core.Context + // event: map[string]interface{} + // return: + // error: not nil, response status code 500 + event.SetTypeCallback(conf, "app_status_change", func(coreCtx *core.Context, event map[string]interface{}) error { + fmt.Println(coreCtx.GetRequestID()) + fmt.Println(tools.Prettify(event)) + data := event["event"].(map[string]interface{}) + fmt.Println(tools.Prettify(data)) + return nil + }) + + ``` + +## Module card + - Encapsulated + - Verification of the validity and source reliability of card data + - Instructions for use + - Message card callback service started + - webhook address:http://ip:8089/[APP_ID]/webhook/card + - [Start with native http server](sample/card/http_server.go) + - [Start with Gin](sample/card/gin.go) + - [Other](sample/card/go.go) + - Set the message card handler, the code is as follows: + ```go + import "github.com/larksuite/oapi-sdk-go/card" + + // conf: config.Config + // func + // coreCtx: *core.Context + // card: *model.Card + // return: + // interface{}: can be string(json string of message card) or map(The map package of the message card) + // error: not nil, response status code 500 + 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 + }) + + ``` \ No newline at end of file diff --git a/doc/README.zh.old.md b/doc/README.zh.old.md new file mode 100644 index 00000000..d8f095bd --- /dev/null +++ b/doc/README.zh.old.md @@ -0,0 +1,214 @@ +# larksuit open api sdk +[English](README.md) + +| 模块 | 描述 | +|--------------|--------------| +| core | 应用信息配置及一些通用的方法 | +| api | 请求larksuite/feishu的接口 | +| event | 监听larksuite/feishu的业务数据发生变化,产生的事件 | +| card | 监听消息卡片交互时的动作 | +| service | 生成的业务SDK(api&event) | +| sample | 示例 | + +### 包引入 +```shell script +$ go get -u github.com/larksuite/oapi-sdk-go +``` + +### 模块core +- 使用说明 + - 获取应用配置 + - 方便开发提供了[代码样例 GetConfig方法](sample/config/config.go) + - 使用 redis 实现 [Store接口](core/store/store.go),用于维护 `app_ticket`、`app_access_token`、`tenant_access_token` 的生命周期 + - 使用 logrus 实现 [Logger接口](core/log/log.go) + - 方法使用说明,如下: + ```go + 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" + ) + + // 创建应用配置,防止泄漏,建议将应用信息放在环境变量中。 + // 环境变量或参数名: + // APP_ID:应用凭证中的App ID + // APP_SECRET:应用凭证中的App Secret + // VERIFICATION_TOKEN:事件订阅中的Verification Token + // ENCRYPT_KEY:事件订阅中的Encrypt Key,可以为空,表示事件内容不加密 + // 企业自建应用的配置 + appSettings := config.NewInternalAppSettings("[APP_ID]", "[APP_SECRET]", "[VERIFICATION_TOKEN]", "[ENCRYPT_KEY]") + // 企业自建应用的配置,通过环境变量获取应用配置 + appSettings := config.GetInternalAppSettingsByEnv() + // 应用商店应用的配置 + appSettings := config.NewISVAppSettings("[APP_ID]", "[APP_SECRET]", "[VERIFICATION_TOKEN]", "[ENCRYPT_KEY]") + // 应用商店应用的配置,通过环境变量获取应用配置 + appSettings := config.GetISVAppSettingsByEnv() + + + // 创建Config + // domain:域名http地址:constants.DomainFeiShu / constants.DomainLarkSuite + // appSettings:应用配置 + // logger:[日志接口](core/log/log.go) + // loggerLevel:输出的日志级别 log.LevelDebug/LevelInfo/LevelWarn/LevelError + // store: [存储接口](core/store/store.go),用来存储 app_ticket/app_access_token/tenant_access_token + // 用于线上的config + conf := config.NewConfig(domain, appSettings, logger, loggerLevel, store) + + // 用于开发测试的Config + // logger:使用默认实现(core/log/log.go defaultLogger) + // loggerLevel:Debug级别 + // store:使用默认实现(core/store/store.go DefaultStore) + conf := config.NewTestConfig(domain, appSettings) + + // 创建CoreContext(*core.Context),用于API请求、Event回调、Card回调等,作为函数的参数 + // core.Context实现了context.Context接口 + coreCtx := core.WrapContext(context.Background()) + // 获取 API请求、Event回调、Card回调的RequestID(string),用于问题反馈时,开放平台查询相关日志,可以快速的定位问题 + requestID := coreCtx.GetRequestID() + // 获取 API请求的响应状态码(int) + statusCode := coreCtx.GetHTTPStatusCode() + + ``` + +### 模块api +- 处理流程 + - 对app_access_token、tenant_access_token的获取及生命周期的维护做了封装,**开发者可直接访问业务接口** + ![处理流程图](api_process.jpg) +- 已经生成的业务API SDK + + | 业务服务 | 版本 | 路径 | 示例 | + |--------------|--------------|------|------| + | 身份验证 | v1 | [service/authen](service/authen) | [sample/api/authen.go](sample/api/authen.go)| + | 图片 | v4 | [service/image](service/image)|[sample/api/image.go](sample/api/image.go)| + | 通讯录 | v3 | [service/contact](service/contact)|[sample/api/contact.go](sample/api/contact.go)| + | 日历 | v4 | [service/calendar](service/calendar)|[sample/api/calendar.go](sample/api/calendar.go)| + | 云空间文件 | v1 | [service/drive](service/drive)|[sample/api/drive.go](sample/api/drive.go)| + + +- 使用说明(对于`没有生成业务API SDK`的处理方式) + - 对于`应用商店应用`,在获取`app_access_token`时,需要 `app_ticket`,需要启动事件订阅服务(`模块event`) + - [使用示例](sample/api/api.go) + - 封装请求,如下: + ```go + 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/api/core/request" + ) + // 创建请求 + // httpPath:API路径(`open-apis/`之后的路径),例如:https://{domain}/open-apis/authen/v1/user_info,则 httpPath:"authen/v1/user_info" + // httpMethod: GET/POST/PUT/BATCH/DELETE + // accessTokenType:API使用哪种token访问,取值范围:request.AccessTokenTypeApp/request.AccessTokenTypeTenant/request.AccessTokenTypeUser,例如:request.AccessTokenTypeTenant + // input:请求体(可能是request.NewFormData()(例如:文件上传)),如果不需要请求体(例如一些GET请求),则传:nil + // output:响应体(output := response["data"]) + // optFns:扩展函数,一些不常用的参数封装,如下: + // request.SetPathParams(map[string]interface{}{"user_id": 4}):设置URL Path参数(有:前缀)值,当httpPath="users/:user_id"时,请求的URL="https://{domain}/open-apis/users/4" + // request.SetQueryParams(map[string]interface{}{"age":4,"types":[1,2]}):设置 URL qeury,会在url追加?age=4&types=1&types=2 + // request.setResponseStream(),设置响应的是否是流,例如下载文件,这时:output值是Buffer类型 + // request.SetNotDataField(),设置响应的是否 没有`data`字段,业务接口都是有`data`字段,所以不需要设置 + // request.SetTenantKey("TenantKey"),以`应用商店应用`身份,表示使用`tenant_access_token`访问API,需要设置 + // request.SetUserAccessToken("UserAccessToken"),表示使用`user_access_token`访问API,需要设置 + // req := request.NewRequestWithNative(httpPath:string, httpMethod:string, accessTokenType:AccessTokenType, input:interface, output:interface, ... optFns:OptFn [))) + // Example: + 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("message/v4/send", "POST", request.AccessTokenTypeTenant, body, &ret)coreCtx := core.WarpContext(context.Background()) + 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)) + + ``` + - 工具 + + | 工具 | 路径 | 描述 | + |--------------|--------------|------| + | 文件下载 | [api/core/tools/file.go](api/core/tools/file.go) | 例如,可以下载图片,用于图片上传 | + +### 模块event +- 处理流程 + - 封装了 + - `应用商店应用`的`app_ticket`事件(需要再次设置该事件的处理者),将其存入Store,供 `模块api` 使用 + - 已封装challenge验证 + - 事件数据的解密与来源可靠性的验证 + - 已经生成的业务Event SDK + + | 业务服务 | 版本 | 路径 | 示例 | + |--------------|--------------|------|------| + | 应用 | v1 | [service/application](service/application) | [sample/event/application.go](sample/event/application.go) | + | 通讯录 | v3 | [service/contact](service/contact) | [sample/event/contact.go](sample/event/contact.go) | + + - 使用说明 + - 事件监听服务启动 + - webhook地址:http://ip:8089/[APP_ID]/webhook/event + - [使用原生的http server启动](sample/event/http_server.go) + - [使用Gin启动](sample/event/gin.go) + - [其他情况使用](sample/event/go.go) + - 对于`没有生成业务Event SDK`的处理方式 + - 设置事件的处理者,样例如下: + ```go + import "github.com/larksuite/oapi-sdk-go/event" + + // conf: config.Config + // app_status_change: 事件类型 + // func + // coreCtx: *core.Context + // event: 事件数据 + // return: + // error: 不为nil,响应状态码 500 + event.SetTypeCallback(conf, "app_status_change", func(coreCtx *core.Context, event map[string]interface{}) error { + fmt.Println(coreCtx.GetRequestID()) + fmt.Println(tools.Prettify(event)) + data := event["event"].(map[string]interface{}) + fmt.Println(tools.Prettify(data)) + return nil + }) + + ``` + +## 模块card + - 封装了 + - 已封装challenge验证 + - 卡片数据的有效性、来源可靠性的验证 + - 使用说明 + - 消息卡片回调服务启动 + - webhook地址:http://ip:8089/[APP_ID]/webhook/card + - [使用原生的http server启动](sample/card/http_server.go) + - [使用Gin启动](sample/card/gin.go) + - [其他情况使用](sample/card/go.go) + - 设置卡片的处理者,代码如下: + ```go + import "github.com/larksuite/oapi-sdk-go/card" + + // conf: config.Config + // func + // coreCtx: *core.Context + // card: 卡片 + // return: + // interface{}: 可以是string(消息卡片 的json字符串),也可以是map(消息卡片 的map封装) + // error: 不为nil,响应状态码 500 + 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 + }) + + ``` + + + + diff --git a/doc/app_type.en.png b/doc/app_type.en.png new file mode 100644 index 00000000..33473ab4 Binary files /dev/null and b/doc/app_type.en.png differ diff --git a/doc/app_type.zh.png b/doc/app_type.zh.png new file mode 100644 index 00000000..91e25ba6 Binary files /dev/null and b/doc/app_type.zh.png differ diff --git a/sample/config/config.go b/sample/config/config.go index 207deca3..3f89bd54 100644 --- a/sample/config/config.go +++ b/sample/config/config.go @@ -2,13 +2,10 @@ package config import ( "context" - "github.com/go-redis/redis/v8" "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/log" - "github.com/sirupsen/logrus" - "time" ) func GetConfig(domain constants.Domain, appSettings *config.AppSettings, level log.Level) *config.Config { @@ -18,60 +15,3 @@ func GetConfig(domain constants.Domain, appSettings *config.AppSettings, level l coreCtx.GetHTTPStatusCode() return config.NewConfig(constants.DomainLarkSuite, appSettings, logger, level, store) } - -// use logrus implement log.Logger -type Logrus struct { -} - -func (Logrus) Debug(ctx context.Context, args ...interface{}) { - logrus.Debug(args...) -} -func (Logrus) Info(ctx context.Context, args ...interface{}) { - logrus.Debug(args...) -} -func (Logrus) Warn(ctx context.Context, args ...interface{}) { - logrus.Debug(args...) -} -func (Logrus) Error(ctx context.Context, args ...interface{}) { - logrus.Debug(args...) -} - -// use redis implement store.Store -type RedisStore struct { - client *redis.Client -} - -func NewRedisStore() *RedisStore { - rdb := redis.NewClient(&redis.Options{ - Addr: "localhost:6379", - Password: "", // no password set - DB: 0, // use default DB - }) - _, err := rdb.Ping(context.Background()).Result() - if err != nil { - panic(err) - } - return &RedisStore{client: rdb} -} - -func (rs *RedisStore) Get(ctx context.Context, key string) (string, error) { - if rs.client == nil { - panic("redis client is not initialized") - } - value, err := rs.client.Get(ctx, key).Result() - if err != nil { - return "", err - } - return value, nil -} - -func (rs *RedisStore) Put(ctx context.Context, key string, value string, expired time.Duration) error { - if rs.client == nil { - panic("redis client is not initialized") - } - _, err := rs.client.Set(ctx, key, value, expired).Result() - if err != nil { - return err - } - return nil -} diff --git a/sample/config/logrus.go b/sample/config/logrus.go new file mode 100644 index 00000000..98581730 --- /dev/null +++ b/sample/config/logrus.go @@ -0,0 +1,23 @@ +package config + +import ( + "context" + "github.com/sirupsen/logrus" +) + +// use logrus implement log.Logger +type Logrus struct { +} + +func (Logrus) Debug(ctx context.Context, args ...interface{}) { + logrus.Debug(args...) +} +func (Logrus) Info(ctx context.Context, args ...interface{}) { + logrus.Debug(args...) +} +func (Logrus) Warn(ctx context.Context, args ...interface{}) { + logrus.Debug(args...) +} +func (Logrus) Error(ctx context.Context, args ...interface{}) { + logrus.Debug(args...) +} diff --git a/sample/config/redis_store.go b/sample/config/redis_store.go new file mode 100644 index 00000000..b7cee177 --- /dev/null +++ b/sample/config/redis_store.go @@ -0,0 +1,47 @@ +package config + +import ( + "context" + "github.com/go-redis/redis/v8" + "time" +) + +// use redis implement store.Store +type RedisStore struct { + client *redis.Client +} + +func NewRedisStore() *RedisStore { + rdb := redis.NewClient(&redis.Options{ + Addr: "localhost:6379", + Password: "", // no password set + DB: 0, // use default DB + }) + _, err := rdb.Ping(context.Background()).Result() + if err != nil { + panic(err) + } + return &RedisStore{client: rdb} +} + +func (rs *RedisStore) Get(ctx context.Context, key string) (string, error) { + if rs.client == nil { + panic("redis client is not initialized") + } + value, err := rs.client.Get(ctx, key).Result() + if err != nil { + return "", err + } + return value, nil +} + +func (rs *RedisStore) Put(ctx context.Context, key string, value string, expired time.Duration) error { + if rs.client == nil { + panic("redis client is not initialized") + } + _, err := rs.client.Set(ctx, key, value, expired).Result() + if err != nil { + return err + } + return nil +} diff --git a/sample/tools/file_download.go b/sample/tools/file_download.go new file mode 100644 index 00000000..6e051803 --- /dev/null +++ b/sample/tools/file_download.go @@ -0,0 +1,28 @@ +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/calendar/v4/api.go b/service/calendar/v4/api.go index 633e8962..e65114a3 100644 --- a/service/calendar/v4/api.go +++ b/service/calendar/v4/api.go @@ -19,9 +19,10 @@ type Service struct { CalendarAcls *CalendarAclService CalendarEvents *CalendarEventService CalendarEventAttendees *CalendarEventAttendeeService - CalendarEventAttendeeChatMembers *CalendarEventAttendeeChatMemberService Freebusys *FreebusyService TimeoffEvents *TimeoffEventService + Settings *SettingService + CalendarEventAttendeeChatMembers *CalendarEventAttendeeChatMemberService } func NewService(conf *config.Config) *Service { @@ -33,9 +34,10 @@ func NewService(conf *config.Config) *Service { s.CalendarAcls = newCalendarAclService(s) s.CalendarEvents = newCalendarEventService(s) s.CalendarEventAttendees = newCalendarEventAttendeeService(s) - s.CalendarEventAttendeeChatMembers = newCalendarEventAttendeeChatMemberService(s) s.Freebusys = newFreebusyService(s) s.TimeoffEvents = newTimeoffEventService(s) + s.Settings = newSettingService(s) + s.CalendarEventAttendeeChatMembers = newCalendarEventAttendeeChatMemberService(s) return s } @@ -79,16 +81,6 @@ func newCalendarEventAttendeeService(service *Service) *CalendarEventAttendeeSer } } -type CalendarEventAttendeeChatMemberService struct { - service *Service -} - -func newCalendarEventAttendeeChatMemberService(service *Service) *CalendarEventAttendeeChatMemberService { - return &CalendarEventAttendeeChatMemberService{ - service: service, - } -} - type FreebusyService struct { service *Service } @@ -109,142 +101,147 @@ func newTimeoffEventService(service *Service) *TimeoffEventService { } } -type CalendarAclCreateReqCall struct { - ctx *core.Context - calendarAcls *CalendarAclService - body *CalendarAcl - pathParams map[string]interface{} +type SettingService struct { + service *Service +} - queryParams map[string]interface{} - optFns []request.OptFn +func newSettingService(service *Service) *SettingService { + return &SettingService{ + service: service, + } } -func (rc *CalendarAclCreateReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId +type CalendarEventAttendeeChatMemberService struct { + service *Service } -func (rc *CalendarAclCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType + +func newCalendarEventAttendeeChatMemberService(service *Service) *CalendarEventAttendeeChatMemberService { + return &CalendarEventAttendeeChatMemberService{ + service: service, + } } -func (rc *CalendarAclCreateReqCall) Do() (*CalendarAcl, error) { - httpPath := path.Join(rc.calendarAcls.service.basePath, "calendars/:calendar_id/acls") - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &CalendarAcl{} + +type CalendarCreateReqCall struct { + ctx *core.Context + calendars *CalendarService + body *Calendar + + optFns []request.OptFn +} + +func (rc *CalendarCreateReqCall) Do() (*CalendarCreateResult, error) { + httpPath := path.Join(rc.calendars.service.basePath, "calendars") + var result = &CalendarCreateResult{} req := request.NewRequest(httpPath, "POST", []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarAcls.service.conf, req) + err := api.Send(rc.ctx, rc.calendars.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, +func (calendars *CalendarService) Create(ctx *core.Context, body *Calendar, optFns ...request.OptFn) *CalendarCreateReqCall { + return &CalendarCreateReqCall{ + ctx: ctx, + calendars: calendars, + body: body, + optFns: optFns, } } -type CalendarAclDeleteReqCall struct { - ctx *core.Context - calendarAcls *CalendarAclService - pathParams map[string]interface{} +type CalendarEventDeleteReqCall struct { + ctx *core.Context + calendarEvents *CalendarEventService + pathParams map[string]interface{} optFns []request.OptFn } -func (rc *CalendarAclDeleteReqCall) SetCalendarId(calendarId string) { +func (rc *CalendarEventDeleteReqCall) SetCalendarId(calendarId string) { rc.pathParams["calendar_id"] = calendarId } -func (rc *CalendarAclDeleteReqCall) SetAclId(aclId string) { - rc.pathParams["acl_id"] = aclId +func (rc *CalendarEventDeleteReqCall) SetEventId(eventId string) { + rc.pathParams["event_id"] = eventId } -func (rc *CalendarAclDeleteReqCall) Do() (*response.NoData, error) { - httpPath := path.Join(rc.calendarAcls.service.basePath, "calendars/:calendar_id/acls/:acl_id") +func (rc *CalendarEventDeleteReqCall) Do() (*response.NoData, error) { + httpPath := path.Join(rc.calendarEvents.service.basePath, "calendars/:calendar_id/events/:event_id") rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) var result = &response.NoData{} req := request.NewRequest(httpPath, "DELETE", []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarAcls.service.conf, req) + err := api.Send(rc.ctx, rc.calendarEvents.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, +func (calendarEvents *CalendarEventService) Delete(ctx *core.Context, optFns ...request.OptFn) *CalendarEventDeleteReqCall { + return &CalendarEventDeleteReqCall{ + ctx: ctx, + calendarEvents: calendarEvents, + pathParams: map[string]interface{}{}, + optFns: optFns, } } -type CalendarAclListReqCall struct { - ctx *core.Context - calendarAcls *CalendarAclService - pathParams map[string]interface{} +type CalendarEventGetReqCall struct { + ctx *core.Context + calendarEvents *CalendarEventService + pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn + optFns []request.OptFn } -func (rc *CalendarAclListReqCall) SetCalendarId(calendarId string) { +func (rc *CalendarEventGetReqCall) 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 *CalendarEventGetReqCall) SetEventId(eventId string) { + rc.pathParams["event_id"] = eventId } -func (rc *CalendarAclListReqCall) Do() (*CalendarAclListResult, error) { - httpPath := path.Join(rc.calendarAcls.service.basePath, "calendars/:calendar_id/acls") +func (rc *CalendarEventGetReqCall) Do() (*CalendarEventGetResult, error) { + httpPath := path.Join(rc.calendarEvents.service.basePath, "calendars/:calendar_id/events/:event_id") rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &CalendarAclListResult{} + var result = &CalendarEventGetResult{} req := request.NewRequest(httpPath, "GET", []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarAcls.service.conf, req) + err := api.Send(rc.ctx, rc.calendarEvents.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, +func (calendarEvents *CalendarEventService) Get(ctx *core.Context, optFns ...request.OptFn) *CalendarEventGetReqCall { + return &CalendarEventGetReqCall{ + ctx: ctx, + calendarEvents: calendarEvents, + pathParams: map[string]interface{}{}, + optFns: optFns, } } -type CalendarCreateReqCall struct { - ctx *core.Context - calendars *CalendarService - body *Calendar +type CalendarPatchReqCall struct { + ctx *core.Context + calendars *CalendarService + body *Calendar + pathParams map[string]interface{} optFns []request.OptFn } -func (rc *CalendarCreateReqCall) Do() (*CalendarCreateResult, error) { - httpPath := path.Join(rc.calendars.service.basePath, "calendars") - var result = &CalendarCreateResult{} - req := request.NewRequest(httpPath, "POST", +func (rc *CalendarPatchReqCall) SetCalendarId(calendarId string) { + rc.pathParams["calendar_id"] = calendarId +} +func (rc *CalendarPatchReqCall) Do() (*CalendarPatchResult, error) { + httpPath := path.Join(rc.calendars.service.basePath, "calendars/:calendar_id") + rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) + var result = &CalendarPatchResult{} + req := request.NewRequest(httpPath, "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) Create(ctx *core.Context, body *Calendar, optFns ...request.OptFn) *CalendarCreateReqCall { - return &CalendarCreateReqCall{ - ctx: ctx, - calendars: calendars, - body: body, - optFns: optFns, +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, } } @@ -278,124 +275,184 @@ func (calendars *CalendarService) Delete(ctx *core.Context, optFns ...request.Op } } -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) { - httpPath := path.Join(rc.calendarEventAttendees.service.basePath, "calendars/:calendar_id/events/:event_id/attendees/batch_delete") - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest(httpPath, "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 CalendarEventAttendeeChatMemberListReqCall struct { - ctx *core.Context - calendarEventAttendeeChatMembers *CalendarEventAttendeeChatMemberService - pathParams map[string]interface{} +type CalendarAclListReqCall struct { + ctx *core.Context + calendarAcls *CalendarAclService + pathParams map[string]interface{} queryParams map[string]interface{} optFns []request.OptFn } -func (rc *CalendarEventAttendeeChatMemberListReqCall) SetCalendarId(calendarId string) { +func (rc *CalendarAclListReqCall) 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 *CalendarAclListReqCall) SetUserIdType(userIdType string) { + rc.queryParams["user_id_type"] = userIdType } -func (rc *CalendarEventAttendeeChatMemberListReqCall) SetPageToken(pageToken string) { +func (rc *CalendarAclListReqCall) SetPageToken(pageToken string) { rc.queryParams["page_token"] = pageToken } -func (rc *CalendarEventAttendeeChatMemberListReqCall) SetPageSize(pageSize int) { +func (rc *CalendarAclListReqCall) SetPageSize(pageSize int) { rc.queryParams["page_size"] = pageSize } -func (rc *CalendarEventAttendeeChatMemberListReqCall) Do() (*CalendarEventAttendeeChatMemberListResult, error) { - httpPath := path.Join(rc.calendarEventAttendeeChatMembers.service.basePath, "calendars/:calendar_id/events/:event_id/attendees/:attendee_id/chat_members") +func (rc *CalendarAclListReqCall) Do() (*CalendarAclListResult, error) { + httpPath := path.Join(rc.calendarAcls.service.basePath, "calendars/:calendar_id/acls") rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &CalendarEventAttendeeChatMemberListResult{} + var result = &CalendarAclListResult{} req := request.NewRequest(httpPath, "GET", []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarEventAttendeeChatMembers.service.conf, req) + err := api.Send(rc.ctx, rc.calendarAcls.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, - } -} - -type CalendarEventAttendeeCreateReqCall struct { - ctx *core.Context - calendarEventAttendees *CalendarEventAttendeeService - body *CalendarEventAttendeeCreateReqBody - pathParams map[string]interface{} +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) { + httpPath := path.Join(rc.calendarAcls.service.basePath, "calendars/:calendar_id/acls/:acl_id") + rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) + var result = &response.NoData{} + req := request.NewRequest(httpPath, "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 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) { + httpPath := path.Join(rc.calendarEvents.service.basePath, "calendars/:calendar_id/events") + rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) + var result = &CalendarEventCreateResult{} + req := request.NewRequest(httpPath, "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 CalendarAclCreateReqCall struct { + ctx *core.Context + calendarAcls *CalendarAclService + body *CalendarAcl + pathParams map[string]interface{} queryParams map[string]interface{} optFns []request.OptFn } -func (rc *CalendarEventAttendeeCreateReqCall) SetCalendarId(calendarId string) { +func (rc *CalendarAclCreateReqCall) 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) { +func (rc *CalendarAclCreateReqCall) SetUserIdType(userIdType string) { rc.queryParams["user_id_type"] = userIdType } -func (rc *CalendarEventAttendeeCreateReqCall) Do() (*CalendarEventAttendeeCreateResult, error) { - httpPath := path.Join(rc.calendarEventAttendees.service.basePath, "calendars/:calendar_id/events/:event_id/attendees") +func (rc *CalendarAclCreateReqCall) Do() (*CalendarAcl, error) { + httpPath := path.Join(rc.calendarAcls.service.basePath, "calendars/:calendar_id/acls") rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &CalendarEventAttendeeCreateResult{} + var result = &CalendarAcl{} req := request.NewRequest(httpPath, "POST", []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarEventAttendees.service.conf, req) + err := api.Send(rc.ctx, rc.calendarAcls.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, +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 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) { + httpPath := path.Join(rc.calendars.service.basePath, "calendars") + rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) + var result = &CalendarListResult{} + req := request.NewRequest(httpPath, "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, } } @@ -444,101 +501,109 @@ func (calendarEventAttendees *CalendarEventAttendeeService) List(ctx *core.Conte } } -type CalendarEventCreateReqCall struct { - ctx *core.Context - calendarEvents *CalendarEventService - body *CalendarEvent - pathParams map[string]interface{} +type CalendarEventAttendeeBatchDeleteReqCall struct { + ctx *core.Context + calendarEventAttendees *CalendarEventAttendeeService + body *CalendarEventAttendeeBatchDeleteReqBody + pathParams map[string]interface{} optFns []request.OptFn } -func (rc *CalendarEventCreateReqCall) SetCalendarId(calendarId string) { +func (rc *CalendarEventAttendeeBatchDeleteReqCall) SetCalendarId(calendarId string) { rc.pathParams["calendar_id"] = calendarId } -func (rc *CalendarEventCreateReqCall) Do() (*CalendarEventCreateResult, error) { - httpPath := path.Join(rc.calendarEvents.service.basePath, "calendars/:calendar_id/events") +func (rc *CalendarEventAttendeeBatchDeleteReqCall) SetEventId(eventId string) { + rc.pathParams["event_id"] = eventId +} +func (rc *CalendarEventAttendeeBatchDeleteReqCall) Do() (*response.NoData, error) { + httpPath := path.Join(rc.calendarEventAttendees.service.basePath, "calendars/:calendar_id/events/:event_id/attendees/batch_delete") rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &CalendarEventCreateResult{} + var result = &response.NoData{} req := request.NewRequest(httpPath, "POST", []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarEvents.service.conf, req) + err := api.Send(rc.ctx, rc.calendarEventAttendees.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, +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 CalendarEventDeleteReqCall struct { - ctx *core.Context - calendarEvents *CalendarEventService - pathParams map[string]interface{} +type CalendarEventAttendeeCreateReqCall struct { + ctx *core.Context + calendarEventAttendees *CalendarEventAttendeeService + body *CalendarEventAttendeeCreateReqBody + pathParams map[string]interface{} - optFns []request.OptFn + queryParams map[string]interface{} + optFns []request.OptFn } -func (rc *CalendarEventDeleteReqCall) SetCalendarId(calendarId string) { +func (rc *CalendarEventAttendeeCreateReqCall) SetCalendarId(calendarId string) { rc.pathParams["calendar_id"] = calendarId } -func (rc *CalendarEventDeleteReqCall) SetEventId(eventId string) { +func (rc *CalendarEventAttendeeCreateReqCall) SetEventId(eventId string) { rc.pathParams["event_id"] = eventId } -func (rc *CalendarEventDeleteReqCall) Do() (*response.NoData, error) { - httpPath := path.Join(rc.calendarEvents.service.basePath, "calendars/:calendar_id/events/:event_id") +func (rc *CalendarEventAttendeeCreateReqCall) SetUserIdType(userIdType string) { + rc.queryParams["user_id_type"] = userIdType +} +func (rc *CalendarEventAttendeeCreateReqCall) Do() (*CalendarEventAttendeeCreateResult, error) { + httpPath := path.Join(rc.calendarEventAttendees.service.basePath, "calendars/:calendar_id/events/:event_id/attendees") rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest(httpPath, "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarEvents.service.conf, req) + rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) + var result = &CalendarEventAttendeeCreateResult{} + req := request.NewRequest(httpPath, "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 (calendarEvents *CalendarEventService) Delete(ctx *core.Context, optFns ...request.OptFn) *CalendarEventDeleteReqCall { - return &CalendarEventDeleteReqCall{ - ctx: ctx, - calendarEvents: calendarEvents, - pathParams: map[string]interface{}{}, - optFns: optFns, +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 CalendarEventGetReqCall struct { - ctx *core.Context - calendarEvents *CalendarEventService - pathParams map[string]interface{} +type CalendarGetReqCall struct { + ctx *core.Context + calendars *CalendarService + pathParams map[string]interface{} optFns []request.OptFn } -func (rc *CalendarEventGetReqCall) SetCalendarId(calendarId string) { +func (rc *CalendarGetReqCall) 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) { - httpPath := path.Join(rc.calendarEvents.service.basePath, "calendars/:calendar_id/events/:event_id") +func (rc *CalendarGetReqCall) Do() (*Calendar, error) { + httpPath := path.Join(rc.calendars.service.basePath, "calendars/:calendar_id") rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &CalendarEventGetResult{} + var result = &Calendar{} req := request.NewRequest(httpPath, "GET", []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendarEvents.service.conf, req) + err := api.Send(rc.ctx, rc.calendars.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, +func (calendars *CalendarService) Get(ctx *core.Context, optFns ...request.OptFn) *CalendarGetReqCall { + return &CalendarGetReqCall{ + ctx: ctx, + calendars: calendars, + pathParams: map[string]interface{}{}, + optFns: optFns, } } @@ -563,11 +628,11 @@ func (rc *CalendarEventListReqCall) SetPageToken(pageToken string) { func (rc *CalendarEventListReqCall) SetSyncToken(syncToken string) { rc.queryParams["sync_token"] = syncToken } -func (rc *CalendarEventListReqCall) Do() (*response.NoData, error) { +func (rc *CalendarEventListReqCall) Do() (*CalendarEventListResult, error) { httpPath := path.Join(rc.calendarEvents.service.basePath, "calendars/:calendar_id/events") rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &response.NoData{} + var result = &CalendarEventListResult{} req := request.NewRequest(httpPath, "GET", []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) err := api.Send(rc.ctx, rc.calendarEvents.service.conf, req) @@ -584,6 +649,73 @@ func (calendarEvents *CalendarEventService) List(ctx *core.Context, optFns ...re } } +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) { + httpPath := path.Join(rc.calendars.service.basePath, "calendars/search") + rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) + var result = &CalendarSearchResult{} + req := request.NewRequest(httpPath, "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) { + httpPath := path.Join(rc.freebusys.service.basePath, "freebusy/list") + rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) + var result = &FreebusyListResult{} + req := request.NewRequest(httpPath, "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 @@ -619,180 +751,139 @@ func (calendarEvents *CalendarEventService) Patch(ctx *core.Context, body *Calen } } -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) { - httpPath := path.Join(rc.calendarEvents.service.basePath, "calendars/:calendar_id/events/search") - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &CalendarEventSearchResult{} - req := request.NewRequest(httpPath, "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 CalendarGetReqCall struct { - ctx *core.Context - calendars *CalendarService - pathParams map[string]interface{} +type TimeoffEventDeleteReqCall struct { + ctx *core.Context + timeoffEvents *TimeoffEventService + pathParams map[string]interface{} optFns []request.OptFn } -func (rc *CalendarGetReqCall) SetCalendarId(calendarId string) { - rc.pathParams["calendar_id"] = calendarId +func (rc *TimeoffEventDeleteReqCall) SetTimeoffEventId(timeoffEventId string) { + rc.pathParams["timeoff_event_id"] = timeoffEventId } -func (rc *CalendarGetReqCall) Do() (*Calendar, error) { - httpPath := path.Join(rc.calendars.service.basePath, "calendars/:calendar_id") +func (rc *TimeoffEventDeleteReqCall) Do() (*response.NoData, error) { + httpPath := path.Join(rc.timeoffEvents.service.basePath, "timeoff_events/:timeoff_event_id") rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &Calendar{} - req := request.NewRequest(httpPath, "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendars.service.conf, req) + var result = &response.NoData{} + req := request.NewRequest(httpPath, "DELETE", + []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) + err := api.Send(rc.ctx, rc.timeoffEvents.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, +func (timeoffEvents *TimeoffEventService) Delete(ctx *core.Context, optFns ...request.OptFn) *TimeoffEventDeleteReqCall { + return &TimeoffEventDeleteReqCall{ + ctx: ctx, + timeoffEvents: timeoffEvents, + pathParams: map[string]interface{}{}, + optFns: optFns, } } -type CalendarListReqCall struct { - ctx *core.Context - calendars *CalendarService +type TimeoffEventCreateReqCall struct { + ctx *core.Context + timeoffEvents *TimeoffEventService + body *TimeoffEvent 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 *TimeoffEventCreateReqCall) SetUserIdType(userIdType string) { + rc.queryParams["user_id_type"] = userIdType } -func (rc *CalendarListReqCall) Do() (*CalendarListResult, error) { - httpPath := path.Join(rc.calendars.service.basePath, "calendars") +func (rc *TimeoffEventCreateReqCall) Do() (*TimeoffEvent, error) { + httpPath := path.Join(rc.timeoffEvents.service.basePath, "timeoff_events") rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &CalendarListResult{} - req := request.NewRequest(httpPath, "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendars.service.conf, req) + var result = &TimeoffEvent{} + req := request.NewRequest(httpPath, "POST", + []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) + err := api.Send(rc.ctx, rc.timeoffEvents.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, +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 CalendarPatchReqCall struct { +type CalendarUnsubscribeReqCall struct { ctx *core.Context calendars *CalendarService - body *Calendar pathParams map[string]interface{} optFns []request.OptFn } -func (rc *CalendarPatchReqCall) SetCalendarId(calendarId string) { +func (rc *CalendarUnsubscribeReqCall) SetCalendarId(calendarId string) { rc.pathParams["calendar_id"] = calendarId } -func (rc *CalendarPatchReqCall) Do() (*CalendarPatchResult, error) { - httpPath := path.Join(rc.calendars.service.basePath, "calendars/:calendar_id") +func (rc *CalendarUnsubscribeReqCall) Do() (*response.NoData, error) { + httpPath := path.Join(rc.calendars.service.basePath, "calendars/:calendar_id/unsubscribe") rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &CalendarPatchResult{} - req := request.NewRequest(httpPath, "PATCH", - []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) + var result = &response.NoData{} + req := request.NewRequest(httpPath, "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) Patch(ctx *core.Context, body *Calendar, optFns ...request.OptFn) *CalendarPatchReqCall { - return &CalendarPatchReqCall{ +func (calendars *CalendarService) Unsubscribe(ctx *core.Context, optFns ...request.OptFn) *CalendarUnsubscribeReqCall { + return &CalendarUnsubscribeReqCall{ ctx: ctx, calendars: calendars, - body: body, pathParams: map[string]interface{}{}, optFns: optFns, } } -type CalendarSearchReqCall struct { - ctx *core.Context - calendars *CalendarService - body *CalendarSearchReqBody +type CalendarEventSearchReqCall struct { + ctx *core.Context + calendarEvents *CalendarEventService + body *CalendarEventSearchReqBody + pathParams map[string]interface{} queryParams map[string]interface{} optFns []request.OptFn } -func (rc *CalendarSearchReqCall) SetPageToken(pageToken string) { +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 *CalendarSearchReqCall) SetPageSize(pageSize int) { +func (rc *CalendarEventSearchReqCall) SetPageSize(pageSize int) { rc.queryParams["page_size"] = pageSize } -func (rc *CalendarSearchReqCall) Do() (*CalendarSearchResult, error) { - httpPath := path.Join(rc.calendars.service.basePath, "calendars/search") +func (rc *CalendarEventSearchReqCall) Do() (*CalendarEventSearchResult, error) { + httpPath := path.Join(rc.calendarEvents.service.basePath, "calendars/:calendar_id/events/search") + rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &CalendarSearchResult{} + var result = &CalendarEventSearchResult{} req := request.NewRequest(httpPath, "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendars.service.conf, req) + []request.AccessTokenType{request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) + err := api.Send(rc.ctx, rc.calendarEvents.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, +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, } } @@ -826,126 +917,157 @@ func (calendars *CalendarService) Subscribe(ctx *core.Context, optFns ...request } } -type CalendarUnsubscribeReqCall struct { - ctx *core.Context - calendars *CalendarService - pathParams map[string]interface{} +type SettingGenerateCaldavConfReqCall struct { + ctx *core.Context + settings *SettingService + body *SettingGenerateCaldavConfReqBody optFns []request.OptFn } -func (rc *CalendarUnsubscribeReqCall) SetCalendarId(calendarId string) { +func (rc *SettingGenerateCaldavConfReqCall) Do() (*SettingGenerateCaldavConfResult, error) { + httpPath := path.Join(rc.settings.service.basePath, "settings/generate_caldav_conf") + var result = &SettingGenerateCaldavConfResult{} + req := request.NewRequest(httpPath, "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 *CalendarUnsubscribeReqCall) Do() (*response.NoData, error) { - httpPath := path.Join(rc.calendars.service.basePath, "calendars/:calendar_id/unsubscribe") +func (rc *CalendarEventSubscriptionReqCall) Do() (*response.NoData, error) { + httpPath := path.Join(rc.calendarEvents.service.basePath, "calendars/:calendar_id/events/subscription") rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) var result = &response.NoData{} req := request.NewRequest(httpPath, "POST", - []request.AccessTokenType{request.AccessTokenTypeUser, request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.calendars.service.conf, req) + []request.AccessTokenType{request.AccessTokenTypeUser}, nil, result, rc.optFns...) + err := api.Send(rc.ctx, rc.calendarEvents.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, +func (calendarEvents *CalendarEventService) Subscription(ctx *core.Context, optFns ...request.OptFn) *CalendarEventSubscriptionReqCall { + return &CalendarEventSubscriptionReqCall{ + ctx: ctx, + calendarEvents: calendarEvents, + pathParams: map[string]interface{}{}, + optFns: optFns, } } -type FreebusyListReqCall struct { +type CalendarSubscriptionReqCall struct { ctx *core.Context - freebusys *FreebusyService - body *FreebusyListReqBody + calendars *CalendarService - queryParams map[string]interface{} - optFns []request.OptFn + optFns []request.OptFn } -func (rc *FreebusyListReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *FreebusyListReqCall) Do() (*FreebusyListResult, error) { - httpPath := path.Join(rc.freebusys.service.basePath, "freebusy/list") - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &FreebusyListResult{} +func (rc *CalendarSubscriptionReqCall) Do() (*response.NoData, error) { + httpPath := path.Join(rc.calendars.service.basePath, "calendars/subscription") + var result = &response.NoData{} req := request.NewRequest(httpPath, "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.freebusys.service.conf, req) + []request.AccessTokenType{request.AccessTokenTypeUser}, nil, result, rc.optFns...) + err := api.Send(rc.ctx, rc.calendars.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, +func (calendars *CalendarService) Subscription(ctx *core.Context, optFns ...request.OptFn) *CalendarSubscriptionReqCall { + return &CalendarSubscriptionReqCall{ + ctx: ctx, + calendars: calendars, + optFns: optFns, } } -type TimeoffEventCreateReqCall struct { - ctx *core.Context - timeoffEvents *TimeoffEventService - body *TimeoffEvent +type CalendarAclSubscriptionReqCall struct { + ctx *core.Context + calendarAcls *CalendarAclService + pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn + optFns []request.OptFn } -func (rc *TimeoffEventCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType +func (rc *CalendarAclSubscriptionReqCall) SetCalendarId(calendarId string) { + rc.pathParams["calendar_id"] = calendarId } -func (rc *TimeoffEventCreateReqCall) Do() (*TimeoffEvent, error) { - httpPath := path.Join(rc.timeoffEvents.service.basePath, "timeoff_events") - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &TimeoffEvent{} +func (rc *CalendarAclSubscriptionReqCall) Do() (*response.NoData, error) { + httpPath := path.Join(rc.calendarAcls.service.basePath, "calendars/:calendar_id/acls/subscription") + rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) + var result = &response.NoData{} req := request.NewRequest(httpPath, "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.timeoffEvents.service.conf, req) + []request.AccessTokenType{request.AccessTokenTypeUser}, nil, result, rc.optFns...) + err := api.Send(rc.ctx, rc.calendarAcls.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, +func (calendarAcls *CalendarAclService) Subscription(ctx *core.Context, optFns ...request.OptFn) *CalendarAclSubscriptionReqCall { + return &CalendarAclSubscriptionReqCall{ + ctx: ctx, + calendarAcls: calendarAcls, + pathParams: map[string]interface{}{}, + optFns: optFns, } } -type TimeoffEventDeleteReqCall struct { - ctx *core.Context - timeoffEvents *TimeoffEventService - pathParams map[string]interface{} +type CalendarEventAttendeeChatMemberListReqCall struct { + ctx *core.Context + calendarEventAttendeeChatMembers *CalendarEventAttendeeChatMemberService + pathParams map[string]interface{} - optFns []request.OptFn + queryParams map[string]interface{} + optFns []request.OptFn } -func (rc *TimeoffEventDeleteReqCall) SetTimeoffEventId(timeoffEventId string) { - rc.pathParams["timeoff_event_id"] = timeoffEventId +func (rc *CalendarEventAttendeeChatMemberListReqCall) SetCalendarId(calendarId string) { + rc.pathParams["calendar_id"] = calendarId } -func (rc *TimeoffEventDeleteReqCall) Do() (*response.NoData, error) { - httpPath := path.Join(rc.timeoffEvents.service.basePath, "timeoff_events/:timeoff_event_id") +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) { + httpPath := path.Join(rc.calendarEventAttendeeChatMembers.service.basePath, "calendars/:calendar_id/events/:event_id/attendees/:attendee_id/chat_members") rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest(httpPath, "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.timeoffEvents.service.conf, req) + rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) + var result = &CalendarEventAttendeeChatMemberListResult{} + req := request.NewRequest(httpPath, "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 (timeoffEvents *TimeoffEventService) Delete(ctx *core.Context, optFns ...request.OptFn) *TimeoffEventDeleteReqCall { - return &TimeoffEventDeleteReqCall{ - ctx: ctx, - timeoffEvents: timeoffEvents, - pathParams: map[string]interface{}{}, - optFns: optFns, +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 new file mode 100644 index 00000000..6bb39797 --- /dev/null +++ b/service/calendar/v4/event.go @@ -0,0 +1,72 @@ +// 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 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 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 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 index e1a5d501..988122d5 100644 --- a/service/calendar/v4/model.go +++ b/service/calendar/v4/model.go @@ -1,23 +1,44 @@ // 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 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"` + 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"` + 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 CalendarEvent struct { EventId string `json:"event_id,omitempty"` Summary string `json:"summary,omitempty"` @@ -36,7 +57,15 @@ type CalendarEvent struct { 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"` @@ -50,67 +79,189 @@ type CalendarEventAttendee struct { ChatId string `json:"chat_id,omitempty"` RoomId string `json:"room_id,omitempty"` ThirdPartyEmail string `json:"third_party_email,omitempty"` + ForceSendFields []string `json:"-"` } -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"` + +func (s *CalendarEventAttendee) MarshalJSON() ([]byte, error) { + type cp CalendarEventAttendee + raw := cp(*s) + return tools.MarshalJSON(raw, s.ForceSendFields) } + type Freebusy struct { - StartTime string `json:"start_time,omitempty"` - EndTime string `json:"end_time,omitempty"` + 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 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"` + 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:"-"` } -type AclScope struct { - Type string `json:"type,omitempty"` - UserId string `json:"user_id,omitempty"` +func (s *TimeoffEvent) MarshalJSON() ([]byte, error) { + type cp TimeoffEvent + 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"` + +type Setting struct { } -type EventLocation struct { - Name string `json:"name,omitempty"` - Address string `json:"address,omitempty"` - Latitude float64 `json:"latitude,omitempty"` - Longitude float64 `json:"longitude,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"` + ForceSendFields []string `json:"-"` } -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"` + +func (s *CalendarEventAttendeeChatMember) MarshalJSON() ([]byte, error) { + type cp CalendarEventAttendeeChatMember + raw := cp(*s) + return tools.MarshalJSON(raw, s.ForceSendFields) } -type Reminder struct { - Minutes int `json:"minutes,omitempty"` + +type Vchat struct { + MeetingUrl string `json:"meeting_url,omitempty"` + ForceSendFields []string `json:"-"` } -type Schema struct { - UiName string `json:"ui_name,omitempty"` - UiStatus string `json:"ui_status,omitempty"` - AppLink string `json:"app_link,omitempty"` + +func (s *Vchat) MarshalJSON() ([]byte, error) { + type cp Vchat + raw := cp(*s) + return tools.MarshalJSON(raw, s.ForceSendFields) } + +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 TimeInfo struct { - Date string `json:"date,omitempty"` - Timestamp string `json:"timestamp,omitempty"` - Timezone string `json:"timezone,omitempty"` + Date string `json:"date,omitempty"` + Timestamp string `json:"timestamp,omitempty"` + Timezone string `json:"timezone,omitempty"` + ForceSendFields []string `json:"-"` } -type Vchat struct { - MeetingUrl string `json:"meeting_url,omitempty"` + +func (s *TimeInfo) MarshalJSON() ([]byte, error) { + type cp TimeInfo + 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 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 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 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 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 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 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 { @@ -119,40 +270,88 @@ type CalendarAclListResult struct { PageToken string `json:"page_token,omitempty"` } -type CalendarCreateResult struct { - Calendar *Calendar `json:"calendar,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"` + AttendeeIds []string `json:"attendee_ids,omitempty"` + ForceSendFields []string `json:"-"` } -type CalendarEventAttendeeChatMemberListResult struct { - Items []*CalendarEventAttendeeChatMember `json:"items,omitempty"` - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` +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"` + Attendees []*CalendarEventAttendee `json:"attendees,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 CalendarEventAttendeeListResult struct { - Items []*CalendarEventAttendee `json:"items,omitempty"` - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,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 CalendarEventCreateResult struct { - Event *CalendarEvent `json:"event,omitempty"` +type CalendarSearchReqBody struct { + Query string `json:"query,omitempty"` + ForceSendFields []string `json:"-"` } -type CalendarEventGetResult struct { - Event *CalendarEvent `json:"event,omitempty"` +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 { @@ -160,8 +359,15 @@ type CalendarEventPatchResult struct { } type CalendarEventSearchReqBody struct { - Query string `json:"query,omitempty"` - Filter *EventSearchFilter `json:"filter,omitempty"` + 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 { @@ -169,37 +375,69 @@ type CalendarEventSearchResult struct { PageToken string `json:"page_token,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 CalendarSubscribeResult struct { + Calendar *Calendar `json:"calendar,omitempty"` } -type CalendarPatchResult struct { - Calendar *Calendar `json:"calendar,omitempty"` +type SettingGenerateCaldavConfReqBody struct { + DeviceName string `json:"device_name,omitempty"` + ForceSendFields []string `json:"-"` } -type CalendarSearchReqBody struct { - Query string `json:"query,omitempty"` +func (s *SettingGenerateCaldavConfReqBody) MarshalJSON() ([]byte, error) { + type cp SettingGenerateCaldavConfReqBody + raw := cp(*s) + return tools.MarshalJSON(raw, s.ForceSendFields) } -type CalendarSearchResult struct { - Items []*Calendar `json:"items,omitempty"` - PageToken string `json:"page_token,omitempty"` +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 CalendarSubscribeResult struct { - Calendar *Calendar `json:"calendar,omitempty"` +type CalendarEventAttendeeChatMemberListResult struct { + Items []*CalendarEventAttendeeChatMember `json:"items,omitempty"` + HasMore bool `json:"has_more,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"` +type CalendarChangedEventData struct { } -type FreebusyListResult struct { - FreebusyList []*Freebusy `json:"freebusy_list,omitempty"` +type CalendarChangedEvent struct { + *model.BaseEventV2 + Event *CalendarChangedEventData `json:"event"` +} + +type CalendarEventChangedEventData struct { + CalendarId string `json:"calendar_id,omitempty"` +} + +type CalendarEventChangedEvent struct { + *model.BaseEventV2 + Event *CalendarEventChangedEventData `json:"event"` +} + +type CalendarAclCreatedEventData struct { + AclId string `json:"acl_id,omitempty"` + Role string `json:"role,omitempty"` + Scope *AclScope `json:"scope,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 *AclScope `json:"scope,omitempty"` +} + +type CalendarAclDeletedEvent struct { + *model.BaseEventV2 + Event *CalendarAclDeletedEventData `json:"event"` } diff --git a/service/contact/v3/api.go b/service/contact/v3/api.go index 5ba65503..9b0b0e4d 100644 --- a/service/contact/v3/api.go +++ b/service/contact/v3/api.go @@ -15,16 +15,16 @@ const serviceBasePath = "contact/v3" type Service struct { conf *config.Config basePath string - Departments *DepartmentService - DepartmentEvents *DepartmentEventService DepartmentUnits *DepartmentUnitService - GroupEvents *GroupEventService - Members *MemberService - Scopes *ScopeService Users *UserService - UserEvents *UserEventService UserGroups *UserGroupService UserGroupMembers *UserGroupMemberService + Departments *DepartmentService + DepartmentEvents *DepartmentEventService + GroupEvents *GroupEventService + UserEvents *UserEventService + Scopes *ScopeService + CustomAttrEvents *CustomAttrEventService } func NewService(conf *config.Config) *Service { @@ -32,85 +32,85 @@ func NewService(conf *config.Config) *Service { conf: conf, basePath: serviceBasePath, } - s.Departments = newDepartmentService(s) - s.DepartmentEvents = newDepartmentEventService(s) s.DepartmentUnits = newDepartmentUnitService(s) - s.GroupEvents = newGroupEventService(s) - s.Members = newMemberService(s) - s.Scopes = newScopeService(s) s.Users = newUserService(s) - s.UserEvents = newUserEventService(s) s.UserGroups = newUserGroupService(s) s.UserGroupMembers = newUserGroupMemberService(s) + s.Departments = newDepartmentService(s) + s.DepartmentEvents = newDepartmentEventService(s) + s.GroupEvents = newGroupEventService(s) + s.UserEvents = newUserEventService(s) + s.Scopes = newScopeService(s) + s.CustomAttrEvents = newCustomAttrEventService(s) return s } -type DepartmentService struct { +type DepartmentUnitService struct { service *Service } -func newDepartmentService(service *Service) *DepartmentService { - return &DepartmentService{ +func newDepartmentUnitService(service *Service) *DepartmentUnitService { + return &DepartmentUnitService{ service: service, } } -type DepartmentEventService struct { +type UserService struct { service *Service } -func newDepartmentEventService(service *Service) *DepartmentEventService { - return &DepartmentEventService{ +func newUserService(service *Service) *UserService { + return &UserService{ service: service, } } -type DepartmentUnitService struct { +type UserGroupService struct { service *Service } -func newDepartmentUnitService(service *Service) *DepartmentUnitService { - return &DepartmentUnitService{ +func newUserGroupService(service *Service) *UserGroupService { + return &UserGroupService{ service: service, } } -type GroupEventService struct { +type UserGroupMemberService struct { service *Service } -func newGroupEventService(service *Service) *GroupEventService { - return &GroupEventService{ +func newUserGroupMemberService(service *Service) *UserGroupMemberService { + return &UserGroupMemberService{ service: service, } } -type MemberService struct { +type DepartmentService struct { service *Service } -func newMemberService(service *Service) *MemberService { - return &MemberService{ +func newDepartmentService(service *Service) *DepartmentService { + return &DepartmentService{ service: service, } } -type ScopeService struct { +type DepartmentEventService struct { service *Service } -func newScopeService(service *Service) *ScopeService { - return &ScopeService{ +func newDepartmentEventService(service *Service) *DepartmentEventService { + return &DepartmentEventService{ service: service, } } -type UserService struct { +type GroupEventService struct { service *Service } -func newUserService(service *Service) *UserService { - return &UserService{ +func newGroupEventService(service *Service) *GroupEventService { + return &GroupEventService{ service: service, } } @@ -125,65 +125,27 @@ func newUserEventService(service *Service) *UserEventService { } } -type UserGroupService struct { +type ScopeService struct { service *Service } -func newUserGroupService(service *Service) *UserGroupService { - return &UserGroupService{ +func newScopeService(service *Service) *ScopeService { + return &ScopeService{ service: service, } } -type UserGroupMemberService struct { +type CustomAttrEventService struct { service *Service } -func newUserGroupMemberService(service *Service) *UserGroupMemberService { - return &UserGroupMemberService{ +func newCustomAttrEventService(service *Service) *CustomAttrEventService { + return &CustomAttrEventService{ service: service, } } -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) { - httpPath := path.Join(rc.departments.service.basePath, "departments") - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &DepartmentCreateResult{} - req := request.NewRequest(httpPath, "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 { +type DepartmentGetReqCall struct { ctx *core.Context departments *DepartmentService pathParams map[string]interface{} @@ -192,28 +154,28 @@ type DepartmentDeleteReqCall struct { optFns []request.OptFn } -func (rc *DepartmentDeleteReqCall) SetDepartmentId(departmentId string) { +func (rc *DepartmentGetReqCall) SetDepartmentId(departmentId string) { rc.pathParams["department_id"] = departmentId } -func (rc *DepartmentDeleteReqCall) SetUserIdType(userIdType string) { +func (rc *DepartmentGetReqCall) SetUserIdType(userIdType string) { rc.queryParams["user_id_type"] = userIdType } -func (rc *DepartmentDeleteReqCall) SetDepartmentIdType(departmentIdType string) { +func (rc *DepartmentGetReqCall) SetDepartmentIdType(departmentIdType string) { rc.queryParams["department_id_type"] = departmentIdType } -func (rc *DepartmentDeleteReqCall) Do() (*response.NoData, error) { +func (rc *DepartmentGetReqCall) Do() (*DepartmentGetResult, error) { httpPath := path.Join(rc.departments.service.basePath, "departments/:department_id") 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(httpPath, "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) + var result = &DepartmentGetResult{} + req := request.NewRequest(httpPath, "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) Delete(ctx *core.Context, optFns ...request.OptFn) *DepartmentDeleteReqCall { - return &DepartmentDeleteReqCall{ +func (departments *DepartmentService) Get(ctx *core.Context, optFns ...request.OptFn) *DepartmentGetReqCall { + return &DepartmentGetReqCall{ ctx: ctx, departments: departments, pathParams: map[string]interface{}{}, @@ -222,39 +184,38 @@ func (departments *DepartmentService) Delete(ctx *core.Context, optFns ...reques } } -type DepartmentGetReqCall struct { - ctx *core.Context - departments *DepartmentService - pathParams map[string]interface{} +type UserDeleteReqCall struct { + ctx *core.Context + users *UserService + body *UserDeleteReqBody + pathParams map[string]interface{} queryParams map[string]interface{} optFns []request.OptFn } -func (rc *DepartmentGetReqCall) SetDepartmentId(departmentId string) { - rc.pathParams["department_id"] = departmentId +func (rc *UserDeleteReqCall) SetUserId(userId string) { + rc.pathParams["user_id"] = userId } -func (rc *DepartmentGetReqCall) SetUserIdType(userIdType string) { +func (rc *UserDeleteReqCall) 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) { - httpPath := path.Join(rc.departments.service.basePath, "departments/:department_id") +func (rc *UserDeleteReqCall) Do() (*response.NoData, error) { + httpPath := path.Join(rc.users.service.basePath, "users/:user_id") rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &DepartmentGetResult{} - req := request.NewRequest(httpPath, "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.departments.service.conf, req) + var result = &response.NoData{} + req := request.NewRequest(httpPath, "DELETE", + []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) + err := api.Send(rc.ctx, rc.users.service.conf, req) return result, err } -func (departments *DepartmentService) Get(ctx *core.Context, optFns ...request.OptFn) *DepartmentGetReqCall { - return &DepartmentGetReqCall{ +func (users *UserService) Delete(ctx *core.Context, body *UserDeleteReqBody, optFns ...request.OptFn) *UserDeleteReqCall { + return &UserDeleteReqCall{ ctx: ctx, - departments: departments, + users: users, + body: body, pathParams: map[string]interface{}{}, queryParams: map[string]interface{}{}, optFns: optFns, @@ -264,6 +225,7 @@ func (departments *DepartmentService) Get(ctx *core.Context, optFns ...request.O type DepartmentListReqCall struct { ctx *core.Context departments *DepartmentService + body *DepartmentListReqBody queryParams map[string]interface{} optFns []request.OptFn @@ -289,213 +251,240 @@ func (rc *DepartmentListReqCall) Do() (*DepartmentListResult, error) { rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) var result = &DepartmentListResult{} req := request.NewRequest(httpPath, "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) + []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, rc.body, 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 { +func (departments *DepartmentService) List(ctx *core.Context, body *DepartmentListReqBody, optFns ...request.OptFn) *DepartmentListReqCall { return &DepartmentListReqCall{ ctx: ctx, departments: departments, + body: body, queryParams: map[string]interface{}{}, optFns: optFns, } } -type DepartmentNomalizeReqCall struct { - ctx *core.Context - departments *DepartmentService - body *DepartmentNomalizeReqBody +type UserGroupUpdateUserGroupIdReqCall struct { + ctx *core.Context + userGroups *UserGroupService + body *UserGroupUpdateUserGroupIdReqBody + pathParams map[string]interface{} - queryParams map[string]interface{} - optFns []request.OptFn + optFns []request.OptFn } -func (rc *DepartmentNomalizeReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType +func (rc *UserGroupUpdateUserGroupIdReqCall) SetUserGroupId(userGroupId string) { + rc.pathParams["user_group_id"] = userGroupId } -func (rc *DepartmentNomalizeReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken +func (rc *UserGroupUpdateUserGroupIdReqCall) Do() (*response.NoData, error) { + httpPath := path.Join(rc.userGroups.service.basePath, "user_groups/:user_group_id/update_user_group_id") + rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) + var result = &response.NoData{} + req := request.NewRequest(httpPath, "PATCH", + []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) + err := api.Send(rc.ctx, rc.userGroups.service.conf, req) + return result, err } -func (rc *DepartmentNomalizeReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize + +func (userGroups *UserGroupService) UpdateUserGroupId(ctx *core.Context, body *UserGroupUpdateUserGroupIdReqBody, optFns ...request.OptFn) *UserGroupUpdateUserGroupIdReqCall { + return &UserGroupUpdateUserGroupIdReqCall{ + ctx: ctx, + userGroups: userGroups, + body: body, + pathParams: map[string]interface{}{}, + optFns: optFns, + } } -func (rc *DepartmentNomalizeReqCall) Do() (*response.NoData, error) { - httpPath := path.Join(rc.departments.service.basePath, "departments/nomalize") - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) + +type DepartmentUnitDeleteReqCall struct { + ctx *core.Context + departmentUnits *DepartmentUnitService + pathParams map[string]interface{} + + optFns []request.OptFn +} + +func (rc *DepartmentUnitDeleteReqCall) SetUnitId(unitId string) { + rc.pathParams["unit_id"] = unitId +} +func (rc *DepartmentUnitDeleteReqCall) Do() (*response.NoData, error) { + httpPath := path.Join(rc.departmentUnits.service.basePath, "department_units/:unit_id") + rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) var result = &response.NoData{} - req := request.NewRequest(httpPath, "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.departments.service.conf, req) + req := request.NewRequest(httpPath, "DELETE", + []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) + err := api.Send(rc.ctx, rc.departmentUnits.service.conf, req) return result, err } -func (departments *DepartmentService) Nomalize(ctx *core.Context, body *DepartmentNomalizeReqBody, optFns ...request.OptFn) *DepartmentNomalizeReqCall { - return &DepartmentNomalizeReqCall{ - ctx: ctx, - departments: departments, - body: body, - queryParams: map[string]interface{}{}, - optFns: optFns, +func (departmentUnits *DepartmentUnitService) Delete(ctx *core.Context, optFns ...request.OptFn) *DepartmentUnitDeleteReqCall { + return &DepartmentUnitDeleteReqCall{ + ctx: ctx, + departmentUnits: departmentUnits, + pathParams: map[string]interface{}{}, + optFns: optFns, } } -type DepartmentNomalizeDepartmentChatReqCall struct { +type DepartmentPatchReqCall struct { ctx *core.Context departments *DepartmentService - body *DepartmentNomalizeDepartmentChatReqBody + body *Department + pathParams map[string]interface{} queryParams map[string]interface{} optFns []request.OptFn } -func (rc *DepartmentNomalizeDepartmentChatReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType +func (rc *DepartmentPatchReqCall) SetDepartmentId(departmentId string) { + rc.pathParams["department_id"] = departmentId } -func (rc *DepartmentNomalizeDepartmentChatReqCall) SetPageToken(pageToken string) { - rc.queryParams["page_token"] = pageToken +func (rc *DepartmentPatchReqCall) SetUserIdType(userIdType string) { + rc.queryParams["user_id_type"] = userIdType } -func (rc *DepartmentNomalizeDepartmentChatReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize +func (rc *DepartmentPatchReqCall) SetDepartmentIdType(departmentIdType string) { + rc.queryParams["department_id_type"] = departmentIdType } -func (rc *DepartmentNomalizeDepartmentChatReqCall) Do() (*response.NoData, error) { - httpPath := path.Join(rc.departments.service.basePath, "departments/nomalize_department_chat") +func (rc *DepartmentPatchReqCall) Do() (*DepartmentPatchResult, error) { + httpPath := path.Join(rc.departments.service.basePath, "departments/:department_id") + 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(httpPath, "POST", + var result = &DepartmentPatchResult{} + req := request.NewRequest(httpPath, "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) NomalizeDepartmentChat(ctx *core.Context, body *DepartmentNomalizeDepartmentChatReqBody, optFns ...request.OptFn) *DepartmentNomalizeDepartmentChatReqCall { - return &DepartmentNomalizeDepartmentChatReqCall{ +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 DepartmentParentReqCall struct { - ctx *core.Context - departments *DepartmentService - - queryParams map[string]interface{} +type UserUpdateReqCall struct { + ctx *core.Context + users *UserService + body *User + pathParams map[string]interface{} + + queryParams map[string]interface{} optFns []request.OptFn } -func (rc *DepartmentParentReqCall) SetUserIdType(userIdType string) { +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 *DepartmentParentReqCall) SetDepartmentIdType(departmentIdType string) { +func (rc *UserUpdateReqCall) 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) { - httpPath := path.Join(rc.departments.service.basePath, "departments/parent") +func (rc *UserUpdateReqCall) Do() (*UserUpdateResult, error) { + httpPath := path.Join(rc.users.service.basePath, "users/:user_id") + rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &DepartmentParentResult{} - req := request.NewRequest(httpPath, "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.departments.service.conf, req) + var result = &UserUpdateResult{} + req := request.NewRequest(httpPath, "PUT", + []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) + err := api.Send(rc.ctx, rc.users.service.conf, req) return result, err } -func (departments *DepartmentService) Parent(ctx *core.Context, optFns ...request.OptFn) *DepartmentParentReqCall { - return &DepartmentParentReqCall{ +func (users *UserService) Update(ctx *core.Context, body *User, optFns ...request.OptFn) *UserUpdateReqCall { + return &UserUpdateReqCall{ ctx: ctx, - departments: departments, + users: users, + body: body, + pathParams: map[string]interface{}{}, queryParams: map[string]interface{}{}, optFns: optFns, } } -type DepartmentPatchReqCall struct { - ctx *core.Context - departments *DepartmentService - body *Department - pathParams map[string]interface{} +type UserCreateReqCall struct { + ctx *core.Context + users *UserService + body *User queryParams map[string]interface{} optFns []request.OptFn } -func (rc *DepartmentPatchReqCall) SetDepartmentId(departmentId string) { - rc.pathParams["department_id"] = departmentId -} -func (rc *DepartmentPatchReqCall) SetUserIdType(userIdType string) { +func (rc *UserCreateReqCall) SetUserIdType(userIdType string) { rc.queryParams["user_id_type"] = userIdType } -func (rc *DepartmentPatchReqCall) SetDepartmentIdType(departmentIdType string) { +func (rc *UserCreateReqCall) SetDepartmentIdType(departmentIdType string) { rc.queryParams["department_id_type"] = departmentIdType } -func (rc *DepartmentPatchReqCall) Do() (*DepartmentPatchResult, error) { - httpPath := path.Join(rc.departments.service.basePath, "departments/:department_id") - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) +func (rc *UserCreateReqCall) SetClientToken(clientToken string) { + rc.queryParams["client_token"] = clientToken +} +func (rc *UserCreateReqCall) SetNeedSendNotification(needSendNotification bool) { + rc.queryParams["need_send_notification"] = needSendNotification +} +func (rc *UserCreateReqCall) Do() (*UserCreateResult, error) { + httpPath := path.Join(rc.users.service.basePath, "users") rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &DepartmentPatchResult{} - req := request.NewRequest(httpPath, "PATCH", + var result = &UserCreateResult{} + req := request.NewRequest(httpPath, "POST", []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.departments.service.conf, req) + err := api.Send(rc.ctx, rc.users.service.conf, req) return result, err } -func (departments *DepartmentService) Patch(ctx *core.Context, body *Department, optFns ...request.OptFn) *DepartmentPatchReqCall { - return &DepartmentPatchReqCall{ +func (users *UserService) Create(ctx *core.Context, body *User, optFns ...request.OptFn) *UserCreateReqCall { + return &UserCreateReqCall{ ctx: ctx, - departments: departments, + users: users, body: body, - pathParams: map[string]interface{}{}, queryParams: map[string]interface{}{}, optFns: optFns, } } -type DepartmentUpdateReqCall struct { - ctx *core.Context - departments *DepartmentService - body *Department - pathParams map[string]interface{} +type UserPatchReqCall struct { + ctx *core.Context + users *UserService + body *User + pathParams map[string]interface{} queryParams map[string]interface{} optFns []request.OptFn } -func (rc *DepartmentUpdateReqCall) SetDepartmentId(departmentId string) { - rc.pathParams["department_id"] = departmentId +func (rc *UserPatchReqCall) SetUserId(userId string) { + rc.pathParams["user_id"] = userId } -func (rc *DepartmentUpdateReqCall) SetUserIdType(userIdType string) { +func (rc *UserPatchReqCall) SetUserIdType(userIdType string) { rc.queryParams["user_id_type"] = userIdType } -func (rc *DepartmentUpdateReqCall) SetDepartmentIdType(departmentIdType string) { +func (rc *UserPatchReqCall) SetDepartmentIdType(departmentIdType string) { rc.queryParams["department_id_type"] = departmentIdType } -func (rc *DepartmentUpdateReqCall) Do() (*DepartmentUpdateResult, error) { - httpPath := path.Join(rc.departments.service.basePath, "departments/:department_id") +func (rc *UserPatchReqCall) Do() (*UserPatchResult, error) { + httpPath := path.Join(rc.users.service.basePath, "users/:user_id") rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &DepartmentUpdateResult{} - req := request.NewRequest(httpPath, "PUT", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.departments.service.conf, req) + var result = &UserPatchResult{} + req := request.NewRequest(httpPath, "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 (departments *DepartmentService) Update(ctx *core.Context, body *Department, optFns ...request.OptFn) *DepartmentUpdateReqCall { - return &DepartmentUpdateReqCall{ +func (users *UserService) Patch(ctx *core.Context, body *User, optFns ...request.OptFn) *UserPatchReqCall { + return &UserPatchReqCall{ ctx: ctx, - departments: departments, + users: users, body: body, pathParams: map[string]interface{}{}, queryParams: map[string]interface{}{}, @@ -503,37 +492,37 @@ func (departments *DepartmentService) Update(ctx *core.Context, body *Department } } -type DepartmentUpdateDepartmentIdReqCall struct { - ctx *core.Context - departments *DepartmentService - body *DepartmentUpdateDepartmentIdReqBody - pathParams map[string]interface{} +type UserUpdateUserIdReqCall struct { + ctx *core.Context + users *UserService + body *UserUpdateUserIdReqBody + pathParams map[string]interface{} queryParams map[string]interface{} optFns []request.OptFn } -func (rc *DepartmentUpdateDepartmentIdReqCall) SetDepartmentId(departmentId string) { - rc.pathParams["department_id"] = departmentId +func (rc *UserUpdateUserIdReqCall) SetUserId(userId string) { + rc.pathParams["user_id"] = userId } -func (rc *DepartmentUpdateDepartmentIdReqCall) SetDepartmentIdType(departmentIdType string) { - rc.queryParams["department_id_type"] = departmentIdType +func (rc *UserUpdateUserIdReqCall) SetUserIdType(userIdType string) { + rc.queryParams["user_id_type"] = userIdType } -func (rc *DepartmentUpdateDepartmentIdReqCall) Do() (*response.NoData, error) { - httpPath := path.Join(rc.departments.service.basePath, "departments/:department_id/update_department_id") +func (rc *UserUpdateUserIdReqCall) Do() (*response.NoData, error) { + httpPath := path.Join(rc.users.service.basePath, "users/:user_id/update_user_id") 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(httpPath, "PATCH", []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.departments.service.conf, req) + err := api.Send(rc.ctx, rc.users.service.conf, req) return result, err } -func (departments *DepartmentService) UpdateDepartmentId(ctx *core.Context, body *DepartmentUpdateDepartmentIdReqBody, optFns ...request.OptFn) *DepartmentUpdateDepartmentIdReqCall { - return &DepartmentUpdateDepartmentIdReqCall{ +func (users *UserService) UpdateUserId(ctx *core.Context, body *UserUpdateUserIdReqBody, optFns ...request.OptFn) *UserUpdateUserIdReqCall { + return &UserUpdateUserIdReqCall{ ctx: ctx, - departments: departments, + users: users, body: body, pathParams: map[string]interface{}{}, queryParams: map[string]interface{}{}, @@ -541,87 +530,169 @@ func (departments *DepartmentService) UpdateDepartmentId(ctx *core.Context, body } } -type DepartmentUnitCreateReqCall struct { - ctx *core.Context - departmentUnits *DepartmentUnitService - body *DepartmentUnit +type UserGroupMemberCreateReqCall struct { + ctx *core.Context + userGroupMembers *UserGroupMemberService + body *UserGroupMemberCreateReqBody + pathParams map[string]interface{} - optFns []request.OptFn + queryParams map[string]interface{} + optFns []request.OptFn } -func (rc *DepartmentUnitCreateReqCall) Do() (*DepartmentUnitCreateResult, error) { - httpPath := path.Join(rc.departmentUnits.service.basePath, "department_units") - var result = &DepartmentUnitCreateResult{} +func (rc *UserGroupMemberCreateReqCall) SetUserGroupId(userGroupId string) { + rc.pathParams["user_group_id"] = userGroupId +} +func (rc *UserGroupMemberCreateReqCall) SetUserIdType(userIdType string) { + rc.queryParams["user_id_type"] = userIdType +} +func (rc *UserGroupMemberCreateReqCall) Do() (*response.NoData, error) { + httpPath := path.Join(rc.userGroupMembers.service.basePath, "user_groups/:user_group_id/members") + 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(httpPath, "POST", []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.departmentUnits.service.conf, req) + err := api.Send(rc.ctx, rc.userGroupMembers.service.conf, req) return result, err } -func (departmentUnits *DepartmentUnitService) Create(ctx *core.Context, body *DepartmentUnit, optFns ...request.OptFn) *DepartmentUnitCreateReqCall { - return &DepartmentUnitCreateReqCall{ - ctx: ctx, - departmentUnits: departmentUnits, - body: body, - optFns: optFns, +func (userGroupMembers *UserGroupMemberService) Create(ctx *core.Context, body *UserGroupMemberCreateReqBody, optFns ...request.OptFn) *UserGroupMemberCreateReqCall { + return &UserGroupMemberCreateReqCall{ + ctx: ctx, + userGroupMembers: userGroupMembers, + body: body, + pathParams: map[string]interface{}{}, + queryParams: map[string]interface{}{}, + optFns: optFns, } } -type DepartmentUnitDeleteReqCall struct { - ctx *core.Context - departmentUnits *DepartmentUnitService - pathParams map[string]interface{} +type UserGroupDeleteReqCall struct { + ctx *core.Context + userGroups *UserGroupService + pathParams map[string]interface{} optFns []request.OptFn } -func (rc *DepartmentUnitDeleteReqCall) SetUnitId(unitId string) { - rc.pathParams["unit_id"] = unitId +func (rc *UserGroupDeleteReqCall) SetUserGroupId(userGroupId string) { + rc.pathParams["user_group_id"] = userGroupId } -func (rc *DepartmentUnitDeleteReqCall) Do() (*response.NoData, error) { - httpPath := path.Join(rc.departmentUnits.service.basePath, "department_units/:unit_id") +func (rc *UserGroupDeleteReqCall) Do() (*response.NoData, error) { + httpPath := path.Join(rc.userGroups.service.basePath, "user_groups/:user_group_id") rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) var result = &response.NoData{} req := request.NewRequest(httpPath, "DELETE", []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.departmentUnits.service.conf, req) + err := api.Send(rc.ctx, rc.userGroups.service.conf, req) return result, err } -func (departmentUnits *DepartmentUnitService) Delete(ctx *core.Context, optFns ...request.OptFn) *DepartmentUnitDeleteReqCall { - return &DepartmentUnitDeleteReqCall{ - ctx: ctx, - departmentUnits: departmentUnits, - pathParams: map[string]interface{}{}, - optFns: optFns, +func (userGroups *UserGroupService) Delete(ctx *core.Context, optFns ...request.OptFn) *UserGroupDeleteReqCall { + return &UserGroupDeleteReqCall{ + ctx: ctx, + userGroups: userGroups, + pathParams: map[string]interface{}{}, + optFns: optFns, } } -type DepartmentUnitPatchReqCall struct { - ctx *core.Context - departmentUnits *DepartmentUnitService - body *DepartmentUnitPatchReqBody - pathParams map[string]interface{} +type DepartmentCreateReqCall struct { + ctx *core.Context + departments *DepartmentService + body *Department - optFns []request.OptFn + queryParams map[string]interface{} + optFns []request.OptFn } -func (rc *DepartmentUnitPatchReqCall) SetUnitId(unitId string) { - rc.pathParams["unit_id"] = unitId +func (rc *DepartmentCreateReqCall) SetUserIdType(userIdType string) { + rc.queryParams["user_id_type"] = userIdType } -func (rc *DepartmentUnitPatchReqCall) Do() (*DepartmentUnitPatchResult, error) { - httpPath := path.Join(rc.departmentUnits.service.basePath, "department_units/:unit_id") - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &DepartmentUnitPatchResult{} - req := request.NewRequest(httpPath, "PATCH", +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) { + httpPath := path.Join(rc.departments.service.basePath, "departments") + rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) + var result = &DepartmentCreateResult{} + req := request.NewRequest(httpPath, "POST", []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.departmentUnits.service.conf, req) + err := api.Send(rc.ctx, rc.departments.service.conf, req) return result, err } -func (departmentUnits *DepartmentUnitService) Patch(ctx *core.Context, body *DepartmentUnitPatchReqBody, optFns ...request.OptFn) *DepartmentUnitPatchReqCall { - return &DepartmentUnitPatchReqCall{ - ctx: ctx, +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 UserGroupPatchReqCall struct { + ctx *core.Context + userGroups *UserGroupService + body *UserGroup + pathParams map[string]interface{} + + optFns []request.OptFn +} + +func (rc *UserGroupPatchReqCall) SetUserGroupId(userGroupId string) { + rc.pathParams["user_group_id"] = userGroupId +} +func (rc *UserGroupPatchReqCall) Do() (*UserGroupPatchResult, error) { + httpPath := path.Join(rc.userGroups.service.basePath, "user_groups/:user_group_id") + rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) + var result = &UserGroupPatchResult{} + req := request.NewRequest(httpPath, "PATCH", + []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) + err := api.Send(rc.ctx, rc.userGroups.service.conf, req) + return result, err +} + +func (userGroups *UserGroupService) Patch(ctx *core.Context, body *UserGroup, optFns ...request.OptFn) *UserGroupPatchReqCall { + return &UserGroupPatchReqCall{ + ctx: ctx, + userGroups: userGroups, + body: body, + pathParams: map[string]interface{}{}, + optFns: optFns, + } +} + +type DepartmentUnitPatchReqCall struct { + ctx *core.Context + departmentUnits *DepartmentUnitService + body *DepartmentUnitPatchReqBody + pathParams map[string]interface{} + + optFns []request.OptFn +} + +func (rc *DepartmentUnitPatchReqCall) SetUnitId(unitId string) { + rc.pathParams["unit_id"] = unitId +} +func (rc *DepartmentUnitPatchReqCall) Do() (*DepartmentUnitPatchResult, error) { + httpPath := path.Join(rc.departmentUnits.service.basePath, "department_units/:unit_id") + rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) + var result = &DepartmentUnitPatchResult{} + req := request.NewRequest(httpPath, "PATCH", + []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) + err := api.Send(rc.ctx, rc.departmentUnits.service.conf, req) + return result, err +} + +func (departmentUnits *DepartmentUnitService) Patch(ctx *core.Context, body *DepartmentUnitPatchReqBody, optFns ...request.OptFn) *DepartmentUnitPatchReqCall { + return &DepartmentUnitPatchReqCall{ + ctx: ctx, departmentUnits: departmentUnits, body: body, pathParams: map[string]interface{}{}, @@ -629,76 +700,98 @@ func (departmentUnits *DepartmentUnitService) Patch(ctx *core.Context, body *Dep } } -type UserCreateReqCall struct { - ctx *core.Context - users *UserService - body *User +type UserGroupCreateReqCall struct { + ctx *core.Context + userGroups *UserGroupService + body *UserGroup + + optFns []request.OptFn +} + +func (rc *UserGroupCreateReqCall) Do() (*UserGroupCreateResult, error) { + httpPath := path.Join(rc.userGroups.service.basePath, "user_groups") + var result = &UserGroupCreateResult{} + req := request.NewRequest(httpPath, "POST", + []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) + err := api.Send(rc.ctx, rc.userGroups.service.conf, req) + return result, err +} + +func (userGroups *UserGroupService) Create(ctx *core.Context, body *UserGroup, optFns ...request.OptFn) *UserGroupCreateReqCall { + return &UserGroupCreateReqCall{ + ctx: ctx, + userGroups: userGroups, + body: body, + optFns: optFns, + } +} + +type UserGroupListReqCall struct { + ctx *core.Context + userGroups *UserGroupService 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 *UserGroupListReqCall) SetPageSize(pageSize int) { + rc.queryParams["page_size"] = pageSize } -func (rc *UserCreateReqCall) SetClientToken(clientToken string) { - rc.queryParams["client_token"] = clientToken +func (rc *UserGroupListReqCall) SetPageToken(pageToken string) { + rc.queryParams["page_token"] = pageToken } -func (rc *UserCreateReqCall) Do() (*UserCreateResult, error) { - httpPath := path.Join(rc.users.service.basePath, "users") +func (rc *UserGroupListReqCall) Do() (*UserGroupListResult, error) { + httpPath := path.Join(rc.userGroups.service.basePath, "user_groups") rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &UserCreateResult{} - req := request.NewRequest(httpPath, "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.users.service.conf, req) + var result = &UserGroupListResult{} + req := request.NewRequest(httpPath, "GET", + []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) + err := api.Send(rc.ctx, rc.userGroups.service.conf, req) return result, err } -func (users *UserService) Create(ctx *core.Context, body *User, optFns ...request.OptFn) *UserCreateReqCall { - return &UserCreateReqCall{ +func (userGroups *UserGroupService) List(ctx *core.Context, optFns ...request.OptFn) *UserGroupListReqCall { + return &UserGroupListReqCall{ ctx: ctx, - users: users, - body: body, + userGroups: userGroups, queryParams: map[string]interface{}{}, optFns: optFns, } } -type UserDeleteReqCall struct { - ctx *core.Context - users *UserService - body *UserDeleteReqBody - pathParams map[string]interface{} +type DepartmentDeleteReqCall struct { + ctx *core.Context + departments *DepartmentService + pathParams map[string]interface{} queryParams map[string]interface{} optFns []request.OptFn } -func (rc *UserDeleteReqCall) SetUserId(userId string) { - rc.pathParams["user_id"] = userId +func (rc *DepartmentDeleteReqCall) SetDepartmentId(departmentId string) { + rc.pathParams["department_id"] = departmentId } -func (rc *UserDeleteReqCall) SetUserIdType(userIdType string) { +func (rc *DepartmentDeleteReqCall) SetUserIdType(userIdType string) { rc.queryParams["user_id_type"] = userIdType } -func (rc *UserDeleteReqCall) Do() (*response.NoData, error) { - httpPath := path.Join(rc.users.service.basePath, "users/:user_id") +func (rc *DepartmentDeleteReqCall) SetDepartmentIdType(departmentIdType string) { + rc.queryParams["department_id_type"] = departmentIdType +} +func (rc *DepartmentDeleteReqCall) Do() (*response.NoData, error) { + httpPath := path.Join(rc.departments.service.basePath, "departments/:department_id") 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(httpPath, "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.users.service.conf, req) + []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) + err := api.Send(rc.ctx, rc.departments.service.conf, req) return result, err } -func (users *UserService) Delete(ctx *core.Context, body *UserDeleteReqBody, optFns ...request.OptFn) *UserDeleteReqCall { - return &UserDeleteReqCall{ +func (departments *DepartmentService) Delete(ctx *core.Context, optFns ...request.OptFn) *DepartmentDeleteReqCall { + return &DepartmentDeleteReqCall{ ctx: ctx, - users: users, - body: body, + departments: departments, pathParams: map[string]interface{}{}, queryParams: map[string]interface{}{}, optFns: optFns, @@ -729,7 +822,7 @@ func (rc *UserGetReqCall) Do() (*UserGetResult, error) { rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) var result = &UserGetResult{} req := request.NewRequest(httpPath, "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) + []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) err := api.Send(rc.ctx, rc.users.service.conf, req) return result, err } @@ -744,123 +837,124 @@ func (users *UserService) Get(ctx *core.Context, optFns ...request.OptFn) *UserG } } -type UserListReqCall struct { - ctx *core.Context - users *UserService +type UserGroupMemberListReqCall struct { + ctx *core.Context + userGroupMembers *UserGroupMemberService + pathParams map[string]interface{} queryParams map[string]interface{} optFns []request.OptFn } -func (rc *UserListReqCall) SetUserIdType(userIdType string) { +func (rc *UserGroupMemberListReqCall) SetUserGroupId(userGroupId string) { + rc.pathParams["user_group_id"] = userGroupId +} +func (rc *UserGroupMemberListReqCall) SetUserIdType(userIdType string) { rc.queryParams["user_id_type"] = userIdType } -func (rc *UserListReqCall) SetDepartmentIdType(departmentIdType string) { +func (rc *UserGroupMemberListReqCall) 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) { +func (rc *UserGroupMemberListReqCall) SetPageToken(pageToken string) { rc.queryParams["page_token"] = pageToken } -func (rc *UserListReqCall) SetPageSize(pageSize int) { +func (rc *UserGroupMemberListReqCall) SetPageSize(pageSize int) { rc.queryParams["page_size"] = pageSize } -func (rc *UserListReqCall) Do() (*UserListResult, error) { - httpPath := path.Join(rc.users.service.basePath, "users") +func (rc *UserGroupMemberListReqCall) Do() (*UserGroupMemberListResult, error) { + httpPath := path.Join(rc.userGroupMembers.service.basePath, "user_groups/:user_group_id/members") + rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &UserListResult{} + var result = &UserGroupMemberListResult{} req := request.NewRequest(httpPath, "GET", []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.users.service.conf, req) + err := api.Send(rc.ctx, rc.userGroupMembers.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, +func (userGroupMembers *UserGroupMemberService) List(ctx *core.Context, optFns ...request.OptFn) *UserGroupMemberListReqCall { + return &UserGroupMemberListReqCall{ + ctx: ctx, + userGroupMembers: userGroupMembers, + pathParams: map[string]interface{}{}, + queryParams: map[string]interface{}{}, + optFns: optFns, } } -type UserPatchReqCall struct { - ctx *core.Context - users *UserService - body *User - pathParams map[string]interface{} +type UserGroupMemberDeleteReqCall struct { + ctx *core.Context + userGroupMembers *UserGroupMemberService + pathParams map[string]interface{} queryParams map[string]interface{} optFns []request.OptFn } -func (rc *UserPatchReqCall) SetUserId(userId string) { +func (rc *UserGroupMemberDeleteReqCall) SetUserGroupId(userGroupId string) { + rc.pathParams["user_group_id"] = userGroupId +} +func (rc *UserGroupMemberDeleteReqCall) SetUserId(userId string) { rc.pathParams["user_id"] = userId } -func (rc *UserPatchReqCall) SetUserIdType(userIdType string) { +func (rc *UserGroupMemberDeleteReqCall) 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) { - httpPath := path.Join(rc.users.service.basePath, "users/:user_id") +func (rc *UserGroupMemberDeleteReqCall) Do() (*response.NoData, error) { + httpPath := path.Join(rc.userGroupMembers.service.basePath, "user_groups/:user_group_id/members/:user_id") rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &UserPatchResult{} - req := request.NewRequest(httpPath, "PATCH", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.users.service.conf, req) + var result = &response.NoData{} + req := request.NewRequest(httpPath, "DELETE", + []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) + err := api.Send(rc.ctx, rc.userGroupMembers.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, +func (userGroupMembers *UserGroupMemberService) Delete(ctx *core.Context, optFns ...request.OptFn) *UserGroupMemberDeleteReqCall { + return &UserGroupMemberDeleteReqCall{ + ctx: ctx, + userGroupMembers: userGroupMembers, + pathParams: map[string]interface{}{}, + queryParams: map[string]interface{}{}, + optFns: optFns, } } -type UserUpdateReqCall struct { - ctx *core.Context - users *UserService - body *User - pathParams map[string]interface{} +type DepartmentUpdateReqCall struct { + ctx *core.Context + departments *DepartmentService + body *Department + pathParams map[string]interface{} queryParams map[string]interface{} optFns []request.OptFn } -func (rc *UserUpdateReqCall) SetUserId(userId string) { - rc.pathParams["user_id"] = userId +func (rc *DepartmentUpdateReqCall) SetDepartmentId(departmentId string) { + rc.pathParams["department_id"] = departmentId } -func (rc *UserUpdateReqCall) SetUserIdType(userIdType string) { +func (rc *DepartmentUpdateReqCall) SetUserIdType(userIdType string) { rc.queryParams["user_id_type"] = userIdType } -func (rc *UserUpdateReqCall) SetDepartmentIdType(departmentIdType string) { +func (rc *DepartmentUpdateReqCall) SetDepartmentIdType(departmentIdType string) { rc.queryParams["department_id_type"] = departmentIdType } -func (rc *UserUpdateReqCall) Do() (*UserUpdateResult, error) { - httpPath := path.Join(rc.users.service.basePath, "users/:user_id") +func (rc *DepartmentUpdateReqCall) Do() (*DepartmentUpdateResult, error) { + httpPath := path.Join(rc.departments.service.basePath, "departments/:department_id") rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &UserUpdateResult{} + var result = &DepartmentUpdateResult{} req := request.NewRequest(httpPath, "PUT", []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.users.service.conf, req) + err := api.Send(rc.ctx, rc.departments.service.conf, req) return result, err } -func (users *UserService) Update(ctx *core.Context, body *User, optFns ...request.OptFn) *UserUpdateReqCall { - return &UserUpdateReqCall{ +func (departments *DepartmentService) Update(ctx *core.Context, body *Department, optFns ...request.OptFn) *DepartmentUpdateReqCall { + return &DepartmentUpdateReqCall{ ctx: ctx, - users: users, + departments: departments, body: body, pathParams: map[string]interface{}{}, queryParams: map[string]interface{}{}, @@ -868,97 +962,71 @@ func (users *UserService) Update(ctx *core.Context, body *User, optFns ...reques } } -type UserUpdateUserIdReqCall struct { - ctx *core.Context - users *UserService - body *UserUpdateUserIdReqBody - pathParams map[string]interface{} +type DepartmentUnitCreateReqCall struct { + ctx *core.Context + departmentUnits *DepartmentUnitService + body *DepartmentUnit - queryParams map[string]interface{} - optFns []request.OptFn + optFns []request.OptFn } -func (rc *UserUpdateUserIdReqCall) SetUserId(userId string) { - rc.pathParams["user_id"] = userId -} -func (rc *UserUpdateUserIdReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType -} -func (rc *UserUpdateUserIdReqCall) Do() (*response.NoData, error) { - httpPath := path.Join(rc.users.service.basePath, "users/:user_id/update_user_id") - 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(httpPath, "PATCH", +func (rc *DepartmentUnitCreateReqCall) Do() (*DepartmentUnitCreateResult, error) { + httpPath := path.Join(rc.departmentUnits.service.basePath, "department_units") + var result = &DepartmentUnitCreateResult{} + req := request.NewRequest(httpPath, "POST", []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.users.service.conf, req) + err := api.Send(rc.ctx, rc.departmentUnits.service.conf, req) return result, err } -func (users *UserService) UpdateUserId(ctx *core.Context, body *UserUpdateUserIdReqBody, optFns ...request.OptFn) *UserUpdateUserIdReqCall { - return &UserUpdateUserIdReqCall{ - ctx: ctx, - users: users, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, +func (departmentUnits *DepartmentUnitService) Create(ctx *core.Context, body *DepartmentUnit, optFns ...request.OptFn) *DepartmentUnitCreateReqCall { + return &DepartmentUnitCreateReqCall{ + ctx: ctx, + departmentUnits: departmentUnits, + body: body, + optFns: optFns, } } -type UserGroupCreateReqCall struct { - ctx *core.Context - userGroups *UserGroupService - body *UserGroup +type UserListReqCall struct { + ctx *core.Context + users *UserService - optFns []request.OptFn + queryParams map[string]interface{} + optFns []request.OptFn } -func (rc *UserGroupCreateReqCall) Do() (*UserGroupCreateResult, error) { - httpPath := path.Join(rc.userGroups.service.basePath, "user_groups") - var result = &UserGroupCreateResult{} - req := request.NewRequest(httpPath, "POST", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.userGroups.service.conf, req) - return result, err +func (rc *UserListReqCall) SetUserIdType(userIdType string) { + rc.queryParams["user_id_type"] = userIdType } - -func (userGroups *UserGroupService) Create(ctx *core.Context, body *UserGroup, optFns ...request.OptFn) *UserGroupCreateReqCall { - return &UserGroupCreateReqCall{ - ctx: ctx, - userGroups: userGroups, - body: body, - optFns: optFns, - } +func (rc *UserListReqCall) SetDepartmentIdType(departmentIdType string) { + rc.queryParams["department_id_type"] = departmentIdType } - -type UserGroupDeleteReqCall struct { - ctx *core.Context - userGroups *UserGroupService - pathParams map[string]interface{} - - optFns []request.OptFn +func (rc *UserListReqCall) SetDepartmentId(departmentId string) { + rc.queryParams["department_id"] = departmentId } - -func (rc *UserGroupDeleteReqCall) SetUserGroupId(userGroupId string) { - rc.pathParams["user_group_id"] = userGroupId +func (rc *UserListReqCall) SetPageToken(pageToken string) { + rc.queryParams["page_token"] = pageToken } -func (rc *UserGroupDeleteReqCall) Do() (*response.NoData, error) { - httpPath := path.Join(rc.userGroups.service.basePath, "user_groups/:user_group_id") - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest(httpPath, "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.userGroups.service.conf, req) +func (rc *UserListReqCall) SetPageSize(pageSize int) { + rc.queryParams["page_size"] = pageSize +} +func (rc *UserListReqCall) Do() (*UserListResult, error) { + httpPath := path.Join(rc.users.service.basePath, "users") + rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) + var result = &UserListResult{} + req := request.NewRequest(httpPath, "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 (userGroups *UserGroupService) Delete(ctx *core.Context, optFns ...request.OptFn) *UserGroupDeleteReqCall { - return &UserGroupDeleteReqCall{ - ctx: ctx, - userGroups: userGroups, - pathParams: map[string]interface{}{}, - optFns: optFns, +func (users *UserService) List(ctx *core.Context, optFns ...request.OptFn) *UserListReqCall { + return &UserListReqCall{ + ctx: ctx, + users: users, + queryParams: map[string]interface{}{}, + optFns: optFns, } } @@ -992,215 +1060,155 @@ func (userGroups *UserGroupService) Get(ctx *core.Context, optFns ...request.Opt } } -type UserGroupListReqCall struct { - ctx *core.Context - userGroups *UserGroupService +type DepartmentParentReqCall struct { + ctx *core.Context + departments *DepartmentService queryParams map[string]interface{} optFns []request.OptFn } -func (rc *UserGroupListReqCall) SetPageSize(pageSize int) { - rc.queryParams["page_size"] = pageSize +func (rc *DepartmentParentReqCall) SetUserIdType(userIdType string) { + rc.queryParams["user_id_type"] = userIdType } -func (rc *UserGroupListReqCall) SetPageToken(pageToken string) { +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 *UserGroupListReqCall) Do() (*UserGroupListResult, error) { - httpPath := path.Join(rc.userGroups.service.basePath, "user_groups") +func (rc *DepartmentParentReqCall) SetPageSize(pageSize int) { + rc.queryParams["page_size"] = pageSize +} +func (rc *DepartmentParentReqCall) Do() (*DepartmentParentResult, error) { + httpPath := path.Join(rc.departments.service.basePath, "departments/parent") rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &UserGroupListResult{} + var result = &DepartmentParentResult{} req := request.NewRequest(httpPath, "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.userGroups.service.conf, req) + []request.AccessTokenType{request.AccessTokenTypeTenant, request.AccessTokenTypeUser}, nil, result, rc.optFns...) + err := api.Send(rc.ctx, rc.departments.service.conf, req) return result, err } -func (userGroups *UserGroupService) List(ctx *core.Context, optFns ...request.OptFn) *UserGroupListReqCall { - return &UserGroupListReqCall{ +func (departments *DepartmentService) Parent(ctx *core.Context, optFns ...request.OptFn) *DepartmentParentReqCall { + return &DepartmentParentReqCall{ ctx: ctx, - userGroups: userGroups, + departments: departments, queryParams: map[string]interface{}{}, optFns: optFns, } } -type UserGroupMemberCreateReqCall struct { - ctx *core.Context - userGroupMembers *UserGroupMemberService - body *UserGroupMemberCreateReqBody - pathParams map[string]interface{} +type DepartmentUpdateDepartmentIdReqCall struct { + ctx *core.Context + departments *DepartmentService + body *DepartmentUpdateDepartmentIdReqBody + pathParams map[string]interface{} queryParams map[string]interface{} optFns []request.OptFn } -func (rc *UserGroupMemberCreateReqCall) SetUserGroupId(userGroupId string) { - rc.pathParams["user_group_id"] = userGroupId +func (rc *DepartmentUpdateDepartmentIdReqCall) SetDepartmentId(departmentId string) { + rc.pathParams["department_id"] = departmentId } -func (rc *UserGroupMemberCreateReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType +func (rc *DepartmentUpdateDepartmentIdReqCall) SetDepartmentIdType(departmentIdType string) { + rc.queryParams["department_id_type"] = departmentIdType } -func (rc *UserGroupMemberCreateReqCall) Do() (*response.NoData, error) { - httpPath := path.Join(rc.userGroupMembers.service.basePath, "user_groups/:user_group_id/members") +func (rc *DepartmentUpdateDepartmentIdReqCall) Do() (*response.NoData, error) { + httpPath := path.Join(rc.departments.service.basePath, "departments/:department_id/update_department_id") 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(httpPath, "POST", + req := request.NewRequest(httpPath, "PATCH", []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.userGroupMembers.service.conf, req) + err := api.Send(rc.ctx, rc.departments.service.conf, req) return result, err } -func (userGroupMembers *UserGroupMemberService) Create(ctx *core.Context, body *UserGroupMemberCreateReqBody, optFns ...request.OptFn) *UserGroupMemberCreateReqCall { - return &UserGroupMemberCreateReqCall{ - ctx: ctx, - userGroupMembers: userGroupMembers, - body: body, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, +func (departments *DepartmentService) UpdateDepartmentId(ctx *core.Context, body *DepartmentUpdateDepartmentIdReqBody, optFns ...request.OptFn) *DepartmentUpdateDepartmentIdReqCall { + return &DepartmentUpdateDepartmentIdReqCall{ + ctx: ctx, + departments: departments, + body: body, + pathParams: map[string]interface{}{}, + queryParams: map[string]interface{}{}, + optFns: optFns, } } -type UserGroupMemberDeleteReqCall struct { - ctx *core.Context - userGroupMembers *UserGroupMemberService - pathParams map[string]interface{} +type DepartmentUnbindDepartmentChatReqCall struct { + ctx *core.Context + departments *DepartmentService + body *DepartmentUnbindDepartmentChatReqBody queryParams map[string]interface{} optFns []request.OptFn } -func (rc *UserGroupMemberDeleteReqCall) SetUserGroupId(userGroupId string) { - rc.pathParams["user_group_id"] = userGroupId -} -func (rc *UserGroupMemberDeleteReqCall) SetUserId(userId string) { - rc.pathParams["user_id"] = userId -} -func (rc *UserGroupMemberDeleteReqCall) SetUserIdType(userIdType string) { - rc.queryParams["user_id_type"] = userIdType +func (rc *DepartmentUnbindDepartmentChatReqCall) SetDepartmentIdType(departmentIdType string) { + rc.queryParams["department_id_type"] = departmentIdType } -func (rc *UserGroupMemberDeleteReqCall) Do() (*response.NoData, error) { - httpPath := path.Join(rc.userGroupMembers.service.basePath, "user_groups/:user_group_id/members/:user_id") - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) +func (rc *DepartmentUnbindDepartmentChatReqCall) Do() (*response.NoData, error) { + httpPath := path.Join(rc.departments.service.basePath, "departments/unbind_department_chat") rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) var result = &response.NoData{} - req := request.NewRequest(httpPath, "DELETE", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.userGroupMembers.service.conf, req) + req := request.NewRequest(httpPath, "POST", + []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) + err := api.Send(rc.ctx, rc.departments.service.conf, req) return result, err } -func (userGroupMembers *UserGroupMemberService) Delete(ctx *core.Context, optFns ...request.OptFn) *UserGroupMemberDeleteReqCall { - return &UserGroupMemberDeleteReqCall{ - ctx: ctx, - userGroupMembers: userGroupMembers, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, +func (departments *DepartmentService) UnbindDepartmentChat(ctx *core.Context, body *DepartmentUnbindDepartmentChatReqBody, optFns ...request.OptFn) *DepartmentUnbindDepartmentChatReqCall { + return &DepartmentUnbindDepartmentChatReqCall{ + ctx: ctx, + departments: departments, + body: body, + queryParams: map[string]interface{}{}, + optFns: optFns, } } -type UserGroupMemberListReqCall struct { - ctx *core.Context - userGroupMembers *UserGroupMemberService - pathParams map[string]interface{} +type DepartmentSearchReqCall struct { + ctx *core.Context + departments *DepartmentService + body *DepartmentSearchReqBody queryParams map[string]interface{} optFns []request.OptFn } -func (rc *UserGroupMemberListReqCall) SetUserGroupId(userGroupId string) { - rc.pathParams["user_group_id"] = userGroupId -} -func (rc *UserGroupMemberListReqCall) SetUserIdType(userIdType string) { +func (rc *DepartmentSearchReqCall) SetUserIdType(userIdType string) { rc.queryParams["user_id_type"] = userIdType } -func (rc *UserGroupMemberListReqCall) SetDepartmentIdType(departmentIdType string) { +func (rc *DepartmentSearchReqCall) SetDepartmentIdType(departmentIdType string) { rc.queryParams["department_id_type"] = departmentIdType } -func (rc *UserGroupMemberListReqCall) Do() (*UserGroupMemberListResult, error) { - httpPath := path.Join(rc.userGroupMembers.service.basePath, "user_groups/:user_group_id/members") - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) - var result = &UserGroupMemberListResult{} - req := request.NewRequest(httpPath, "GET", - []request.AccessTokenType{request.AccessTokenTypeTenant}, nil, result, rc.optFns...) - err := api.Send(rc.ctx, rc.userGroupMembers.service.conf, req) - return result, err -} - -func (userGroupMembers *UserGroupMemberService) List(ctx *core.Context, optFns ...request.OptFn) *UserGroupMemberListReqCall { - return &UserGroupMemberListReqCall{ - ctx: ctx, - userGroupMembers: userGroupMembers, - pathParams: map[string]interface{}{}, - queryParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type UserGroupPatchReqCall struct { - ctx *core.Context - userGroups *UserGroupService - body *UserGroup - pathParams map[string]interface{} - - optFns []request.OptFn -} - -func (rc *UserGroupPatchReqCall) SetUserGroupId(userGroupId string) { - rc.pathParams["user_group_id"] = userGroupId -} -func (rc *UserGroupPatchReqCall) Do() (*UserGroupPatchResult, error) { - httpPath := path.Join(rc.userGroups.service.basePath, "user_groups/:user_group_id") - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &UserGroupPatchResult{} - req := request.NewRequest(httpPath, "PATCH", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.userGroups.service.conf, req) - return result, err -} - -func (userGroups *UserGroupService) Patch(ctx *core.Context, body *UserGroup, optFns ...request.OptFn) *UserGroupPatchReqCall { - return &UserGroupPatchReqCall{ - ctx: ctx, - userGroups: userGroups, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, - } -} - -type UserGroupUpdateUserGroupIdReqCall struct { - ctx *core.Context - userGroups *UserGroupService - body *UserGroupUpdateUserGroupIdReqBody - pathParams map[string]interface{} - - optFns []request.OptFn +func (rc *DepartmentSearchReqCall) SetPageToken(pageToken string) { + rc.queryParams["page_token"] = pageToken } - -func (rc *UserGroupUpdateUserGroupIdReqCall) SetUserGroupId(userGroupId string) { - rc.pathParams["user_group_id"] = userGroupId +func (rc *DepartmentSearchReqCall) SetPageSize(pageSize int) { + rc.queryParams["page_size"] = pageSize } -func (rc *UserGroupUpdateUserGroupIdReqCall) Do() (*response.NoData, error) { - httpPath := path.Join(rc.userGroups.service.basePath, "user_groups/:user_group_id/update_user_group_id") - rc.optFns = append(rc.optFns, request.SetPathParams(rc.pathParams)) - var result = &response.NoData{} - req := request.NewRequest(httpPath, "PATCH", - []request.AccessTokenType{request.AccessTokenTypeTenant}, rc.body, result, rc.optFns...) - err := api.Send(rc.ctx, rc.userGroups.service.conf, req) +func (rc *DepartmentSearchReqCall) Do() (*DepartmentSearchResult, error) { + httpPath := path.Join(rc.departments.service.basePath, "departments/search") + rc.optFns = append(rc.optFns, request.SetQueryParams(rc.queryParams)) + var result = &DepartmentSearchResult{} + req := request.NewRequest(httpPath, "POST", + []request.AccessTokenType{request.AccessTokenTypeUser}, rc.body, result, rc.optFns...) + err := api.Send(rc.ctx, rc.departments.service.conf, req) return result, err } -func (userGroups *UserGroupService) UpdateUserGroupId(ctx *core.Context, body *UserGroupUpdateUserGroupIdReqBody, optFns ...request.OptFn) *UserGroupUpdateUserGroupIdReqCall { - return &UserGroupUpdateUserGroupIdReqCall{ - ctx: ctx, - userGroups: userGroups, - body: body, - pathParams: map[string]interface{}{}, - optFns: optFns, +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 index fb679822..94f92b41 100644 --- a/service/contact/v3/event.go +++ b/service/contact/v3/event.go @@ -7,22 +7,6 @@ import ( "github.com/larksuite/oapi-sdk-go/event" ) -type DepartmentCreateEventHandler struct { - Fn func(*core.Context, *DepartmentCreateEvent) error -} - -func (h *DepartmentCreateEventHandler) GetEvent() interface{} { - return &DepartmentCreateEvent{} -} - -func (h *DepartmentCreateEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*DepartmentCreateEvent)) -} - -func SetDepartmentCreateEventHandler(conf *config.Config, fn func(ctx *core.Context, event *DepartmentCreateEvent) error) { - event.SetTypeHandler(conf, "contact.department.create_v3", &DepartmentCreateEventHandler{Fn: fn}) -} - type DepartmentCreatedEventHandler struct { Fn func(*core.Context, *DepartmentCreatedEvent) error } @@ -39,38 +23,6 @@ func SetDepartmentCreatedEventHandler(conf *config.Config, fn func(ctx *core.Con event.SetTypeHandler(conf, "contact.department.created_v3", &DepartmentCreatedEventHandler{Fn: fn}) } -type DepartmentCreatedV3EventHandler struct { - Fn func(*core.Context, *DepartmentCreatedV3Event) error -} - -func (h *DepartmentCreatedV3EventHandler) GetEvent() interface{} { - return &DepartmentCreatedV3Event{} -} - -func (h *DepartmentCreatedV3EventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*DepartmentCreatedV3Event)) -} - -func SetDepartmentCreatedV3EventHandler(conf *config.Config, fn func(ctx *core.Context, event *DepartmentCreatedV3Event) error) { - event.SetTypeHandler(conf, "contact.department.created_v3_v3", &DepartmentCreatedV3EventHandler{Fn: fn}) -} - -type DepartmentDeleteEventHandler struct { - Fn func(*core.Context, *DepartmentDeleteEvent) error -} - -func (h *DepartmentDeleteEventHandler) GetEvent() interface{} { - return &DepartmentDeleteEvent{} -} - -func (h *DepartmentDeleteEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*DepartmentDeleteEvent)) -} - -func SetDepartmentDeleteEventHandler(conf *config.Config, fn func(ctx *core.Context, event *DepartmentDeleteEvent) error) { - event.SetTypeHandler(conf, "contact.department.delete_v3", &DepartmentDeleteEventHandler{Fn: fn}) -} - type DepartmentDeletedEventHandler struct { Fn func(*core.Context, *DepartmentDeletedEvent) error } @@ -87,22 +39,6 @@ func SetDepartmentDeletedEventHandler(conf *config.Config, fn func(ctx *core.Con event.SetTypeHandler(conf, "contact.department.deleted_v3", &DepartmentDeletedEventHandler{Fn: fn}) } -type DepartmentUpdateEventHandler struct { - Fn func(*core.Context, *DepartmentUpdateEvent) error -} - -func (h *DepartmentUpdateEventHandler) GetEvent() interface{} { - return &DepartmentUpdateEvent{} -} - -func (h *DepartmentUpdateEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*DepartmentUpdateEvent)) -} - -func SetDepartmentUpdateEventHandler(conf *config.Config, fn func(ctx *core.Context, event *DepartmentUpdateEvent) error) { - event.SetTypeHandler(conf, "contact.department.update_v3", &DepartmentUpdateEventHandler{Fn: fn}) -} - type DepartmentUpdatedEventHandler struct { Fn func(*core.Context, *DepartmentUpdatedEvent) error } @@ -119,38 +55,6 @@ func SetDepartmentUpdatedEventHandler(conf *config.Config, fn func(ctx *core.Con event.SetTypeHandler(conf, "contact.department.updated_v3", &DepartmentUpdatedEventHandler{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 UserCreateEventHandler struct { - Fn func(*core.Context, *UserCreateEvent) error -} - -func (h *UserCreateEventHandler) GetEvent() interface{} { - return &UserCreateEvent{} -} - -func (h *UserCreateEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*UserCreateEvent)) -} - -func SetUserCreateEventHandler(conf *config.Config, fn func(ctx *core.Context, event *UserCreateEvent) error) { - event.SetTypeHandler(conf, "contact.user.create_v3", &UserCreateEventHandler{Fn: fn}) -} - type UserCreatedEventHandler struct { Fn func(*core.Context, *UserCreatedEvent) error } @@ -167,22 +71,6 @@ func SetUserCreatedEventHandler(conf *config.Config, fn func(ctx *core.Context, event.SetTypeHandler(conf, "contact.user.created_v3", &UserCreatedEventHandler{Fn: fn}) } -type UserDeleteEventHandler struct { - Fn func(*core.Context, *UserDeleteEvent) error -} - -func (h *UserDeleteEventHandler) GetEvent() interface{} { - return &UserDeleteEvent{} -} - -func (h *UserDeleteEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*UserDeleteEvent)) -} - -func SetUserDeleteEventHandler(conf *config.Config, fn func(ctx *core.Context, event *UserDeleteEvent) error) { - event.SetTypeHandler(conf, "contact.user.delete_v3", &UserDeleteEventHandler{Fn: fn}) -} - type UserDeletedEventHandler struct { Fn func(*core.Context, *UserDeletedEvent) error } @@ -199,22 +87,6 @@ func SetUserDeletedEventHandler(conf *config.Config, fn func(ctx *core.Context, event.SetTypeHandler(conf, "contact.user.deleted_v3", &UserDeletedEventHandler{Fn: fn}) } -type UserUpdateEventHandler struct { - Fn func(*core.Context, *UserUpdateEvent) error -} - -func (h *UserUpdateEventHandler) GetEvent() interface{} { - return &UserUpdateEvent{} -} - -func (h *UserUpdateEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*UserUpdateEvent)) -} - -func SetUserUpdateEventHandler(conf *config.Config, fn func(ctx *core.Context, event *UserUpdateEvent) error) { - event.SetTypeHandler(conf, "contact.user.update_v3", &UserUpdateEventHandler{Fn: fn}) -} - type UserUpdatedEventHandler struct { Fn func(*core.Context, *UserUpdatedEvent) error } @@ -231,22 +103,6 @@ func SetUserUpdatedEventHandler(conf *config.Config, fn func(ctx *core.Context, event.SetTypeHandler(conf, "contact.user.updated_v3", &UserUpdatedEventHandler{Fn: fn}) } -type UserGroupCreateEventHandler struct { - Fn func(*core.Context, *UserGroupCreateEvent) error -} - -func (h *UserGroupCreateEventHandler) GetEvent() interface{} { - return &UserGroupCreateEvent{} -} - -func (h *UserGroupCreateEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*UserGroupCreateEvent)) -} - -func SetUserGroupCreateEventHandler(conf *config.Config, fn func(ctx *core.Context, event *UserGroupCreateEvent) error) { - event.SetTypeHandler(conf, "contact.user_group.create_v3", &UserGroupCreateEventHandler{Fn: fn}) -} - type UserGroupCreatedEventHandler struct { Fn func(*core.Context, *UserGroupCreatedEvent) error } @@ -263,22 +119,6 @@ func SetUserGroupCreatedEventHandler(conf *config.Config, fn func(ctx *core.Cont event.SetTypeHandler(conf, "contact.user_group.created_v3", &UserGroupCreatedEventHandler{Fn: fn}) } -type UserGroupDeleteEventHandler struct { - Fn func(*core.Context, *UserGroupDeleteEvent) error -} - -func (h *UserGroupDeleteEventHandler) GetEvent() interface{} { - return &UserGroupDeleteEvent{} -} - -func (h *UserGroupDeleteEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*UserGroupDeleteEvent)) -} - -func SetUserGroupDeleteEventHandler(conf *config.Config, fn func(ctx *core.Context, event *UserGroupDeleteEvent) error) { - event.SetTypeHandler(conf, "contact.user_group.delete_v3", &UserGroupDeleteEventHandler{Fn: fn}) -} - type UserGroupDeletedEventHandler struct { Fn func(*core.Context, *UserGroupDeletedEvent) error } @@ -295,22 +135,6 @@ func SetUserGroupDeletedEventHandler(conf *config.Config, fn func(ctx *core.Cont event.SetTypeHandler(conf, "contact.user_group.deleted_v3", &UserGroupDeletedEventHandler{Fn: fn}) } -type UserGroupUpdateEventHandler struct { - Fn func(*core.Context, *UserGroupUpdateEvent) error -} - -func (h *UserGroupUpdateEventHandler) GetEvent() interface{} { - return &UserGroupUpdateEvent{} -} - -func (h *UserGroupUpdateEventHandler) Handle(ctx *core.Context, event interface{}) error { - return h.Fn(ctx, event.(*UserGroupUpdateEvent)) -} - -func SetUserGroupUpdateEventHandler(conf *config.Config, fn func(ctx *core.Context, event *UserGroupUpdateEvent) error) { - event.SetTypeHandler(conf, "contact.user_group.update_v3", &UserGroupUpdateEventHandler{Fn: fn}) -} - type UserGroupUpdatedEventHandler struct { Fn func(*core.Context, *UserGroupUpdatedEvent) error } @@ -326,3 +150,51 @@ func (h *UserGroupUpdatedEventHandler) Handle(ctx *core.Context, event interface 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}) +} diff --git a/service/contact/v3/model.go b/service/contact/v3/model.go index bd79664c..b912f05b 100644 --- a/service/contact/v3/model.go +++ b/service/contact/v3/model.go @@ -2,52 +2,23 @@ package v3 import ( + "github.com/larksuite/oapi-sdk-go/api/core/tools" "github.com/larksuite/oapi-sdk-go/event/core/model" ) -type Department 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"` - UnitIds []string `json:"unit_ids,omitempty"` - MemberCount int `json:"member_count,omitempty"` - Status int `json:"status,omitempty"` - CreateGroupChat bool `json:"create_group_chat,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"` - UnitIds []string `json:"unit_ids,omitempty"` - MemberCount int `json:"member_count,omitempty"` - Status int `json:"status,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 Member struct { - UserGroupId string `json:"user_group_id,omitempty"` - UserId string `json:"user_id,omitempty"` + UnitId string `json:"unit_id,omitempty"` + UnitType string `json:"unit_type,omitempty"` + UnitName string `json:"unit_name,omitempty"` + ForceSendFields []string `json:"-"` } -type Scope struct { - Departments []*Department `json:"departments,omitempty"` - Users []*User `json:"users,omitempty"` - UserGroups []*UserGroup `json:"user_groups,omitempty"` + +func (s *DepartmentUnit) MarshalJSON() ([]byte, error) { + type cp DepartmentUnit + raw := cp(*s) + return tools.MarshalJSON(raw, s.ForceSendFields) } + type User struct { UnionId string `json:"union_id,omitempty"` UserId string `json:"user_id,omitempty"` @@ -72,9 +43,91 @@ type User struct { EmployeeType int `json:"employee_type,omitempty"` Positions []*UserPosition `json:"positions,omitempty"` Orders []*UserOrder `json:"orders,omitempty"` - TimeZone string `json:"time_zone,omitempty"` CustomAttrs []*UserCustomAttr `json:"custom_attrs,omitempty"` + EnterpriseEmail string `json:"enterprise_email,omitempty"` + IdpType string `json:"idp_type,omitempty"` + TimeZone string `json:"time_zone,omitempty"` + ForceSendFields []string `json:"-"` } + +func (s *User) MarshalJSON() ([]byte, error) { + type cp User + 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 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 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"` + UnitIds []string `json:"unit_ids,omitempty"` + MemberCount int `json:"member_count,omitempty"` + Status int `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 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 UserEvent struct { OpenId string `json:"open_id,omitempty"` UserId string `json:"user_id,omitempty"` @@ -99,145 +152,272 @@ type UserEvent struct { Orders []*UserOrder `json:"orders,omitempty"` TimeZone string `json:"time_zone,omitempty"` CustomAttrs []*UserCustomAttr `json:"custom_attrs,omitempty"` + ForceSendFields []string `json:"-"` } -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"` + +func (s *UserEvent) MarshalJSON() ([]byte, error) { + type cp UserEvent + raw := cp(*s) + return tools.MarshalJSON(raw, s.ForceSendFields) } -type UserGroupMember struct { + +type Scope struct { + Departments []*Department `json:"departments,omitempty"` + Users []*User `json:"users,omitempty"` + UserGroups []*UserGroup `json:"user_groups,omitempty"` + ForceSendFields []string `json:"-"` } -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"` +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"` + +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:"-"` } -type UserCustomAttrValue struct { - Text string `json:"text,omitempty"` - Url string `json:"url,omitempty"` - PcUrl string `json:"pc_url,omitempty"` + +func (s *CustomAttrEvent) MarshalJSON() ([]byte, error) { + type cp CustomAttrEvent + raw := cp(*s) + return tools.MarshalJSON(raw, s.ForceSendFields) } -type UserOrder struct { - DepartmentId string `json:"department_id,omitempty"` - UserOrder int `json:"user_order,omitempty"` - DepartmentOrder int `json:"department_order,omitempty"` + +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 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"` + 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:"-"` } -type UserStatus struct { - IsFrozen bool `json:"is_frozen,omitempty"` - IsResigned bool `json:"is_resigned,omitempty"` - IsActivated bool `json:"is_activated,omitempty"` + +func (s *UserPosition) MarshalJSON() ([]byte, error) { + type cp UserPosition + raw := cp(*s) + return tools.MarshalJSON(raw, s.ForceSendFields) } -type DepartmentCreateResult struct { - Department *Department `json:"department,omitempty"` +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 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 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 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 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 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 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 DepartmentGetResult struct { Department *Department `json:"department,omitempty"` } -type DepartmentListResult struct { - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` - Items []*Department `json:"items,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:"-"` } -type DepartmentNomalizeReqBody struct { - DepartmentId string `json:"department_id,omitempty"` +func (s *UserDeleteReqBody) MarshalJSON() ([]byte, error) { + type cp UserDeleteReqBody + raw := cp(*s) + return tools.MarshalJSON(raw, s.ForceSendFields) } -type DepartmentNomalizeDepartmentChatReqBody struct { - DepartmentId string `json:"department_id,omitempty"` +type DepartmentListReqBody struct { + FetchChild bool `json:"fetch_child,omitempty"` + ForceSendFields []string `json:"-"` } -type DepartmentParentResult struct { +func (s *DepartmentListReqBody) MarshalJSON() ([]byte, error) { + type cp DepartmentListReqBody + 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 UserGroupUpdateUserGroupIdReqBody struct { + NewUserGroupId string `json:"new_user_group_id,omitempty"` + ForceSendFields []string `json:"-"` } -type DepartmentUpdateResult struct { +func (s *UserGroupUpdateUserGroupIdReqBody) MarshalJSON() ([]byte, error) { + type cp UserGroupUpdateUserGroupIdReqBody + raw := cp(*s) + return tools.MarshalJSON(raw, s.ForceSendFields) +} + +type DepartmentPatchResult struct { Department *Department `json:"department,omitempty"` } -type DepartmentUpdateDepartmentIdReqBody struct { - NewDepartmentId string `json:"new_department_id,omitempty"` +type UserUpdateResult struct { + User *User `json:"user,omitempty"` } -type DepartmentUnitCreateResult struct { - DepartmentUnit *DepartmentUnit `json:"department_unit,omitempty"` +type UserCreateResult struct { + User *User `json:"user,omitempty"` } -type DepartmentUnitPatchReqBody struct { - UnitType string `json:"unit_type,omitempty"` - UnitName string `json:"unit_name,omitempty"` +type UserPatchResult struct { + User *User `json:"user,omitempty"` } -type DepartmentUnitPatchResult struct { - DepartmentUnit *DepartmentUnit `json:"department_unit,omitempty"` +type UserUpdateUserIdReqBody struct { + NewUserId string `json:"new_user_id,omitempty"` + ForceSendFields []string `json:"-"` } -type UserCreateResult struct { - User *User `json:"user,omitempty"` +func (s *UserUpdateUserIdReqBody) MarshalJSON() ([]byte, error) { + type cp UserUpdateUserIdReqBody + raw := cp(*s) + return tools.MarshalJSON(raw, s.ForceSendFields) } -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 UserGroupMemberCreateReqBody struct { + UserId string `json:"user_id,omitempty"` + ForceSendFields []string `json:"-"` } -type UserGetResult struct { - User *User `json:"user,omitempty"` +func (s *UserGroupMemberCreateReqBody) MarshalJSON() ([]byte, error) { + type cp UserGroupMemberCreateReqBody + raw := cp(*s) + return tools.MarshalJSON(raw, s.ForceSendFields) } -type UserListResult struct { - HasMore bool `json:"has_more,omitempty"` - PageToken string `json:"page_token,omitempty"` - Items []*User `json:"items,omitempty"` +type DepartmentCreateResult struct { + Department *Department `json:"department,omitempty"` } -type UserPatchResult struct { - User *User `json:"user,omitempty"` +type UserGroupPatchResult struct { + UserGroup *UserGroup `json:"user_group,omitempty"` } -type UserUpdateResult struct { - User *User `json:"user,omitempty"` +type DepartmentUnitPatchReqBody struct { + UnitType string `json:"unit_type,omitempty"` + UnitName string `json:"unit_name,omitempty"` + ForceSendFields []string `json:"-"` } -type UserUpdateUserIdReqBody struct { - NewUserId string `json:"new_user_id,omitempty"` +func (s *DepartmentUnitPatchReqBody) MarshalJSON() ([]byte, error) { + type cp DepartmentUnitPatchReqBody + raw := cp(*s) + return tools.MarshalJSON(raw, s.ForceSendFields) } -type UserGroupCreateResult struct { - UserGroup *UserGroup `json:"user_group,omitempty"` +type DepartmentUnitPatchResult struct { + DepartmentUnit *DepartmentUnit `json:"department_unit,omitempty"` } -type UserGroupGetResult struct { +type UserGroupCreateResult struct { UserGroup *UserGroup `json:"user_group,omitempty"` } @@ -247,8 +427,8 @@ type UserGroupListResult struct { Items []*UserGroup `json:"items,omitempty"` } -type UserGroupMemberCreateReqBody struct { - UserId string `json:"user_id,omitempty"` +type UserGetResult struct { + User *User `json:"user,omitempty"` } type UserGroupMemberListResult struct { @@ -257,68 +437,86 @@ type UserGroupMemberListResult struct { Items []*User `json:"items,omitempty"` } -type UserGroupPatchResult struct { - UserGroup *UserGroup `json:"user_group,omitempty"` +type DepartmentUpdateResult struct { + Department *Department `json:"department,omitempty"` } -type UserGroupUpdateUserGroupIdReqBody struct { - NewUserGroupId string `json:"new_user_group_id,omitempty"` +type DepartmentUnitCreateResult struct { + DepartmentUnit *DepartmentUnit `json:"department_unit,omitempty"` } -type DepartmentCreateEventData struct { - Object *DepartmentEvent `json:"object,omitempty"` +type UserListResult struct { + HasMore bool `json:"has_more,omitempty"` + PageToken string `json:"page_token,omitempty"` + Items []*User `json:"items,omitempty"` } -type DepartmentCreateEvent struct { - *model.BaseEventV2 - Event *DepartmentCreateEventData `json:"event"` +type UserGroupGetResult struct { + UserGroup *UserGroup `json:"user_group,omitempty"` } -type DepartmentCreatedEventData struct { - Object *DepartmentEvent `json:"object,omitempty"` +type DepartmentParentResult struct { + HasMore bool `json:"has_more,omitempty"` + PageToken string `json:"page_token,omitempty"` + Items []*Department `json:"items,omitempty"` } -type DepartmentCreatedEvent struct { - *model.BaseEventV2 - Event *DepartmentCreatedEventData `json:"event"` +type DepartmentUpdateDepartmentIdReqBody struct { + NewDepartmentId string `json:"new_department_id,omitempty"` + ForceSendFields []string `json:"-"` } -type DepartmentCreatedV3EventData struct { - Object *DepartmentEvent `json:"object,omitempty"` +func (s *DepartmentUpdateDepartmentIdReqBody) MarshalJSON() ([]byte, error) { + type cp DepartmentUpdateDepartmentIdReqBody + raw := cp(*s) + return tools.MarshalJSON(raw, s.ForceSendFields) } -type DepartmentCreatedV3Event struct { - *model.BaseEventV2 - Event *DepartmentCreatedV3EventData `json:"event"` +type DepartmentUnbindDepartmentChatReqBody struct { + DepartmentId string `json:"department_id,omitempty"` + ForceSendFields []string `json:"-"` } -type DepartmentDeleteEventData struct { - Object *DepartmentEvent `json:"object,omitempty"` - OldObject *DepartmentEvent `json:"old_object,omitempty"` +func (s *DepartmentUnbindDepartmentChatReqBody) MarshalJSON() ([]byte, error) { + type cp DepartmentUnbindDepartmentChatReqBody + raw := cp(*s) + return tools.MarshalJSON(raw, s.ForceSendFields) } -type DepartmentDeleteEvent struct { - *model.BaseEventV2 - Event *DepartmentDeleteEventData `json:"event"` +type DepartmentSearchReqBody struct { + Query string `json:"query,omitempty"` + ForceSendFields []string `json:"-"` } -type DepartmentDeletedEventData struct { +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 DepartmentDeletedEvent struct { +type DepartmentCreatedEvent struct { *model.BaseEventV2 - Event *DepartmentDeletedEventData `json:"event"` + Event *DepartmentCreatedEventData `json:"event"` } -type DepartmentUpdateEventData struct { +type DepartmentDeletedEventData struct { Object *DepartmentEvent `json:"object,omitempty"` OldObject *DepartmentEvent `json:"old_object,omitempty"` } -type DepartmentUpdateEvent struct { +type DepartmentDeletedEvent struct { *model.BaseEventV2 - Event *DepartmentUpdateEventData `json:"event"` + Event *DepartmentDeletedEventData `json:"event"` } type DepartmentUpdatedEventData struct { @@ -331,25 +529,6 @@ type DepartmentUpdatedEvent struct { Event *DepartmentUpdatedEventData `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 UserCreateEventData struct { - Object *UserEvent `json:"object,omitempty"` -} - -type UserCreateEvent struct { - *model.BaseEventV2 - Event *UserCreateEventData `json:"event"` -} - type UserCreatedEventData struct { Object *UserEvent `json:"object,omitempty"` } @@ -359,32 +538,14 @@ type UserCreatedEvent struct { Event *UserCreatedEventData `json:"event"` } -type UserDeleteEventData struct { - Object *UserEvent `json:"object,omitempty"` -} - -type UserDeleteEvent struct { - *model.BaseEventV2 - Event *UserDeleteEventData `json:"event"` -} - type UserDeletedEventData struct { - Object *UserEvent `json:"object,omitempty"` -} - -type UserDeletedEvent struct { - *model.BaseEventV2 - Event *UserDeletedEventData `json:"event"` -} - -type UserUpdateEventData struct { Object *UserEvent `json:"object,omitempty"` OldObject *UserEvent `json:"old_object,omitempty"` } -type UserUpdateEvent struct { +type UserDeletedEvent struct { *model.BaseEventV2 - Event *UserUpdateEventData `json:"event"` + Event *UserDeletedEventData `json:"event"` } type UserUpdatedEventData struct { @@ -397,59 +558,59 @@ type UserUpdatedEvent struct { Event *UserUpdatedEventData `json:"event"` } -type UserGroupCreateEventData struct { +type UserGroupCreatedEventData struct { Object *GroupEvent `json:"object,omitempty"` } -type UserGroupCreateEvent struct { +type UserGroupCreatedEvent struct { *model.BaseEventV2 - Event *UserGroupCreateEventData `json:"event"` + Event *UserGroupCreatedEventData `json:"event"` } -type UserGroupCreatedEventData struct { +type UserGroupDeletedEventData struct { Object *GroupEvent `json:"object,omitempty"` } -type UserGroupCreatedEvent struct { +type UserGroupDeletedEvent struct { *model.BaseEventV2 - Event *UserGroupCreatedEventData `json:"event"` + Event *UserGroupDeletedEventData `json:"event"` } -type UserGroupDeleteEventData struct { +type UserGroupUpdatedEventData struct { Object *GroupEvent `json:"object,omitempty"` OldObject *GroupEvent `json:"old_object,omitempty"` } -type UserGroupDeleteEvent struct { +type UserGroupUpdatedEvent struct { *model.BaseEventV2 - Event *UserGroupDeleteEventData `json:"event"` + Event *UserGroupUpdatedEventData `json:"event"` } -type UserGroupDeletedEventData struct { - Object *GroupEvent `json:"object,omitempty"` +type ScopeUpdatedEventData struct { + Added *Scope `json:"added,omitempty"` + Removed *Scope `json:"removed,omitempty"` } -type UserGroupDeletedEvent struct { +type ScopeUpdatedEvent struct { *model.BaseEventV2 - Event *UserGroupDeletedEventData `json:"event"` + Event *ScopeUpdatedEventData `json:"event"` } -type UserGroupUpdateEventData struct { - Object *GroupEvent `json:"object,omitempty"` - OldObject *GroupEvent `json:"old_object,omitempty"` +type UserGroupMemberChangedEventData struct { + Object *GroupEvent `json:"object,omitempty"` } -type UserGroupUpdateEvent struct { +type UserGroupMemberChangedEvent struct { *model.BaseEventV2 - Event *UserGroupUpdateEventData `json:"event"` + Event *UserGroupMemberChangedEventData `json:"event"` } -type UserGroupUpdatedEventData struct { - Object *GroupEvent `json:"object,omitempty"` - OldObject *GroupEvent `json:"old_object,omitempty"` +type CustomAttrEventUpdatedEventData struct { + Object *CustomAttrEvent `json:"object,omitempty"` + OldObject *CustomAttrEvent `json:"old_object,omitempty"` } -type UserGroupUpdatedEvent struct { +type CustomAttrEventUpdatedEvent struct { *model.BaseEventV2 - Event *UserGroupUpdatedEventData `json:"event"` + Event *CustomAttrEventUpdatedEventData `json:"event"` }