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

// GetAttendanceShift 通过班次的名称查询班次信息。
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/attendance-v1/shift/query
// new doc: https://open.feishu.cn/document/server-docs/attendance-v1/shift/query
func (r *AttendanceService) GetAttendanceShift(ctx context.Context, request *GetAttendanceShiftReq, options ...MethodOptionFunc) (*GetAttendanceShiftResp, *Response, error) {
	if r.cli.mock.mockAttendanceGetAttendanceShift != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Attendance#GetAttendanceShift mock enable")
		return r.cli.mock.mockAttendanceGetAttendanceShift(ctx, request, options...)
	}

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

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

// MockAttendanceGetAttendanceShift mock AttendanceGetAttendanceShift method
func (r *Mock) MockAttendanceGetAttendanceShift(f func(ctx context.Context, request *GetAttendanceShiftReq, options ...MethodOptionFunc) (*GetAttendanceShiftResp, *Response, error)) {
	r.mockAttendanceGetAttendanceShift = f
}

// UnMockAttendanceGetAttendanceShift un-mock AttendanceGetAttendanceShift method
func (r *Mock) UnMockAttendanceGetAttendanceShift() {
	r.mockAttendanceGetAttendanceShift = nil
}

// GetAttendanceShiftReq ...
type GetAttendanceShiftReq struct {
	ShiftName string `query:"shift_name" json:"-"` // 班次名称, 示例值: 早班
}

// GetAttendanceShiftResp ...
type GetAttendanceShiftResp struct {
	ShiftID           string                                     `json:"shift_id,omitempty"`              // 班次 ID
	ShiftName         string                                     `json:"shift_name,omitempty"`            // 班次名称
	PunchTimes        int64                                      `json:"punch_times,omitempty"`           // 打卡次数
	IsFlexible        bool                                       `json:"is_flexible,omitempty"`           // 是否弹性打卡
	FlexibleMinutes   int64                                      `json:"flexible_minutes,omitempty"`      // 弹性打卡时间, 设置[上班最多可晚到]与[下班最多可早走]时间, 如果不设置flexible_rule则生效
	FlexibleRule      []*GetAttendanceShiftRespFlexibleRule      `json:"flexible_rule,omitempty"`         // 弹性打卡时间设置
	NoNeedOff         bool                                       `json:"no_need_off,omitempty"`           // 不需要打下班卡
	PunchTimeRule     []*GetAttendanceShiftRespPunchTimeRule     `json:"punch_time_rule,omitempty"`       // 打卡规则
	LateOffLateOnRule []*GetAttendanceShiftRespLateOffLateOnRule `json:"late_off_late_on_rule,omitempty"` // 晚走晚到规则
	RestTimeRule      []*GetAttendanceShiftRespRestTimeRule      `json:"rest_time_rule,omitempty"`        // 休息规则
	OvertimeRule      []*GetAttendanceShiftRespOvertimeRule      `json:"overtime_rule,omitempty"`         // 打卡规则
}

// GetAttendanceShiftRespFlexibleRule ...
type GetAttendanceShiftRespFlexibleRule struct {
	FlexibleEarlyMinutes int64 `json:"flexible_early_minutes,omitempty"` // 下班最多可早走（上班早到几分钟, 下班可早走几分钟）
	FlexibleLateMinutes  int64 `json:"flexible_late_minutes,omitempty"`  // 上班最多可晚到（上班晚到几分钟, 下班须晚走几分钟）
}

// GetAttendanceShiftRespLateOffLateOnRule ...
type GetAttendanceShiftRespLateOffLateOnRule struct {
	LateOffMinutes int64 `json:"late_off_minutes,omitempty"` // 晚走多久
	LateOnMinutes  int64 `json:"late_on_minutes,omitempty"`  // 晚到多久
}

// GetAttendanceShiftRespOvertimeRule ...
type GetAttendanceShiftRespOvertimeRule struct {
	OnOvertime  string `json:"on_overtime,omitempty"`  // 上班时间
	OffOvertime string `json:"off_overtime,omitempty"` // 下班时间
}

// GetAttendanceShiftRespPunchTimeRule ...
type GetAttendanceShiftRespPunchTimeRule struct {
	OnTime                   string `json:"on_time,omitempty"`                      // 上班时间
	OffTime                  string `json:"off_time,omitempty"`                     // 下班时间
	LateMinutesAsLate        int64  `json:"late_minutes_as_late,omitempty"`         // 晚到多久记为迟到
	LateMinutesAsLack        int64  `json:"late_minutes_as_lack,omitempty"`         // 晚到多久记为缺卡
	OnAdvanceMinutes         int64  `json:"on_advance_minutes,omitempty"`           // 最早多久可打上班卡
	EarlyMinutesAsEarly      int64  `json:"early_minutes_as_early,omitempty"`       // 早退多久记为早退
	EarlyMinutesAsLack       int64  `json:"early_minutes_as_lack,omitempty"`        // 早退多久记为缺卡
	OffDelayMinutes          int64  `json:"off_delay_minutes,omitempty"`            // 最晚多久可打下班卡
	LateMinutesAsSeriousLate int64  `json:"late_minutes_as_serious_late,omitempty"` // 晚到多久记为严重迟到
}

// GetAttendanceShiftRespRestTimeRule ...
type GetAttendanceShiftRespRestTimeRule struct {
	RestBeginTime string `json:"rest_begin_time,omitempty"` // 休息开始
	RestEndTime   string `json:"rest_end_time,omitempty"`   // 休息结束
}

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