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

// SearchAttendanceGroup 按考勤组名称查询考勤组摘要信息。查询条件支持名称精确匹配和模糊匹配两种方式。查询结果按考勤组修改时间 desc 排序, 且最大记录数为 10 条。
//
// 该接口依赖的数据和考勤组主数据间存在数据同步延时（正常数据同步 2 秒以内）, 因此在使用该接口时需注意评估数据延迟潜在风险。
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/attendance-v1/group/search
// new doc: https://open.feishu.cn/document/server-docs/attendance-v1/group/search
func (r *AttendanceService) SearchAttendanceGroup(ctx context.Context, request *SearchAttendanceGroupReq, options ...MethodOptionFunc) (*SearchAttendanceGroupResp, *Response, error) {
	if r.cli.mock.mockAttendanceSearchAttendanceGroup != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Attendance#SearchAttendanceGroup mock enable")
		return r.cli.mock.mockAttendanceSearchAttendanceGroup(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:                 "Attendance",
		API:                   "SearchAttendanceGroup",
		Method:                "POST",
		URL:                   r.cli.openBaseURL + "/open-apis/attendance/v1/groups/search",
		Body:                  request,
		MethodOption:          newMethodOption(options),
		NeedTenantAccessToken: true,
	}
	resp := new(searchAttendanceGroupResp)

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

// MockAttendanceSearchAttendanceGroup mock AttendanceSearchAttendanceGroup method
func (r *Mock) MockAttendanceSearchAttendanceGroup(f func(ctx context.Context, request *SearchAttendanceGroupReq, options ...MethodOptionFunc) (*SearchAttendanceGroupResp, *Response, error)) {
	r.mockAttendanceSearchAttendanceGroup = f
}

// UnMockAttendanceSearchAttendanceGroup un-mock AttendanceSearchAttendanceGroup method
func (r *Mock) UnMockAttendanceSearchAttendanceGroup() {
	r.mockAttendanceSearchAttendanceGroup = nil
}

// SearchAttendanceGroupReq ...
type SearchAttendanceGroupReq struct {
	GroupName string `json:"group_name,omitempty"` // 考勤组名称, 示例值: "考勤组1"
}

// SearchAttendanceGroupResp ...
type SearchAttendanceGroupResp struct {
	GroupList []*SearchAttendanceGroupRespGroup `json:"group_list,omitempty"` // 考勤组列表
}

// SearchAttendanceGroupRespGroup ...
type SearchAttendanceGroupRespGroup struct {
	GroupID   string `json:"group_id,omitempty"`   // 考勤组 ID
	GroupName string `json:"group_name,omitempty"` // 考勤组名称
}

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