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

// UpdateBitableTable 该接口用于更新数据表的基本信息, 包括数据表的名称等。
//
// ::: note
// 首次调用请参考 [云文档接口快速入门](https://open.feishu.cn/document/ukTMukTMukTM/uczNzUjL3czM14yN3MTN)[多维表格接口接入指南](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/bitable/notification)
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/bitable-v1/app-table/patch
// new doc: https://open.feishu.cn/document/server-docs/docs/bitable-v1/app-table/patch
func (r *BitableService) UpdateBitableTable(ctx context.Context, request *UpdateBitableTableReq, options ...MethodOptionFunc) (*UpdateBitableTableResp, *Response, error) {
	if r.cli.mock.mockBitableUpdateBitableTable != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Bitable#UpdateBitableTable mock enable")
		return r.cli.mock.mockBitableUpdateBitableTable(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:                 "Bitable",
		API:                   "UpdateBitableTable",
		Method:                "PATCH",
		URL:                   r.cli.openBaseURL + "/open-apis/bitable/v1/apps/:app_token/tables/:table_id",
		Body:                  request,
		MethodOption:          newMethodOption(options),
		NeedTenantAccessToken: true,
		NeedUserAccessToken:   true,
	}
	resp := new(updateBitableTableResp)

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

// MockBitableUpdateBitableTable mock BitableUpdateBitableTable method
func (r *Mock) MockBitableUpdateBitableTable(f func(ctx context.Context, request *UpdateBitableTableReq, options ...MethodOptionFunc) (*UpdateBitableTableResp, *Response, error)) {
	r.mockBitableUpdateBitableTable = f
}

// UnMockBitableUpdateBitableTable un-mock BitableUpdateBitableTable method
func (r *Mock) UnMockBitableUpdateBitableTable() {
	r.mockBitableUpdateBitableTable = nil
}

// UpdateBitableTableReq ...
type UpdateBitableTableReq struct {
	AppToken string  `path:"app_token" json:"-"` // 多维表格的唯一标识符 [app_token 参数说明](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/bitable/notification#8121eebe), 示例值: "XrgTb4y1haKYnasu0xXb1g7lcSg", 最小长度: `1` 字符
	TableID  string  `path:"table_id" json:"-"`  // 多维表格数据表的唯一标识符 [table_id 参数说明](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/bitable/notification#735fe883), 示例值: "tbl1TkhyTWDkSoZ3"
	Name     *string `json:"name,omitempty"`     // 数据表的新名称, 请注意: 1. 名称中的首尾空格将会被去除, 2. 如果名称为空或和旧名称相同, 接口仍然会返回成功, 但是名称不会被更改, 示例值: "数据表的新名称", 长度范围: `1` ～ `100` 字符, 正则校验: `^[^\[\]\:\\\/\?\*]+$`
}

// UpdateBitableTableResp ...
type UpdateBitableTableResp struct {
	Name string `json:"name,omitempty"` // 数据表的名称
}

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