// Package baike 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 larkbaike

import (
	"io"

	"io/ioutil"

	"fmt"

	"context"
	"errors"

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

const (
	UserIdTypeUserId  = "user_id"  // 以user_id来识别用户
	UserIdTypeUnionId = "union_id" // 以union_id来识别用户
	UserIdTypeOpenId  = "open_id"  // 以open_id来识别用户
)

const (
	UserIdTypeUpdateDraftUserId  = "user_id"  // 以user_id来识别用户
	UserIdTypeUpdateDraftUnionId = "union_id" // 以union_id来识别用户
	UserIdTypeUpdateDraftOpenId  = "open_id"  // 以open_id来识别用户
)

const (
	UserIdTypeCreateEntityUserId  = "user_id"  // 以user_id来识别用户
	UserIdTypeCreateEntityUnionId = "union_id" // 以union_id来识别用户
	UserIdTypeCreateEntityOpenId  = "open_id"  // 以open_id来识别用户
)

const (
	UserIdTypeGetEntityUserId  = "user_id"  // 以user_id来识别用户
	UserIdTypeGetEntityUnionId = "union_id" // 以union_id来识别用户
	UserIdTypeGetEntityOpenId  = "open_id"  // 以open_id来识别用户
)

const (
	UserIdTypeListEntityUserId  = "user_id"  // 以user_id来识别用户
	UserIdTypeListEntityUnionId = "union_id" // 以union_id来识别用户
	UserIdTypeListEntityOpenId  = "open_id"  // 以open_id来识别用户
)

const (
	UserIdTypeSearchEntityUserId  = "user_id"  // 以user_id来识别用户
	UserIdTypeSearchEntityUnionId = "union_id" // 以union_id来识别用户
	UserIdTypeSearchEntityOpenId  = "open_id"  // 以open_id来识别用户
)

const (
	UserIdTypeUpdateEntityUserId  = "user_id"  // 以user_id来识别用户
	UserIdTypeUpdateEntityUnionId = "union_id" // 以union_id来识别用户
	UserIdTypeUpdateEntityOpenId  = "open_id"  // 以open_id来识别用户
)

type Abbreviation struct {
	Id *string `json:"id,omitempty"` // 相关词条 ID
}

type AbbreviationBuilder struct {
	id     string // 相关词条 ID
	idFlag bool
}

func NewAbbreviationBuilder() *AbbreviationBuilder {
	builder := &AbbreviationBuilder{}
	return builder
}

// 相关词条 ID
//
// 示例值：enterprise_51587960
func (builder *AbbreviationBuilder) Id(id string) *AbbreviationBuilder {
	builder.id = id
	builder.idFlag = true
	return builder
}

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

	}
	return req
}

type BaikeImage struct {
	Token *string `json:"token,omitempty"` // 通过文件接口上传图片后，获得的图片 token
}

type BaikeImageBuilder struct {
	token     string // 通过文件接口上传图片后，获得的图片 token
	tokenFlag bool
}

func NewBaikeImageBuilder() *BaikeImageBuilder {
	builder := &BaikeImageBuilder{}
	return builder
}

// 通过文件接口上传图片后，获得的图片 token
//
// 示例值：boxbcEcmKiD3SGHvgqWTpvdc7jc
func (builder *BaikeImageBuilder) Token(token string) *BaikeImageBuilder {
	builder.token = token
	builder.tokenFlag = true
	return builder
}

func (builder *BaikeImageBuilder) Build() *BaikeImage {
	req := &BaikeImage{}
	if builder.tokenFlag {
		req.Token = &builder.token

	}
	return req
}

type Classification struct {
	Id *string `json:"id,omitempty"` // 二级分类 ID

	Name *string `json:"name,omitempty"` // 二级分类名称

	FatherId *string `json:"father_id,omitempty"` // 对应一级分类 ID
}

type ClassificationBuilder struct {
	id     string // 二级分类 ID
	idFlag bool

	name     string // 二级分类名称
	nameFlag bool

	fatherId     string // 对应一级分类 ID
	fatherIdFlag bool
}

func NewClassificationBuilder() *ClassificationBuilder {
	builder := &ClassificationBuilder{}
	return builder
}

// 二级分类 ID
//
// 示例值：7049606926702837761
func (builder *ClassificationBuilder) Id(id string) *ClassificationBuilder {
	builder.id = id
	builder.idFlag = true
	return builder
}

// 二级分类名称
//
// 示例值：行业术语
func (builder *ClassificationBuilder) Name(name string) *ClassificationBuilder {
	builder.name = name
	builder.nameFlag = true
	return builder
}

// 对应一级分类 ID
//
// 示例值：7049606926702837777
func (builder *ClassificationBuilder) FatherId(fatherId string) *ClassificationBuilder {
	builder.fatherId = fatherId
	builder.fatherIdFlag = true
	return builder
}

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

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

	}
	if builder.fatherIdFlag {
		req.FatherId = &builder.fatherId

	}
	return req
}

type ClassificationFilter struct {
	Include []string `json:"include,omitempty"` // 需要获取的分类

	Exclude []string `json:"exclude,omitempty"` // 需要排除的分类
}

type ClassificationFilterBuilder struct {
	include     []string // 需要获取的分类
	includeFlag bool

	exclude     []string // 需要排除的分类
	excludeFlag bool
}

func NewClassificationFilterBuilder() *ClassificationFilterBuilder {
	builder := &ClassificationFilterBuilder{}
	return builder
}

// 需要获取的分类
//
// 示例值：
func (builder *ClassificationFilterBuilder) Include(include []string) *ClassificationFilterBuilder {
	builder.include = include
	builder.includeFlag = true
	return builder
}

// 需要排除的分类
//
// 示例值：
func (builder *ClassificationFilterBuilder) Exclude(exclude []string) *ClassificationFilterBuilder {
	builder.exclude = exclude
	builder.excludeFlag = true
	return builder
}

func (builder *ClassificationFilterBuilder) Build() *ClassificationFilter {
	req := &ClassificationFilter{}
	if builder.includeFlag {
		req.Include = builder.include
	}
	if builder.excludeFlag {
		req.Exclude = builder.exclude
	}
	return req
}

type CorrectError struct {
	Type *int `json:"type,omitempty"` //

	Total *int `json:"total,omitempty"` // 该类型错误在请求时间周期内的累计数量

	CorrectPairs []*CorrectPair `json:"correct_pairs,omitempty"` // 该类型错误在周期内具体的纠错对
}

type CorrectErrorBuilder struct {
	type_    int //
	typeFlag bool

	total     int // 该类型错误在请求时间周期内的累计数量
	totalFlag bool

	correctPairs     []*CorrectPair // 该类型错误在周期内具体的纠错对
	correctPairsFlag bool
}

func NewCorrectErrorBuilder() *CorrectErrorBuilder {
	builder := &CorrectErrorBuilder{}
	return builder
}

//
//
// 示例值：
func (builder *CorrectErrorBuilder) Type(type_ int) *CorrectErrorBuilder {
	builder.type_ = type_
	builder.typeFlag = true
	return builder
}

// 该类型错误在请求时间周期内的累计数量
//
// 示例值：
func (builder *CorrectErrorBuilder) Total(total int) *CorrectErrorBuilder {
	builder.total = total
	builder.totalFlag = true
	return builder
}

// 该类型错误在周期内具体的纠错对
//
// 示例值：
func (builder *CorrectErrorBuilder) CorrectPairs(correctPairs []*CorrectPair) *CorrectErrorBuilder {
	builder.correctPairs = correctPairs
	builder.correctPairsFlag = true
	return builder
}

func (builder *CorrectErrorBuilder) Build() *CorrectError {
	req := &CorrectError{}
	if builder.typeFlag {
		req.Type = &builder.type_

	}
	if builder.totalFlag {
		req.Total = &builder.total

	}
	if builder.correctPairsFlag {
		req.CorrectPairs = builder.correctPairs
	}
	return req
}

type CorrectInfo struct {
	CorrectTotal *int `json:"correct_total,omitempty"` // 用户英文纠错数总数

	EachdayCorrect []int `json:"eachday_correct,omitempty"` // 时间区间内每一天纠错数

	GrammarError *CorrectError `json:"grammar_error,omitempty"` // 语法错误相关统计信息

	SpellError *CorrectError `json:"spell_error,omitempty"` // 拼写错误相关统计信息

	NounError *CorrectError `json:"noun_error,omitempty"` // 单复数错误相关统计信息

	VerbTenseError *CorrectError `json:"verb_tense_error,omitempty"` // 时态错误相关统计信息
}

type CorrectInfoBuilder struct {
	correctTotal     int // 用户英文纠错数总数
	correctTotalFlag bool

	eachdayCorrect     []int // 时间区间内每一天纠错数
	eachdayCorrectFlag bool

	grammarError     *CorrectError // 语法错误相关统计信息
	grammarErrorFlag bool

	spellError     *CorrectError // 拼写错误相关统计信息
	spellErrorFlag bool

	nounError     *CorrectError // 单复数错误相关统计信息
	nounErrorFlag bool

	verbTenseError     *CorrectError // 时态错误相关统计信息
	verbTenseErrorFlag bool
}

func NewCorrectInfoBuilder() *CorrectInfoBuilder {
	builder := &CorrectInfoBuilder{}
	return builder
}

// 用户英文纠错数总数
//
// 示例值：
func (builder *CorrectInfoBuilder) CorrectTotal(correctTotal int) *CorrectInfoBuilder {
	builder.correctTotal = correctTotal
	builder.correctTotalFlag = true
	return builder
}

// 时间区间内每一天纠错数
//
// 示例值：
func (builder *CorrectInfoBuilder) EachdayCorrect(eachdayCorrect []int) *CorrectInfoBuilder {
	builder.eachdayCorrect = eachdayCorrect
	builder.eachdayCorrectFlag = true
	return builder
}

// 语法错误相关统计信息
//
// 示例值：
func (builder *CorrectInfoBuilder) GrammarError(grammarError *CorrectError) *CorrectInfoBuilder {
	builder.grammarError = grammarError
	builder.grammarErrorFlag = true
	return builder
}

// 拼写错误相关统计信息
//
// 示例值：
func (builder *CorrectInfoBuilder) SpellError(spellError *CorrectError) *CorrectInfoBuilder {
	builder.spellError = spellError
	builder.spellErrorFlag = true
	return builder
}

// 单复数错误相关统计信息
//
// 示例值：
func (builder *CorrectInfoBuilder) NounError(nounError *CorrectError) *CorrectInfoBuilder {
	builder.nounError = nounError
	builder.nounErrorFlag = true
	return builder
}

// 时态错误相关统计信息
//
// 示例值：
func (builder *CorrectInfoBuilder) VerbTenseError(verbTenseError *CorrectError) *CorrectInfoBuilder {
	builder.verbTenseError = verbTenseError
	builder.verbTenseErrorFlag = true
	return builder
}

func (builder *CorrectInfoBuilder) Build() *CorrectInfo {
	req := &CorrectInfo{}
	if builder.correctTotalFlag {
		req.CorrectTotal = &builder.correctTotal

	}
	if builder.eachdayCorrectFlag {
		req.EachdayCorrect = builder.eachdayCorrect
	}
	if builder.grammarErrorFlag {
		req.GrammarError = builder.grammarError
	}
	if builder.spellErrorFlag {
		req.SpellError = builder.spellError
	}
	if builder.nounErrorFlag {
		req.NounError = builder.nounError
	}
	if builder.verbTenseErrorFlag {
		req.VerbTenseError = builder.verbTenseError
	}
	return req
}

type CorrectPair struct {
	SourceText *string `json:"source_text,omitempty"` // 被纠错的原词

	TargetText *string `json:"target_text,omitempty"` // 纠错建议替换的新词

	Total *int `json:"total,omitempty"` // 纠错对在周期内出现的次数
}

type CorrectPairBuilder struct {
	sourceText     string // 被纠错的原词
	sourceTextFlag bool

	targetText     string // 纠错建议替换的新词
	targetTextFlag bool

	total     int // 纠错对在周期内出现的次数
	totalFlag bool
}

func NewCorrectPairBuilder() *CorrectPairBuilder {
	builder := &CorrectPairBuilder{}
	return builder
}

// 被纠错的原词
//
// 示例值：
func (builder *CorrectPairBuilder) SourceText(sourceText string) *CorrectPairBuilder {
	builder.sourceText = sourceText
	builder.sourceTextFlag = true
	return builder
}

// 纠错建议替换的新词
//
// 示例值：
func (builder *CorrectPairBuilder) TargetText(targetText string) *CorrectPairBuilder {
	builder.targetText = targetText
	builder.targetTextFlag = true
	return builder
}

// 纠错对在周期内出现的次数
//
// 示例值：
func (builder *CorrectPairBuilder) Total(total int) *CorrectPairBuilder {
	builder.total = total
	builder.totalFlag = true
	return builder
}

func (builder *CorrectPairBuilder) Build() *CorrectPair {
	req := &CorrectPair{}
	if builder.sourceTextFlag {
		req.SourceText = &builder.sourceText

	}
	if builder.targetTextFlag {
		req.TargetText = &builder.targetText

	}
	if builder.totalFlag {
		req.Total = &builder.total

	}
	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 DisplayStatus struct {
	AllowHighlight *bool `json:"allow_highlight,omitempty"` // 对应名称是否在消息/云文档高亮

	AllowSearch *bool `json:"allow_search,omitempty"` // 对应名称是否在搜索结果中展示
}

type DisplayStatusBuilder struct {
	allowHighlight     bool // 对应名称是否在消息/云文档高亮
	allowHighlightFlag bool

	allowSearch     bool // 对应名称是否在搜索结果中展示
	allowSearchFlag bool
}

func NewDisplayStatusBuilder() *DisplayStatusBuilder {
	builder := &DisplayStatusBuilder{}
	return builder
}

// 对应名称是否在消息/云文档高亮
//
// 示例值：true
func (builder *DisplayStatusBuilder) AllowHighlight(allowHighlight bool) *DisplayStatusBuilder {
	builder.allowHighlight = allowHighlight
	builder.allowHighlightFlag = true
	return builder
}

// 对应名称是否在搜索结果中展示
//
// 示例值：true
func (builder *DisplayStatusBuilder) AllowSearch(allowSearch bool) *DisplayStatusBuilder {
	builder.allowSearch = allowSearch
	builder.allowSearchFlag = true
	return builder
}

func (builder *DisplayStatusBuilder) Build() *DisplayStatus {
	req := &DisplayStatus{}
	if builder.allowHighlightFlag {
		req.AllowHighlight = &builder.allowHighlight

	}
	if builder.allowSearchFlag {
		req.AllowSearch = &builder.allowSearch

	}
	return req
}

type Draft struct {
	DraftId *string `json:"draft_id,omitempty"` // 草稿 ID

	Entity *Entity `json:"entity,omitempty"` // 词条信息
}

type DraftBuilder struct {
	draftId     string // 草稿 ID
	draftIdFlag bool

	entity     *Entity // 词条信息
	entityFlag bool
}

func NewDraftBuilder() *DraftBuilder {
	builder := &DraftBuilder{}
	return builder
}

// 草稿 ID
//
// 示例值：42322
func (builder *DraftBuilder) DraftId(draftId string) *DraftBuilder {
	builder.draftId = draftId
	builder.draftIdFlag = true
	return builder
}

// 词条信息
//
// 示例值：
func (builder *DraftBuilder) Entity(entity *Entity) *DraftBuilder {
	builder.entity = entity
	builder.entityFlag = true
	return builder
}

func (builder *DraftBuilder) Build() *Draft {
	req := &Draft{}
	if builder.draftIdFlag {
		req.DraftId = &builder.draftId

	}
	if builder.entityFlag {
		req.Entity = builder.entity
	}
	return req
}

type Entity struct {
	Id *string `json:"id,omitempty"` // 词条 ID （需要更新某个词条时填写，若是创建新词条可不填写）

	MainKeys []*Term `json:"main_keys,omitempty"` // 词条名

	FullNames []*Term `json:"full_names,omitempty"` // 全称

	Aliases []*Term `json:"aliases,omitempty"` // 别名

	Description *string `json:"description,omitempty"` // 词条释义（纯文本格式）

	Creator *string `json:"creator,omitempty"` // 创建者

	CreateTime *string `json:"create_time,omitempty"` // 词条创建时间

	Updater *string `json:"updater,omitempty"` // 最近一次更新者

	UpdateTime *string `json:"update_time,omitempty"` // 词条最近更新时间

	RelatedMeta *RelatedMeta `json:"related_meta,omitempty"` // 更多相关信息

	Statistics *Statistics `json:"statistics,omitempty"` // 当前词条收到的反馈数据

	OuterInfo *OuterInfo `json:"outer_info,omitempty"` // 外部系统关联数据

	RichText *string `json:"rich_text,omitempty"` // 富文本格式（当填写富文本内容时，description字段将会失效可不填写），支持的格式参考[企业百科指南](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/baike-v1/overview)中的释义部分

	Source *int `json:"source,omitempty"` // 词条的创建来源，1：用户主动创建，2：批量导入，3：官方词，4：OpenAPI 创建
}

type EntityBuilder struct {
	id     string // 词条 ID （需要更新某个词条时填写，若是创建新词条可不填写）
	idFlag bool

	mainKeys     []*Term // 词条名
	mainKeysFlag bool

	fullNames     []*Term // 全称
	fullNamesFlag bool

	aliases     []*Term // 别名
	aliasesFlag bool

	description     string // 词条释义（纯文本格式）
	descriptionFlag bool

	creator     string // 创建者
	creatorFlag bool

	createTime     string // 词条创建时间
	createTimeFlag bool

	updater     string // 最近一次更新者
	updaterFlag bool

	updateTime     string // 词条最近更新时间
	updateTimeFlag bool

	relatedMeta     *RelatedMeta // 更多相关信息
	relatedMetaFlag bool

	statistics     *Statistics // 当前词条收到的反馈数据
	statisticsFlag bool

	outerInfo     *OuterInfo // 外部系统关联数据
	outerInfoFlag bool

	richText     string // 富文本格式（当填写富文本内容时，description字段将会失效可不填写），支持的格式参考[企业百科指南](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/baike-v1/overview)中的释义部分
	richTextFlag bool

	source     int // 词条的创建来源，1：用户主动创建，2：批量导入，3：官方词，4：OpenAPI 创建
	sourceFlag bool
}

func NewEntityBuilder() *EntityBuilder {
	builder := &EntityBuilder{}
	return builder
}

// 词条 ID （需要更新某个词条时填写，若是创建新词条可不填写）
//
// 示例值：enterprise_40217521
func (builder *EntityBuilder) Id(id string) *EntityBuilder {
	builder.id = id
	builder.idFlag = true
	return builder
}

// 词条名
//
// 示例值：
func (builder *EntityBuilder) MainKeys(mainKeys []*Term) *EntityBuilder {
	builder.mainKeys = mainKeys
	builder.mainKeysFlag = true
	return builder
}

// 全称
//
// 示例值：
func (builder *EntityBuilder) FullNames(fullNames []*Term) *EntityBuilder {
	builder.fullNames = fullNames
	builder.fullNamesFlag = true
	return builder
}

// 别名
//
// 示例值：
func (builder *EntityBuilder) Aliases(aliases []*Term) *EntityBuilder {
	builder.aliases = aliases
	builder.aliasesFlag = true
	return builder
}

// 词条释义（纯文本格式）
//
// 示例值：企业百科是飞书提供的一款知识管理工具，通过企业百科可以帮助企业将分散的知识信息进行聚合，并通过UGC的方式，促进企业知识的保鲜和流通
func (builder *EntityBuilder) Description(description string) *EntityBuilder {
	builder.description = description
	builder.descriptionFlag = true
	return builder
}

// 创建者
//
// 示例值：ou_30b07b63089ea46518789914dac63d36
func (builder *EntityBuilder) Creator(creator string) *EntityBuilder {
	builder.creator = creator
	builder.creatorFlag = true
	return builder
}

// 词条创建时间
//
// 示例值：1649318125
func (builder *EntityBuilder) CreateTime(createTime string) *EntityBuilder {
	builder.createTime = createTime
	builder.createTimeFlag = true
	return builder
}

// 最近一次更新者
//
// 示例值：ou_30b07b63089ea46518789914dac63d36
func (builder *EntityBuilder) Updater(updater string) *EntityBuilder {
	builder.updater = updater
	builder.updaterFlag = true
	return builder
}

// 词条最近更新时间
//
// 示例值：1649318125
func (builder *EntityBuilder) UpdateTime(updateTime string) *EntityBuilder {
	builder.updateTime = updateTime
	builder.updateTimeFlag = true
	return builder
}

// 更多相关信息
//
// 示例值：
func (builder *EntityBuilder) RelatedMeta(relatedMeta *RelatedMeta) *EntityBuilder {
	builder.relatedMeta = relatedMeta
	builder.relatedMetaFlag = true
	return builder
}

// 当前词条收到的反馈数据
//
// 示例值：
func (builder *EntityBuilder) Statistics(statistics *Statistics) *EntityBuilder {
	builder.statistics = statistics
	builder.statisticsFlag = true
	return builder
}

// 外部系统关联数据
//
// 示例值：
func (builder *EntityBuilder) OuterInfo(outerInfo *OuterInfo) *EntityBuilder {
	builder.outerInfo = outerInfo
	builder.outerInfoFlag = true
	return builder
}

// 富文本格式（当填写富文本内容时，description字段将会失效可不填写），支持的格式参考[企业百科指南](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/baike-v1/overview)中的释义部分
//
// 示例值：&lt;b&gt;加粗&lt;/b&gt;&lt;i&gt;斜体&lt;/i&gt;&lt;p&gt;&lt;a href=\"https://feishu.cn\"&gt;链接&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;企业百科是飞书提供的一款知识管理工具，通过企业百科可以帮助企业将分散的知识信息进行聚合，并通过UGC的方式，促进企业知识的保鲜和流通&lt;/span&gt;&lt;/p&gt;
func (builder *EntityBuilder) RichText(richText string) *EntityBuilder {
	builder.richText = richText
	builder.richTextFlag = true
	return builder
}

// 词条的创建来源，1：用户主动创建，2：批量导入，3：官方词，4：OpenAPI 创建
//
// 示例值：1
func (builder *EntityBuilder) Source(source int) *EntityBuilder {
	builder.source = source
	builder.sourceFlag = true
	return builder
}

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

	}
	if builder.mainKeysFlag {
		req.MainKeys = builder.mainKeys
	}
	if builder.fullNamesFlag {
		req.FullNames = builder.fullNames
	}
	if builder.aliasesFlag {
		req.Aliases = builder.aliases
	}
	if builder.descriptionFlag {
		req.Description = &builder.description

	}
	if builder.creatorFlag {
		req.Creator = &builder.creator

	}
	if builder.createTimeFlag {
		req.CreateTime = &builder.createTime

	}
	if builder.updaterFlag {
		req.Updater = &builder.updater

	}
	if builder.updateTimeFlag {
		req.UpdateTime = &builder.updateTime

	}
	if builder.relatedMetaFlag {
		req.RelatedMeta = builder.relatedMeta
	}
	if builder.statisticsFlag {
		req.Statistics = builder.statistics
	}
	if builder.outerInfoFlag {
		req.OuterInfo = builder.outerInfo
	}
	if builder.richTextFlag {
		req.RichText = &builder.richText

	}
	if builder.sourceFlag {
		req.Source = &builder.source

	}
	return req
}

type EntityWord struct {
	Name *string `json:"name,omitempty"` // 抽取出的词条名

	Aliases []string `json:"aliases,omitempty"` // 词条可能的别名
}

type EntityWordBuilder struct {
	name     string // 抽取出的词条名
	nameFlag bool

	aliases     []string // 词条可能的别名
	aliasesFlag bool
}

func NewEntityWordBuilder() *EntityWordBuilder {
	builder := &EntityWordBuilder{}
	return builder
}

// 抽取出的词条名
//
// 示例值：企业百科
func (builder *EntityWordBuilder) Name(name string) *EntityWordBuilder {
	builder.name = name
	builder.nameFlag = true
	return builder
}

// 词条可能的别名
//
// 示例值：
func (builder *EntityWordBuilder) Aliases(aliases []string) *EntityWordBuilder {
	builder.aliases = aliases
	builder.aliasesFlag = true
	return builder
}

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

	}
	if builder.aliasesFlag {
		req.Aliases = builder.aliases
	}
	return req
}

type File struct {
	Name *string `json:"name,omitempty"` // 文件名称，当前仅支持上传图片且图片格式为以下六种：icon、bmp、gif、png、jpeg、webp

	File io.Reader `json:"file,omitempty"` // 二进制文件内容，高宽像素在 320-4096 像素之间，大小在 3KB-10MB 的图片
}

type FileBuilder struct {
	name     string // 文件名称，当前仅支持上传图片且图片格式为以下六种：icon、bmp、gif、png、jpeg、webp
	nameFlag bool

	file     io.Reader // 二进制文件内容，高宽像素在 320-4096 像素之间，大小在 3KB-10MB 的图片
	fileFlag bool
}

func NewFileBuilder() *FileBuilder {
	builder := &FileBuilder{}
	return builder
}

// 文件名称，当前仅支持上传图片且图片格式为以下六种：icon、bmp、gif、png、jpeg、webp
//
// 示例值：示例图片.png
func (builder *FileBuilder) Name(name string) *FileBuilder {
	builder.name = name
	builder.nameFlag = true
	return builder
}

// 二进制文件内容，高宽像素在 320-4096 像素之间，大小在 3KB-10MB 的图片
//
// 示例值：file binary
func (builder *FileBuilder) File(file io.Reader) *FileBuilder {
	builder.file = file
	builder.fileFlag = true
	return builder
}

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

	}
	if builder.fileFlag {
		req.File = builder.file
	}
	return req
}

type MatchInfo struct {
	EntityId *string `json:"entity_id,omitempty"` // 词条 ID

	Type *int `json:"type,omitempty"` // 命中的字段
}

type MatchInfoBuilder struct {
	entityId     string // 词条 ID
	entityIdFlag bool

	type_    int // 命中的字段
	typeFlag bool
}

func NewMatchInfoBuilder() *MatchInfoBuilder {
	builder := &MatchInfoBuilder{}
	return builder
}

// 词条 ID
//
// 示例值：enterprise_34809584
func (builder *MatchInfoBuilder) EntityId(entityId string) *MatchInfoBuilder {
	builder.entityId = entityId
	builder.entityIdFlag = true
	return builder
}

// 命中的字段
//
// 示例值：0
func (builder *MatchInfoBuilder) Type(type_ int) *MatchInfoBuilder {
	builder.type_ = type_
	builder.typeFlag = true
	return builder
}

func (builder *MatchInfoBuilder) Build() *MatchInfo {
	req := &MatchInfo{}
	if builder.entityIdFlag {
		req.EntityId = &builder.entityId

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

	}
	return req
}

type OuterInfo struct {
	Provider *string `json:"provider,omitempty"` // 外部系统（不能包含中横线 "-"）

	OuterId *string `json:"outer_id,omitempty"` // 词条在外部系统中对应的唯一 ID（不能包含中横线 "-"）
}

type OuterInfoBuilder struct {
	provider     string // 外部系统（不能包含中横线 "-"）
	providerFlag bool

	outerId     string // 词条在外部系统中对应的唯一 ID（不能包含中横线 "-"）
	outerIdFlag bool
}

func NewOuterInfoBuilder() *OuterInfoBuilder {
	builder := &OuterInfoBuilder{}
	return builder
}

// 外部系统（不能包含中横线 "-"）
//
// 示例值：星云
func (builder *OuterInfoBuilder) Provider(provider string) *OuterInfoBuilder {
	builder.provider = provider
	builder.providerFlag = true
	return builder
}

// 词条在外部系统中对应的唯一 ID（不能包含中横线 "-"）
//
// 示例值：client_6539i3498d
func (builder *OuterInfoBuilder) OuterId(outerId string) *OuterInfoBuilder {
	builder.outerId = outerId
	builder.outerIdFlag = true
	return builder
}

func (builder *OuterInfoBuilder) Build() *OuterInfo {
	req := &OuterInfo{}
	if builder.providerFlag {
		req.Provider = &builder.provider

	}
	if builder.outerIdFlag {
		req.OuterId = &builder.outerId

	}
	return req
}

type Phrase struct {
	Name *string `json:"name,omitempty"` // 识别到的关键词

	EntityIds []string `json:"entity_ids,omitempty"` // 对应的词条 ID

	Span *Span `json:"span,omitempty"` // 词条所在位置
}

type PhraseBuilder struct {
	name     string // 识别到的关键词
	nameFlag bool

	entityIds     []string // 对应的词条 ID
	entityIdsFlag bool

	span     *Span // 词条所在位置
	spanFlag bool
}

func NewPhraseBuilder() *PhraseBuilder {
	builder := &PhraseBuilder{}
	return builder
}

// 识别到的关键词
//
// 示例值：企业百科
func (builder *PhraseBuilder) Name(name string) *PhraseBuilder {
	builder.name = name
	builder.nameFlag = true
	return builder
}

// 对应的词条 ID
//
// 示例值：
func (builder *PhraseBuilder) EntityIds(entityIds []string) *PhraseBuilder {
	builder.entityIds = entityIds
	builder.entityIdsFlag = true
	return builder
}

// 词条所在位置
//
// 示例值：
func (builder *PhraseBuilder) Span(span *Span) *PhraseBuilder {
	builder.span = span
	builder.spanFlag = true
	return builder
}

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

	}
	if builder.entityIdsFlag {
		req.EntityIds = builder.entityIds
	}
	if builder.spanFlag {
		req.Span = builder.span
	}
	return req
}

type Referer struct {
	Id *string `json:"id,omitempty"` // 对应相关信息 ID

	Title *string `json:"title,omitempty"` // 对应相关信息的描述，如相关联系人的描述、相关链接的标题

	Url *string `json:"url,omitempty"` // 链接地址
}

type RefererBuilder struct {
	id     string // 对应相关信息 ID
	idFlag bool

	title     string // 对应相关信息的描述，如相关联系人的描述、相关链接的标题
	titleFlag bool

	url     string // 链接地址
	urlFlag bool
}

func NewRefererBuilder() *RefererBuilder {
	builder := &RefererBuilder{}
	return builder
}

// 对应相关信息 ID
//
// 示例值：格式请看请求体示例
func (builder *RefererBuilder) Id(id string) *RefererBuilder {
	builder.id = id
	builder.idFlag = true
	return builder
}

// 对应相关信息的描述，如相关联系人的描述、相关链接的标题
//
// 示例值：企业百科帮助中心
func (builder *RefererBuilder) Title(title string) *RefererBuilder {
	builder.title = title
	builder.titleFlag = true
	return builder
}

// 链接地址
//
// 示例值：https://www.feishu.cn/hc/zh-CN
func (builder *RefererBuilder) Url(url string) *RefererBuilder {
	builder.url = url
	builder.urlFlag = true
	return builder
}

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

	}
	if builder.titleFlag {
		req.Title = &builder.title

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

	}
	return req
}

type RelatedMeta struct {
	Users []*Referer `json:"users,omitempty"` // 相关联系人

	Chats []*Referer `json:"chats,omitempty"` // 相关服务中的相关公开群

	Docs []*Referer `json:"docs,omitempty"` // 相关云文档

	Oncalls []*Referer `json:"oncalls,omitempty"` // 相关服务中的相关值班号

	Links []*Referer `json:"links,omitempty"` // 相关链接

	Abbreviations []*Abbreviation `json:"abbreviations,omitempty"` // 相关词条

	Classifications []*Classification `json:"classifications,omitempty"` // 当前词条所属分类;词条只能属于二级分类，且每个一级分类下只能选择一个二级分类。

	Images []*BaikeImage `json:"images,omitempty"` // 上传的图片
}

type RelatedMetaBuilder struct {
	users     []*Referer // 相关联系人
	usersFlag bool

	chats     []*Referer // 相关服务中的相关公开群
	chatsFlag bool

	docs     []*Referer // 相关云文档
	docsFlag bool

	oncalls     []*Referer // 相关服务中的相关值班号
	oncallsFlag bool

	links     []*Referer // 相关链接
	linksFlag bool

	abbreviations     []*Abbreviation // 相关词条
	abbreviationsFlag bool

	classifications     []*Classification // 当前词条所属分类;词条只能属于二级分类，且每个一级分类下只能选择一个二级分类。
	classificationsFlag bool

	images     []*BaikeImage // 上传的图片
	imagesFlag bool
}

func NewRelatedMetaBuilder() *RelatedMetaBuilder {
	builder := &RelatedMetaBuilder{}
	return builder
}

// 相关联系人
//
// 示例值：
func (builder *RelatedMetaBuilder) Users(users []*Referer) *RelatedMetaBuilder {
	builder.users = users
	builder.usersFlag = true
	return builder
}

// 相关服务中的相关公开群
//
// 示例值：
func (builder *RelatedMetaBuilder) Chats(chats []*Referer) *RelatedMetaBuilder {
	builder.chats = chats
	builder.chatsFlag = true
	return builder
}

// 相关云文档
//
// 示例值：
func (builder *RelatedMetaBuilder) Docs(docs []*Referer) *RelatedMetaBuilder {
	builder.docs = docs
	builder.docsFlag = true
	return builder
}

// 相关服务中的相关值班号
//
// 示例值：
func (builder *RelatedMetaBuilder) Oncalls(oncalls []*Referer) *RelatedMetaBuilder {
	builder.oncalls = oncalls
	builder.oncallsFlag = true
	return builder
}

// 相关链接
//
// 示例值：
func (builder *RelatedMetaBuilder) Links(links []*Referer) *RelatedMetaBuilder {
	builder.links = links
	builder.linksFlag = true
	return builder
}

// 相关词条
//
// 示例值：
func (builder *RelatedMetaBuilder) Abbreviations(abbreviations []*Abbreviation) *RelatedMetaBuilder {
	builder.abbreviations = abbreviations
	builder.abbreviationsFlag = true
	return builder
}

// 当前词条所属分类;词条只能属于二级分类，且每个一级分类下只能选择一个二级分类。
//
// 示例值：
func (builder *RelatedMetaBuilder) Classifications(classifications []*Classification) *RelatedMetaBuilder {
	builder.classifications = classifications
	builder.classificationsFlag = true
	return builder
}

// 上传的图片
//
// 示例值：
func (builder *RelatedMetaBuilder) Images(images []*BaikeImage) *RelatedMetaBuilder {
	builder.images = images
	builder.imagesFlag = true
	return builder
}

func (builder *RelatedMetaBuilder) Build() *RelatedMeta {
	req := &RelatedMeta{}
	if builder.usersFlag {
		req.Users = builder.users
	}
	if builder.chatsFlag {
		req.Chats = builder.chats
	}
	if builder.docsFlag {
		req.Docs = builder.docs
	}
	if builder.oncallsFlag {
		req.Oncalls = builder.oncalls
	}
	if builder.linksFlag {
		req.Links = builder.links
	}
	if builder.abbreviationsFlag {
		req.Abbreviations = builder.abbreviations
	}
	if builder.classificationsFlag {
		req.Classifications = builder.classifications
	}
	if builder.imagesFlag {
		req.Images = builder.images
	}
	return req
}

type Span struct {
	Start *int `json:"start,omitempty"` // 关键词开始位置，从 0 开始计数（编码格式采用 utf-8）

	End *int `json:"end,omitempty"` // 关键词结束位置，从 0 开始计数（编码格式采用 utf-8）
}

type SpanBuilder struct {
	start     int // 关键词开始位置，从 0 开始计数（编码格式采用 utf-8）
	startFlag bool

	end     int // 关键词结束位置，从 0 开始计数（编码格式采用 utf-8）
	endFlag bool
}

func NewSpanBuilder() *SpanBuilder {
	builder := &SpanBuilder{}
	return builder
}

// 关键词开始位置，从 0 开始计数（编码格式采用 utf-8）
//
// 示例值：0
func (builder *SpanBuilder) Start(start int) *SpanBuilder {
	builder.start = start
	builder.startFlag = true
	return builder
}

// 关键词结束位置，从 0 开始计数（编码格式采用 utf-8）
//
// 示例值：4
func (builder *SpanBuilder) End(end int) *SpanBuilder {
	builder.end = end
	builder.endFlag = true
	return builder
}

func (builder *SpanBuilder) Build() *Span {
	req := &Span{}
	if builder.startFlag {
		req.Start = &builder.start

	}
	if builder.endFlag {
		req.End = &builder.end

	}
	return req
}

type StatisticalReport struct {
	DateInterval *int `json:"date_interval,omitempty"` // 请求时间区间

	WordInfo *WordInfo `json:"word_info,omitempty"` // 词汇量相关数据

	CorrectInfo *CorrectInfo `json:"correct_info,omitempty"` // 纠错相关数据

	UpdateDate *string `json:"update_date,omitempty"` // 天维度的时间戳，用于确认数据最近一次更新时间
}

type StatisticalReportBuilder struct {
	dateInterval     int // 请求时间区间
	dateIntervalFlag bool

	wordInfo     *WordInfo // 词汇量相关数据
	wordInfoFlag bool

	correctInfo     *CorrectInfo // 纠错相关数据
	correctInfoFlag bool

	updateDate     string // 天维度的时间戳，用于确认数据最近一次更新时间
	updateDateFlag bool
}

func NewStatisticalReportBuilder() *StatisticalReportBuilder {
	builder := &StatisticalReportBuilder{}
	return builder
}

// 请求时间区间
//
// 示例值：请求时间区间
func (builder *StatisticalReportBuilder) DateInterval(dateInterval int) *StatisticalReportBuilder {
	builder.dateInterval = dateInterval
	builder.dateIntervalFlag = true
	return builder
}

// 词汇量相关数据
//
// 示例值：
func (builder *StatisticalReportBuilder) WordInfo(wordInfo *WordInfo) *StatisticalReportBuilder {
	builder.wordInfo = wordInfo
	builder.wordInfoFlag = true
	return builder
}

// 纠错相关数据
//
// 示例值：
func (builder *StatisticalReportBuilder) CorrectInfo(correctInfo *CorrectInfo) *StatisticalReportBuilder {
	builder.correctInfo = correctInfo
	builder.correctInfoFlag = true
	return builder
}

// 天维度的时间戳，用于确认数据最近一次更新时间
//
// 示例值：“20221101”
func (builder *StatisticalReportBuilder) UpdateDate(updateDate string) *StatisticalReportBuilder {
	builder.updateDate = updateDate
	builder.updateDateFlag = true
	return builder
}

func (builder *StatisticalReportBuilder) Build() *StatisticalReport {
	req := &StatisticalReport{}
	if builder.dateIntervalFlag {
		req.DateInterval = &builder.dateInterval

	}
	if builder.wordInfoFlag {
		req.WordInfo = builder.wordInfo
	}
	if builder.correctInfoFlag {
		req.CorrectInfo = builder.correctInfo
	}
	if builder.updateDateFlag {
		req.UpdateDate = &builder.updateDate

	}
	return req
}

type Statistics struct {
	LikeCount *int `json:"like_count,omitempty"` // 累计点赞

	DislikeCount *int `json:"dislike_count,omitempty"` // 当前词条版本收到的负反馈数量
}

type StatisticsBuilder struct {
	likeCount     int // 累计点赞
	likeCountFlag bool

	dislikeCount     int // 当前词条版本收到的负反馈数量
	dislikeCountFlag bool
}

func NewStatisticsBuilder() *StatisticsBuilder {
	builder := &StatisticsBuilder{}
	return builder
}

// 累计点赞
//
// 示例值：55
func (builder *StatisticsBuilder) LikeCount(likeCount int) *StatisticsBuilder {
	builder.likeCount = likeCount
	builder.likeCountFlag = true
	return builder
}

// 当前词条版本收到的负反馈数量
//
// 示例值：3
func (builder *StatisticsBuilder) DislikeCount(dislikeCount int) *StatisticsBuilder {
	builder.dislikeCount = dislikeCount
	builder.dislikeCountFlag = true
	return builder
}

func (builder *StatisticsBuilder) Build() *Statistics {
	req := &Statistics{}
	if builder.likeCountFlag {
		req.LikeCount = &builder.likeCount

	}
	if builder.dislikeCountFlag {
		req.DislikeCount = &builder.dislikeCount

	}
	return req
}

type Term struct {
	Key *string `json:"key,omitempty"` // 名称的值

	DisplayStatus *DisplayStatus `json:"display_status,omitempty"` // 名称展示范围
}

type TermBuilder struct {
	key     string // 名称的值
	keyFlag bool

	displayStatus     *DisplayStatus // 名称展示范围
	displayStatusFlag bool
}

func NewTermBuilder() *TermBuilder {
	builder := &TermBuilder{}
	return builder
}

// 名称的值
//
// 示例值：企业百科
func (builder *TermBuilder) Key(key string) *TermBuilder {
	builder.key = key
	builder.keyFlag = true
	return builder
}

// 名称展示范围
//
// 示例值：
func (builder *TermBuilder) DisplayStatus(displayStatus *DisplayStatus) *TermBuilder {
	builder.displayStatus = displayStatus
	builder.displayStatusFlag = true
	return builder
}

func (builder *TermBuilder) Build() *Term {
	req := &Term{}
	if builder.keyFlag {
		req.Key = &builder.key

	}
	if builder.displayStatusFlag {
		req.DisplayStatus = builder.displayStatus
	}
	return req
}

type WordInfo struct {
	InputTotal *int `json:"input_total,omitempty"` // 用户输入的总词汇量

	DedupInputTotal *int `json:"dedup_input_total,omitempty"` // 用户输入的去重后的总词汇量

	EachdayInput []int `json:"eachday_input,omitempty"` // 时间区间内每一天发送的英文词数，时间是由远到近。以七天数据为例：下标6为昨天，下标5位前天以此类推

	EachdayDedupInput []int `json:"eachday_dedup_input,omitempty"` // 时间区间内每一天发送的归一化去重后的英文词数，时间是由远到近。以七天数据为例：下标6为昨天，下标5位前天以此类推

	SendMessageTotal *int `json:"send_message_total,omitempty"` // 发送的消息总数

	SendEnMessageTotal *int `json:"send_en_message_total,omitempty"` // 发送的英语消息总数

	ReceiveMessageTotal *int `json:"receive_message_total,omitempty"` // 接收消息的数量

	ReceiveEnMessageTotal *int `json:"receive_en_message_total,omitempty"` // 接收英文消息的数量

	HistoryWordsTotal *int `json:"history_words_total,omitempty"` // 历史总计英语词数（包含新增）

	NewWordsTotal *int `json:"new_words_total,omitempty"` // 新增英语词数

	EachdaySendEnMessage []int `json:"eachday_send_en_message,omitempty"` // 时间区间内每一天发送的英语消息数

	EachdaySendMessage []int `json:"eachday_send_message,omitempty"` // 时间区间内每一天发送的消息数

	EachdayReceiveEnMessage []int `json:"eachday_receive_en_message,omitempty"` // 时间区间内每一天接收的英文消息数

	EachdayReceiveMessage []int `json:"eachday_receive_message,omitempty"` // 时间区间内每一天接收的英文消息数

	SendEngMessageRateRingGrowth *float64 `json:"send_eng_message_rate_ring_growth,omitempty"` // 发送消息占比环比增长变化

	SendEngWordsRingGrowth *int `json:"send_eng_words_ring_growth,omitempty"` // 发送英文单词数环比增长变化
}

type WordInfoBuilder struct {
	inputTotal     int // 用户输入的总词汇量
	inputTotalFlag bool

	dedupInputTotal     int // 用户输入的去重后的总词汇量
	dedupInputTotalFlag bool

	eachdayInput     []int // 时间区间内每一天发送的英文词数，时间是由远到近。以七天数据为例：下标6为昨天，下标5位前天以此类推
	eachdayInputFlag bool

	eachdayDedupInput     []int // 时间区间内每一天发送的归一化去重后的英文词数，时间是由远到近。以七天数据为例：下标6为昨天，下标5位前天以此类推
	eachdayDedupInputFlag bool

	sendMessageTotal     int // 发送的消息总数
	sendMessageTotalFlag bool

	sendEnMessageTotal     int // 发送的英语消息总数
	sendEnMessageTotalFlag bool

	receiveMessageTotal     int // 接收消息的数量
	receiveMessageTotalFlag bool

	receiveEnMessageTotal     int // 接收英文消息的数量
	receiveEnMessageTotalFlag bool

	historyWordsTotal     int // 历史总计英语词数（包含新增）
	historyWordsTotalFlag bool

	newWordsTotal     int // 新增英语词数
	newWordsTotalFlag bool

	eachdaySendEnMessage     []int // 时间区间内每一天发送的英语消息数
	eachdaySendEnMessageFlag bool

	eachdaySendMessage     []int // 时间区间内每一天发送的消息数
	eachdaySendMessageFlag bool

	eachdayReceiveEnMessage     []int // 时间区间内每一天接收的英文消息数
	eachdayReceiveEnMessageFlag bool

	eachdayReceiveMessage     []int // 时间区间内每一天接收的英文消息数
	eachdayReceiveMessageFlag bool

	sendEngMessageRateRingGrowth     float64 // 发送消息占比环比增长变化
	sendEngMessageRateRingGrowthFlag bool

	sendEngWordsRingGrowth     int // 发送英文单词数环比增长变化
	sendEngWordsRingGrowthFlag bool
}

func NewWordInfoBuilder() *WordInfoBuilder {
	builder := &WordInfoBuilder{}
	return builder
}

// 用户输入的总词汇量
//
// 示例值：100
func (builder *WordInfoBuilder) InputTotal(inputTotal int) *WordInfoBuilder {
	builder.inputTotal = inputTotal
	builder.inputTotalFlag = true
	return builder
}

// 用户输入的去重后的总词汇量
//
// 示例值：50
func (builder *WordInfoBuilder) DedupInputTotal(dedupInputTotal int) *WordInfoBuilder {
	builder.dedupInputTotal = dedupInputTotal
	builder.dedupInputTotalFlag = true
	return builder
}

// 时间区间内每一天发送的英文词数，时间是由远到近。以七天数据为例：下标6为昨天，下标5位前天以此类推
//
// 示例值：
func (builder *WordInfoBuilder) EachdayInput(eachdayInput []int) *WordInfoBuilder {
	builder.eachdayInput = eachdayInput
	builder.eachdayInputFlag = true
	return builder
}

// 时间区间内每一天发送的归一化去重后的英文词数，时间是由远到近。以七天数据为例：下标6为昨天，下标5位前天以此类推
//
// 示例值：
func (builder *WordInfoBuilder) EachdayDedupInput(eachdayDedupInput []int) *WordInfoBuilder {
	builder.eachdayDedupInput = eachdayDedupInput
	builder.eachdayDedupInputFlag = true
	return builder
}

// 发送的消息总数
//
// 示例值：200
func (builder *WordInfoBuilder) SendMessageTotal(sendMessageTotal int) *WordInfoBuilder {
	builder.sendMessageTotal = sendMessageTotal
	builder.sendMessageTotalFlag = true
	return builder
}

// 发送的英语消息总数
//
// 示例值：150
func (builder *WordInfoBuilder) SendEnMessageTotal(sendEnMessageTotal int) *WordInfoBuilder {
	builder.sendEnMessageTotal = sendEnMessageTotal
	builder.sendEnMessageTotalFlag = true
	return builder
}

// 接收消息的数量
//
// 示例值：500
func (builder *WordInfoBuilder) ReceiveMessageTotal(receiveMessageTotal int) *WordInfoBuilder {
	builder.receiveMessageTotal = receiveMessageTotal
	builder.receiveMessageTotalFlag = true
	return builder
}

// 接收英文消息的数量
//
// 示例值：100
func (builder *WordInfoBuilder) ReceiveEnMessageTotal(receiveEnMessageTotal int) *WordInfoBuilder {
	builder.receiveEnMessageTotal = receiveEnMessageTotal
	builder.receiveEnMessageTotalFlag = true
	return builder
}

// 历史总计英语词数（包含新增）
//
// 示例值：300
func (builder *WordInfoBuilder) HistoryWordsTotal(historyWordsTotal int) *WordInfoBuilder {
	builder.historyWordsTotal = historyWordsTotal
	builder.historyWordsTotalFlag = true
	return builder
}

// 新增英语词数
//
// 示例值：20
func (builder *WordInfoBuilder) NewWordsTotal(newWordsTotal int) *WordInfoBuilder {
	builder.newWordsTotal = newWordsTotal
	builder.newWordsTotalFlag = true
	return builder
}

// 时间区间内每一天发送的英语消息数
//
// 示例值：
func (builder *WordInfoBuilder) EachdaySendEnMessage(eachdaySendEnMessage []int) *WordInfoBuilder {
	builder.eachdaySendEnMessage = eachdaySendEnMessage
	builder.eachdaySendEnMessageFlag = true
	return builder
}

// 时间区间内每一天发送的消息数
//
// 示例值：
func (builder *WordInfoBuilder) EachdaySendMessage(eachdaySendMessage []int) *WordInfoBuilder {
	builder.eachdaySendMessage = eachdaySendMessage
	builder.eachdaySendMessageFlag = true
	return builder
}

// 时间区间内每一天接收的英文消息数
//
// 示例值：
func (builder *WordInfoBuilder) EachdayReceiveEnMessage(eachdayReceiveEnMessage []int) *WordInfoBuilder {
	builder.eachdayReceiveEnMessage = eachdayReceiveEnMessage
	builder.eachdayReceiveEnMessageFlag = true
	return builder
}

// 时间区间内每一天接收的英文消息数
//
// 示例值：
func (builder *WordInfoBuilder) EachdayReceiveMessage(eachdayReceiveMessage []int) *WordInfoBuilder {
	builder.eachdayReceiveMessage = eachdayReceiveMessage
	builder.eachdayReceiveMessageFlag = true
	return builder
}

// 发送消息占比环比增长变化
//
// 示例值：2.1
func (builder *WordInfoBuilder) SendEngMessageRateRingGrowth(sendEngMessageRateRingGrowth float64) *WordInfoBuilder {
	builder.sendEngMessageRateRingGrowth = sendEngMessageRateRingGrowth
	builder.sendEngMessageRateRingGrowthFlag = true
	return builder
}

// 发送英文单词数环比增长变化
//
// 示例值：9
func (builder *WordInfoBuilder) SendEngWordsRingGrowth(sendEngWordsRingGrowth int) *WordInfoBuilder {
	builder.sendEngWordsRingGrowth = sendEngWordsRingGrowth
	builder.sendEngWordsRingGrowthFlag = true
	return builder
}

func (builder *WordInfoBuilder) Build() *WordInfo {
	req := &WordInfo{}
	if builder.inputTotalFlag {
		req.InputTotal = &builder.inputTotal

	}
	if builder.dedupInputTotalFlag {
		req.DedupInputTotal = &builder.dedupInputTotal

	}
	if builder.eachdayInputFlag {
		req.EachdayInput = builder.eachdayInput
	}
	if builder.eachdayDedupInputFlag {
		req.EachdayDedupInput = builder.eachdayDedupInput
	}
	if builder.sendMessageTotalFlag {
		req.SendMessageTotal = &builder.sendMessageTotal

	}
	if builder.sendEnMessageTotalFlag {
		req.SendEnMessageTotal = &builder.sendEnMessageTotal

	}
	if builder.receiveMessageTotalFlag {
		req.ReceiveMessageTotal = &builder.receiveMessageTotal

	}
	if builder.receiveEnMessageTotalFlag {
		req.ReceiveEnMessageTotal = &builder.receiveEnMessageTotal

	}
	if builder.historyWordsTotalFlag {
		req.HistoryWordsTotal = &builder.historyWordsTotal

	}
	if builder.newWordsTotalFlag {
		req.NewWordsTotal = &builder.newWordsTotal

	}
	if builder.eachdaySendEnMessageFlag {
		req.EachdaySendEnMessage = builder.eachdaySendEnMessage
	}
	if builder.eachdaySendMessageFlag {
		req.EachdaySendMessage = builder.eachdaySendMessage
	}
	if builder.eachdayReceiveEnMessageFlag {
		req.EachdayReceiveEnMessage = builder.eachdayReceiveEnMessage
	}
	if builder.eachdayReceiveMessageFlag {
		req.EachdayReceiveMessage = builder.eachdayReceiveMessage
	}
	if builder.sendEngMessageRateRingGrowthFlag {
		req.SendEngMessageRateRingGrowth = &builder.sendEngMessageRateRingGrowth

	}
	if builder.sendEngWordsRingGrowthFlag {
		req.SendEngWordsRingGrowth = &builder.sendEngWordsRingGrowth

	}
	return req
}

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

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

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

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

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

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

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

}

type ListClassificationRespData struct {
	Items []*Classification `json:"items,omitempty"` // 分类

	PageToken *string `json:"page_token,omitempty"` // 分页标记，当还有下一页时会返回新的 page_token，否则 page_token 为空
}

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

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

type CreateDraftReqBuilder struct {
	apiReq *larkcore.ApiReq
	entity *Entity
}

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

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

// 草稿并非百科词条，而是指通过 API 发起创建新词条或更新现有词条的申请。百科管理员审核通过后，草稿将变为新的词条或覆盖已有词条。
func (builder *CreateDraftReqBuilder) Entity(entity *Entity) *CreateDraftReqBuilder {
	builder.entity = entity
	return builder
}

func (builder *CreateDraftReqBuilder) Build() *CreateDraftReq {
	req := &CreateDraftReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.QueryParams = builder.apiReq.QueryParams
	req.apiReq.Body = builder.entity
	return req
}

type CreateDraftReq struct {
	apiReq *larkcore.ApiReq
	Entity *Entity `body:""`
}

type CreateDraftRespData struct {
	Draft *Draft `json:"draft,omitempty"` // 草稿信息
}

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

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

type UpdateDraftReqBuilder struct {
	apiReq *larkcore.ApiReq
	entity *Entity
}

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

// 草稿 ID
//
// 示例值：5347
func (builder *UpdateDraftReqBuilder) DraftId(draftId string) *UpdateDraftReqBuilder {
	builder.apiReq.PathParams.Set("draft_id", fmt.Sprint(draftId))
	return builder
}

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

// 根据 draft_id 更新草稿内容，已审批的草稿无法编辑
func (builder *UpdateDraftReqBuilder) Entity(entity *Entity) *UpdateDraftReqBuilder {
	builder.entity = entity
	return builder
}

func (builder *UpdateDraftReqBuilder) Build() *UpdateDraftReq {
	req := &UpdateDraftReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.PathParams = builder.apiReq.PathParams
	req.apiReq.QueryParams = builder.apiReq.QueryParams
	req.apiReq.Body = builder.entity
	return req
}

type UpdateDraftReq struct {
	apiReq *larkcore.ApiReq
	Entity *Entity `body:""`
}

type UpdateDraftRespData struct {
	Draft *Draft `json:"draft,omitempty"` // 草稿
}

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

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

type CreateEntityReqBuilder struct {
	apiReq *larkcore.ApiReq
	entity *Entity
}

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

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

// 通过此接口创建的词条，不需要百科管理员审核可直接写入词库，请慎重使用【租户管理员请慎重审批】。
func (builder *CreateEntityReqBuilder) Entity(entity *Entity) *CreateEntityReqBuilder {
	builder.entity = entity
	return builder
}

func (builder *CreateEntityReqBuilder) Build() *CreateEntityReq {
	req := &CreateEntityReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.QueryParams = builder.apiReq.QueryParams
	req.apiReq.Body = builder.entity
	return req
}

type CreateEntityReq struct {
	apiReq *larkcore.ApiReq
	Entity *Entity `body:""`
}

type CreateEntityRespData struct {
	Entity *Entity `json:"entity,omitempty"` // 词条信息
}

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

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

type ExtractEntityReqBodyBuilder struct {
	text     string // 需要被提取百科实体词的文本（不会过滤租户已成为百科词条的内容）
	textFlag bool
}

func NewExtractEntityReqBodyBuilder() *ExtractEntityReqBodyBuilder {
	builder := &ExtractEntityReqBodyBuilder{}
	return builder
}

// 需要被提取百科实体词的文本（不会过滤租户已成为百科词条的内容）
//
//示例值：企业百科是一部高效汇聚企业内各类信息，并可由企业成员参与编辑的在线百科全书
func (builder *ExtractEntityReqBodyBuilder) Text(text string) *ExtractEntityReqBodyBuilder {
	builder.text = text
	builder.textFlag = true
	return builder
}

func (builder *ExtractEntityReqBodyBuilder) Build() *ExtractEntityReqBody {
	req := &ExtractEntityReqBody{}
	if builder.textFlag {
		req.Text = &builder.text
	}
	return req
}

type ExtractEntityPathReqBodyBuilder struct {
	text     string
	textFlag bool
}

func NewExtractEntityPathReqBodyBuilder() *ExtractEntityPathReqBodyBuilder {
	builder := &ExtractEntityPathReqBodyBuilder{}
	return builder
}

// 需要被提取百科实体词的文本（不会过滤租户已成为百科词条的内容）
//
// 示例值：企业百科是一部高效汇聚企业内各类信息，并可由企业成员参与编辑的在线百科全书
func (builder *ExtractEntityPathReqBodyBuilder) Text(text string) *ExtractEntityPathReqBodyBuilder {
	builder.text = text
	builder.textFlag = true
	return builder
}

func (builder *ExtractEntityPathReqBodyBuilder) Build() (*ExtractEntityReqBody, error) {
	req := &ExtractEntityReqBody{}
	if builder.textFlag {
		req.Text = &builder.text
	}
	return req, nil
}

type ExtractEntityReqBuilder struct {
	apiReq *larkcore.ApiReq
	body   *ExtractEntityReqBody
}

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

// 提取文本中可能成为百科词条的词语，且不会过滤已经成为百科词条的词语。同时，会返回推荐的别名。
func (builder *ExtractEntityReqBuilder) Body(body *ExtractEntityReqBody) *ExtractEntityReqBuilder {
	builder.body = body
	return builder
}

func (builder *ExtractEntityReqBuilder) Build() *ExtractEntityReq {
	req := &ExtractEntityReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.Body = builder.body
	return req
}

type ExtractEntityReqBody struct {
	Text *string `json:"text,omitempty"` // 需要被提取百科实体词的文本（不会过滤租户已成为百科词条的内容）
}

type ExtractEntityReq struct {
	apiReq *larkcore.ApiReq
	Body   *ExtractEntityReqBody `body:""`
}

type ExtractEntityRespData struct {
	EntityWord []*EntityWord `json:"entity_word,omitempty"` // 文本中可能的成为百科词条的词汇
}

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

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

type GetEntityReqBuilder struct {
	apiReq *larkcore.ApiReq
}

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

// 词条 ID
//
// 示例值：enterprise_515879
func (builder *GetEntityReqBuilder) EntityId(entityId string) *GetEntityReqBuilder {
	builder.apiReq.PathParams.Set("entity_id", fmt.Sprint(entityId))
	return builder
}

// 外部系统
//
// 示例值：星云
func (builder *GetEntityReqBuilder) Provider(provider string) *GetEntityReqBuilder {
	builder.apiReq.QueryParams.Set("provider", fmt.Sprint(provider))
	return builder
}

// 词条在外部系统中对应的唯一 ID
//
// 示例值：12345
func (builder *GetEntityReqBuilder) OuterId(outerId string) *GetEntityReqBuilder {
	builder.apiReq.QueryParams.Set("outer_id", fmt.Sprint(outerId))
	return builder
}

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

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

type GetEntityReq struct {
	apiReq *larkcore.ApiReq
}

type GetEntityRespData struct {
	Entity *Entity `json:"entity,omitempty"` // 百科词条
}

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

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

type HighlightEntityReqBodyBuilder struct {
	text     string // 需要识别百科词条的内容（不超过1000字）
	textFlag bool
}

func NewHighlightEntityReqBodyBuilder() *HighlightEntityReqBodyBuilder {
	builder := &HighlightEntityReqBodyBuilder{}
	return builder
}

// 需要识别百科词条的内容（不超过1000字）
//
//示例值：企业百科是飞书提供的一款知识管理工具
func (builder *HighlightEntityReqBodyBuilder) Text(text string) *HighlightEntityReqBodyBuilder {
	builder.text = text
	builder.textFlag = true
	return builder
}

func (builder *HighlightEntityReqBodyBuilder) Build() *HighlightEntityReqBody {
	req := &HighlightEntityReqBody{}
	if builder.textFlag {
		req.Text = &builder.text
	}
	return req
}

type HighlightEntityPathReqBodyBuilder struct {
	text     string
	textFlag bool
}

func NewHighlightEntityPathReqBodyBuilder() *HighlightEntityPathReqBodyBuilder {
	builder := &HighlightEntityPathReqBodyBuilder{}
	return builder
}

// 需要识别百科词条的内容（不超过1000字）
//
// 示例值：企业百科是飞书提供的一款知识管理工具
func (builder *HighlightEntityPathReqBodyBuilder) Text(text string) *HighlightEntityPathReqBodyBuilder {
	builder.text = text
	builder.textFlag = true
	return builder
}

func (builder *HighlightEntityPathReqBodyBuilder) Build() (*HighlightEntityReqBody, error) {
	req := &HighlightEntityReqBody{}
	if builder.textFlag {
		req.Text = &builder.text
	}
	return req, nil
}

type HighlightEntityReqBuilder struct {
	apiReq *larkcore.ApiReq
	body   *HighlightEntityReqBody
}

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

// 传入一句话，智能识别句中对应的词条，并返回词条位置和 entity_id，可在外部系统中快速实现百科词条智能高亮。
func (builder *HighlightEntityReqBuilder) Body(body *HighlightEntityReqBody) *HighlightEntityReqBuilder {
	builder.body = body
	return builder
}

func (builder *HighlightEntityReqBuilder) Build() *HighlightEntityReq {
	req := &HighlightEntityReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.Body = builder.body
	return req
}

type HighlightEntityReqBody struct {
	Text *string `json:"text,omitempty"` // 需要识别百科词条的内容（不超过1000字）
}

type HighlightEntityReq struct {
	apiReq *larkcore.ApiReq
	Body   *HighlightEntityReqBody `body:""`
}

type HighlightEntityRespData struct {
	Phrases []*Phrase `json:"phrases,omitempty"` // 识别到的词条信息
}

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

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

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

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

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

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

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

// 相关外部系统【可用来过滤词条数据】
//
// 示例值：星云
func (builder *ListEntityReqBuilder) Provider(provider string) *ListEntityReqBuilder {
	builder.apiReq.QueryParams.Set("provider", fmt.Sprint(provider))
	return builder
}

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

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

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

}

type ListEntityRespData struct {
	Entities []*Entity `json:"entities,omitempty"` // 词条列表

	PageToken *string `json:"page_token,omitempty"` // 分页标记，当还有下一页时会返回新的 page_token，否则 page_token 为空
}

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

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

type MatchEntityReqBodyBuilder struct {
	word     string // 搜索关键词，将与词条名、别名进行精准匹配
	wordFlag bool
}

func NewMatchEntityReqBodyBuilder() *MatchEntityReqBodyBuilder {
	builder := &MatchEntityReqBodyBuilder{}
	return builder
}

// 搜索关键词，将与词条名、别名进行精准匹配
//
//示例值：企业百科
func (builder *MatchEntityReqBodyBuilder) Word(word string) *MatchEntityReqBodyBuilder {
	builder.word = word
	builder.wordFlag = true
	return builder
}

func (builder *MatchEntityReqBodyBuilder) Build() *MatchEntityReqBody {
	req := &MatchEntityReqBody{}
	if builder.wordFlag {
		req.Word = &builder.word
	}
	return req
}

type MatchEntityPathReqBodyBuilder struct {
	word     string
	wordFlag bool
}

func NewMatchEntityPathReqBodyBuilder() *MatchEntityPathReqBodyBuilder {
	builder := &MatchEntityPathReqBodyBuilder{}
	return builder
}

// 搜索关键词，将与词条名、别名进行精准匹配
//
// 示例值：企业百科
func (builder *MatchEntityPathReqBodyBuilder) Word(word string) *MatchEntityPathReqBodyBuilder {
	builder.word = word
	builder.wordFlag = true
	return builder
}

func (builder *MatchEntityPathReqBodyBuilder) Build() (*MatchEntityReqBody, error) {
	req := &MatchEntityReqBody{}
	if builder.wordFlag {
		req.Word = &builder.word
	}
	return req, nil
}

type MatchEntityReqBuilder struct {
	apiReq *larkcore.ApiReq
	body   *MatchEntityReqBody
}

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

// 将关键词与词条名、别名精准匹配，并返回对应的 词条 ID。
func (builder *MatchEntityReqBuilder) Body(body *MatchEntityReqBody) *MatchEntityReqBuilder {
	builder.body = body
	return builder
}

func (builder *MatchEntityReqBuilder) Build() *MatchEntityReq {
	req := &MatchEntityReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.Body = builder.body
	return req
}

type MatchEntityReqBody struct {
	Word *string `json:"word,omitempty"` // 搜索关键词，将与词条名、别名进行精准匹配
}

type MatchEntityReq struct {
	apiReq *larkcore.ApiReq
	Body   *MatchEntityReqBody `body:""`
}

type MatchEntityRespData struct {
	Results []*MatchInfo `json:"results,omitempty"` // 搜索结果
}

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

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

type SearchEntityReqBodyBuilder struct {
	query     string // 搜索关键词
	queryFlag bool

	classificationFilter     *ClassificationFilter // 分类筛选
	classificationFilterFlag bool

	sources     []int // 词条的创建来源，1：用户主动创建，2：批量导入，3：官方词，4：OpenAPI 创建
	sourcesFlag bool

	creators     []string // 创建者
	creatorsFlag bool
}

func NewSearchEntityReqBodyBuilder() *SearchEntityReqBodyBuilder {
	builder := &SearchEntityReqBodyBuilder{}
	return builder
}

// 搜索关键词
//
//示例值：百科
func (builder *SearchEntityReqBodyBuilder) Query(query string) *SearchEntityReqBodyBuilder {
	builder.query = query
	builder.queryFlag = true
	return builder
}

// 分类筛选
//
//示例值：
func (builder *SearchEntityReqBodyBuilder) ClassificationFilter(classificationFilter *ClassificationFilter) *SearchEntityReqBodyBuilder {
	builder.classificationFilter = classificationFilter
	builder.classificationFilterFlag = true
	return builder
}

// 词条的创建来源，1：用户主动创建，2：批量导入，3：官方词，4：OpenAPI 创建
//
//示例值：
func (builder *SearchEntityReqBodyBuilder) Sources(sources []int) *SearchEntityReqBodyBuilder {
	builder.sources = sources
	builder.sourcesFlag = true
	return builder
}

// 创建者
//
//示例值：ou_30b07b63089ea46518789914dac63d36
func (builder *SearchEntityReqBodyBuilder) Creators(creators []string) *SearchEntityReqBodyBuilder {
	builder.creators = creators
	builder.creatorsFlag = true
	return builder
}

func (builder *SearchEntityReqBodyBuilder) Build() *SearchEntityReqBody {
	req := &SearchEntityReqBody{}
	if builder.queryFlag {
		req.Query = &builder.query
	}
	if builder.classificationFilterFlag {
		req.ClassificationFilter = builder.classificationFilter
	}
	if builder.sourcesFlag {
		req.Sources = builder.sources
	}
	if builder.creatorsFlag {
		req.Creators = builder.creators
	}
	return req
}

type SearchEntityPathReqBodyBuilder struct {
	query                    string
	queryFlag                bool
	classificationFilter     *ClassificationFilter
	classificationFilterFlag bool
	sources                  []int
	sourcesFlag              bool
	creators                 []string
	creatorsFlag             bool
}

func NewSearchEntityPathReqBodyBuilder() *SearchEntityPathReqBodyBuilder {
	builder := &SearchEntityPathReqBodyBuilder{}
	return builder
}

// 搜索关键词
//
// 示例值：百科
func (builder *SearchEntityPathReqBodyBuilder) Query(query string) *SearchEntityPathReqBodyBuilder {
	builder.query = query
	builder.queryFlag = true
	return builder
}

// 分类筛选
//
// 示例值：
func (builder *SearchEntityPathReqBodyBuilder) ClassificationFilter(classificationFilter *ClassificationFilter) *SearchEntityPathReqBodyBuilder {
	builder.classificationFilter = classificationFilter
	builder.classificationFilterFlag = true
	return builder
}

// 词条的创建来源，1：用户主动创建，2：批量导入，3：官方词，4：OpenAPI 创建
//
// 示例值：
func (builder *SearchEntityPathReqBodyBuilder) Sources(sources []int) *SearchEntityPathReqBodyBuilder {
	builder.sources = sources
	builder.sourcesFlag = true
	return builder
}

// 创建者
//
// 示例值：ou_30b07b63089ea46518789914dac63d36
func (builder *SearchEntityPathReqBodyBuilder) Creators(creators []string) *SearchEntityPathReqBodyBuilder {
	builder.creators = creators
	builder.creatorsFlag = true
	return builder
}

func (builder *SearchEntityPathReqBodyBuilder) Build() (*SearchEntityReqBody, error) {
	req := &SearchEntityReqBody{}
	if builder.queryFlag {
		req.Query = &builder.query
	}
	if builder.classificationFilterFlag {
		req.ClassificationFilter = builder.classificationFilter
	}
	if builder.sourcesFlag {
		req.Sources = builder.sources
	}
	if builder.creatorsFlag {
		req.Creators = builder.creators
	}
	return req, nil
}

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

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

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

// 每页返回的词条量
//
// 示例值：10
func (builder *SearchEntityReqBuilder) PageSize(pageSize int) *SearchEntityReqBuilder {
	builder.apiReq.QueryParams.Set("page_size", fmt.Sprint(pageSize))
	return builder
}

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

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

// 传入关键词，与词条名、别名、释义等信息进行模糊匹配，返回搜到的词条信息。
func (builder *SearchEntityReqBuilder) Body(body *SearchEntityReqBody) *SearchEntityReqBuilder {
	builder.body = body
	return builder
}

func (builder *SearchEntityReqBuilder) Build() *SearchEntityReq {
	req := &SearchEntityReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.Limit = builder.limit
	req.apiReq.QueryParams = builder.apiReq.QueryParams
	req.apiReq.Body = builder.body
	return req
}

type SearchEntityReqBody struct {
	Query *string `json:"query,omitempty"` // 搜索关键词

	ClassificationFilter *ClassificationFilter `json:"classification_filter,omitempty"` // 分类筛选

	Sources []int `json:"sources,omitempty"` // 词条的创建来源，1：用户主动创建，2：批量导入，3：官方词，4：OpenAPI 创建

	Creators []string `json:"creators,omitempty"` // 创建者
}

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

}

type SearchEntityRespData struct {
	Entities []*Entity `json:"entities,omitempty"` // 搜索结果

	PageToken *string `json:"page_token,omitempty"` // 分页标记，当还有下一页时会返回新的 page_token，否则 page_token 为空
}

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

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

type UpdateEntityReqBuilder struct {
	apiReq *larkcore.ApiReq
	entity *Entity
}

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

// 实体词 ID
//
// 示例值：enterprise_40217521
func (builder *UpdateEntityReqBuilder) EntityId(entityId string) *UpdateEntityReqBuilder {
	builder.apiReq.PathParams.Set("entity_id", fmt.Sprint(entityId))
	return builder
}

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

// 通过此接口更新已有的词条，不需要百科管理员审核可直接写入词库，请慎重使用【租户管理员请慎重审批】。
func (builder *UpdateEntityReqBuilder) Entity(entity *Entity) *UpdateEntityReqBuilder {
	builder.entity = entity
	return builder
}

func (builder *UpdateEntityReqBuilder) Build() *UpdateEntityReq {
	req := &UpdateEntityReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.PathParams = builder.apiReq.PathParams
	req.apiReq.QueryParams = builder.apiReq.QueryParams
	req.apiReq.Body = builder.entity
	return req
}

type UpdateEntityReq struct {
	apiReq *larkcore.ApiReq
	Entity *Entity `body:""`
}

type UpdateEntityRespData struct {
	Entity *Entity `json:"entity,omitempty"` // 词条信息
}

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

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

type DownloadFileReqBuilder struct {
	apiReq *larkcore.ApiReq
}

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

// 需要下载的文件 token
//
// 示例值：boxbcEcmKiD3SGHvgqWTpvdc7jc
func (builder *DownloadFileReqBuilder) FileToken(fileToken string) *DownloadFileReqBuilder {
	builder.apiReq.PathParams.Set("file_token", fmt.Sprint(fileToken))
	return builder
}

func (builder *DownloadFileReqBuilder) Build() *DownloadFileReq {
	req := &DownloadFileReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.PathParams = builder.apiReq.PathParams
	return req
}

type DownloadFileReq struct {
	apiReq *larkcore.ApiReq
}

type DownloadFileResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
	File     io.Reader `json:"-"`
	FileName string    `json:"-"`
}

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

func (resp *DownloadFileResp) WriteFile(fileName string) error {
	bs, err := ioutil.ReadAll(resp.File)
	if err != nil {
		return err
	}

	err = ioutil.WriteFile(fileName, bs, 0666)
	if err != nil {
		return err
	}
	return nil
}

type UploadFileReqBuilder struct {
	apiReq *larkcore.ApiReq
	file   *File
}

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

// 百科词条图片资源上传。
func (builder *UploadFileReqBuilder) File(file *File) *UploadFileReqBuilder {
	builder.file = file
	return builder
}

func (builder *UploadFileReqBuilder) Build() *UploadFileReq {
	req := &UploadFileReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.Body = builder.file
	return req
}

type UploadFileReq struct {
	apiReq *larkcore.ApiReq
	File   *File `body:""`
}

type UploadFileRespData struct {
	FileToken *string `json:"file_token,omitempty"` // 文件 token
}

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

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

type ListClassificationIterator struct {
	nextPageToken *string
	items         []*Classification
	index         int
	limit         int
	ctx           context.Context
	req           *ListClassificationReq
	listFunc      func(ctx context.Context, req *ListClassificationReq, options ...larkcore.RequestOptionFunc) (*ListClassificationResp, error)
	options       []larkcore.RequestOptionFunc
	curlNum       int
}

func (iterator *ListClassificationIterator) Next() (bool, *Classification, 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 *ListClassificationIterator) NextPageToken() *string {
	return iterator.nextPageToken
}

type ListEntityIterator struct {
	nextPageToken *string
	items         []*Entity
	index         int
	limit         int
	ctx           context.Context
	req           *ListEntityReq
	listFunc      func(ctx context.Context, req *ListEntityReq, options ...larkcore.RequestOptionFunc) (*ListEntityResp, error)
	options       []larkcore.RequestOptionFunc
	curlNum       int
}

func (iterator *ListEntityIterator) Next() (bool, *Entity, 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.Entities) == 0 {
			return false, nil, nil
		}

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

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

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

type SearchEntityIterator struct {
	nextPageToken *string
	items         []*Entity
	index         int
	limit         int
	ctx           context.Context
	req           *SearchEntityReq
	listFunc      func(ctx context.Context, req *SearchEntityReq, options ...larkcore.RequestOptionFunc) (*SearchEntityResp, error)
	options       []larkcore.RequestOptionFunc
	curlNum       int
}

func (iterator *SearchEntityIterator) Next() (bool, *Entity, 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.Entities) == 0 {
			return false, nil, nil
		}

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

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

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