// Package drive code generated by oapi sdk gen
/*
 * MIT License
 *
 * Copyright (c) 2022 Lark Technologies Pte. Ltd.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package larkdrive

import (
	"fmt"

	"context"
	"errors"

	"github.com/larksuite/oapi-sdk-go/v3/core"
)

const (
	FileTypeDoc  = "doc"  // 旧版文档
	FileTypeDocX = "docx" // 新版文档
	FileTypeFile = "file" // 文件
)

const (
	OpenAPIListFileLikesUserIDTypeUserId  = "user_id"  // 以user_id来识别用户
	OpenAPIListFileLikesUserIDTypeUnionId = "union_id" // 以union_id来识别用户
	OpenAPIListFileLikesUserIDTypeOpenId  = "open_id"  // 以open_id来识别用户
)

const (
	TokenTypeDoc      = "doc"      // 旧版文档
	TokenTypeSheet    = "sheet"    // 电子表格
	TokenTypeFile     = "file"     // 云空间文件
	TokenTypeWiki     = "wiki"     // 知识库节点
	TokenTypeBitable  = "bitable"  // 多维表格
	TokenTypeDocx     = "docx"     // 新版文档
	TokenTypeMindnote = "mindnote" // 思维笔记
	TokenTypeMinutes  = "minutes"  // 妙记
	TokenTypeSlides   = "slides"   // 幻灯片
)

const (
	PermissionPublicExternalAccessEntityOpen                    = "open"                       // 打开
	PermissionPublicExternalAccessEntityClosed                  = "closed"                     // 关闭
	PermissionPublicExternalAccessEntityAllowSharePartnerTenant = "allow_share_partner_tenant" // 允许分享给关联组织
)

const (
	PermissionPublicSecurityEntityAnyoneCanView  = "anyone_can_view"  // 拥有可阅读权限的用户
	PermissionPublicSecurityEntityAnyoneCanEdit  = "anyone_can_edit"  // 拥有可编辑权限的用户
	PermissionPublicSecurityEntityOnlyFullAccess = "only_full_access" // 拥有可管理权限（包括我）的用户
)

const (
	PermissionPublicCommentEntityAnyoneCanView = "anyone_can_view" // 拥有可阅读权限的用户
	PermissionPublicCommentEntityAnyoneCanEdit = "anyone_can_edit" // 拥有可编辑权限的用户
)

const (
	PermissionPublicShareEntityAnyone     = "anyone"      // 所有可阅读或编辑此文档的用户
	PermissionPublicShareEntitySameTenant = "same_tenant" // 组织内所有可阅读或编辑此文档的用户
)

const (
	PermissionPublicManageCollaboratorEntityCollaboratorCanView    = "collaborator_can_view"    // 拥有可阅读权限的协作者
	PermissionPublicManageCollaboratorEntityCollaboratorCanEdit    = "collaborator_can_edit"    // 拥有可编辑权限的协作者
	PermissionPublicManageCollaboratorEntityCollaboratorFullAccess = "collaborator_full_access" // 拥有可管理权限（包括我）的协作者
)

const (
	PermissionPublicLinkShareEntityTenantReadable        = "tenant_readable"         // 组织内获得链接的人可阅读
	PermissionPublicLinkShareEntityTenantEditable        = "tenant_editable"         // 组织内获得链接的人可编辑
	PermissionPublicLinkShareEntityPartnerTenantReadable = "partner_tenant_readable" // 关联组织的人可阅读
	PermissionPublicLinkShareEntityPartnerTenantEditable = "partner_tenant_editable" // 关联组织的人可编辑
	PermissionPublicLinkShareEntityAnyoneReadable        = "anyone_readable"         // 互联网上获得链接的任何人可阅读（仅external_access=“true”时有效）
	PermissionPublicLinkShareEntityAnyoneEditable        = "anyone_editable"         // 互联网上获得链接的任何人可编辑（仅external_access=“true”时有效）
	PermissionPublicLinkShareEntityClosed                = "closed"                  // 关闭链接分享
)

const (
	PermissionPublicCopyEntityAnyoneCanView  = "anyone_can_view"  // 拥有可阅读权限的用户
	PermissionPublicCopyEntityAnyoneCanEdit  = "anyone_can_edit"  // 拥有可编辑权限的用户
	PermissionPublicCopyEntityOnlyFullAccess = "only_full_access" // 拥有可管理权限（包括我）的协作者
)

const (
	TokenTypePatchPermissionPublicDoc      = "doc"      // 旧版文档
	TokenTypePatchPermissionPublicSheet    = "sheet"    // 电子表格
	TokenTypePatchPermissionPublicFile     = "file"     // 云空间文件
	TokenTypePatchPermissionPublicWiki     = "wiki"     // 知识库节点
	TokenTypePatchPermissionPublicBitable  = "bitable"  // 多维表格
	TokenTypePatchPermissionPublicDocx     = "docx"     // 新版文档
	TokenTypePatchPermissionPublicMindnote = "mindnote" // 思维笔记
	TokenTypePatchPermissionPublicMinutes  = "minutes"  // 妙记
	TokenTypePatchPermissionPublicSlides   = "slides"   // 幻灯片
)

type BizInfo struct {
	Name *string `json:"name,omitempty"` // 业务名称，ccm代表云文档容量，vc代表视频会议，mail代表邮箱，im代表聊天文件

	Used *string `json:"used,omitempty"` // 业务已经使用的容量，单位byte，最大可能为int64，需要自己转换为数字

	Quota *string `json:"quota,omitempty"` // 额度，单位byte，最大可能为int64，需要自己转换为数字

	Unlimited *bool `json:"unlimited,omitempty"` // 是否没设置容量限制
}

type BizInfoBuilder struct {
	name     string // 业务名称，ccm代表云文档容量，vc代表视频会议，mail代表邮箱，im代表聊天文件
	nameFlag bool

	used     string // 业务已经使用的容量，单位byte，最大可能为int64，需要自己转换为数字
	usedFlag bool

	quota     string // 额度，单位byte，最大可能为int64，需要自己转换为数字
	quotaFlag bool

	unlimited     bool // 是否没设置容量限制
	unlimitedFlag bool
}

func NewBizInfoBuilder() *BizInfoBuilder {
	builder := &BizInfoBuilder{}
	return builder
}

// 业务名称，ccm代表云文档容量，vc代表视频会议，mail代表邮箱，im代表聊天文件
//
// 示例值：ccm
func (builder *BizInfoBuilder) Name(name string) *BizInfoBuilder {
	builder.name = name
	builder.nameFlag = true
	return builder
}

// 业务已经使用的容量，单位byte，最大可能为int64，需要自己转换为数字
//
// 示例值：345567888
func (builder *BizInfoBuilder) Used(used string) *BizInfoBuilder {
	builder.used = used
	builder.usedFlag = true
	return builder
}

// 额度，单位byte，最大可能为int64，需要自己转换为数字
//
// 示例值：23455666
func (builder *BizInfoBuilder) Quota(quota string) *BizInfoBuilder {
	builder.quota = quota
	builder.quotaFlag = true
	return builder
}

// 是否没设置容量限制
//
// 示例值：true
func (builder *BizInfoBuilder) Unlimited(unlimited bool) *BizInfoBuilder {
	builder.unlimited = unlimited
	builder.unlimitedFlag = true
	return builder
}

func (builder *BizInfoBuilder) Build() *BizInfo {
	req := &BizInfo{}
	if builder.nameFlag {
		req.Name = &builder.name

	}
	if builder.usedFlag {
		req.Used = &builder.used

	}
	if builder.quotaFlag {
		req.Quota = &builder.quota

	}
	if builder.unlimitedFlag {
		req.Unlimited = &builder.unlimited

	}
	return req
}

type Condition struct {
	Range *int `json:"range,omitempty"` // 条件类型

	Operator *string `json:"operator,omitempty"` // 操作符

	Params []string `json:"params,omitempty"` // 参数，具体取值与range有关，见range描述
}

type ConditionBuilder struct {
	range_    int // 条件类型
	rangeFlag bool

	operator     string // 操作符
	operatorFlag bool

	params     []string // 参数，具体取值与range有关，见range描述
	paramsFlag bool
}

func NewConditionBuilder() *ConditionBuilder {
	builder := &ConditionBuilder{}
	return builder
}

// 条件类型
//
// 示例值：范围
func (builder *ConditionBuilder) Range(range_ int) *ConditionBuilder {
	builder.range_ = range_
	builder.rangeFlag = true
	return builder
}

// 操作符
//
// 示例值：resign
func (builder *ConditionBuilder) Operator(operator string) *ConditionBuilder {
	builder.operator = operator
	builder.operatorFlag = true
	return builder
}

// 参数，具体取值与range有关，见range描述
//
// 示例值：
func (builder *ConditionBuilder) Params(params []string) *ConditionBuilder {
	builder.params = params
	builder.paramsFlag = true
	return builder
}

func (builder *ConditionBuilder) Build() *Condition {
	req := &Condition{}
	if builder.rangeFlag {
		req.Range = &builder.range_

	}
	if builder.operatorFlag {
		req.Operator = &builder.operator

	}
	if builder.paramsFlag {
		req.Params = builder.params
	}
	return req
}

type DepartmentId struct {
	DepartmentId *string `json:"department_id,omitempty"` //

	OpenDepartmentId *string `json:"open_department_id,omitempty"` //
}

type DepartmentIdBuilder struct {
	departmentId     string //
	departmentIdFlag bool

	openDepartmentId     string //
	openDepartmentIdFlag bool
}

func NewDepartmentIdBuilder() *DepartmentIdBuilder {
	builder := &DepartmentIdBuilder{}
	return builder
}

//
//
// 示例值：
func (builder *DepartmentIdBuilder) DepartmentId(departmentId string) *DepartmentIdBuilder {
	builder.departmentId = departmentId
	builder.departmentIdFlag = true
	return builder
}

//
//
// 示例值：
func (builder *DepartmentIdBuilder) OpenDepartmentId(openDepartmentId string) *DepartmentIdBuilder {
	builder.openDepartmentId = openDepartmentId
	builder.openDepartmentIdFlag = true
	return builder
}

func (builder *DepartmentIdBuilder) Build() *DepartmentId {
	req := &DepartmentId{}
	if builder.departmentIdFlag {
		req.DepartmentId = &builder.departmentId

	}
	if builder.openDepartmentIdFlag {
		req.OpenDepartmentId = &builder.openDepartmentId

	}
	return req
}

type DepartmentInfo struct {
	DepartmentName *string `json:"department_name,omitempty"` // 部门名称

	DepartmentFullPath *string `json:"department_full_path,omitempty"` // 部门全路径

	CustomId *string `json:"custom_id,omitempty"` // 部门id
}

type DepartmentInfoBuilder struct {
	departmentName     string // 部门名称
	departmentNameFlag bool

	departmentFullPath     string // 部门全路径
	departmentFullPathFlag bool

	customId     string // 部门id
	customIdFlag bool
}

func NewDepartmentInfoBuilder() *DepartmentInfoBuilder {
	builder := &DepartmentInfoBuilder{}
	return builder
}

// 部门名称
//
// 示例值：部门
func (builder *DepartmentInfoBuilder) DepartmentName(departmentName string) *DepartmentInfoBuilder {
	builder.departmentName = departmentName
	builder.departmentNameFlag = true
	return builder
}

// 部门全路径
//
// 示例值：根部门/次级部门/叶子部门
func (builder *DepartmentInfoBuilder) DepartmentFullPath(departmentFullPath string) *DepartmentInfoBuilder {
	builder.departmentFullPath = departmentFullPath
	builder.departmentFullPathFlag = true
	return builder
}

// 部门id
//
// 示例值：dg25d5662fdd639g
func (builder *DepartmentInfoBuilder) CustomId(customId string) *DepartmentInfoBuilder {
	builder.customId = customId
	builder.customIdFlag = true
	return builder
}

func (builder *DepartmentInfoBuilder) Build() *DepartmentInfo {
	req := &DepartmentInfo{}
	if builder.departmentNameFlag {
		req.DepartmentName = &builder.departmentName

	}
	if builder.departmentFullPathFlag {
		req.DepartmentFullPath = &builder.departmentFullPath

	}
	if builder.customIdFlag {
		req.CustomId = &builder.customId

	}
	return req
}

type ExportJob struct {
	FileExtension *string `json:"file_extension,omitempty"` // 导出文件扩展名

	Token *string `json:"token,omitempty"` // 导出文档 token

	Type *string `json:"type,omitempty"` // 导出文档类型

	FileName *string `json:"file_name,omitempty"` // 导出文件名

	FileToken *string `json:"file_token,omitempty"` // 导出文件 Drive Token

	JobErrorMsg *string `json:"job_error_msg,omitempty"` // 任务失败原因

	JobStatus *int `json:"job_status,omitempty"` // 任务状态
}

type ExportJobBuilder struct {
	fileExtension     string // 导出文件扩展名
	fileExtensionFlag bool

	token     string // 导出文档 token
	tokenFlag bool

	type_    string // 导出文档类型
	typeFlag bool

	fileName     string // 导出文件名
	fileNameFlag bool

	fileToken     string // 导出文件 Drive Token
	fileTokenFlag bool

	jobErrorMsg     string // 任务失败原因
	jobErrorMsgFlag bool

	jobStatus     int // 任务状态
	jobStatusFlag bool
}

func NewExportJobBuilder() *ExportJobBuilder {
	builder := &ExportJobBuilder{}
	return builder
}

// 导出文件扩展名
//
// 示例值：larkdoc
func (builder *ExportJobBuilder) FileExtension(fileExtension string) *ExportJobBuilder {
	builder.fileExtension = fileExtension
	builder.fileExtensionFlag = true
	return builder
}

// 导出文档 token
//
// 示例值：doccnxe5OxxxxxxxSNdsJviENsk
func (builder *ExportJobBuilder) Token(token string) *ExportJobBuilder {
	builder.token = token
	builder.tokenFlag = true
	return builder
}

// 导出文档类型
//
// 示例值：sheet
func (builder *ExportJobBuilder) Type(type_ string) *ExportJobBuilder {
	builder.type_ = type_
	builder.typeFlag = true
	return builder
}

// 导出文件名
//
// 示例值：docName
func (builder *ExportJobBuilder) FileName(fileName string) *ExportJobBuilder {
	builder.fileName = fileName
	builder.fileNameFlag = true
	return builder
}

// 导出文件 Drive Token
//
// 示例值：boxcnxe5OxxxxxxxSNdsJviENsk
func (builder *ExportJobBuilder) FileToken(fileToken string) *ExportJobBuilder {
	builder.fileToken = fileToken
	builder.fileTokenFlag = true
	return builder
}

// 任务失败原因
//
// 示例值：success
func (builder *ExportJobBuilder) JobErrorMsg(jobErrorMsg string) *ExportJobBuilder {
	builder.jobErrorMsg = jobErrorMsg
	builder.jobErrorMsgFlag = true
	return builder
}

// 任务状态
//
// 示例值：0
func (builder *ExportJobBuilder) JobStatus(jobStatus int) *ExportJobBuilder {
	builder.jobStatus = jobStatus
	builder.jobStatusFlag = true
	return builder
}

func (builder *ExportJobBuilder) Build() *ExportJob {
	req := &ExportJob{}
	if builder.fileExtensionFlag {
		req.FileExtension = &builder.fileExtension

	}
	if builder.tokenFlag {
		req.Token = &builder.token

	}
	if builder.typeFlag {
		req.Type = &builder.type_

	}
	if builder.fileNameFlag {
		req.FileName = &builder.fileName

	}
	if builder.fileTokenFlag {
		req.FileToken = &builder.fileToken

	}
	if builder.jobErrorMsgFlag {
		req.JobErrorMsg = &builder.jobErrorMsg

	}
	if builder.jobStatusFlag {
		req.JobStatus = &builder.jobStatus

	}
	return req
}

type FileLike struct {
	UserId *string `json:"user_id,omitempty"` // 用户 ID

	LastLikedTime *string `json:"last_liked_time,omitempty"` // 用户最后点赞时间，秒级时间戳

	UserName *string `json:"user_name,omitempty"` // 用户名字，用户信息被脱敏时此值不会返回

	UserEnName *string `json:"user_en_name,omitempty"` // 用户英文名字，用户信息被脱敏时此值不会返回

	UserAvatarUrl *string `json:"user_avatar_url,omitempty"` // 用户头像，用户信息被脱敏时此值不会返回

	UserIsDesensitized *bool `json:"user_is_desensitized,omitempty"` // 用户信息是否脱敏
}

type FileLikeBuilder struct {
	userId     string // 用户 ID
	userIdFlag bool

	lastLikedTime     string // 用户最后点赞时间，秒级时间戳
	lastLikedTimeFlag bool

	userName     string // 用户名字，用户信息被脱敏时此值不会返回
	userNameFlag bool

	userEnName     string // 用户英文名字，用户信息被脱敏时此值不会返回
	userEnNameFlag bool

	userAvatarUrl     string // 用户头像，用户信息被脱敏时此值不会返回
	userAvatarUrlFlag bool

	userIsDesensitized     bool // 用户信息是否脱敏
	userIsDesensitizedFlag bool
}

func NewFileLikeBuilder() *FileLikeBuilder {
	builder := &FileLikeBuilder{}
	return builder
}

// 用户 ID
//
// 示例值：ou_3bbe8a09c20e89cce9bff989ed840674
func (builder *FileLikeBuilder) UserId(userId string) *FileLikeBuilder {
	builder.userId = userId
	builder.userIdFlag = true
	return builder
}

// 用户最后点赞时间，秒级时间戳
//
// 示例值：1690857821
func (builder *FileLikeBuilder) LastLikedTime(lastLikedTime string) *FileLikeBuilder {
	builder.lastLikedTime = lastLikedTime
	builder.lastLikedTimeFlag = true
	return builder
}

// 用户名字，用户信息被脱敏时此值不会返回
//
// 示例值：张三
func (builder *FileLikeBuilder) UserName(userName string) *FileLikeBuilder {
	builder.userName = userName
	builder.userNameFlag = true
	return builder
}

// 用户英文名字，用户信息被脱敏时此值不会返回
//
// 示例值：San Zhang
func (builder *FileLikeBuilder) UserEnName(userEnName string) *FileLikeBuilder {
	builder.userEnName = userEnName
	builder.userEnNameFlag = true
	return builder
}

// 用户头像，用户信息被脱敏时此值不会返回
//
// 示例值：https://foo.icon.com/xxxx
func (builder *FileLikeBuilder) UserAvatarUrl(userAvatarUrl string) *FileLikeBuilder {
	builder.userAvatarUrl = userAvatarUrl
	builder.userAvatarUrlFlag = true
	return builder
}

// 用户信息是否脱敏
//
// 示例值：false
func (builder *FileLikeBuilder) UserIsDesensitized(userIsDesensitized bool) *FileLikeBuilder {
	builder.userIsDesensitized = userIsDesensitized
	builder.userIsDesensitizedFlag = true
	return builder
}

func (builder *FileLikeBuilder) Build() *FileLike {
	req := &FileLike{}
	if builder.userIdFlag {
		req.UserId = &builder.userId

	}
	if builder.lastLikedTimeFlag {
		req.LastLikedTime = &builder.lastLikedTime

	}
	if builder.userNameFlag {
		req.UserName = &builder.userName

	}
	if builder.userEnNameFlag {
		req.UserEnName = &builder.userEnName

	}
	if builder.userAvatarUrlFlag {
		req.UserAvatarUrl = &builder.userAvatarUrl

	}
	if builder.userIsDesensitizedFlag {
		req.UserIsDesensitized = &builder.userIsDesensitized

	}
	return req
}

type ImportJob struct {
	FileExtension *string `json:"file_extension,omitempty"` // 导入文件扩展名

	FileToken *string `json:"file_token,omitempty"` // 导入文件 Drive File Token

	Type *string `json:"type,omitempty"` // 导入文档类型

	FileName *string `json:"file_name,omitempty"` // 导入目标云文档文件名，若为空使用 Drive 文件名

	Point *ImportJobMountPoint `json:"point,omitempty"` // 挂载点

	JobStatus *int `json:"job_status,omitempty"` // 任务状态

	JobErrorMsg *string `json:"job_error_msg,omitempty"` // 任务失败原因

	Token *string `json:"token,omitempty"` // 导入云文档 Token

	Url *string `json:"url,omitempty"` // 导入云文档 URL
}

type ImportJobBuilder struct {
	fileExtension     string // 导入文件扩展名
	fileExtensionFlag bool

	fileToken     string // 导入文件 Drive File Token
	fileTokenFlag bool

	type_    string // 导入文档类型
	typeFlag bool

	fileName     string // 导入目标云文档文件名，若为空使用 Drive 文件名
	fileNameFlag bool

	point     *ImportJobMountPoint // 挂载点
	pointFlag bool

	jobStatus     int // 任务状态
	jobStatusFlag bool

	jobErrorMsg     string // 任务失败原因
	jobErrorMsgFlag bool

	token     string // 导入云文档 Token
	tokenFlag bool

	url     string // 导入云文档 URL
	urlFlag bool
}

func NewImportJobBuilder() *ImportJobBuilder {
	builder := &ImportJobBuilder{}
	return builder
}

// 导入文件扩展名
//
// 示例值：larkdoc
func (builder *ImportJobBuilder) FileExtension(fileExtension string) *ImportJobBuilder {
	builder.fileExtension = fileExtension
	builder.fileExtensionFlag = true
	return builder
}

// 导入文件 Drive File Token
//
// 示例值：boxcnxe5OxxxxxxxSNdsJviENsk
func (builder *ImportJobBuilder) FileToken(fileToken string) *ImportJobBuilder {
	builder.fileToken = fileToken
	builder.fileTokenFlag = true
	return builder
}

// 导入文档类型
//
// 示例值：sheet
func (builder *ImportJobBuilder) Type(type_ string) *ImportJobBuilder {
	builder.type_ = type_
	builder.typeFlag = true
	return builder
}

// 导入目标云文档文件名，若为空使用 Drive 文件名
//
// 示例值：test
func (builder *ImportJobBuilder) FileName(fileName string) *ImportJobBuilder {
	builder.fileName = fileName
	builder.fileNameFlag = true
	return builder
}

// 挂载点
//
// 示例值：
func (builder *ImportJobBuilder) Point(point *ImportJobMountPoint) *ImportJobBuilder {
	builder.point = point
	builder.pointFlag = true
	return builder
}

// 任务状态
//
// 示例值：
func (builder *ImportJobBuilder) JobStatus(jobStatus int) *ImportJobBuilder {
	builder.jobStatus = jobStatus
	builder.jobStatusFlag = true
	return builder
}

// 任务失败原因
//
// 示例值：success
func (builder *ImportJobBuilder) JobErrorMsg(jobErrorMsg string) *ImportJobBuilder {
	builder.jobErrorMsg = jobErrorMsg
	builder.jobErrorMsgFlag = true
	return builder
}

// 导入云文档 Token
//
// 示例值：shtcnVBTG6SuxxxxxxxkM2tUX
func (builder *ImportJobBuilder) Token(token string) *ImportJobBuilder {
	builder.token = token
	builder.tokenFlag = true
	return builder
}

// 导入云文档 URL
//
// 示例值：https://example.feishu.cn/sheets/shtcnVBTG6SuxxxxxxxkM2tUX
func (builder *ImportJobBuilder) Url(url string) *ImportJobBuilder {
	builder.url = url
	builder.urlFlag = true
	return builder
}

func (builder *ImportJobBuilder) Build() *ImportJob {
	req := &ImportJob{}
	if builder.fileExtensionFlag {
		req.FileExtension = &builder.fileExtension

	}
	if builder.fileTokenFlag {
		req.FileToken = &builder.fileToken

	}
	if builder.typeFlag {
		req.Type = &builder.type_

	}
	if builder.fileNameFlag {
		req.FileName = &builder.fileName

	}
	if builder.pointFlag {
		req.Point = builder.point
	}
	if builder.jobStatusFlag {
		req.JobStatus = &builder.jobStatus

	}
	if builder.jobErrorMsgFlag {
		req.JobErrorMsg = &builder.jobErrorMsg

	}
	if builder.tokenFlag {
		req.Token = &builder.token

	}
	if builder.urlFlag {
		req.Url = &builder.url

	}
	return req
}

type ImportJobMountPoint struct {
	MountType *int `json:"mount_type,omitempty"` // 挂载类型

	MountKey *string `json:"mount_key,omitempty"` // 挂载位置，对于 mount_type=1 ，云空间目录 Token ，空表示根目录
}

type ImportJobMountPointBuilder struct {
	mountType     int // 挂载类型
	mountTypeFlag bool

	mountKey     string // 挂载位置，对于 mount_type=1 ，云空间目录 Token ，空表示根目录
	mountKeyFlag bool
}

func NewImportJobMountPointBuilder() *ImportJobMountPointBuilder {
	builder := &ImportJobMountPointBuilder{}
	return builder
}

// 挂载类型
//
// 示例值：
func (builder *ImportJobMountPointBuilder) MountType(mountType int) *ImportJobMountPointBuilder {
	builder.mountType = mountType
	builder.mountTypeFlag = true
	return builder
}

// 挂载位置，对于 mount_type=1 ，云空间目录 Token ，空表示根目录
//
// 示例值：Y1HiwCGd8iOYixkLRUvb6viVcoZ
func (builder *ImportJobMountPointBuilder) MountKey(mountKey string) *ImportJobMountPointBuilder {
	builder.mountKey = mountKey
	builder.mountKeyFlag = true
	return builder
}

func (builder *ImportJobMountPointBuilder) Build() *ImportJobMountPoint {
	req := &ImportJobMountPoint{}
	if builder.mountTypeFlag {
		req.MountType = &builder.mountType

	}
	if builder.mountKeyFlag {
		req.MountKey = &builder.mountKey

	}
	return req
}

type MyLike struct {
	LastLikedTime *string `json:"last_liked_time,omitempty"` // 用户最后点赞时间，秒级时间戳

	FileToken *string `json:"file_token,omitempty"` // 点赞的文件 token

	FileType *string `json:"file_type,omitempty"` // 点赞的文件类型

	FileName *string `json:"file_name,omitempty"` // 点赞的文件名，无文件阅读权限时不返回此字段

	FileUrl *string `json:"file_url,omitempty"` // 点赞的文件链接，无文件阅读权限时不返回此字段

	FileIsDeleted *bool `json:"file_is_deleted,omitempty"` // 点赞的文件是否已被删除
}

type MyLikeBuilder struct {
	lastLikedTime     string // 用户最后点赞时间，秒级时间戳
	lastLikedTimeFlag bool

	fileToken     string // 点赞的文件 token
	fileTokenFlag bool

	fileType     string // 点赞的文件类型
	fileTypeFlag bool

	fileName     string // 点赞的文件名，无文件阅读权限时不返回此字段
	fileNameFlag bool

	fileUrl     string // 点赞的文件链接，无文件阅读权限时不返回此字段
	fileUrlFlag bool

	fileIsDeleted     bool // 点赞的文件是否已被删除
	fileIsDeletedFlag bool
}

func NewMyLikeBuilder() *MyLikeBuilder {
	builder := &MyLikeBuilder{}
	return builder
}

// 用户最后点赞时间，秒级时间戳
//
// 示例值：1690857821
func (builder *MyLikeBuilder) LastLikedTime(lastLikedTime string) *MyLikeBuilder {
	builder.lastLikedTime = lastLikedTime
	builder.lastLikedTimeFlag = true
	return builder
}

// 点赞的文件 token
//
// 示例值：J6Lddz22AovnqkxWEXBcUJIingx
func (builder *MyLikeBuilder) FileToken(fileToken string) *MyLikeBuilder {
	builder.fileToken = fileToken
	builder.fileTokenFlag = true
	return builder
}

// 点赞的文件类型
//
// 示例值：doc
func (builder *MyLikeBuilder) FileType(fileType string) *MyLikeBuilder {
	builder.fileType = fileType
	builder.fileTypeFlag = true
	return builder
}

// 点赞的文件名，无文件阅读权限时不返回此字段
//
// 示例值：title
func (builder *MyLikeBuilder) FileName(fileName string) *MyLikeBuilder {
	builder.fileName = fileName
	builder.fileNameFlag = true
	return builder
}

// 点赞的文件链接，无文件阅读权限时不返回此字段
//
// 示例值：https://sample.feishu.cn/docs/doccnfYZzTlvXqZIGTdAHKabcef
func (builder *MyLikeBuilder) FileUrl(fileUrl string) *MyLikeBuilder {
	builder.fileUrl = fileUrl
	builder.fileUrlFlag = true
	return builder
}

// 点赞的文件是否已被删除
//
// 示例值：false
func (builder *MyLikeBuilder) FileIsDeleted(fileIsDeleted bool) *MyLikeBuilder {
	builder.fileIsDeleted = fileIsDeleted
	builder.fileIsDeletedFlag = true
	return builder
}

func (builder *MyLikeBuilder) Build() *MyLike {
	req := &MyLike{}
	if builder.lastLikedTimeFlag {
		req.LastLikedTime = &builder.lastLikedTime

	}
	if builder.fileTokenFlag {
		req.FileToken = &builder.fileToken

	}
	if builder.fileTypeFlag {
		req.FileType = &builder.fileType

	}
	if builder.fileNameFlag {
		req.FileName = &builder.fileName

	}
	if builder.fileUrlFlag {
		req.FileUrl = &builder.fileUrl

	}
	if builder.fileIsDeletedFlag {
		req.FileIsDeleted = &builder.fileIsDeleted

	}
	return req
}

type PermissionPublic struct {
	ExternalAccessEntity *string `json:"external_access_entity,omitempty"` // 允许内容被分享到组织外

	SecurityEntity *string `json:"security_entity,omitempty"` // 谁可以创建副本、打印、下载

	CommentEntity *string `json:"comment_entity,omitempty"` // 谁可以评论

	ShareEntity *string `json:"share_entity,omitempty"` // 谁可以添加和管理协作者-组织维度

	ManageCollaboratorEntity *string `json:"manage_collaborator_entity,omitempty"` // 谁可以添加和管理协作者-协作者维度

	LinkShareEntity *string `json:"link_share_entity,omitempty"` // 链接分享设置

	CopyEntity *string `json:"copy_entity,omitempty"` // 谁可以复制内容

	LockSwitch *bool `json:"lock_switch,omitempty"` // 节点是否已加锁，加锁之后不再继承父级页面的权限
}

type PermissionPublicBuilder struct {
	externalAccessEntity     string // 允许内容被分享到组织外
	externalAccessEntityFlag bool

	securityEntity     string // 谁可以创建副本、打印、下载
	securityEntityFlag bool

	commentEntity     string // 谁可以评论
	commentEntityFlag bool

	shareEntity     string // 谁可以添加和管理协作者-组织维度
	shareEntityFlag bool

	manageCollaboratorEntity     string // 谁可以添加和管理协作者-协作者维度
	manageCollaboratorEntityFlag bool

	linkShareEntity     string // 链接分享设置
	linkShareEntityFlag bool

	copyEntity     string // 谁可以复制内容
	copyEntityFlag bool

	lockSwitch     bool // 节点是否已加锁，加锁之后不再继承父级页面的权限
	lockSwitchFlag bool
}

func NewPermissionPublicBuilder() *PermissionPublicBuilder {
	builder := &PermissionPublicBuilder{}
	return builder
}

// 允许内容被分享到组织外
//
// 示例值：open
func (builder *PermissionPublicBuilder) ExternalAccessEntity(externalAccessEntity string) *PermissionPublicBuilder {
	builder.externalAccessEntity = externalAccessEntity
	builder.externalAccessEntityFlag = true
	return builder
}

// 谁可以创建副本、打印、下载
//
// 示例值：anyone_can_view
func (builder *PermissionPublicBuilder) SecurityEntity(securityEntity string) *PermissionPublicBuilder {
	builder.securityEntity = securityEntity
	builder.securityEntityFlag = true
	return builder
}

// 谁可以评论
//
// 示例值：anyone_can_view
func (builder *PermissionPublicBuilder) CommentEntity(commentEntity string) *PermissionPublicBuilder {
	builder.commentEntity = commentEntity
	builder.commentEntityFlag = true
	return builder
}

// 谁可以添加和管理协作者-组织维度
//
// 示例值：anyone
func (builder *PermissionPublicBuilder) ShareEntity(shareEntity string) *PermissionPublicBuilder {
	builder.shareEntity = shareEntity
	builder.shareEntityFlag = true
	return builder
}

// 谁可以添加和管理协作者-协作者维度
//
// 示例值：collaborator_can_view
func (builder *PermissionPublicBuilder) ManageCollaboratorEntity(manageCollaboratorEntity string) *PermissionPublicBuilder {
	builder.manageCollaboratorEntity = manageCollaboratorEntity
	builder.manageCollaboratorEntityFlag = true
	return builder
}

// 链接分享设置
//
// 示例值：tenant_readable
func (builder *PermissionPublicBuilder) LinkShareEntity(linkShareEntity string) *PermissionPublicBuilder {
	builder.linkShareEntity = linkShareEntity
	builder.linkShareEntityFlag = true
	return builder
}

// 谁可以复制内容
//
// 示例值：anyone_can_view
func (builder *PermissionPublicBuilder) CopyEntity(copyEntity string) *PermissionPublicBuilder {
	builder.copyEntity = copyEntity
	builder.copyEntityFlag = true
	return builder
}

// 节点是否已加锁，加锁之后不再继承父级页面的权限
//
// 示例值：false
func (builder *PermissionPublicBuilder) LockSwitch(lockSwitch bool) *PermissionPublicBuilder {
	builder.lockSwitch = lockSwitch
	builder.lockSwitchFlag = true
	return builder
}

func (builder *PermissionPublicBuilder) Build() *PermissionPublic {
	req := &PermissionPublic{}
	if builder.externalAccessEntityFlag {
		req.ExternalAccessEntity = &builder.externalAccessEntity

	}
	if builder.securityEntityFlag {
		req.SecurityEntity = &builder.securityEntity

	}
	if builder.commentEntityFlag {
		req.CommentEntity = &builder.commentEntity

	}
	if builder.shareEntityFlag {
		req.ShareEntity = &builder.shareEntity

	}
	if builder.manageCollaboratorEntityFlag {
		req.ManageCollaboratorEntity = &builder.manageCollaboratorEntity

	}
	if builder.linkShareEntityFlag {
		req.LinkShareEntity = &builder.linkShareEntity

	}
	if builder.copyEntityFlag {
		req.CopyEntity = &builder.copyEntity

	}
	if builder.lockSwitchFlag {
		req.LockSwitch = &builder.lockSwitch

	}
	return req
}

type QuotaDetail struct {
	UserInfo *UserInfo `json:"user_info,omitempty"` // 用户信息

	DepartmentInfo []*DepartmentInfo `json:"department_info,omitempty"` // 部门

	BizLists []*BizInfo `json:"biz_lists,omitempty"` // 每个业务的使用量列表
}

type QuotaDetailBuilder struct {
	userInfo     *UserInfo // 用户信息
	userInfoFlag bool

	departmentInfo     []*DepartmentInfo // 部门
	departmentInfoFlag bool

	bizLists     []*BizInfo // 每个业务的使用量列表
	bizListsFlag bool
}

func NewQuotaDetailBuilder() *QuotaDetailBuilder {
	builder := &QuotaDetailBuilder{}
	return builder
}

// 用户信息
//
// 示例值：
func (builder *QuotaDetailBuilder) UserInfo(userInfo *UserInfo) *QuotaDetailBuilder {
	builder.userInfo = userInfo
	builder.userInfoFlag = true
	return builder
}

// 部门
//
// 示例值：
func (builder *QuotaDetailBuilder) DepartmentInfo(departmentInfo []*DepartmentInfo) *QuotaDetailBuilder {
	builder.departmentInfo = departmentInfo
	builder.departmentInfoFlag = true
	return builder
}

// 每个业务的使用量列表
//
// 示例值：
func (builder *QuotaDetailBuilder) BizLists(bizLists []*BizInfo) *QuotaDetailBuilder {
	builder.bizLists = bizLists
	builder.bizListsFlag = true
	return builder
}

func (builder *QuotaDetailBuilder) Build() *QuotaDetail {
	req := &QuotaDetail{}
	if builder.userInfoFlag {
		req.UserInfo = builder.userInfo
	}
	if builder.departmentInfoFlag {
		req.DepartmentInfo = builder.departmentInfo
	}
	if builder.bizListsFlag {
		req.BizLists = builder.bizLists
	}
	return req
}

type SecureLabel struct {
	Id *string `json:"id,omitempty"` // 密级标签 ID

	Name *string `json:"name,omitempty"` // 密级标签名称
}

type SecureLabelBuilder struct {
	id     string // 密级标签 ID
	idFlag bool

	name     string // 密级标签名称
	nameFlag bool
}

func NewSecureLabelBuilder() *SecureLabelBuilder {
	builder := &SecureLabelBuilder{}
	return builder
}

// 密级标签 ID
//
// 示例值：7217780879644737540
func (builder *SecureLabelBuilder) Id(id string) *SecureLabelBuilder {
	builder.id = id
	builder.idFlag = true
	return builder
}

// 密级标签名称
//
// 示例值：L1
func (builder *SecureLabelBuilder) Name(name string) *SecureLabelBuilder {
	builder.name = name
	builder.nameFlag = true
	return builder
}

func (builder *SecureLabelBuilder) Build() *SecureLabel {
	req := &SecureLabel{}
	if builder.idFlag {
		req.Id = &builder.id

	}
	if builder.nameFlag {
		req.Name = &builder.name

	}
	return req
}

type StorageTask struct {
	PolicyId *int `json:"policy_id,omitempty"` // 策略ID，固定1100

	TaskName *string `json:"task_name,omitempty"` // 清理任务名称

	Config *TaskConfig `json:"config,omitempty"` // 任务条件

	TrashRemainDays *int `json:"trash_remain_days,omitempty"` // 回收站保留时间
}

type StorageTaskBuilder struct {
	policyId     int // 策略ID，固定1100
	policyIdFlag bool

	taskName     string // 清理任务名称
	taskNameFlag bool

	config     *TaskConfig // 任务条件
	configFlag bool

	trashRemainDays     int // 回收站保留时间
	trashRemainDaysFlag bool
}

func NewStorageTaskBuilder() *StorageTaskBuilder {
	builder := &StorageTaskBuilder{}
	return builder
}

// 策略ID，固定1100
//
// 示例值：1100
func (builder *StorageTaskBuilder) PolicyId(policyId int) *StorageTaskBuilder {
	builder.policyId = policyId
	builder.policyIdFlag = true
	return builder
}

// 清理任务名称
//
// 示例值：清理任务1
func (builder *StorageTaskBuilder) TaskName(taskName string) *StorageTaskBuilder {
	builder.taskName = taskName
	builder.taskNameFlag = true
	return builder
}

// 任务条件
//
// 示例值：
func (builder *StorageTaskBuilder) Config(config *TaskConfig) *StorageTaskBuilder {
	builder.config = config
	builder.configFlag = true
	return builder
}

// 回收站保留时间
//
// 示例值：30
func (builder *StorageTaskBuilder) TrashRemainDays(trashRemainDays int) *StorageTaskBuilder {
	builder.trashRemainDays = trashRemainDays
	builder.trashRemainDaysFlag = true
	return builder
}

func (builder *StorageTaskBuilder) Build() *StorageTask {
	req := &StorageTask{}
	if builder.policyIdFlag {
		req.PolicyId = &builder.policyId

	}
	if builder.taskNameFlag {
		req.TaskName = &builder.taskName

	}
	if builder.configFlag {
		req.Config = builder.config
	}
	if builder.trashRemainDaysFlag {
		req.TrashRemainDays = &builder.trashRemainDays

	}
	return req
}

type TaskConfig struct {
	Includes []*Condition `json:"includes,omitempty"` // 被圈选的用户范围

	Excludes []*Condition `json:"excludes,omitempty"` // 白名单，即被剔除的用户范围
}

type TaskConfigBuilder struct {
	includes     []*Condition // 被圈选的用户范围
	includesFlag bool

	excludes     []*Condition // 白名单，即被剔除的用户范围
	excludesFlag bool
}

func NewTaskConfigBuilder() *TaskConfigBuilder {
	builder := &TaskConfigBuilder{}
	return builder
}

// 被圈选的用户范围
//
// 示例值：
func (builder *TaskConfigBuilder) Includes(includes []*Condition) *TaskConfigBuilder {
	builder.includes = includes
	builder.includesFlag = true
	return builder
}

// 白名单，即被剔除的用户范围
//
// 示例值：
func (builder *TaskConfigBuilder) Excludes(excludes []*Condition) *TaskConfigBuilder {
	builder.excludes = excludes
	builder.excludesFlag = true
	return builder
}

func (builder *TaskConfigBuilder) Build() *TaskConfig {
	req := &TaskConfig{}
	if builder.includesFlag {
		req.Includes = builder.includes
	}
	if builder.excludesFlag {
		req.Excludes = builder.excludes
	}
	return req
}

type UserInfo struct {
	UserName *string `json:"user_name,omitempty"` // 用户姓名

	AvatarUrl *string `json:"avatar_url,omitempty"` // 头像url

	Status *int `json:"status,omitempty"` // 用户状态，用二进制的位表示，总共6bit（如111111），从左到右，每个标识位分别代表：未加入，主动退出，设置自定义头像，未激活 ，离职，冻结。如返回satus=2，其二进制为000010，表示该员工已离职

	EmployeeId *string `json:"employee_id,omitempty"` // 雇员id
}

type UserInfoBuilder struct {
	userName     string // 用户姓名
	userNameFlag bool

	avatarUrl     string // 头像url
	avatarUrlFlag bool

	status     int // 用户状态，用二进制的位表示，总共6bit（如111111），从左到右，每个标识位分别代表：未加入，主动退出，设置自定义头像，未激活 ，离职，冻结。如返回satus=2，其二进制为000010，表示该员工已离职
	statusFlag bool

	employeeId     string // 雇员id
	employeeIdFlag bool
}

func NewUserInfoBuilder() *UserInfoBuilder {
	builder := &UserInfoBuilder{}
	return builder
}

// 用户姓名
//
// 示例值：张三
func (builder *UserInfoBuilder) UserName(userName string) *UserInfoBuilder {
	builder.userName = userName
	builder.userNameFlag = true
	return builder
}

// 头像url
//
// 示例值：https://xxx.feishu.cn/static-resource/v1/xxx
func (builder *UserInfoBuilder) AvatarUrl(avatarUrl string) *UserInfoBuilder {
	builder.avatarUrl = avatarUrl
	builder.avatarUrlFlag = true
	return builder
}

// 用户状态，用二进制的位表示，总共6bit（如111111），从左到右，每个标识位分别代表：未加入，主动退出，设置自定义头像，未激活 ，离职，冻结。如返回satus=2，其二进制为000010，表示该员工已离职
//
// 示例值：1
func (builder *UserInfoBuilder) Status(status int) *UserInfoBuilder {
	builder.status = status
	builder.statusFlag = true
	return builder
}

// 雇员id
//
// 示例值：153dfegf
func (builder *UserInfoBuilder) EmployeeId(employeeId string) *UserInfoBuilder {
	builder.employeeId = employeeId
	builder.employeeIdFlag = true
	return builder
}

func (builder *UserInfoBuilder) Build() *UserInfo {
	req := &UserInfo{}
	if builder.userNameFlag {
		req.UserName = &builder.userName

	}
	if builder.avatarUrlFlag {
		req.AvatarUrl = &builder.avatarUrl

	}
	if builder.statusFlag {
		req.Status = &builder.status

	}
	if builder.employeeIdFlag {
		req.EmployeeId = &builder.employeeId

	}
	return req
}

type ListFileLikeReqBuilder struct {
	apiReq *larkcore.ApiReq
	limit  int // 最大返回多少记录，当使用迭代器访问时才有效
}

func NewListFileLikeReqBuilder() *ListFileLikeReqBuilder {
	builder := &ListFileLikeReqBuilder{}
	builder.apiReq = &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	return builder
}

// 最大返回多少记录，当使用迭代器访问时才有效
func (builder *ListFileLikeReqBuilder) Limit(limit int) *ListFileLikeReqBuilder {
	builder.limit = limit
	return builder
}

// 需要查询点赞列表的文件 token
//
// 示例值：J6Lddz22AovnqkxWEXBcUJIingx
func (builder *ListFileLikeReqBuilder) FileToken(fileToken string) *ListFileLikeReqBuilder {
	builder.apiReq.PathParams.Set("file_token", fmt.Sprint(fileToken))
	return builder
}

// 文件类型，如果该值为空或者与文件实际类型不匹配，接口会返回失败。
//
// 示例值：doc
func (builder *ListFileLikeReqBuilder) FileType(fileType string) *ListFileLikeReqBuilder {
	builder.apiReq.QueryParams.Set("file_type", fmt.Sprint(fileType))
	return builder
}

// 分页大小
//
// 示例值：10
func (builder *ListFileLikeReqBuilder) PageSize(pageSize int) *ListFileLikeReqBuilder {
	builder.apiReq.QueryParams.Set("page_size", fmt.Sprint(pageSize))
	return builder
}

// 分页标记，第一次请求不填，表示从头开始遍历；分页查询结果还有更多项时会同时返回新的 page_token，下次遍历可采用该 page_token 获取查询结果
//
// 示例值：aw7DoMKBFMOGwqHCrcO8w6jCmMOvw6ILeADCvsKNw57Di8O5XGV3LG4_w5HCqhFxSnDCrCzCn0BgZcOYUg85EMOYcEAcwqYOw4ojw5QFwofCu8KoIMO3K8Ktw4IuNMOBBHNYw4bCgCV3U1zDu8K-J8KSR8Kgw7Y0fsKZdsKvW3d9w53DnkHDrcO5bDkYwrvDisOEPcOtVFJ-I03CnsOILMOoAmLDknd6dsKqG1bClAjDuS3CvcOTwo7Dg8OrwovDsRdqIcKxw5HDohTDtXN9w5rCkWo
func (builder *ListFileLikeReqBuilder) PageToken(pageToken string) *ListFileLikeReqBuilder {
	builder.apiReq.QueryParams.Set("page_token", fmt.Sprint(pageToken))
	return builder
}

// 此次调用中使用的用户ID的类型
//
// 示例值：
func (builder *ListFileLikeReqBuilder) UserIdType(userIdType string) *ListFileLikeReqBuilder {
	builder.apiReq.QueryParams.Set("user_id_type", fmt.Sprint(userIdType))
	return builder
}

func (builder *ListFileLikeReqBuilder) Build() *ListFileLikeReq {
	req := &ListFileLikeReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.Limit = builder.limit
	req.apiReq.PathParams = builder.apiReq.PathParams
	req.apiReq.QueryParams = builder.apiReq.QueryParams
	return req
}

type ListFileLikeReq struct {
	apiReq *larkcore.ApiReq
	Limit  int // 最多返回多少记录，只有在使用迭代器访问时，才有效

}

type ListFileLikeRespData struct {
	Items []*FileLike `json:"items,omitempty"` // 文件的点赞者列表

	PageToken *string `json:"page_token,omitempty"` // 分页标记，当 has_more 为 true 时，会同时返回新的 page_token，否则不返回 page_token

	HasMore *bool `json:"has_more,omitempty"` // 是否还有更多点赞记录
}

type ListFileLikeResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
	Data *ListFileLikeRespData `json:"data"` // 业务数据
}

func (resp *ListFileLikeResp) Success() bool {
	return resp.Code == 0
}

type GetPermissionPublicReqBuilder struct {
	apiReq *larkcore.ApiReq
}

func NewGetPermissionPublicReqBuilder() *GetPermissionPublicReqBuilder {
	builder := &GetPermissionPublicReqBuilder{}
	builder.apiReq = &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	return builder
}

// 文件的 token
//
// 示例值：doccnBKgoMyY5OMbUG6FioTXuBe
func (builder *GetPermissionPublicReqBuilder) Token(token string) *GetPermissionPublicReqBuilder {
	builder.apiReq.PathParams.Set("token", fmt.Sprint(token))
	return builder
}

// 文件类型，需要与文件的 token 相匹配
//
// 示例值：doc
func (builder *GetPermissionPublicReqBuilder) Type(type_ string) *GetPermissionPublicReqBuilder {
	builder.apiReq.QueryParams.Set("type", fmt.Sprint(type_))
	return builder
}

func (builder *GetPermissionPublicReqBuilder) Build() *GetPermissionPublicReq {
	req := &GetPermissionPublicReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.PathParams = builder.apiReq.PathParams
	req.apiReq.QueryParams = builder.apiReq.QueryParams
	return req
}

type GetPermissionPublicReq struct {
	apiReq *larkcore.ApiReq
}

type GetPermissionPublicRespData struct {
	PermissionPublic *PermissionPublic `json:"permission_public,omitempty"` // 返回的文档公共设置
}

type GetPermissionPublicResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
	Data *GetPermissionPublicRespData `json:"data"` // 业务数据
}

func (resp *GetPermissionPublicResp) Success() bool {
	return resp.Code == 0
}

type PatchPermissionPublicReqBuilder struct {
	apiReq           *larkcore.ApiReq
	permissionPublic *PermissionPublic
}

func NewPatchPermissionPublicReqBuilder() *PatchPermissionPublicReqBuilder {
	builder := &PatchPermissionPublicReqBuilder{}
	builder.apiReq = &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	return builder
}

// 文件的 token
//
// 示例值：doccnBKgoMyY5OMbUG6FioTXuBe
func (builder *PatchPermissionPublicReqBuilder) Token(token string) *PatchPermissionPublicReqBuilder {
	builder.apiReq.PathParams.Set("token", fmt.Sprint(token))
	return builder
}

// 文件类型，需要与文件的 token 相匹配
//
// 示例值：doc
func (builder *PatchPermissionPublicReqBuilder) Type(type_ string) *PatchPermissionPublicReqBuilder {
	builder.apiReq.QueryParams.Set("type", fmt.Sprint(type_))
	return builder
}

//
func (builder *PatchPermissionPublicReqBuilder) PermissionPublic(permissionPublic *PermissionPublic) *PatchPermissionPublicReqBuilder {
	builder.permissionPublic = permissionPublic
	return builder
}

func (builder *PatchPermissionPublicReqBuilder) Build() *PatchPermissionPublicReq {
	req := &PatchPermissionPublicReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.PathParams = builder.apiReq.PathParams
	req.apiReq.QueryParams = builder.apiReq.QueryParams
	req.apiReq.Body = builder.permissionPublic
	return req
}

type PatchPermissionPublicReq struct {
	apiReq           *larkcore.ApiReq
	PermissionPublic *PermissionPublic `body:""`
}

type PatchPermissionPublicRespData struct {
	PermissionPublic *PermissionPublic `json:"permission_public,omitempty"` // 本次更新后文档公共设置
}

type PatchPermissionPublicResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
	Data *PatchPermissionPublicRespData `json:"data"` // 业务数据
}

func (resp *PatchPermissionPublicResp) Success() bool {
	return resp.Code == 0
}

type ListFileLikeIterator struct {
	nextPageToken *string
	items         []*FileLike
	index         int
	limit         int
	ctx           context.Context
	req           *ListFileLikeReq
	listFunc      func(ctx context.Context, req *ListFileLikeReq, options ...larkcore.RequestOptionFunc) (*ListFileLikeResp, error)
	options       []larkcore.RequestOptionFunc
	curlNum       int
}

func (iterator *ListFileLikeIterator) Next() (bool, *FileLike, error) {
	// 达到最大量，则返回
	if iterator.limit > 0 && iterator.curlNum >= iterator.limit {
		return false, nil, nil
	}

	// 为0则拉取数据
	if iterator.index == 0 || iterator.index >= len(iterator.items) {
		if iterator.index != 0 && iterator.nextPageToken == nil {
			return false, nil, nil
		}
		if iterator.nextPageToken != nil {
			iterator.req.apiReq.QueryParams.Set("page_token", *iterator.nextPageToken)
		}
		resp, err := iterator.listFunc(iterator.ctx, iterator.req, iterator.options...)
		if err != nil {
			return false, nil, err
		}

		if resp.Code != 0 {
			return false, nil, errors.New(fmt.Sprintf("Code:%d,Msg:%s", resp.Code, resp.Msg))
		}

		if len(resp.Data.Items) == 0 {
			return false, nil, nil
		}

		iterator.nextPageToken = resp.Data.PageToken
		iterator.items = resp.Data.Items
		iterator.index = 0
	}

	block := iterator.items[iterator.index]
	iterator.index++
	iterator.curlNum++
	return true, block, nil
}

func (iterator *ListFileLikeIterator) NextPageToken() *string {
	return iterator.nextPageToken
}
