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

// GetTaskAttachment 提供一个附件GUID, 返回附件的详细信息, 包括GUID, 名称, 大小, 上传时间, 临时可下载链接等。
//
// 获取附件需要附件归属资源的可读取权限。
//
// doc: https://open.larkoffice.com/document/uAjLw4CM/ukTMukTMukTM/task-v2/attachment/get
func (r *TaskService) GetTaskAttachment(ctx context.Context, request *GetTaskAttachmentReq, options ...MethodOptionFunc) (*GetTaskAttachmentResp, *Response, error) {
	if r.cli.mock.mockTaskGetTaskAttachment != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Task#GetTaskAttachment mock enable")
		return r.cli.mock.mockTaskGetTaskAttachment(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:                 "Task",
		API:                   "GetTaskAttachment",
		Method:                "GET",
		URL:                   r.cli.openBaseURL + "/open-apis/task/v2/attachments/:attachment_guid",
		Body:                  request,
		MethodOption:          newMethodOption(options),
		NeedTenantAccessToken: true,
		NeedUserAccessToken:   true,
	}
	resp := new(getTaskAttachmentResp)

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

// MockTaskGetTaskAttachment mock TaskGetTaskAttachment method
func (r *Mock) MockTaskGetTaskAttachment(f func(ctx context.Context, request *GetTaskAttachmentReq, options ...MethodOptionFunc) (*GetTaskAttachmentResp, *Response, error)) {
	r.mockTaskGetTaskAttachment = f
}

// UnMockTaskGetTaskAttachment un-mock TaskGetTaskAttachment method
func (r *Mock) UnMockTaskGetTaskAttachment() {
	r.mockTaskGetTaskAttachment = nil
}

// GetTaskAttachmentReq ...
type GetTaskAttachmentReq struct {
	AttachmentGuid string  `path:"attachment_guid" json:"-"` // 获取详情的附件GUID。可以通过创建[上传附件](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/task-v2/attachment/upload)接口创建, 或者通过[列取附件](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/task-v2/attachment/list)接口查询得到, 示例值: "b59aa7a3-e98c-4830-8273-cbb29f89b837"
	UserIDType     *IDType `query:"user_id_type" json:"-"`   // 用户 ID 类型, 示例值: open_id, 默认值: `open_id`
}

// GetTaskAttachmentResp ...
type GetTaskAttachmentResp struct {
	Attachment *GetTaskAttachmentRespAttachment `json:"attachment,omitempty"` // 附件详情
}

// GetTaskAttachmentRespAttachment ...
type GetTaskAttachmentRespAttachment struct {
	Guid       string                                   `json:"guid,omitempty"`        // 附件guid
	FileToken  string                                   `json:"file_token,omitempty"`  // 附件在云文档系统中的token
	Name       string                                   `json:"name,omitempty"`        // 附件名
	Size       int64                                    `json:"size,omitempty"`        // 附件的字节大小
	Resource   *GetTaskAttachmentRespAttachmentResource `json:"resource,omitempty"`    // 附件归属的资源
	Uploader   *GetTaskAttachmentRespAttachmentUploader `json:"uploader,omitempty"`    // 附件上传者
	IsCover    bool                                     `json:"is_cover,omitempty"`    // 是否是封面图
	UploadedAt string                                   `json:"uploaded_at,omitempty"` // 上传时间戳(ms)
	URL        string                                   `json:"url,omitempty"`         // 附件的临时下载url, 有效时间3分钟, 且只允许调用3次进行附件下载。只有在获取附件时会动态生成。
}

// GetTaskAttachmentRespAttachmentResource ...
type GetTaskAttachmentRespAttachmentResource struct {
	Type string `json:"type,omitempty"` // 资源类型
	ID   string `json:"id,omitempty"`   // 资源ID
}

// GetTaskAttachmentRespAttachmentUploader ...
type GetTaskAttachmentRespAttachmentUploader struct {
	ID   string `json:"id,omitempty"`   // 表示member的id
	Type string `json:"type,omitempty"` // 成员的类型
	Role string `json:"role,omitempty"` // 成员角色
}

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