-
-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathapi_drive_sheet_value_get.go
89 lines (78 loc) · 5.82 KB
/
api_drive_sheet_value_get.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// 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"
)
// GetSheetValue 该接口用于根据 spreadsheetToken 和 range 读取表格单个范围的值, 返回数据限制为10M。
//
// doc: https://open.feishu.cn/document/ukTMukTMukTM/ugTMzUjL4EzM14COxMTN
// new doc: https://open.feishu.cn/document/server-docs/docs/sheets-v3/data-operation/reading-a-single-range
func (r *DriveService) GetSheetValue(ctx context.Context, request *GetSheetValueReq, options ...MethodOptionFunc) (*GetSheetValueResp, *Response, error) {
if r.cli.mock.mockDriveGetSheetValue != nil {
r.cli.Log(ctx, LogLevelDebug, "[lark] Drive#GetSheetValue mock enable")
return r.cli.mock.mockDriveGetSheetValue(ctx, request, options...)
}
req := &RawRequestReq{
Scope: "Drive",
API: "GetSheetValue",
Method: "GET",
URL: r.cli.openBaseURL + "/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/values/:range",
Body: request,
MethodOption: newMethodOption(options),
NeedTenantAccessToken: true,
NeedUserAccessToken: true,
}
resp := new(getSheetValueResp)
response, err := r.cli.RawRequest(ctx, req, resp)
return resp.Data, response, err
}
// MockDriveGetSheetValue mock DriveGetSheetValue method
func (r *Mock) MockDriveGetSheetValue(f func(ctx context.Context, request *GetSheetValueReq, options ...MethodOptionFunc) (*GetSheetValueResp, *Response, error)) {
r.mockDriveGetSheetValue = f
}
// UnMockDriveGetSheetValue un-mock DriveGetSheetValue method
func (r *Mock) UnMockDriveGetSheetValue() {
r.mockDriveGetSheetValue = nil
}
// GetSheetValueReq ...
type GetSheetValueReq struct {
SpreadSheetToken string `path:"spreadsheetToken" json:"-"` // spreadsheet 的 token, 详见电子表格[概述](https://open.feishu.cn/document/ukTMukTMukTM/uATMzUjLwEzM14CMxMTN/overview)
Range string `path:"range" json:"-"` // 查询范围, 包含 sheetId 与单元格范围两部分, 详见[在线表格开发指南](https://open.feishu.cn/document/ukTMukTMukTM/uATMzUjLwEzM14CMxMTN/overview)。若查询范围中使用形如 `<sheetId>!<开始单元格>:<结束列>`的范围时, 仅支持获取100列数据
ValueRenderOption *string `query:"valueRenderOption" json:"-"` // 指定单元格数据的格式。可选值为如下所示。当参数缺省时, 默认不进行公式计算, 返回公式本身;数值不进行数字格式化, valueRenderOption=ToString: 返回纯文本的值(数值类型除外), valueRenderOption=FormattedValue: 计算并格式化单元格, valueRenderOption=Formula: 单元格中含有公式时, 返回公式本身, valueRenderOption=UnformattedValue: 计算但不对单元格进行格式化
DateTimeRenderOption *string `query:"dateTimeRenderOption" json:"-"` // 指定数据类型为日期、时间、或时间日期的单元格数据的格式, 当参数缺省时, 默认返回浮点数值, 整数部分为自 1899 年 12 月 30 日以来的天数;小数部分为该时间占 24 小时的份额。例如: 若时间为 1900 年 1 月 1 日中午 12 点, 则默认返回 2.5。其中, 2 表示 1900 年 1 月 1 日为 1899 年12 月 30 日之后的 2 天;0.5 表示 12 点占 24 小时的二分之一, 即 12/24=0.5, dateTimeRenderOption=FormattedString: 计算并对时间、日期类型数据进行格式化, 但不会对数字进行格式化。将返回格式化后的字符串。详见[电子表格常见问题](https://open.feishu.cn/document/ukTMukTMukTM/uATMzUjLwEzM14CMxMTN/guide/sheets-faq)
UserIDType *IDType `query:"user_id_type" json:"-"` // 当单元格中包含@用户等涉及用户信息的元素时, 该参数可指定返回的用户 ID 类型。默认为 lark_id, 建议选择 open_id 或 union_id。了解更多, 参考[用户身份概述](https://open.feishu.cn/document/home/user-identity-introduction/introduction), open_id: 用户在应用内的身份。 同一个 user_id 在不同应用中的 open_id 不同, 其值统一以 ou_ 为前缀, 如`ou_c99c5f35d542efc7ee492afe11af19ef`, union_id: 用户在同一应用服务商提供的多个应用间的统一身份。
}
// GetSheetValueResp ...
type GetSheetValueResp struct {
Revision int64 `json:"revision,omitempty"` // sheet 的版本号
SpreadSheetToken string `json:"spreadsheetToken,omitempty"` // spreadsheet 的 token, 详见电子表格[概述](https://open.feishu.cn/document/ukTMukTMukTM/uATMzUjLwEzM14CMxMTN/overview)
ValueRange *GetSheetValueRespValueRange `json:"valueRange,omitempty"` // 值与范围
}
// GetSheetValueRespValueRange ...
type GetSheetValueRespValueRange struct {
MajorDimension string `json:"majorDimension,omitempty"` // 插入维度
Range string `json:"range,omitempty"` // 返回数据的范围, 为空时表示查询范围没有数据
Revision int64 `json:"revision,omitempty"` // sheet 的版本号
Values [][]SheetContent `json:"values,omitempty"` // 查询得到的值
}
// getSheetValueResp ...
type getSheetValueResp struct {
Code int64 `json:"code,omitempty"`
Msg string `json:"msg,omitempty"`
Data *GetSheetValueResp `json:"data,omitempty"`
}