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

// GetOKRPeriodList 获取 OKR 周期列表。
//
// 使用tenant_access_token需要额外申请权限以应用身份访问OKR信息
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/okr-v1/period/list
// new doc: https://open.feishu.cn/document/server-docs/okr-v1/period/list
func (r *OKRService) GetOKRPeriodList(ctx context.Context, request *GetOKRPeriodListReq, options ...MethodOptionFunc) (*GetOKRPeriodListResp, *Response, error) {
	if r.cli.mock.mockOKRGetOKRPeriodList != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] OKR#GetOKRPeriodList mock enable")
		return r.cli.mock.mockOKRGetOKRPeriodList(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:                 "OKR",
		API:                   "GetOKRPeriodList",
		Method:                "GET",
		URL:                   r.cli.openBaseURL + "/open-apis/okr/v1/periods",
		Body:                  request,
		MethodOption:          newMethodOption(options),
		NeedTenantAccessToken: true,
	}
	resp := new(getOKRPeriodListResp)

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

// MockOKRGetOKRPeriodList mock OKRGetOKRPeriodList method
func (r *Mock) MockOKRGetOKRPeriodList(f func(ctx context.Context, request *GetOKRPeriodListReq, options ...MethodOptionFunc) (*GetOKRPeriodListResp, *Response, error)) {
	r.mockOKRGetOKRPeriodList = f
}

// UnMockOKRGetOKRPeriodList un-mock OKRGetOKRPeriodList method
func (r *Mock) UnMockOKRGetOKRPeriodList() {
	r.mockOKRGetOKRPeriodList = nil
}

// GetOKRPeriodListReq ...
type GetOKRPeriodListReq struct {
	PageToken *string `query:"page_token" json:"-"` // 分页标记, 第一次请求不填, 表示从头开始遍历；分页查询结果还有更多项时会同时返回新的 page_token, 下次遍历可采用该 page_token 获取查询结果, 示例值: xaasdasdax
	PageSize  *int64  `query:"page_size" json:"-"`  // 分页大小, 默认10, 示例值: 10, 默认值: `10`
}

// GetOKRPeriodListResp ...
type GetOKRPeriodListResp struct {
	PageToken string                      `json:"page_token,omitempty"` // 分页标记, 当 has_more 为 true 时, 会同时返回新的 page_token, 否则不返回 page_token
	HasMore   bool                        `json:"has_more,omitempty"`   // 是否还有更多项
	Items     []*GetOKRPeriodListRespItem `json:"items,omitempty"`      // 数据项
}

// GetOKRPeriodListRespItem ...
type GetOKRPeriodListRespItem struct {
	ID              string `json:"id,omitempty"`                // id
	ZhName          string `json:"zh_name,omitempty"`           // 中文名称
	EnName          string `json:"en_name,omitempty"`           // 英文名称
	Status          int64  `json:"status,omitempty"`            // 启用状态, 可选值有: 0: 正常状态, 1: 暂不处理, 2: 标记失效, 3: 隐藏周期
	PeriodStartTime string `json:"period_start_time,omitempty"` // 周期开始时间
	PeriodEndTime   string `json:"period_end_time,omitempty"`   // 周期结束时间
}

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