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

// AddApprovalInstanceSign 对于单个审批任务进行加签操作。
//
// doc: https://open.feishu.cn/document/ukTMukTMukTM/ukTM5UjL5ETO14SOxkTN/approval-task-addsign
// new doc: https://open.feishu.cn/document/server-docs/approval-v4/task/approval-task-addsign
func (r *ApprovalService) AddApprovalInstanceSign(ctx context.Context, request *AddApprovalInstanceSignReq, options ...MethodOptionFunc) (*AddApprovalInstanceSignResp, *Response, error) {
	if r.cli.mock.mockApprovalAddApprovalInstanceSign != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Approval#AddApprovalInstanceSign mock enable")
		return r.cli.mock.mockApprovalAddApprovalInstanceSign(ctx, request, options...)
	}

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

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

// MockApprovalAddApprovalInstanceSign mock ApprovalAddApprovalInstanceSign method
func (r *Mock) MockApprovalAddApprovalInstanceSign(f func(ctx context.Context, request *AddApprovalInstanceSignReq, options ...MethodOptionFunc) (*AddApprovalInstanceSignResp, *Response, error)) {
	r.mockApprovalAddApprovalInstanceSign = f
}

// UnMockApprovalAddApprovalInstanceSign un-mock ApprovalAddApprovalInstanceSign method
func (r *Mock) UnMockApprovalAddApprovalInstanceSign() {
	r.mockApprovalAddApprovalInstanceSign = nil
}

// AddApprovalInstanceSignReq ...
type AddApprovalInstanceSignReq struct {
	ApprovalCode   string   `json:"approval_code,omitempty"`     // 审批定义 Code
	InstanceCode   string   `json:"instance_code,omitempty"`     // 审批实例 Code
	UserID         string   `json:"user_id,omitempty"`           // 操作用户
	TaskID         string   `json:"task_id,omitempty"`           // 任务 ID 审批实例详情task_list中id, 详情请参考[](https://open.feishu.cn/document/ukTMukTMukTM/uEDNyUjLxQjM14SM0ITN)
	Comment        *string  `json:"comment,omitempty"`           // 意见
	AddSignUserIDs []string `json:"add_sign_user_ids,omitempty"` // 被加签人id
	AddSignType    int64    `json:"add_sign_type,omitempty"`     // 1/2/3分别代表前加签/后加签/并加签
	ApprovalMethod *int64   `json:"approval_method,omitempty"`   // 仅在前加签、后加签时需要填写, 1/2 分别代表或签/会签
}

// AddApprovalInstanceSignResp ...
type AddApprovalInstanceSignResp struct {
}

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