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

// CreateDriveMemberPermissionOld 该接口用于根据 filetoken 给用户增加文档的权限。
//
// doc: https://open.feishu.cn/document/ukTMukTMukTM/uMzNzUjLzczM14yM3MTN
func (r *DriveService) CreateDriveMemberPermissionOld(ctx context.Context, request *CreateDriveMemberPermissionOldReq, options ...MethodOptionFunc) (*CreateDriveMemberPermissionOldResp, *Response, error) {
	if r.cli.mock.mockDriveCreateDriveMemberPermissionOld != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Drive#CreateDriveMemberPermissionOld mock enable")
		return r.cli.mock.mockDriveCreateDriveMemberPermissionOld(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:                 "Drive",
		API:                   "CreateDriveMemberPermissionOld",
		Method:                "POST",
		URL:                   r.cli.openBaseURL + "/open-apis/drive/permission/member/create",
		Body:                  request,
		MethodOption:          newMethodOption(options),
		NeedTenantAccessToken: true,
		NeedUserAccessToken:   true,
	}
	resp := new(createDriveMemberPermissionOldResp)

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

// MockDriveCreateDriveMemberPermissionOld mock DriveCreateDriveMemberPermissionOld method
func (r *Mock) MockDriveCreateDriveMemberPermissionOld(f func(ctx context.Context, request *CreateDriveMemberPermissionOldReq, options ...MethodOptionFunc) (*CreateDriveMemberPermissionOldResp, *Response, error)) {
	r.mockDriveCreateDriveMemberPermissionOld = f
}

// UnMockDriveCreateDriveMemberPermissionOld un-mock DriveCreateDriveMemberPermissionOld method
func (r *Mock) UnMockDriveCreateDriveMemberPermissionOld() {
	r.mockDriveCreateDriveMemberPermissionOld = nil
}

// CreateDriveMemberPermissionOldReq ...
type CreateDriveMemberPermissionOldReq struct {
	Token      string                                    `json:"token,omitempty"`       // 文件的 token, 获取方式见 [对接前说明](https://open.feishu.cn/document/ukTMukTMukTM/uczNzUjL3czM14yN3MTN)的第 4 项
	Type       string                                    `json:"type,omitempty"`        // 文档类型  "doc" 、"sheet" 、 "bitable" or "file"
	Members    *CreateDriveMemberPermissionOldReqMembers `json:"members,omitempty"`     // 用户
	NotifyLark *bool                                     `json:"notify_lark,omitempty"` // 添加权限后是否飞书/lark通知对方 true 通知 or false 不通知
}

// CreateDriveMemberPermissionOldReqMembers ...
type CreateDriveMemberPermissionOldReqMembers struct {
	MemberType string `json:"member_type,omitempty"` // 用户类型, 可选 email 、openid、openchat、userid
	MemberID   string `json:"member_id,omitempty"`   // 用户类型下的值
	Perm       string `json:"perm,omitempty"`        // 需要增加的权限, 权限值: "view", "edit"
}

// CreateDriveMemberPermissionOldResp ...
type CreateDriveMemberPermissionOldResp struct {
	IsAllSuccess bool                                            `json:"is_all_success,omitempty"` // 是否全部成功
	FailMembers  []*CreateDriveMemberPermissionOldRespFailMember `json:"fail_members,omitempty"`   // 添加权限失败的用户信息
}

// CreateDriveMemberPermissionOldRespFailMember ...
type CreateDriveMemberPermissionOldRespFailMember struct {
	MemberType string `json:"member_type,omitempty"` // 用户类型
	MemberID   string `json:"member_id,omitempty"`   // 用户类型下的值
	Perm       string `json:"perm,omitempty"`        // 需要增加的权限
}

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