// Code generated by Lark OpenAPI.

package larkhelpdesk

import (
	"bytes"
	"context"
	"github.com/larksuite/oapi-sdk-go/v3/core"
	"net/http"
)

type V1 struct {
	Agent                 *agent                 // 客服
	AgentSchedules        *agentSchedules        // 客服工作日程
	AgentSchedule         *agentSchedule         // agent_schedule
	AgentSkill            *agentSkill            // 客服技能
	AgentSkillRule        *agentSkillRule        // 客服技能规则
	BotMessage            *botMessage            // 机器人消息
	Category              *category              // 知识库分类
	Event                 *event                 // 事件订阅
	Faq                   *faq                   // 知识库
	Notification          *notification          // 推送中心
	Ticket                *ticket                // 工单
	TicketMessage         *ticketMessage         // 工单消息
	TicketCustomizedField *ticketCustomizedField // 工单自定义字段
}

func New(config *larkcore.Config) *V1 {
	return &V1{
		Agent:                 &agent{config: config},
		AgentSchedules:        &agentSchedules{config: config},
		AgentSchedule:         &agentSchedule{config: config},
		AgentSkill:            &agentSkill{config: config},
		AgentSkillRule:        &agentSkillRule{config: config},
		BotMessage:            &botMessage{config: config},
		Category:              &category{config: config},
		Event:                 &event{config: config},
		Faq:                   &faq{config: config},
		Notification:          &notification{config: config},
		Ticket:                &ticket{config: config},
		TicketMessage:         &ticketMessage{config: config},
		TicketCustomizedField: &ticketCustomizedField{config: config},
	}
}

type agent struct {
	config *larkcore.Config
}
type agentSchedules struct {
	config *larkcore.Config
}
type agentSchedule struct {
	config *larkcore.Config
}
type agentSkill struct {
	config *larkcore.Config
}
type agentSkillRule struct {
	config *larkcore.Config
}
type botMessage struct {
	config *larkcore.Config
}
type category struct {
	config *larkcore.Config
}
type event struct {
	config *larkcore.Config
}
type faq struct {
	config *larkcore.Config
}
type notification struct {
	config *larkcore.Config
}
type ticket struct {
	config *larkcore.Config
}
type ticketMessage struct {
	config *larkcore.Config
}
type ticketCustomizedField struct {
	config *larkcore.Config
}

// AgentEmail 获取客服邮箱地址
//
// - 该接口用于获取客服邮箱地址
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/agent/agent_email
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/agentEmail_agent.go
func (a *agent) AgentEmail(ctx context.Context, options ...larkcore.RequestOptionFunc) (*AgentEmailAgentResp, error) {
	// 发起请求
	apiReq := &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	apiReq.ApiPath = "/open-apis/helpdesk/v1/agent_emails"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, a.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &AgentEmailAgentResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, a.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Patch 更新客服信息
//
// - 更新客服状态等信息
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/agent/patch
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/patch_agent.go
func (a *agent) Patch(ctx context.Context, req *PatchAgentReq, options ...larkcore.RequestOptionFunc) (*PatchAgentResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/agents/:agent_id"
	apiReq.HttpMethod = http.MethodPatch
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, a.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &PatchAgentResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, a.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Delete 删除客服
//
// - 该接口用于删除客服
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/agent-schedules/delete
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/delete_agentSchedules.go
func (a *agentSchedules) Delete(ctx context.Context, req *DeleteAgentSchedulesReq, options ...larkcore.RequestOptionFunc) (*DeleteAgentSchedulesResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/agents/:agent_id/schedules"
	apiReq.HttpMethod = http.MethodDelete
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, a.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &DeleteAgentSchedulesResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, a.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Get 获取客服工作日程;
//
// - 该接口用于获取客服信息
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/agent-schedules/get
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/get_agentSchedules.go
func (a *agentSchedules) Get(ctx context.Context, req *GetAgentSchedulesReq, options ...larkcore.RequestOptionFunc) (*GetAgentSchedulesResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/agents/:agent_id/schedules"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, a.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &GetAgentSchedulesResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, a.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Patch 更新客服日程
//
// - 该接口用于更新客服的日程
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/agent-schedules/patch
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/patch_agentSchedules.go
func (a *agentSchedules) Patch(ctx context.Context, req *PatchAgentSchedulesReq, options ...larkcore.RequestOptionFunc) (*PatchAgentSchedulesResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/agents/:agent_id/schedules"
	apiReq.HttpMethod = http.MethodPatch
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, a.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &PatchAgentSchedulesResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, a.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Create 创建客服
//
// - 该接口用于创建客服
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/agent_schedule/create
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/create_agentSchedule.go
func (a *agentSchedule) Create(ctx context.Context, req *CreateAgentScheduleReq, options ...larkcore.RequestOptionFunc) (*CreateAgentScheduleResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/agent_schedules"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, a.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &CreateAgentScheduleResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, a.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// List 获取全部客服工作日程
//
// - 该接口用于获取所有客服信息
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/agent_schedule/list
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/list_agentSchedule.go
func (a *agentSchedule) List(ctx context.Context, req *ListAgentScheduleReq, options ...larkcore.RequestOptionFunc) (*ListAgentScheduleResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/agent_schedules"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, a.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &ListAgentScheduleResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, a.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Create 创建客服技能
//
// - 该接口用于创建客服技能
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/agent_skill/create
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/create_agentSkill.go
func (a *agentSkill) Create(ctx context.Context, req *CreateAgentSkillReq, options ...larkcore.RequestOptionFunc) (*CreateAgentSkillResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/agent_skills"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, a.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &CreateAgentSkillResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, a.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Delete 删除客服技能
//
// - 该接口用于删除客服技能
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/agent_skill/delete
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/delete_agentSkill.go
func (a *agentSkill) Delete(ctx context.Context, req *DeleteAgentSkillReq, options ...larkcore.RequestOptionFunc) (*DeleteAgentSkillResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/agent_skills/:agent_skill_id"
	apiReq.HttpMethod = http.MethodDelete
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, a.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &DeleteAgentSkillResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, a.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Get 获取客服技能
//
// - 该接口用于获取客服技能
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/agent_skill/get
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/get_agentSkill.go
func (a *agentSkill) Get(ctx context.Context, req *GetAgentSkillReq, options ...larkcore.RequestOptionFunc) (*GetAgentSkillResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/agent_skills/:agent_skill_id"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, a.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &GetAgentSkillResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, a.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// List 获取全部客服技能
//
// - 获取全部客服技能
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/agent_skill/list
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/list_agentSkill.go
func (a *agentSkill) List(ctx context.Context, options ...larkcore.RequestOptionFunc) (*ListAgentSkillResp, error) {
	// 发起请求
	apiReq := &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	apiReq.ApiPath = "/open-apis/helpdesk/v1/agent_skills"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, a.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &ListAgentSkillResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, a.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Patch 更新客服技能
//
// - 该接口用于更新客服技能
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/agent_skill/patch
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/patch_agentSkill.go
func (a *agentSkill) Patch(ctx context.Context, req *PatchAgentSkillReq, options ...larkcore.RequestOptionFunc) (*PatchAgentSkillResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/agent_skills/:agent_skill_id"
	apiReq.HttpMethod = http.MethodPatch
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, a.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &PatchAgentSkillResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, a.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// List 获取客服技能列表
//
// - 该接口用于获取全部客服技能。仅支持自建应用。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/agent_skill_rule/list
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/list_agentSkillRule.go
func (a *agentSkillRule) List(ctx context.Context, options ...larkcore.RequestOptionFunc) (*ListAgentSkillRuleResp, error) {
	// 发起请求
	apiReq := &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	apiReq.ApiPath = "/open-apis/helpdesk/v1/agent_skill_rules"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, a.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &ListAgentSkillRuleResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, a.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Create 服务台机器人发送消息
//
// - 通过服务台机器人给指定用户的服务台专属群或私聊发送消息，支持文本、富文本、卡片、图片。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/bot-message/create
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/create_botMessage.go
func (b *botMessage) Create(ctx context.Context, req *CreateBotMessageReq, options ...larkcore.RequestOptionFunc) (*CreateBotMessageResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/message"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, b.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &CreateBotMessageResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, b.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Create 创建知识库分类
//
// - 该接口用于创建知识库分类。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/category/create
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/create_category.go
func (c *category) Create(ctx context.Context, req *CreateCategoryReq, options ...larkcore.RequestOptionFunc) (*CreateCategoryResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/categories"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &CreateCategoryResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, c.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Delete 删除知识库分类详情
//
// - 该接口用于删除知识库分类详情。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/category/delete
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/delete_category.go
func (c *category) Delete(ctx context.Context, req *DeleteCategoryReq, options ...larkcore.RequestOptionFunc) (*DeleteCategoryResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/categories/:id"
	apiReq.HttpMethod = http.MethodDelete
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &DeleteCategoryResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, c.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Get 获取知识库分类
//
// - 该接口用于获取知识库分类。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/category/get
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/get_category.go
func (c *category) Get(ctx context.Context, req *GetCategoryReq, options ...larkcore.RequestOptionFunc) (*GetCategoryResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/categories/:id"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &GetCategoryResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, c.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// List 获取全部知识库分类 - meta
//
// - 该接口用于获取服务台知识库所有分类
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/category/list
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/list_category.go
func (c *category) List(ctx context.Context, req *ListCategoryReq, options ...larkcore.RequestOptionFunc) (*ListCategoryResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/categories"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &ListCategoryResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, c.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Patch 更新知识库分类详情
//
// - 该接口用于更新知识库分类详情。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/category/patch
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/patch_category.go
func (c *category) Patch(ctx context.Context, req *PatchCategoryReq, options ...larkcore.RequestOptionFunc) (*PatchCategoryResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/categories/:id"
	apiReq.HttpMethod = http.MethodPatch
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, c.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &PatchCategoryResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, c.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Subscribe 订阅服务台事件
//
// - 用于订阅服务台事件
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/event/subscribe
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/subscribe_event.go
func (e *event) Subscribe(ctx context.Context, req *SubscribeEventReq, options ...larkcore.RequestOptionFunc) (*SubscribeEventResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/events/subscribe"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, e.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &SubscribeEventResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, e.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Unsubscribe 取消订阅服务台事件
//
// - 用于取消订阅服务台事件
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/event/unsubscribe
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/unsubscribe_event.go
func (e *event) Unsubscribe(ctx context.Context, req *UnsubscribeEventReq, options ...larkcore.RequestOptionFunc) (*UnsubscribeEventResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/events/unsubscribe"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, e.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &UnsubscribeEventResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, e.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Create 创建知识库
//
// - 该接口用于创建知识库。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/faq/create
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/create_faq.go
func (f *faq) Create(ctx context.Context, req *CreateFaqReq, options ...larkcore.RequestOptionFunc) (*CreateFaqResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/faqs"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, f.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &CreateFaqResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, f.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Delete 删除知识库
//
// - 该接口用于删除知识库。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/faq/delete
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/delete_faq.go
func (f *faq) Delete(ctx context.Context, req *DeleteFaqReq, options ...larkcore.RequestOptionFunc) (*DeleteFaqResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/faqs/:id"
	apiReq.HttpMethod = http.MethodDelete
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, f.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &DeleteFaqResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, f.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// FaqImage 获取知识库图像
//
// - 该接口用于获取知识库图像。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/faq/faq_image
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/faqImage_faq.go
func (f *faq) FaqImage(ctx context.Context, req *FaqImageFaqReq, options ...larkcore.RequestOptionFunc) (*FaqImageFaqResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/faqs/:id/image/:image_key"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, f.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &FaqImageFaqResp{ApiResp: apiResp}
	// 如果是下载，则设置响应结果
	if apiResp.StatusCode == http.StatusOK {
		resp.File = bytes.NewBuffer(apiResp.RawBody)
		resp.FileName = larkcore.FileNameByHeader(apiResp.Header)
		return resp, err
	}
	err = apiResp.JSONUnmarshalBody(resp, f.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Get 获取知识库详情
//
// - 该接口用于获取服务台知识库详情。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/faq/get
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/get_faq.go
func (f *faq) Get(ctx context.Context, req *GetFaqReq, options ...larkcore.RequestOptionFunc) (*GetFaqResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/faqs/:id"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, f.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &GetFaqResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, f.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// List 获取全部知识库详情
//
// - 该接口用于获取服务台知识库详情。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/faq/list
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/list_faq.go
func (f *faq) List(ctx context.Context, req *ListFaqReq, options ...larkcore.RequestOptionFunc) (*ListFaqResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/faqs"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, f.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &ListFaqResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, f.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}
func (f *faq) ListByIterator(ctx context.Context, req *ListFaqReq, options ...larkcore.RequestOptionFunc) (*ListFaqIterator, error) {
	return &ListFaqIterator{
		ctx:      ctx,
		req:      req,
		listFunc: f.List,
		options:  options,
		limit:    req.Limit}, nil
}

// Patch 修改知识库
//
// - 该接口用于修改知识库。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/faq/patch
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/patch_faq.go
func (f *faq) Patch(ctx context.Context, req *PatchFaqReq, options ...larkcore.RequestOptionFunc) (*PatchFaqResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/faqs/:id"
	apiReq.HttpMethod = http.MethodPatch
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, f.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &PatchFaqResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, f.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Search 搜索知识库
//
// - 该接口用于搜索服务台知识库。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/faq/search
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/search_faq.go
func (f *faq) Search(ctx context.Context, req *SearchFaqReq, options ...larkcore.RequestOptionFunc) (*SearchFaqResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/faqs/search"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, f.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &SearchFaqResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, f.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}
func (f *faq) SearchByIterator(ctx context.Context, req *SearchFaqReq, options ...larkcore.RequestOptionFunc) (*SearchFaqIterator, error) {
	return &SearchFaqIterator{
		ctx:      ctx,
		req:      req,
		listFunc: f.Search,
		options:  options,
		limit:    req.Limit}, nil
}

// CancelApprove 取消审核
//
// - 提交审核后，如果需要取消审核，则调用此接口
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/notification/cancel_approve
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/cancelApprove_notification.go
func (n *notification) CancelApprove(ctx context.Context, req *CancelApproveNotificationReq, options ...larkcore.RequestOptionFunc) (*CancelApproveNotificationResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/notifications/:notification_id/cancel_approve"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, n.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &CancelApproveNotificationResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, n.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// CancelSend 取消推送
//
// - 取消推送接口，审核通过后待调度可以调用，发送过程中可以调用（会撤回已发送的消息），发送完成后可以需要推送（会撤回所有已发送的消息）
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/notification/cancel_send
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/cancelSend_notification.go
func (n *notification) CancelSend(ctx context.Context, req *CancelSendNotificationReq, options ...larkcore.RequestOptionFunc) (*CancelSendNotificationResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/notifications/:notification_id/cancel_send"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, n.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &CancelSendNotificationResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, n.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Create 创建推送
//
// - 调用接口创建推送，创建成功后为草稿状态
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/notification/create
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/create_notification.go
func (n *notification) Create(ctx context.Context, req *CreateNotificationReq, options ...larkcore.RequestOptionFunc) (*CreateNotificationResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/notifications"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, n.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &CreateNotificationResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, n.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// ExecuteSend 执行推送
//
// - 审核通过后调用此接口设置推送时间，等待调度系统调度，发送消息
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/notification/execute_send
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/executeSend_notification.go
func (n *notification) ExecuteSend(ctx context.Context, req *ExecuteSendNotificationReq, options ...larkcore.RequestOptionFunc) (*ExecuteSendNotificationResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/notifications/:notification_id/execute_send"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, n.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &ExecuteSendNotificationResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, n.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Get 查询推送
//
// - 查询推送详情
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/notification/get
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/get_notification.go
func (n *notification) Get(ctx context.Context, req *GetNotificationReq, options ...larkcore.RequestOptionFunc) (*GetNotificationResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/notifications/:notification_id"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, n.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &GetNotificationResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, n.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Patch 更新推送
//
// - 更新推送信息，只有在草稿状态下才可以调用此接口进行更新
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/notification/patch
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/patch_notification.go
func (n *notification) Patch(ctx context.Context, req *PatchNotificationReq, options ...larkcore.RequestOptionFunc) (*PatchNotificationResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/notifications/:notification_id"
	apiReq.HttpMethod = http.MethodPatch
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, n.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &PatchNotificationResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, n.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Preview 预览推送内容
//
// - 在正式执行推送之前是可以调用此接口预览设置的推送内容
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/notification/preview
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/preview_notification.go
func (n *notification) Preview(ctx context.Context, req *PreviewNotificationReq, options ...larkcore.RequestOptionFunc) (*PreviewNotificationResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/notifications/:notification_id/preview"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, n.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &PreviewNotificationResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, n.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// SubmitApprove 提交审核
//
// - 正常情况下调用创建推送接口后，就可以调用提交审核接口，如果创建人是服务台owner则会自动审核通过，否则会通知服务台owner审核此推送信息
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/notification/submit_approve
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/submitApprove_notification.go
func (n *notification) SubmitApprove(ctx context.Context, req *SubmitApproveNotificationReq, options ...larkcore.RequestOptionFunc) (*SubmitApproveNotificationResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/notifications/:notification_id/submit_approve"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, n.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &SubmitApproveNotificationResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, n.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// AnswerUserQuery 回复用户提问结果至工单
//
// - 该接口用于回复用户提问结果至工单，需要工单仍处于进行中且未接入人工状态。仅支持自建应用。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/ticket/answer_user_query
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/answerUserQuery_ticket.go
func (t *ticket) AnswerUserQuery(ctx context.Context, req *AnswerUserQueryTicketReq, options ...larkcore.RequestOptionFunc) (*AnswerUserQueryTicketResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/tickets/:ticket_id/answer_user_query"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, t.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &AnswerUserQueryTicketResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, t.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// CustomizedFields 获取服务台自定义字段详情
//
// - 该接口用于获取服务台自定义字段详情。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/ticket/customized_fields
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/customizedFields_ticket.go
func (t *ticket) CustomizedFields(ctx context.Context, req *CustomizedFieldsTicketReq, options ...larkcore.RequestOptionFunc) (*CustomizedFieldsTicketResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/customized_fields"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, t.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &CustomizedFieldsTicketResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, t.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Get 获取工单详情
//
// - 该接口用于获取单个服务台工单详情。仅支持自建应用。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/ticket/get
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/get_ticket.go
func (t *ticket) Get(ctx context.Context, req *GetTicketReq, options ...larkcore.RequestOptionFunc) (*GetTicketResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/tickets/:ticket_id"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, t.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &GetTicketResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, t.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// List 获取全部工单详情
//
// - 该接口用于获取全部工单详情。仅支持自建应用。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/ticket/list
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/list_ticket.go
func (t *ticket) List(ctx context.Context, req *ListTicketReq, options ...larkcore.RequestOptionFunc) (*ListTicketResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/tickets"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, t.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &ListTicketResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, t.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// StartService 创建服务台对话
//
// - 该接口用于创建服务台对话。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/ticket/start_service
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/startService_ticket.go
func (t *ticket) StartService(ctx context.Context, req *StartServiceTicketReq, options ...larkcore.RequestOptionFunc) (*StartServiceTicketResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/start_service"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, t.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &StartServiceTicketResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, t.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// TicketImage 获取服务台工单内消息图像
//
// - 该接口用于获取服务台工单消息图象。仅支持自建应用。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/ticket/ticket_image
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/ticketImage_ticket.go
func (t *ticket) TicketImage(ctx context.Context, req *TicketImageTicketReq, options ...larkcore.RequestOptionFunc) (*TicketImageTicketResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/ticket_images"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, t.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &TicketImageTicketResp{ApiResp: apiResp}
	// 如果是下载，则设置响应结果
	if apiResp.StatusCode == http.StatusOK {
		resp.File = bytes.NewBuffer(apiResp.RawBody)
		resp.FileName = larkcore.FileNameByHeader(apiResp.Header)
		return resp, err
	}
	err = apiResp.JSONUnmarshalBody(resp, t.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Update 更新工单详情
//
// - 该接口用于更新服务台工单详情。只会更新数据，不会触发相关操作。如修改工单状态到关单，不会关闭聊天页面。仅支持自建应用。要更新的工单字段必须至少输入一项。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/ticket/update
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/update_ticket.go
func (t *ticket) Update(ctx context.Context, req *UpdateTicketReq, options ...larkcore.RequestOptionFunc) (*UpdateTicketResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/tickets/:ticket_id"
	apiReq.HttpMethod = http.MethodPut
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, t.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &UpdateTicketResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, t.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Create 工单发送消息
//
// - 该接口用于工单发送消息。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/ticket-message/create
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/create_ticketMessage.go
func (t *ticketMessage) Create(ctx context.Context, req *CreateTicketMessageReq, options ...larkcore.RequestOptionFunc) (*CreateTicketMessageResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/tickets/:ticket_id/messages"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, t.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &CreateTicketMessageResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, t.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// List 获取服务台工单消息详情
//
// - 该接口用于获取服务台工单消息详情。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/ticket-message/list
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/list_ticketMessage.go
func (t *ticketMessage) List(ctx context.Context, req *ListTicketMessageReq, options ...larkcore.RequestOptionFunc) (*ListTicketMessageResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/tickets/:ticket_id/messages"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, t.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &ListTicketMessageResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, t.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Create 创建工单自定义字段
//
// - 该接口用于创建自定义字段
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/ticket_customized_field/create
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/create_ticketCustomizedField.go
func (t *ticketCustomizedField) Create(ctx context.Context, req *CreateTicketCustomizedFieldReq, options ...larkcore.RequestOptionFunc) (*CreateTicketCustomizedFieldResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/ticket_customized_fields"
	apiReq.HttpMethod = http.MethodPost
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, t.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &CreateTicketCustomizedFieldResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, t.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Delete 删除工单自定义字段
//
// - 该接口用于删除工单自定义字段。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/ticket_customized_field/delete
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/delete_ticketCustomizedField.go
func (t *ticketCustomizedField) Delete(ctx context.Context, req *DeleteTicketCustomizedFieldReq, options ...larkcore.RequestOptionFunc) (*DeleteTicketCustomizedFieldResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/ticket_customized_fields/:ticket_customized_field_id"
	apiReq.HttpMethod = http.MethodDelete
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, t.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &DeleteTicketCustomizedFieldResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, t.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Get 获取工单自定义字段
//
// - 该接口用于获取工单自定义字段详情。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/ticket_customized_field/get
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/get_ticketCustomizedField.go
func (t *ticketCustomizedField) Get(ctx context.Context, req *GetTicketCustomizedFieldReq, options ...larkcore.RequestOptionFunc) (*GetTicketCustomizedFieldResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/ticket_customized_fields/:ticket_customized_field_id"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, t.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &GetTicketCustomizedFieldResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, t.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// List 获取全部工单自定义字段
//
// - 该接口用于获取全部工单自定义字段。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/ticket_customized_field/list
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/list_ticketCustomizedField.go
func (t *ticketCustomizedField) List(ctx context.Context, req *ListTicketCustomizedFieldReq, options ...larkcore.RequestOptionFunc) (*ListTicketCustomizedFieldResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/ticket_customized_fields"
	apiReq.HttpMethod = http.MethodGet
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeTenant}
	apiResp, err := larkcore.Request(ctx, apiReq, t.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &ListTicketCustomizedFieldResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, t.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}

// Patch 更新工单自定义字段
//
// - 该接口用于更新自定义字段。
//
// - 官网API文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/ticket_customized_field/patch
//
// - 使用Demo链接:https://github.com/larksuite/oapi-sdk-go/tree/v3_main/sample/apiall/helpdeskv1/patch_ticketCustomizedField.go
func (t *ticketCustomizedField) Patch(ctx context.Context, req *PatchTicketCustomizedFieldReq, options ...larkcore.RequestOptionFunc) (*PatchTicketCustomizedFieldResp, error) {
	// 发起请求
	apiReq := req.apiReq
	apiReq.ApiPath = "/open-apis/helpdesk/v1/ticket_customized_fields/:ticket_customized_field_id"
	apiReq.HttpMethod = http.MethodPatch
	apiReq.SupportedAccessTokenTypes = []larkcore.AccessTokenType{larkcore.AccessTokenTypeUser}
	apiResp, err := larkcore.Request(ctx, apiReq, t.config, options...)
	if err != nil {
		return nil, err
	}
	// 反序列响应结果
	resp := &PatchTicketCustomizedFieldResp{ApiResp: apiResp}
	err = apiResp.JSONUnmarshalBody(resp, t.config)
	if err != nil {
		return nil, err
	}
	return resp, err
}
