// Code generated by lark_sdk_gen. DO NOT EDIT.
/**
 * Copyright 2022 chyroc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package lark

import (
	"context"
)

// CreateDocx 创建文档类型为 docx 的文档。你可选择传入文档标题和文件夹。
//
// 该接口仅支持指定文档标题, 不支持带内容创建文档。
// 应用频率限制: 单个应用调用频率上限为每秒 3 次, 超过该频率限制, 接口将返回 HTTP 状态码 400 及错误码 99991400。当请求被限频, 应用需要处理限频状态码, 并使用指数退避算法或其它一些频控策略降低对 API 的调用速率。
//
// doc: https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document/create
// new doc: https://open.feishu.cn/document/server-docs/docs/docs/docx-v1/document/create
func (r *DriveService) CreateDocx(ctx context.Context, request *CreateDocxReq, options ...MethodOptionFunc) (*CreateDocxResp, *Response, error) {
	if r.cli.mock.mockDriveCreateDocx != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Drive#CreateDocx mock enable")
		return r.cli.mock.mockDriveCreateDocx(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:                 "Drive",
		API:                   "CreateDocx",
		Method:                "POST",
		URL:                   r.cli.openBaseURL + "/open-apis/docx/v1/documents",
		Body:                  request,
		MethodOption:          newMethodOption(options),
		NeedTenantAccessToken: true,
		NeedUserAccessToken:   true,
	}
	resp := new(createDocxResp)

	response, err := r.cli.RawRequest(ctx, req, resp)
	return resp.Data, response, err
}

// MockDriveCreateDocx mock DriveCreateDocx method
func (r *Mock) MockDriveCreateDocx(f func(ctx context.Context, request *CreateDocxReq, options ...MethodOptionFunc) (*CreateDocxResp, *Response, error)) {
	r.mockDriveCreateDocx = f
}

// UnMockDriveCreateDocx un-mock DriveCreateDocx method
func (r *Mock) UnMockDriveCreateDocx() {
	r.mockDriveCreateDocx = nil
}

// CreateDocxReq ...
type CreateDocxReq struct {
	FolderToken *string `json:"folder_token,omitempty"` // 指定文档所在文件夹 的 Token。不传或传空表示根目录。了解如何获取文件夹 Token, 参考[如何获取云文档资源相关 Token](https://open.feishu.cn/document/ukTMukTMukTM/uczNzUjL3czM14yN3MTN#08bb5df6), 若应用使用的是 `tenant_access_token` 权限, 此处仅可指定应用创建的文件夹, 示例值: "fldcnqquW1svRIYVT2Np6Iabcef"
	Title       *string `json:"title,omitempty"`        // 文档标题, 只支持纯文本, 示例值: "一篇新的文档", 长度范围: `1` ～ `800` 字符
}

// CreateDocxResp ...
type CreateDocxResp struct {
	Document *CreateDocxRespDocument `json:"document,omitempty"` // 新建文档的文档信息
}

// CreateDocxRespDocument ...
type CreateDocxRespDocument struct {
	DocumentID string `json:"document_id,omitempty"` // 文档的唯一标识。点击[这里](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-overview)了解如何获取文档的 `document_id`
	RevisionID int64  `json:"revision_id,omitempty"` // 文档版本 ID
	Title      string `json:"title,omitempty"`       // 文档标题
}

// createDocxResp ...
type createDocxResp struct {
	Code  int64           `json:"code,omitempty"` // 错误码, 非 0 表示失败
	Msg   string          `json:"msg,omitempty"`  // 错误描述
	Data  *CreateDocxResp `json:"data,omitempty"`
	Error *ErrorDetail    `json:"error,omitempty"`
}
