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

// GetSheetList 该接口用于获取电子表格下所有工作表及其属性。
//
// doc: https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/sheets-v3/spreadsheet-sheet/query
// new doc: https://open.feishu.cn/document/server-docs/docs/sheets-v3/spreadsheet-sheet/query
func (r *DriveService) GetSheetList(ctx context.Context, request *GetSheetListReq, options ...MethodOptionFunc) (*GetSheetListResp, *Response, error) {
	if r.cli.mock.mockDriveGetSheetList != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Drive#GetSheetList mock enable")
		return r.cli.mock.mockDriveGetSheetList(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:                 "Drive",
		API:                   "GetSheetList",
		Method:                "GET",
		URL:                   r.cli.openBaseURL + "/open-apis/sheets/v3/spreadsheets/:spreadsheet_token/sheets/query",
		Body:                  request,
		MethodOption:          newMethodOption(options),
		NeedTenantAccessToken: true,
		NeedUserAccessToken:   true,
	}
	resp := new(getSheetListResp)

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

// MockDriveGetSheetList mock DriveGetSheetList method
func (r *Mock) MockDriveGetSheetList(f func(ctx context.Context, request *GetSheetListReq, options ...MethodOptionFunc) (*GetSheetListResp, *Response, error)) {
	r.mockDriveGetSheetList = f
}

// UnMockDriveGetSheetList un-mock DriveGetSheetList method
func (r *Mock) UnMockDriveGetSheetList() {
	r.mockDriveGetSheetList = nil
}

// GetSheetListReq ...
type GetSheetListReq struct {
	SpreadSheetToken string `path:"spreadsheet_token" json:"-"` // 电子表格的token, 示例值: "shtxxxxxxxxxxxxxxxx"
}

// GetSheetListResp ...
type GetSheetListResp struct {
	Sheets []*GetSheetListRespSheet `json:"sheets,omitempty"` // 工作表列表
}

// GetSheetListRespSheet ...
type GetSheetListRespSheet struct {
	SheetID        string                               `json:"sheet_id,omitempty"`        // 工作表id
	Title          string                               `json:"title,omitempty"`           // 工作表标题
	Index          int64                                `json:"index,omitempty"`           // 工作表索引位置, 索引从 0 开始计数。
	Hidden         bool                                 `json:"hidden,omitempty"`          // 工作表是否被隐藏, `true`: 表示被隐藏, `false`: 表示未被隐藏
	GridProperties *GetSheetListRespSheetGridProperties `json:"grid_properties,omitempty"` // 单元格属性, 仅当 `resource_type=sheet` 时返回
	ResourceType   string                               `json:"resource_type,omitempty"`   // 工作表类型, `sheet`: 工作表, `bitable`: 多维表格, [多维表格概述](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/bitable-overview), `#UNSUPPORTED_TYPE`: 不支持的类型
	Merges         []*GetSheetListRespSheetMerge        `json:"merges,omitempty"`          // 合并单元格的相关信息
}

// GetSheetListRespSheetGridProperties ...
type GetSheetListRespSheetGridProperties struct {
	FrozenRowCount    int64 `json:"frozen_row_count,omitempty"`    // 冻结的行数量
	FrozenColumnCount int64 `json:"frozen_column_count,omitempty"` // 冻结的列数量
	RowCount          int64 `json:"row_count,omitempty"`           // 工作表的行数
	ColumnCount       int64 `json:"column_count,omitempty"`        // 工作表的列数量
}

// GetSheetListRespSheetMerge ...
type GetSheetListRespSheetMerge struct {
	StartRowIndex    int64 `json:"start_row_index,omitempty"`    // 起始行
	EndRowIndex      int64 `json:"end_row_index,omitempty"`      // 结束行
	StartColumnIndex int64 `json:"start_column_index,omitempty"` // 起始列
	EndColumnIndex   int64 `json:"end_column_index,omitempty"`   // 结束列
}

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