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

// DownloadHelpdeskTicketImage 该接口用于获取服务台工单消息图象。仅支持自建应用。
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/ticket/ticket_image
// new doc: https://open.feishu.cn/document/server-docs/helpdesk-v1/ticket-management/ticket/ticket_image
func (r *HelpdeskService) DownloadHelpdeskTicketImage(ctx context.Context, request *DownloadHelpdeskTicketImageReq, options ...MethodOptionFunc) (*DownloadHelpdeskTicketImageResp, *Response, error) {
	if r.cli.mock.mockHelpdeskDownloadHelpdeskTicketImage != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Helpdesk#DownloadHelpdeskTicketImage mock enable")
		return r.cli.mock.mockHelpdeskDownloadHelpdeskTicketImage(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:                 "Helpdesk",
		API:                   "DownloadHelpdeskTicketImage",
		Method:                "GET",
		URL:                   r.cli.openBaseURL + "/open-apis/helpdesk/v1/ticket_images",
		Body:                  request,
		MethodOption:          newMethodOption(options),
		NeedTenantAccessToken: true,
		NeedHelpdeskAuth:      true,
	}
	resp := new(downloadHelpdeskTicketImageResp)

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

// MockHelpdeskDownloadHelpdeskTicketImage mock HelpdeskDownloadHelpdeskTicketImage method
func (r *Mock) MockHelpdeskDownloadHelpdeskTicketImage(f func(ctx context.Context, request *DownloadHelpdeskTicketImageReq, options ...MethodOptionFunc) (*DownloadHelpdeskTicketImageResp, *Response, error)) {
	r.mockHelpdeskDownloadHelpdeskTicketImage = f
}

// UnMockHelpdeskDownloadHelpdeskTicketImage un-mock HelpdeskDownloadHelpdeskTicketImage method
func (r *Mock) UnMockHelpdeskDownloadHelpdeskTicketImage() {
	r.mockHelpdeskDownloadHelpdeskTicketImage = nil
}

// DownloadHelpdeskTicketImageReq ...
type DownloadHelpdeskTicketImageReq struct {
	TicketID string `query:"ticket_id" json:"-"` // 工单ID, 示例值: 12345
	MsgID    string `query:"msg_id" json:"-"`    // 消息ID, [查询消息ID](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/helpdesk-v1/ticket-message/list), 示例值: 12345
	Index    *int64 `query:"index" json:"-"`     // index, 当消息类型为post时, 需指定图片index, index从0开始。当消息类型为img时, 无需index, 示例值: 0
}

// downloadHelpdeskTicketImageResp ...
type downloadHelpdeskTicketImageResp struct {
	Code  int64                            `json:"code,omitempty"`
	Msg   string                           `json:"msg,omitempty"`
	Data  *DownloadHelpdeskTicketImageResp `json:"data,omitempty"`
	Error *ErrorDetail                     `json:"error,omitempty"`
}

func (r *downloadHelpdeskTicketImageResp) SetReader(file io.Reader) {
	if r.Data == nil {
		r.Data = &DownloadHelpdeskTicketImageResp{}
	}
	r.Data.File = file
}

// DownloadHelpdeskTicketImageResp ...
type DownloadHelpdeskTicketImageResp struct {
	File io.Reader `json:"file,omitempty"`
}
