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

package lark

import (
	"context"
)

// MatchLingoEntity 将关键词与词条名、别名精准匹配, 并返回对应的 词条 ID。
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/lingo-v1/entity/match
func (r *LingoService) MatchLingoEntity(ctx context.Context, request *MatchLingoEntityReq, options ...MethodOptionFunc) (*MatchLingoEntityResp, *Response, error) {
	if r.cli.mock.mockLingoMatchLingoEntity != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Lingo#MatchLingoEntity mock enable")
		return r.cli.mock.mockLingoMatchLingoEntity(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:                 "Lingo",
		API:                   "MatchLingoEntity",
		Method:                "POST",
		URL:                   r.cli.openBaseURL + "/open-apis/lingo/v1/entities/match",
		Body:                  request,
		MethodOption:          newMethodOption(options),
		NeedTenantAccessToken: true,
		NeedUserAccessToken:   true,
	}
	resp := new(matchLingoEntityResp)

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

// MockLingoMatchLingoEntity mock LingoMatchLingoEntity method
func (r *Mock) MockLingoMatchLingoEntity(f func(ctx context.Context, request *MatchLingoEntityReq, options ...MethodOptionFunc) (*MatchLingoEntityResp, *Response, error)) {
	r.mockLingoMatchLingoEntity = f
}

// UnMockLingoMatchLingoEntity un-mock LingoMatchLingoEntity method
func (r *Mock) UnMockLingoMatchLingoEntity() {
	r.mockLingoMatchLingoEntity = nil
}

// MatchLingoEntityReq ...
type MatchLingoEntityReq struct {
	RepoID *string `query:"repo_id" json:"-"` // 词库ID(不传时默认在全员词库内搜索), 如以应用身份搜索非全员词库中的词条, 需要在“词库设置”页面添加应用；若以用户身份搜索非全员词库中的词条, 该用户需要拥有对应词库的可见权限, 示例值: 7202510112396640276
	Word   string  `json:"word,omitempty"`    // 搜索关键词, 将与词条名、别名进行精准匹配, 示例值: "飞书词典", 长度范围: `1` ～ `100` 字符
}

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

// MatchLingoEntityRespResult ...
type MatchLingoEntityRespResult struct {
	EntityID string `json:"entity_id,omitempty"` // 词条 ID
	Type     int64  `json:"type,omitempty"`      // 匹配中的字段, 可选值有: 0: 词条名, 1: 全称, 2: 别名
}

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