// 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"
)

// SearchDriveFile 该接口用于根据搜索关键词（search_key）对当前用户可见的文件进行搜索。
//
// doc: https://open.feishu.cn/document/ukTMukTMukTM/ugDM4UjL4ADO14COwgTN
// new doc: https://open.feishu.cn/document/server-docs/docs/drive-v1/search/document-search
func (r *DriveService) SearchDriveFile(ctx context.Context, request *SearchDriveFileReq, options ...MethodOptionFunc) (*SearchDriveFileResp, *Response, error) {
	if r.cli.mock.mockDriveSearchDriveFile != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Drive#SearchDriveFile mock enable")
		return r.cli.mock.mockDriveSearchDriveFile(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:                 "Drive",
		API:                   "SearchDriveFile",
		Method:                "POST",
		URL:                   r.cli.openBaseURL + "/open-apis/suite/docs-api/search/object",
		Body:                  request,
		MethodOption:          newMethodOption(options),
		NeedTenantAccessToken: true,
		NeedUserAccessToken:   true,
	}
	resp := new(searchDriveFileResp)

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

// MockDriveSearchDriveFile mock DriveSearchDriveFile method
func (r *Mock) MockDriveSearchDriveFile(f func(ctx context.Context, request *SearchDriveFileReq, options ...MethodOptionFunc) (*SearchDriveFileResp, *Response, error)) {
	r.mockDriveSearchDriveFile = f
}

// UnMockDriveSearchDriveFile un-mock DriveSearchDriveFile method
func (r *Mock) UnMockDriveSearchDriveFile() {
	r.mockDriveSearchDriveFile = nil
}

// SearchDriveFileReq ...
type SearchDriveFileReq struct {
	SearchKey string   `json:"search_key,omitempty"` // 指定搜索的关键字
	Count     *int64   `json:"count,omitempty"`      // 指定搜索返回的文件数量。取值范围为 [0, 50]。
	Offset    *int64   `json:"offset,omitempty"`     // 指定搜索的偏移量, 该参数最小为 0, 即不偏移。该参数的值与返回的文件数量之和不得小于或等于 200（即 offset + count < 200）。
	OwnerIDs  []string `json:"owner_ids,omitempty"`  // 文件所有者的用户 ID。了解更多, 参考[如何获取 User ID](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-obtain-user-id)。
	ChatIDs   []string `json:"chat_ids,omitempty"`   // 文件所在群的 ID。了解更多, 参考[群 ID 说明](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-id-description)。
	DocsTypes []string `json:"docs_types,omitempty"` // 文件类型, 支持以下枚举: `doc`: 旧版文档, `sheet`: 电子表格, `slide`: 幻灯片, `bitable`: 多维表格, `mindnote`: 思维笔记, `file`: 文件
}

// SearchDriveFileResp ...
type SearchDriveFileResp struct {
	DocsEntities []*SearchDriveFileRespDocsEntity `json:"docs_entities,omitempty"` // 包含搜索关键词的文件列表。
	HasMore      bool                             `json:"has_more,omitempty"`      // 结果列表后是否还有数据。
	Total        int64                            `json:"total,omitempty"`         // 包含搜索关键词的文件总数量。
}

// SearchDriveFileRespDocsEntity ...
type SearchDriveFileRespDocsEntity struct {
	DocsToken string   `json:"docs_token,omitempty"` // 文件的 token。
	DocsType  string   `json:"docs_type,omitempty"`  // 文件的类型。
	Title     string   `json:"title,omitempty"`      // 文件的标题。
	OwnerID   []string `json:"owner_id,omitempty"`   // 文件的所有者。
}

// searchDriveFileResp ...
type searchDriveFileResp struct {
	Code int64                `json:"code,omitempty"`
	Msg  string               `json:"msg,omitempty"`
	Data *SearchDriveFileResp `json:"data,omitempty"`
}
