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

// GetDriveFolderChildren 获取用户云空间中指定文件夹下的文件清单。清单类型包括文件、各种在线文档（文档、电子表格、多维表格、思维笔记）、文件夹和快捷方式。该接口不支持分页, 并且不会递归的获取子文件夹的清单。
//
// 为了更好地提升该接口的安全性, 我们对其进行了升级, 请尽快迁移至
// [新版本>>](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/drive-v1/file/list)
//
// doc: https://open.feishu.cn/document/ukTMukTMukTM/uEjNzUjLxYzM14SM2MTN
// new doc: https://open.feishu.cn/document/server-docs/historic-version/docs/drive/folder/get-folder-children
//
// Deprecated
func (r *DriveService) GetDriveFolderChildren(ctx context.Context, request *GetDriveFolderChildrenReq, options ...MethodOptionFunc) (*GetDriveFolderChildrenResp, *Response, error) {
	if r.cli.mock.mockDriveGetDriveFolderChildren != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Drive#GetDriveFolderChildren mock enable")
		return r.cli.mock.mockDriveGetDriveFolderChildren(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:                 "Drive",
		API:                   "GetDriveFolderChildren",
		Method:                "GET",
		URL:                   r.cli.openBaseURL + "/open-apis/drive/explorer/v2/folder/:folderToken/children",
		Body:                  request,
		MethodOption:          newMethodOption(options),
		NeedTenantAccessToken: true,
		NeedUserAccessToken:   true,
	}
	resp := new(getDriveFolderChildrenResp)

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

// MockDriveGetDriveFolderChildren mock DriveGetDriveFolderChildren method
func (r *Mock) MockDriveGetDriveFolderChildren(f func(ctx context.Context, request *GetDriveFolderChildrenReq, options ...MethodOptionFunc) (*GetDriveFolderChildrenResp, *Response, error)) {
	r.mockDriveGetDriveFolderChildren = f
}

// UnMockDriveGetDriveFolderChildren un-mock DriveGetDriveFolderChildren method
func (r *Mock) UnMockDriveGetDriveFolderChildren() {
	r.mockDriveGetDriveFolderChildren = nil
}

// GetDriveFolderChildrenReq ...
type GetDriveFolderChildrenReq struct {
	FolderToken string   `path:"folderToken" json:"-"` // 文件夹的 token, 获取方式见 [如何获取云文档资源相关 token](https://open.feishu.cn/document/ukTMukTMukTM/uczNzUjL3czM14yN3MTN#08bb5df6)
	Types       []string `query:"types" json:"-"`      // 需要查询的文件类型, 默认返回所有 children；types 可多选, 可选类型有 doc、sheet、file、bitable、docx、folder、mindnote 。如 url?types=folder&types=sheet
}

// GetDriveFolderChildrenResp ...
type GetDriveFolderChildrenResp struct {
	ParentToken string                                         `json:"parentToken,omitempty"` // 文件夹的 token
	Children    map[string]*GetDriveFolderChildrenRespChildren `json:"children,omitempty"`    // 文件夹的下的文件
}

// GetDriveFolderChildrenRespChildren ...
type GetDriveFolderChildrenRespChildren struct {
	Token      string `json:"token,omitempty"`       // 文件的 token
	Name       string `json:"name,omitempty"`        // 文件的标题
	Type       string `json:"type,omitempty"`        // 文件的类型
	IsShortcut bool   `json:"is_shortcut,omitempty"` // 该文件是否是快捷方式, 如果值为true, 代表该文件是一个快捷方式
}

// getDriveFolderChildrenResp ...
type getDriveFolderChildrenResp struct {
	Code  int64                       `json:"code,omitempty"`
	Msg   string                      `json:"msg,omitempty"`
	Data  *GetDriveFolderChildrenResp `json:"data,omitempty"`
	Error *ErrorDetail                `json:"error,omitempty"`
}
