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

// SendApprovalMessage 此接口可以用来通过飞书审批的Bot推送消息给用户, 当有新的审批待办, 或者审批待办的状态有更新时, 可以通过飞书审批的Bot告知用户。当然开发者也可以利用开放平台的能力自建一个全新的Bot, 用来推送审批相关信息。如果出现推送成功, 但是没有收到消息, 可能是因为开通了审批机器人的聚合推送。
//
// doc: https://open.feishu.cn/document/ukTMukTMukTM/ugDNyYjL4QjM24CO0IjN
// new doc: https://open.feishu.cn/document/server-docs/approval-v4/message/send-bot-messages
func (r *ApprovalService) SendApprovalMessage(ctx context.Context, request *SendApprovalMessageReq, options ...MethodOptionFunc) (*SendApprovalMessageResp, *Response, error) {
	if r.cli.mock.mockApprovalSendApprovalMessage != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Approval#SendApprovalMessage mock enable")
		return r.cli.mock.mockApprovalSendApprovalMessage(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:                 "Approval",
		API:                   "SendApprovalMessage",
		Method:                "POST",
		URL:                   r.cli.openBaseURL + "/open-apis/approval/v1/message/send",
		Body:                  request,
		MethodOption:          newMethodOption(options),
		NeedTenantAccessToken: true,
	}
	resp := new(sendApprovalMessageResp)

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

// MockApprovalSendApprovalMessage mock ApprovalSendApprovalMessage method
func (r *Mock) MockApprovalSendApprovalMessage(f func(ctx context.Context, request *SendApprovalMessageReq, options ...MethodOptionFunc) (*SendApprovalMessageResp, *Response, error)) {
	r.mockApprovalSendApprovalMessage = f
}

// UnMockApprovalSendApprovalMessage un-mock ApprovalSendApprovalMessage method
func (r *Mock) UnMockApprovalSendApprovalMessage() {
	r.mockApprovalSendApprovalMessage = nil
}

// SendApprovalMessageReq ...
type SendApprovalMessageReq struct {
}

// SendApprovalMessageResp ...
type SendApprovalMessageResp struct {
	MessageID string `json:"message_id,omitempty"` // 消息 id, 用于卡片更新
}

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