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

// GetApprovalInstanceList 根据 approval_code 批量获取审批实例的 instance_code, 用于拉取租户下某个审批定义的全部审批实例。默认以审批创建时间先后顺序排列。
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/approval-v4/instance/list
// new doc: https://open.feishu.cn/document/server-docs/approval-v4/instance/list
func (r *ApprovalService) GetApprovalInstanceList(ctx context.Context, request *GetApprovalInstanceListReq, options ...MethodOptionFunc) (*GetApprovalInstanceListResp, *Response, error) {
	if r.cli.mock.mockApprovalGetApprovalInstanceList != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Approval#GetApprovalInstanceList mock enable")
		return r.cli.mock.mockApprovalGetApprovalInstanceList(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:                 "Approval",
		API:                   "GetApprovalInstanceList",
		Method:                "GET",
		URL:                   r.cli.openBaseURL + "/open-apis/approval/v4/instances",
		Body:                  request,
		MethodOption:          newMethodOption(options),
		NeedTenantAccessToken: true,
	}
	resp := new(getApprovalInstanceListResp)

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

// MockApprovalGetApprovalInstanceList mock ApprovalGetApprovalInstanceList method
func (r *Mock) MockApprovalGetApprovalInstanceList(f func(ctx context.Context, request *GetApprovalInstanceListReq, options ...MethodOptionFunc) (*GetApprovalInstanceListResp, *Response, error)) {
	r.mockApprovalGetApprovalInstanceList = f
}

// UnMockApprovalGetApprovalInstanceList un-mock ApprovalGetApprovalInstanceList method
func (r *Mock) UnMockApprovalGetApprovalInstanceList() {
	r.mockApprovalGetApprovalInstanceList = nil
}

// GetApprovalInstanceListReq ...
type GetApprovalInstanceListReq struct {
	PageSize     *int64  `query:"page_size" json:"-"`     // 分页大小, 示例值: 100, 默认值: `100`, 最大值: `100`
	PageToken    *string `query:"page_token" json:"-"`    // 分页标记, 第一次请求不填, 表示从头开始遍历；分页查询结果还有更多项时会同时返回新的 page_token, 下次遍历可采用该 page_token 获取查询结果, 示例值: "nF1ZXJ5VGhlbkZldGNoCgAAAAAA6PZwFmUzSldvTC1yU"
	ApprovalCode string  `query:"approval_code" json:"-"` // 审批定义唯一标识, 示例值: "7C468A54-8745-2245-9675-08B7C63E7A85"
	StartTime    int64   `query:"start_time" json:"-"`    // 审批实例创建时间区间（毫秒）, 示例值: "1567690398020"
	EndTime      int64   `query:"end_time" json:"-"`      // 审批实例创建时间区间（毫秒）, 示例值: "1567690398020"
}

// GetApprovalInstanceListResp ...
type GetApprovalInstanceListResp struct {
	InstanceCodeList []string `json:"instance_code_list,omitempty"` // 审批实例 Code
	PageToken        string   `json:"page_token,omitempty"`         // 分页标记, 当 has_more 为 true 时, 会同时返回新的 page_token, 否则不返回 page_token
	HasMore          bool     `json:"has_more,omitempty"`           // 是否还有更多项
}

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