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

// GetTaskSection 获取一个自定义分组详情, 包括名称, 创建人等信息。如果该自定义分组归属于一个清单, 还会返回清单的摘要信息。
//
// 需要清单归属资源的读取权限。
//
// doc: https://open.larkoffice.com/document/uAjLw4CM/ukTMukTMukTM/task-v2/section/get
func (r *TaskService) GetTaskSection(ctx context.Context, request *GetTaskSectionReq, options ...MethodOptionFunc) (*GetTaskSectionResp, *Response, error) {
	if r.cli.mock.mockTaskGetTaskSection != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Task#GetTaskSection mock enable")
		return r.cli.mock.mockTaskGetTaskSection(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:                 "Task",
		API:                   "GetTaskSection",
		Method:                "GET",
		URL:                   r.cli.openBaseURL + "/open-apis/task/v2/sections/:section_guid",
		Body:                  request,
		MethodOption:          newMethodOption(options),
		NeedTenantAccessToken: true,
		NeedUserAccessToken:   true,
	}
	resp := new(getTaskSectionResp)

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

// MockTaskGetTaskSection mock TaskGetTaskSection method
func (r *Mock) MockTaskGetTaskSection(f func(ctx context.Context, request *GetTaskSectionReq, options ...MethodOptionFunc) (*GetTaskSectionResp, *Response, error)) {
	r.mockTaskGetTaskSection = f
}

// UnMockTaskGetTaskSection un-mock TaskGetTaskSection method
func (r *Mock) UnMockTaskGetTaskSection() {
	r.mockTaskGetTaskSection = nil
}

// GetTaskSectionReq ...
type GetTaskSectionReq struct {
	SectionGuid string  `path:"section_guid" json:"-"`  // 要获取的自定义分组GUID, 示例值: "9842501a-9f47-4ff5-a622-d319eeecb97f", 最大长度: `100` 字符
	UserIDType  *IDType `query:"user_id_type" json:"-"` // 用户 ID 类型, 示例值: open_id, 默认值: `open_id`
}

// GetTaskSectionResp ...
type GetTaskSectionResp struct {
	Section *GetTaskSectionRespSection `json:"section,omitempty"` // 获取的自定义分组详情
}

// GetTaskSectionRespSection ...
type GetTaskSectionRespSection struct {
	Guid         string                             `json:"guid,omitempty"`          // 自定义分组的GUID
	Name         string                             `json:"name,omitempty"`          // 自定义分组的名字
	ResourceType string                             `json:"resource_type,omitempty"` // 资源类型
	IsDefault    bool                               `json:"is_default,omitempty"`    // 分组是否为默认自定义分组
	Creator      *GetTaskSectionRespSectionCreator  `json:"creator,omitempty"`       // 自定义分组的创建者
	Tasklist     *GetTaskSectionRespSectionTasklist `json:"tasklist,omitempty"`      // 如果该分组归属于清单, 展示清单的简要信息
	CreatedAt    string                             `json:"created_at,omitempty"`    // 自定义分组创建时间戳(ms)
	UpdatedAt    string                             `json:"updated_at,omitempty"`    // 自定义分组最近一次更新时间戳(ms)
}

// GetTaskSectionRespSectionCreator ...
type GetTaskSectionRespSectionCreator struct {
	ID   string `json:"id,omitempty"`   // 表示member的id
	Type string `json:"type,omitempty"` // 成员的类型
	Role string `json:"role,omitempty"` // 成员角色
}

// GetTaskSectionRespSectionTasklist ...
type GetTaskSectionRespSectionTasklist struct {
	Guid string `json:"guid,omitempty"` // 清单GUID
	Name string `json:"name,omitempty"` // 清单名字
}

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