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

// UnsubscribeApprovalSubscription 取消订阅 approval_code 后, 无法再收到该审批定义对应实例的事件通知
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/approval-v4/approval/unsubscribe
// new doc: https://open.feishu.cn/document/server-docs/approval-v4/event/event-interface/unsubscribe
func (r *ApprovalService) UnsubscribeApprovalSubscription(ctx context.Context, request *UnsubscribeApprovalSubscriptionReq, options ...MethodOptionFunc) (*UnsubscribeApprovalSubscriptionResp, *Response, error) {
	if r.cli.mock.mockApprovalUnsubscribeApprovalSubscription != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Approval#UnsubscribeApprovalSubscription mock enable")
		return r.cli.mock.mockApprovalUnsubscribeApprovalSubscription(ctx, request, options...)
	}

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

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

// MockApprovalUnsubscribeApprovalSubscription mock ApprovalUnsubscribeApprovalSubscription method
func (r *Mock) MockApprovalUnsubscribeApprovalSubscription(f func(ctx context.Context, request *UnsubscribeApprovalSubscriptionReq, options ...MethodOptionFunc) (*UnsubscribeApprovalSubscriptionResp, *Response, error)) {
	r.mockApprovalUnsubscribeApprovalSubscription = f
}

// UnMockApprovalUnsubscribeApprovalSubscription un-mock ApprovalUnsubscribeApprovalSubscription method
func (r *Mock) UnMockApprovalUnsubscribeApprovalSubscription() {
	r.mockApprovalUnsubscribeApprovalSubscription = nil
}

// UnsubscribeApprovalSubscriptionReq ...
type UnsubscribeApprovalSubscriptionReq struct {
	ApprovalCode string `path:"approval_code" json:"-"` // 审批定义唯一标识, 示例值: "7C468A54-8745-2245-9675-08B7C63E7A85"
}

// UnsubscribeApprovalSubscriptionResp ...
type UnsubscribeApprovalSubscriptionResp struct {
}

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