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

// GetBitableTableForm 获取表单的所有元数据项
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/bitable-v1/app-table-form/get
// new doc: https://open.feishu.cn/document/server-docs/docs/bitable-v1/form/get
func (r *BitableService) GetBitableTableForm(ctx context.Context, request *GetBitableTableFormReq, options ...MethodOptionFunc) (*GetBitableTableFormResp, *Response, error) {
	if r.cli.mock.mockBitableGetBitableTableForm != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Bitable#GetBitableTableForm mock enable")
		return r.cli.mock.mockBitableGetBitableTableForm(ctx, request, options...)
	}

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

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

// MockBitableGetBitableTableForm mock BitableGetBitableTableForm method
func (r *Mock) MockBitableGetBitableTableForm(f func(ctx context.Context, request *GetBitableTableFormReq, options ...MethodOptionFunc) (*GetBitableTableFormResp, *Response, error)) {
	r.mockBitableGetBitableTableForm = f
}

// UnMockBitableGetBitableTableForm un-mock BitableGetBitableTableForm method
func (r *Mock) UnMockBitableGetBitableTableForm() {
	r.mockBitableGetBitableTableForm = nil
}

// GetBitableTableFormReq ...
type GetBitableTableFormReq struct {
	AppToken string `path:"app_token" json:"-"` // 多维表格文档 Token, 示例值: "bascnv1jIEppJdTCn3jOosabcef"
	TableID  string `path:"table_id" json:"-"`  // 表格 ID, 示例值: "tblz8nadEUdxNMt5"
	FormID   string `path:"form_id" json:"-"`   // 表单 ID, 示例值: "vew6oMbAa4"
}

// GetBitableTableFormResp ...
type GetBitableTableFormResp struct {
	Form *GetBitableTableFormRespForm `json:"form,omitempty"` // 表单元数据信息
}

// GetBitableTableFormRespForm ...
type GetBitableTableFormRespForm struct {
	Name            string `json:"name,omitempty"`              // 表单名称
	Description     string `json:"description,omitempty"`       // 表单描述
	Shared          bool   `json:"shared,omitempty"`            // 是否开启共享
	SharedURL       string `json:"shared_url,omitempty"`        // 分享 URL
	SharedLimit     string `json:"shared_limit,omitempty"`      // 分享范围限制, 可选值有: off: 仅邀请的人可填写, tenant_editable: 组织内获得链接的人可填写, anyone_editable: 互联网上获得链接的人可填写
	SubmitLimitOnce bool   `json:"submit_limit_once,omitempty"` // 填写次数限制一次
}

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