| 1 | package QQ::weixin::work::wedoc::smartsheet; | ||
| 2 | |||
| 3 | =encoding utf8 | ||
| 4 | |||
| 5 | =head1 Name | ||
| 6 | |||
| 7 | QQ::weixin::work::wedoc::smartsheet | ||
| 8 | |||
| 9 | =head1 DESCRIPTION | ||
| 10 | |||
| 11 | 智能表格 | ||
| 12 | |||
| 13 | =cut | ||
| 14 | |||
| 15 | use strict; | ||
| 16 | use base qw(QQ::weixin::work::wedoc); | ||
| 17 | use Encode; | ||
| 18 | use LWP::UserAgent; | ||
| 19 | use JSON; | ||
| 20 | use utf8; | ||
| 21 | |||
| 22 | our $VERSION = '0.12'; | ||
| 23 | our @EXPORT = qw/ add_sheet delete_sheet update_sheet | ||
| 24 | add_view delete_views update_view | ||
| 25 | add_fields delete_fields update_fields | ||
| 26 | add_records delete_records update_records/; | ||
| 27 | |||
| 28 | =head1 FUNCTION | ||
| 29 | |||
| 30 | 编辑智能表格内容 | ||
| 31 | |||
| 32 | =head2 add_sheet(access_token, hash); | ||
| 33 | |||
| 34 | 添加子表 | ||
| 35 | 最后更新:2024/05/30 | ||
| 36 | |||
| 37 | =head2 SYNOPSIS | ||
| 38 | |||
| 39 | L<https://developer.work.weixin.qq.com/document/path/99896> | ||
| 40 | |||
| 41 | =head3 请求说明: | ||
| 42 | |||
| 43 | 本接口用于在表格的某个位置添加一个智能表,该智能表不存在视图、记录和字段,可以使用 API 在该智能表中添加视图、记录和字段。 | ||
| 44 | |||
| 45 | =head4 请求包结构体为: | ||
| 46 | |||
| 47 | { | ||
| 48 | "docid": "DOCID", | ||
| 49 | "properties": { | ||
| 50 | "title": "智能表", | ||
| 51 | "index": 3 | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
| 55 | =head4 参数说明: | ||
| 56 | |||
| 57 | 参数 类型 是否必须 说明 | ||
| 58 | access_token 是 调用接口凭证 | ||
| 59 | docid string 是 文档的docid | ||
| 60 | properties object 否 智能表属性 | ||
| 61 | properties.title string 否 智能表标题 | ||
| 62 | properties.index int32 否 智能表下标 | ||
| 63 | |||
| 64 | =head4 权限说明: | ||
| 65 | |||
| 66 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 67 | |||
| 68 | =head3 RETURN 返回结果: | ||
| 69 | |||
| 70 | { | ||
| 71 | "errcode": 0, | ||
| 72 | "errmsg": "ok", | ||
| 73 | "properties": { | ||
| 74 | "title": "智能表", | ||
| 75 | "index": 3, | ||
| 76 | "sheet_id": "123abc" | ||
| 77 | } | ||
| 78 | } | ||
| 79 | |||
| 80 | =head4 RETURN 参数说明: | ||
| 81 | |||
| 82 | 参数 类型 说明 | ||
| 83 | errcode int32 错误码 | ||
| 84 | errmsg string 错误码说明 | ||
| 85 | properties object 智能表属性 | ||
| 86 | properties.sheet_id string 智能表 ID,创建子表时生成的 6 位随机 ID | ||
| 87 | properties.title string 智能表标题 | ||
| 88 | properties.index int32 智能表下标 | ||
| 89 | |||
| 90 | =cut | ||
| 91 | |||
| 92 | sub add_sheet { | ||
| 93 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 94 | my $access_token = $_[0]; | ||
| 95 | my $json = $_[1]; | ||
| 96 | my $ua = LWP::UserAgent->new; | ||
| 97 | $ua->timeout(30); | ||
| 98 | $ua->env_proxy; | ||
| 99 | |||
| 100 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/smartsheet/add_sheet?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 101 | if ($response->is_success) { | ||
| 102 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 103 | } | ||
| 104 | |||
| 105 | } | ||
| 106 | return 0; | ||
| 107 | } | ||
| 108 | |||
| 109 | =head2 delete_sheet(access_token, hash); | ||
| 110 | |||
| 111 | 删除子表 | ||
| 112 | 最后更新:2024/05/30 | ||
| 113 | |||
| 114 | =head2 SYNOPSIS | ||
| 115 | |||
| 116 | L<https://developer.work.weixin.qq.com/document/path/99899> | ||
| 117 | |||
| 118 | =head3 请求说明: | ||
| 119 | |||
| 120 | 本接口用于删除在线表格中的某个智能表。 | ||
| 121 | |||
| 122 | =head4 请求包结构体为: | ||
| 123 | |||
| 124 | { | ||
| 125 | "docid": "DOCID", | ||
| 126 | "sheet_id": "123Abc" | ||
| 127 | } | ||
| 128 | |||
| 129 | =head4 参数说明: | ||
| 130 | |||
| 131 | 参数 类型 是否必须 说明 | ||
| 132 | access_token 是 调用接口凭证 | ||
| 133 | docid string 是 文档的docid | ||
| 134 | sheet_id string 是 删除的Smartsheet 子表 ID | ||
| 135 | |||
| 136 | =head4 权限说明: | ||
| 137 | |||
| 138 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 139 | |||
| 140 | =head3 RETURN 返回结果: | ||
| 141 | |||
| 142 | { | ||
| 143 | "errcode": 0, | ||
| 144 | "errmsg": "ok" | ||
| 145 | } | ||
| 146 | |||
| 147 | =head4 RETURN 参数说明: | ||
| 148 | |||
| 149 | 参数 类型 说明 | ||
| 150 | errcode int32 错误码 | ||
| 151 | errmsg string 错误码说明 | ||
| 152 | |||
| 153 | =cut | ||
| 154 | |||
| 155 | sub delete_sheet { | ||
| 156 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 157 | my $access_token = $_[0]; | ||
| 158 | my $json = $_[1]; | ||
| 159 | my $ua = LWP::UserAgent->new; | ||
| 160 | $ua->timeout(30); | ||
| 161 | $ua->env_proxy; | ||
| 162 | |||
| 163 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/smartsheet/delete_sheet?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 164 | if ($response->is_success) { | ||
| 165 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 166 | } | ||
| 167 | |||
| 168 | } | ||
| 169 | return 0; | ||
| 170 | } | ||
| 171 | |||
| 172 | =head2 update_sheet(access_token, hash); | ||
| 173 | |||
| 174 | 更新子表 | ||
| 175 | 最后更新:2024/05/30 | ||
| 176 | |||
| 177 | =head2 SYNOPSIS | ||
| 178 | |||
| 179 | L<https://developer.work.weixin.qq.com/document/path/99898> | ||
| 180 | |||
| 181 | =head3 请求说明: | ||
| 182 | |||
| 183 | 本接口用于修改表格中某个子表的标题。 | ||
| 184 | |||
| 185 | =head4 请求包结构体为: | ||
| 186 | |||
| 187 | { | ||
| 188 | "docid": "DOCID", | ||
| 189 | "properties": { | ||
| 190 | "sheet_id": "123abc", | ||
| 191 | "title": "XXXX" | ||
| 192 | } | ||
| 193 | } | ||
| 194 | |||
| 195 | =head4 参数说明: | ||
| 196 | |||
| 197 | 参数 类型 是否必须 说明 | ||
| 198 | access_token 是 调用接口凭证 | ||
| 199 | docid string 是 文档的docid | ||
| 200 | properties.sheet_id string 是 子表 ID | ||
| 201 | properties.title string 否 子表标题 | ||
| 202 | |||
| 203 | =head4 权限说明: | ||
| 204 | |||
| 205 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 206 | |||
| 207 | =head3 RETURN 返回结果: | ||
| 208 | |||
| 209 | { | ||
| 210 | "errcode": 0, | ||
| 211 | "errmsg": "ok" | ||
| 212 | } | ||
| 213 | |||
| 214 | =head4 RETURN 参数说明: | ||
| 215 | |||
| 216 | 参数 类型 说明 | ||
| 217 | errcode int32 错误码 | ||
| 218 | errmsg string 错误码说明 | ||
| 219 | |||
| 220 | =cut | ||
| 221 | |||
| 222 | sub update_sheet { | ||
| 223 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 224 | my $access_token = $_[0]; | ||
| 225 | my $json = $_[1]; | ||
| 226 | my $ua = LWP::UserAgent->new; | ||
| 227 | $ua->timeout(30); | ||
| 228 | $ua->env_proxy; | ||
| 229 | |||
| 230 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/smartsheet/update_sheet?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 231 | if ($response->is_success) { | ||
| 232 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 233 | } | ||
| 234 | |||
| 235 | } | ||
| 236 | return 0; | ||
| 237 | } | ||
| 238 | |||
| 239 | =head2 add_view(access_token, hash); | ||
| 240 | |||
| 241 | 添加视图 | ||
| 242 | 最后更新:2024/05/30 | ||
| 243 | |||
| 244 | =head2 SYNOPSIS | ||
| 245 | |||
| 246 | L<https://developer.work.weixin.qq.com/document/path/99900> | ||
| 247 | |||
| 248 | =head3 请求说明: | ||
| 249 | |||
| 250 | 本接口用于在 Smartsheet 中的某个子表里添加一个新视图。单表最多允许有200个视图。 | ||
| 251 | |||
| 252 | =head4 请求包结构体为: | ||
| 253 | |||
| 254 | { | ||
| 255 | "docid": "DOCID", | ||
| 256 | "sheet_id": "123Abc", | ||
| 257 | "view_title": "XXX", | ||
| 258 | "view_type": "VIEW_TYPE_GRID" | ||
| 259 | } | ||
| 260 | |||
| 261 | =head4 参数说明: | ||
| 262 | |||
| 263 | 参数 类型 是否必须 说明 | ||
| 264 | access_token 是 调用接口凭证 | ||
| 265 | docid string 是 文档的docid | ||
| 266 | sheet_id string 是 Smartsheet 子表ID | ||
| 267 | view_title string 是 视图标题 | ||
| 268 | view_type string 是 视图类型。见ViewType | ||
| 269 | property_gantt obect(GanttViewProperty) 否 甘特视图属性,添加甘特图时必填 | ||
| 270 | property_calendar object(CalendarViewProperty) 否 日历视图属性,添加日历视图时必填 | ||
| 271 | |||
| 272 | =head4 权限说明: | ||
| 273 | |||
| 274 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 275 | |||
| 276 | =head3 RETURN 返回结果: | ||
| 277 | |||
| 278 | { | ||
| 279 | "errcode": 0, | ||
| 280 | "errmsg": "ok", | ||
| 281 | "view": { | ||
| 282 | "view_id": "vFYZUS", | ||
| 283 | "view_title": "XXX", | ||
| 284 | "view_type": "VIEW_TYPE_GRID" | ||
| 285 | } | ||
| 286 | } | ||
| 287 | |||
| 288 | =head4 RETURN 参数说明: | ||
| 289 | |||
| 290 | 参数 类型 说明 | ||
| 291 | errcode int32 错误码 | ||
| 292 | errmsg string 错误码说明 | ||
| 293 | view object(View) 添加视图响应 | ||
| 294 | |||
| 295 | =head4 参数详细说明 | ||
| 296 | |||
| 297 | L<https://developer.work.weixin.qq.com/document/path/99900#参数详细说明> | ||
| 298 | |||
| 299 | =cut | ||
| 300 | |||
| 301 | sub add_view { | ||
| 302 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 303 | my $access_token = $_[0]; | ||
| 304 | my $json = $_[1]; | ||
| 305 | my $ua = LWP::UserAgent->new; | ||
| 306 | $ua->timeout(30); | ||
| 307 | $ua->env_proxy; | ||
| 308 | |||
| 309 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/smartsheet/add_view?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 310 | if ($response->is_success) { | ||
| 311 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 312 | } | ||
| 313 | |||
| 314 | } | ||
| 315 | return 0; | ||
| 316 | } | ||
| 317 | |||
| 318 | =head2 delete_views(access_token, hash); | ||
| 319 | |||
| 320 | 删除视图 | ||
| 321 | 最后更新:2024/05/30 | ||
| 322 | |||
| 323 | =head2 SYNOPSIS | ||
| 324 | |||
| 325 | L<https://developer.work.weixin.qq.com/document/path/99901> | ||
| 326 | |||
| 327 | =head3 请求说明: | ||
| 328 | |||
| 329 | 本接口用于在 smartsheet 中的某个子表里删除若干个视图。 | ||
| 330 | |||
| 331 | =head4 请求包结构体为: | ||
| 332 | |||
| 333 | { | ||
| 334 | "docid": "DOCID", | ||
| 335 | "sheet_id": "123Abc", | ||
| 336 | "view_ids": [ | ||
| 337 | "VIEWID1", "VIEWID2" | ||
| 338 | ] | ||
| 339 | } | ||
| 340 | |||
| 341 | =head4 参数说明: | ||
| 342 | |||
| 343 | 参数 类型 是否必须 说明 | ||
| 344 | access_token 是 调用接口凭证 | ||
| 345 | docid string 是 文档的docid | ||
| 346 | sheet_id string 是 Smartsheet 子表ID | ||
| 347 | view_ids string[] 是 要删除的视图ID列表 | ||
| 348 | |||
| 349 | =head4 权限说明: | ||
| 350 | |||
| 351 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 352 | |||
| 353 | =head3 RETURN 返回结果: | ||
| 354 | |||
| 355 | { | ||
| 356 | "errcode": 0, | ||
| 357 | "errmsg": "ok" | ||
| 358 | } | ||
| 359 | |||
| 360 | =head4 RETURN 参数说明: | ||
| 361 | |||
| 362 | 参数 类型 说明 | ||
| 363 | errcode int32 错误码 | ||
| 364 | errmsg string 错误码说明 | ||
| 365 | |||
| 366 | =cut | ||
| 367 | |||
| 368 | sub delete_views { | ||
| 369 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 370 | my $access_token = $_[0]; | ||
| 371 | my $json = $_[1]; | ||
| 372 | my $ua = LWP::UserAgent->new; | ||
| 373 | $ua->timeout(30); | ||
| 374 | $ua->env_proxy; | ||
| 375 | |||
| 376 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/smartsheet/delete_views?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 377 | if ($response->is_success) { | ||
| 378 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 379 | } | ||
| 380 | |||
| 381 | } | ||
| 382 | return 0; | ||
| 383 | } | ||
| 384 | |||
| 385 | =head2 update_view(access_token, hash); | ||
| 386 | |||
| 387 | 更新视图 | ||
| 388 | 最后更新:2024/05/30 | ||
| 389 | |||
| 390 | =head2 SYNOPSIS | ||
| 391 | |||
| 392 | L<https://developer.work.weixin.qq.com/document/path/99902> | ||
| 393 | |||
| 394 | =head3 请求说明: | ||
| 395 | |||
| 396 | 本接口用于在 Smartsheet 中的某个子表里添加一个新视图。 | ||
| 397 | |||
| 398 | =head4 请求包结构体为: | ||
| 399 | |||
| 400 | { | ||
| 401 | "docid": "DOCID", | ||
| 402 | "sheet_id": "123Abc", | ||
| 403 | "view_id": "VIEWID", | ||
| 404 | "view_title": "XXX", | ||
| 405 | "property": { | ||
| 406 | } | ||
| 407 | } | ||
| 408 | |||
| 409 | =head4 参数说明: | ||
| 410 | |||
| 411 | 参数 类型 是否必须 说明 | ||
| 412 | access_token 是 调用接口凭证 | ||
| 413 | docid string 是 文档的docid | ||
| 414 | sheet_id string 是 Smartsheet 子表ID | ||
| 415 | view_id string 是 视图ID | ||
| 416 | view_title string 否 视图标题 | ||
| 417 | property object(ViewProperty) 否 视图的排序/过滤/分组配置,详见ViewProperty | ||
| 418 | |||
| 419 | =head4 权限说明: | ||
| 420 | |||
| 421 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 422 | |||
| 423 | =head3 RETURN 返回结果: | ||
| 424 | |||
| 425 | { | ||
| 426 | "errcode": 0, | ||
| 427 | "errmsg": "ok", | ||
| 428 | "view": { | ||
| 429 | } | ||
| 430 | } | ||
| 431 | |||
| 432 | =head4 RETURN 参数说明: | ||
| 433 | |||
| 434 | 参数 类型 说明 | ||
| 435 | errcode int32 错误码 | ||
| 436 | errmsg string 错误码说明 | ||
| 437 | view object(View) 更新成功的视图内容 | ||
| 438 | |||
| 439 | =head4 参数详细说明 | ||
| 440 | |||
| 441 | L<https://developer.work.weixin.qq.com/document/path/99902#参数详细说明> | ||
| 442 | |||
| 443 | =cut | ||
| 444 | |||
| 445 | sub update_view { | ||
| 446 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 447 | my $access_token = $_[0]; | ||
| 448 | my $json = $_[1]; | ||
| 449 | my $ua = LWP::UserAgent->new; | ||
| 450 | $ua->timeout(30); | ||
| 451 | $ua->env_proxy; | ||
| 452 | |||
| 453 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/smartsheet/update_view?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 454 | if ($response->is_success) { | ||
| 455 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 456 | } | ||
| 457 | |||
| 458 | } | ||
| 459 | return 0; | ||
| 460 | } | ||
| 461 | |||
| 462 | =head2 add_fields(access_token, hash); | ||
| 463 | |||
| 464 | 添加字段 | ||
| 465 | 最后更新:2024/05/30 | ||
| 466 | |||
| 467 | =head2 SYNOPSIS | ||
| 468 | |||
| 469 | L<https://developer.work.weixin.qq.com/document/path/99904> | ||
| 470 | |||
| 471 | =head3 请求说明: | ||
| 472 | |||
| 473 | 本接口用于在智能表中的某个子表里添加一列或多列新字段。单表最多允许有150个字段。 | ||
| 474 | |||
| 475 | =head4 请求包结构体为: | ||
| 476 | |||
| 477 | { | ||
| 478 | "docid": "DOCID", | ||
| 479 | "sheet_id": "SHEETID", | ||
| 480 | "fields": [{ | ||
| 481 | "field_title": "TITLE", | ||
| 482 | "field_type": "FIELD_TYPE_TEXT" | ||
| 483 | }] | ||
| 484 | } | ||
| 485 | |||
| 486 | =head4 参数说明: | ||
| 487 | |||
| 488 | 参数 类型 是否必须 说明 | ||
| 489 | access_token 是 调用接口凭证 | ||
| 490 | docid string 是 文档的docid | ||
| 491 | sheet_id string 是 表格ID | ||
| 492 | fields object [] (AddFiled) 是 字段详情 | ||
| 493 | |||
| 494 | =head4 权限说明: | ||
| 495 | |||
| 496 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 497 | |||
| 498 | =head3 RETURN 返回结果: | ||
| 499 | |||
| 500 | { | ||
| 501 | "errcode": 0, | ||
| 502 | "errmsg": "ok", | ||
| 503 | "fields": [{ | ||
| 504 | "field_id": "FIELDID", | ||
| 505 | "field_title": "TITLE", | ||
| 506 | "field_type": "FIELD_TYPE_TEXT" | ||
| 507 | }] | ||
| 508 | } | ||
| 509 | |||
| 510 | =head4 RETURN 参数说明: | ||
| 511 | |||
| 512 | 参数 类型 说明 | ||
| 513 | errcode int32 错误码 | ||
| 514 | errmsg string 错误码说明 | ||
| 515 | fields object [] (Filed) 字段详情 | ||
| 516 | |||
| 517 | =head4 参数详细说明 | ||
| 518 | |||
| 519 | L<https://developer.work.weixin.qq.com/document/path/99904#参数详细说明> | ||
| 520 | |||
| 521 | =cut | ||
| 522 | |||
| 523 | sub add_fields { | ||
| 524 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 525 | my $access_token = $_[0]; | ||
| 526 | my $json = $_[1]; | ||
| 527 | my $ua = LWP::UserAgent->new; | ||
| 528 | $ua->timeout(30); | ||
| 529 | $ua->env_proxy; | ||
| 530 | |||
| 531 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/smartsheet/add_fields?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 532 | if ($response->is_success) { | ||
| 533 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 534 | } | ||
| 535 | |||
| 536 | } | ||
| 537 | return 0; | ||
| 538 | } | ||
| 539 | |||
| 540 | =head2 delete_fields(access_token, hash); | ||
| 541 | |||
| 542 | 添加字段 | ||
| 543 | 最后更新:2024/05/30 | ||
| 544 | |||
| 545 | =head2 SYNOPSIS | ||
| 546 | |||
| 547 | L<https://developer.work.weixin.qq.com/document/path/99905> | ||
| 548 | |||
| 549 | =head3 请求说明: | ||
| 550 | |||
| 551 | 本接口用于删除智能表中的某个子表里的一列或多列字段。 | ||
| 552 | |||
| 553 | =head4 请求包结构体为: | ||
| 554 | |||
| 555 | { | ||
| 556 | "docid": "DOCID", | ||
| 557 | "sheet_id": "SHEETID", | ||
| 558 | "field_ids": [ | ||
| 559 | "FIELDID" | ||
| 560 | ] | ||
| 561 | } | ||
| 562 | |||
| 563 | =head4 参数说明: | ||
| 564 | |||
| 565 | 参数 类型 是否必须 说明 | ||
| 566 | access_token 是 调用接口凭证 | ||
| 567 | docid string 是 文档的docid | ||
| 568 | sheet_id string 是 表格ID | ||
| 569 | field_ids string[] 是 需要删除的字段id列表 | ||
| 570 | |||
| 571 | =head4 权限说明: | ||
| 572 | |||
| 573 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 574 | |||
| 575 | =head3 RETURN 返回结果: | ||
| 576 | |||
| 577 | { | ||
| 578 | "errcode": 0, | ||
| 579 | "errmsg": "ok" | ||
| 580 | } | ||
| 581 | |||
| 582 | =head4 RETURN 参数说明: | ||
| 583 | |||
| 584 | 参数 类型 说明 | ||
| 585 | errcode int32 错误码 | ||
| 586 | errmsg string 错误码说明 | ||
| 587 | |||
| 588 | =cut | ||
| 589 | |||
| 590 | sub delete_fields { | ||
| 591 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 592 | my $access_token = $_[0]; | ||
| 593 | my $json = $_[1]; | ||
| 594 | my $ua = LWP::UserAgent->new; | ||
| 595 | $ua->timeout(30); | ||
| 596 | $ua->env_proxy; | ||
| 597 | |||
| 598 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/smartsheet/delete_fields?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 599 | if ($response->is_success) { | ||
| 600 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 601 | } | ||
| 602 | |||
| 603 | } | ||
| 604 | return 0; | ||
| 605 | } | ||
| 606 | |||
| 607 | =head2 update_fields(access_token, hash); | ||
| 608 | |||
| 609 | 更新字段 | ||
| 610 | 最后更新:2024/05/30 | ||
| 611 | |||
| 612 | =head2 SYNOPSIS | ||
| 613 | |||
| 614 | L<https://developer.work.weixin.qq.com/document/path/99906> | ||
| 615 | |||
| 616 | =head3 请求说明: | ||
| 617 | |||
| 618 | 本接口用于更新智能中的某个子表里的一个或多个字段的标题和字段属性信息。 | ||
| 619 | 注意 | ||
| 620 | 该接口只能更新字段名、字段属性,不能更新字段类型。 | ||
| 621 | |||
| 622 | =head4 请求包结构体为: | ||
| 623 | |||
| 624 | { | ||
| 625 | "docid": "DOCID", | ||
| 626 | "sheet_id": "SHEETID", | ||
| 627 | "fields": [{ | ||
| 628 | "field_id": "FIELD_ID", | ||
| 629 | "field_title": "TITLE", | ||
| 630 | "field_type": "FIELD_TYPE_TEXT" | ||
| 631 | }] | ||
| 632 | } | ||
| 633 | |||
| 634 | =head4 参数说明: | ||
| 635 | |||
| 636 | 参数 类型 是否必须 说明 | ||
| 637 | access_token 是 调用接口凭证 | ||
| 638 | docid string 是 文档的docid | ||
| 639 | sheet_id string 是 表格ID | ||
| 640 | fields object [](UpdateField) 是 字段详情 | ||
| 641 | |||
| 642 | =head4 权限说明: | ||
| 643 | |||
| 644 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 645 | |||
| 646 | =head3 RETURN 返回结果: | ||
| 647 | |||
| 648 | { | ||
| 649 | "errcode": 0, | ||
| 650 | "errmsg": "ok", | ||
| 651 | "fields": [{ | ||
| 652 | "field_id": "FIELDID", | ||
| 653 | "field_title": "TITLE", | ||
| 654 | "field_type": "FIELD_TYPE_TEXT" | ||
| 655 | }] | ||
| 656 | } | ||
| 657 | |||
| 658 | =head4 RETURN 参数说明: | ||
| 659 | |||
| 660 | 参数 类型 说明 | ||
| 661 | errcode int32 错误码 | ||
| 662 | errmsg string 错误码说明 | ||
| 663 | fields object [] (Filed) 字段详情 | ||
| 664 | |||
| 665 | =head4 参数详细说明 | ||
| 666 | |||
| 667 | L<https://developer.work.weixin.qq.com/document/path/99906#参数详细说明> | ||
| 668 | |||
| 669 | =cut | ||
| 670 | |||
| 671 | sub update_fields { | ||
| 672 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 673 | my $access_token = $_[0]; | ||
| 674 | my $json = $_[1]; | ||
| 675 | my $ua = LWP::UserAgent->new; | ||
| 676 | $ua->timeout(30); | ||
| 677 | $ua->env_proxy; | ||
| 678 | |||
| 679 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/smartsheet/update_fields?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 680 | if ($response->is_success) { | ||
| 681 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 682 | } | ||
| 683 | |||
| 684 | } | ||
| 685 | return 0; | ||
| 686 | } | ||
| 687 | |||
| 688 | =head2 add_records(access_token, hash); | ||
| 689 | |||
| 690 | 添加记录 | ||
| 691 | 最后更新:2024/05/30 | ||
| 692 | |||
| 693 | =head2 SYNOPSIS | ||
| 694 | |||
| 695 | L<https://developer.work.weixin.qq.com/document/path/99907> | ||
| 696 | |||
| 697 | =head3 请求说明: | ||
| 698 | |||
| 699 | 本接口用于在 Smartsheet 中的某个子表里添加一行或多行新记录。单表最多允许有40000行记录。 | ||
| 700 | 注意 | ||
| 701 | 不能通过添加记录接口给创建时间、最后编辑时间、创建人和最后编辑人四种类型的字段添加记录。 | ||
| 702 | |||
| 703 | =head4 请求包结构体为: | ||
| 704 | |||
| 705 | { | ||
| 706 | "docid": "DOCID", | ||
| 707 | "sheet_id": "123Abc", | ||
| 708 | "key_type": "CELL_VALUE_KEY_TYPE_FIELD_TITLE", | ||
| 709 | "records": [{ | ||
| 710 | "values": { | ||
| 711 | "FILED_TITLE": [{ | ||
| 712 | "type": "text", | ||
| 713 | "text": "文本内容" | ||
| 714 | }] | ||
| 715 | } | ||
| 716 | }] | ||
| 717 | } | ||
| 718 | |||
| 719 | =head4 参数说明: | ||
| 720 | |||
| 721 | 参数 类型 是否必须 说明 | ||
| 722 | access_token 是 调用接口凭证 | ||
| 723 | docid string 是 文档的docid | ||
| 724 | sheet_id string 是 Smartsheet 子表ID | ||
| 725 | key_type string(CellValueKeyType) 否 返回记录中单元格的key类型,默认用标题 | ||
| 726 | records Object[](AddRecord) 是 需要添加的记录的具体内容组成的 JSON 数组 | ||
| 727 | |||
| 728 | =head4 权限说明: | ||
| 729 | |||
| 730 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 731 | |||
| 732 | =head3 RETURN 返回结果: | ||
| 733 | |||
| 734 | { | ||
| 735 | "errcode": 0, | ||
| 736 | "errmsg": "ok", | ||
| 737 | "records": [ | ||
| 738 | |||
| 739 | ] | ||
| 740 | } | ||
| 741 | |||
| 742 | =head4 RETURN 参数说明: | ||
| 743 | |||
| 744 | 参数 类型 说明 | ||
| 745 | errcode int32 错误码 | ||
| 746 | errmsg string 错误码说明 | ||
| 747 | records Object[](CommonRecord) 由添加成功的记录的具体内容组成的 JSON 数组 | ||
| 748 | |||
| 749 | =head4 参数详细说明 | ||
| 750 | |||
| 751 | L<https://developer.work.weixin.qq.com/document/path/99904#参数详细说明> | ||
| 752 | |||
| 753 | =cut | ||
| 754 | |||
| 755 | sub add_records { | ||
| 756 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 757 | my $access_token = $_[0]; | ||
| 758 | my $json = $_[1]; | ||
| 759 | my $ua = LWP::UserAgent->new; | ||
| 760 | $ua->timeout(30); | ||
| 761 | $ua->env_proxy; | ||
| 762 | |||
| 763 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/smartsheet/add_records?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 764 | if ($response->is_success) { | ||
| 765 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 766 | } | ||
| 767 | |||
| 768 | } | ||
| 769 | return 0; | ||
| 770 | } | ||
| 771 | |||
| 772 | =head2 delete_records(access_token, hash); | ||
| 773 | |||
| 774 | 添加字段 | ||
| 775 | 最后更新:2024/05/30 | ||
| 776 | |||
| 777 | =head2 SYNOPSIS | ||
| 778 | |||
| 779 | L<https://developer.work.weixin.qq.com/document/path/99908> | ||
| 780 | |||
| 781 | =head3 请求说明: | ||
| 782 | |||
| 783 | 本接口用于删除 Smartsheet 的某个子表中的一行或多行记录。 | ||
| 784 | |||
| 785 | =head4 请求包结构体为: | ||
| 786 | |||
| 787 | { | ||
| 788 | "docid": "DOCID", | ||
| 789 | "sheet_id": "123Abc", | ||
| 790 | "record_ids": [ | ||
| 791 | "re9IqD", | ||
| 792 | "rpS0P9" | ||
| 793 | ] | ||
| 794 | } | ||
| 795 | |||
| 796 | =head4 参数说明: | ||
| 797 | |||
| 798 | 参数 类型 是否必须 说明 | ||
| 799 | access_token 是 调用接口凭证 | ||
| 800 | docid string 是 文档的docid | ||
| 801 | sheet_id string 是 Smartsheet 子表ID | ||
| 802 | record_ids string[] 是 要删除的记录 ID | ||
| 803 | |||
| 804 | =head4 权限说明: | ||
| 805 | |||
| 806 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 807 | |||
| 808 | =head3 RETURN 返回结果: | ||
| 809 | |||
| 810 | { | ||
| 811 | "errcode": 0, | ||
| 812 | "errmsg": "ok" | ||
| 813 | } | ||
| 814 | |||
| 815 | =head4 RETURN 参数说明: | ||
| 816 | |||
| 817 | 参数 类型 说明 | ||
| 818 | errcode int32 错误码 | ||
| 819 | errmsg string 错误码说明 | ||
| 820 | |||
| 821 | =cut | ||
| 822 | |||
| 823 | sub delete_records { | ||
| 824 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 825 | my $access_token = $_[0]; | ||
| 826 | my $json = $_[1]; | ||
| 827 | my $ua = LWP::UserAgent->new; | ||
| 828 | $ua->timeout(30); | ||
| 829 | $ua->env_proxy; | ||
| 830 | |||
| 831 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/smartsheet/delete_records?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 832 | if ($response->is_success) { | ||
| 833 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 834 | } | ||
| 835 | |||
| 836 | } | ||
| 837 | return 0; | ||
| 838 | } | ||
| 839 | |||
| 840 | =head2 update_records(access_token, hash); | ||
| 841 | |||
| 842 | 更新记录 | ||
| 843 | 最后更新:2024/05/30 | ||
| 844 | |||
| 845 | =head2 SYNOPSIS | ||
| 846 | |||
| 847 | L<https://developer.work.weixin.qq.com/document/path/99909> | ||
| 848 | |||
| 849 | =head3 请求说明: | ||
| 850 | |||
| 851 | 本接口用于更新 Smartsheet 中的某个子表里的一行或多行记录。 | ||
| 852 | 注意 | ||
| 853 | 不能通过更新记录接口给创建时间、最后编辑时间、创建人和最后编辑人四种类型的字段更新记录。 | ||
| 854 | |||
| 855 | =head4 请求包结构体为: | ||
| 856 | |||
| 857 | { | ||
| 858 | "docid": "DOCID", | ||
| 859 | "sheet_id": "123Abc", | ||
| 860 | "key_type": "CELL_VALUE_KEY_TYPE_FIELD_TITLE", | ||
| 861 | "records": [ | ||
| 862 | ] | ||
| 863 | } | ||
| 864 | |||
| 865 | =head4 参数说明: | ||
| 866 | |||
| 867 | 参数 类型 是否必须 说明 | ||
| 868 | access_token 是 调用接口凭证 | ||
| 869 | docid string 是 文档的docid | ||
| 870 | sheet_id string 是 Smartsheet 子表ID | ||
| 871 | key_type string(CellValueKeyType) 否 返回记录中单元格的key类型 | ||
| 872 | records Object[](UpdateRecord) 是 由需要更新的记录组成的 JSON 数组 | ||
| 873 | |||
| 874 | =head4 权限说明: | ||
| 875 | |||
| 876 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 877 | |||
| 878 | =head3 RETURN 返回结果: | ||
| 879 | |||
| 880 | { | ||
| 881 | "errcode": 0, | ||
| 882 | "errmsg": "ok", | ||
| 883 | "records": [ | ||
| 884 | ] | ||
| 885 | } | ||
| 886 | |||
| 887 | =head4 RETURN 参数说明: | ||
| 888 | |||
| 889 | 参数 类型 说明 | ||
| 890 | errcode int32 错误码 | ||
| 891 | errmsg string 错误码说明 | ||
| 892 | records Object[](CommonRecord) 由更新成功的记录的具体内容组成的 JSON 数组 | ||
| 893 | |||
| 894 | =head4 参数详细说明 | ||
| 895 | |||
| 896 | L<https://developer.work.weixin.qq.com/document/path/99909#参数详细说明> | ||
| 897 | |||
| 898 | =cut | ||
| 899 | |||
| 900 | sub update_records { | ||
| 901 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 902 | my $access_token = $_[0]; | ||
| 903 | my $json = $_[1]; | ||
| 904 | my $ua = LWP::UserAgent->new; | ||
| 905 | $ua->timeout(30); | ||
| 906 | $ua->env_proxy; | ||
| 907 | |||
| 908 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/smartsheet/update_records?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 909 | if ($response->is_success) { | ||
| 910 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 911 | } | ||
| 912 | |||
| 913 | } | ||
| 914 | return 0; | ||
| 915 | } | ||
| 916 | |||
| 917 | =head1 FUNCTION | ||
| 918 | |||
| 919 | 获取智能表格数据 | ||
| 920 | |||
| 921 | =head2 get_sheet(access_token, hash); | ||
| 922 | |||
| 923 | 查询子表 | ||
| 924 | 最后更新:2024/06/13 | ||
| 925 | |||
| 926 | =head2 SYNOPSIS | ||
| 927 | |||
| 928 | L<https://developer.work.weixin.qq.com/document/path/99911> | ||
| 929 | |||
| 930 | =head3 请求说明: | ||
| 931 | |||
| 932 | 本接口用于查询一篇在线表格中全部智能表信息。 | ||
| 933 | |||
| 934 | =head4 请求包结构体为: | ||
| 935 | |||
| 936 | { | ||
| 937 | "docid": "DOCID", | ||
| 938 | "sheet_id": "xxx" | ||
| 939 | } | ||
| 940 | |||
| 941 | =head4 参数说明: | ||
| 942 | |||
| 943 | 参数 类型 是否必须 说明 | ||
| 944 | access_token 是 调用接口凭证 | ||
| 945 | docid string 是 文档的docid | ||
| 946 | sheet_id string 否 指定子表ID查询 | ||
| 947 | |||
| 948 | =head4 权限说明: | ||
| 949 | |||
| 950 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 951 | |||
| 952 | =head3 RETURN 返回结果: | ||
| 953 | |||
| 954 | { | ||
| 955 | "errcode": 0, | ||
| 956 | "errmsg": "ok", | ||
| 957 | "sheet_list": [ | ||
| 958 | { | ||
| 959 | "sheet_id": "123Abc", | ||
| 960 | "title": "XXXX", | ||
| 961 | "is_visible": true | ||
| 962 | } | ||
| 963 | ] | ||
| 964 | } | ||
| 965 | |||
| 966 | =head4 RETURN 参数说明: | ||
| 967 | |||
| 968 | 参数 类型 说明 | ||
| 969 | errcode int32 错误码 | ||
| 970 | errmsg string 错误码说明 | ||
| 971 | sheet_list object[] 智能表信息 | ||
| 972 | sheet_list.sheet_id string 子表id | ||
| 973 | sheet_list.title string 子表名称 | ||
| 974 | sheet_list.is_visible bool 子表是否可见 | ||
| 975 | |||
| 976 | =cut | ||
| 977 | |||
| 978 | sub get_sheet { | ||
| 979 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 980 | my $access_token = $_[0]; | ||
| 981 | my $json = $_[1]; | ||
| 982 | my $ua = LWP::UserAgent->new; | ||
| 983 | $ua->timeout(30); | ||
| 984 | $ua->env_proxy; | ||
| 985 | |||
| 986 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/smartsheet/get_sheet?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 987 | if ($response->is_success) { | ||
| 988 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 989 | } | ||
| 990 | |||
| 991 | } | ||
| 992 | return 0; | ||
| 993 | } | ||
| 994 | |||
| 995 | =head2 get_views(access_token, hash); | ||
| 996 | |||
| 997 | 查询视图 | ||
| 998 | 最后更新:2024/05/30 | ||
| 999 | |||
| 1000 | =head2 SYNOPSIS | ||
| 1001 | |||
| 1002 | L<https://developer.work.weixin.qq.com/document/path/99913> | ||
| 1003 | |||
| 1004 | =head3 请求说明: | ||
| 1005 | |||
| 1006 | 本接口用于获取 Smartsheet 中某个子表里全部视图信息。 | ||
| 1007 | |||
| 1008 | =head4 请求包结构体为: | ||
| 1009 | |||
| 1010 | { | ||
| 1011 | "docid": "DOCID", | ||
| 1012 | "sheet_id": "ezPcdA", | ||
| 1013 | "view_ids": [ | ||
| 1014 | "vPpw9C", | ||
| 1015 | "vfM2tt" | ||
| 1016 | ], | ||
| 1017 | "offset": 0, | ||
| 1018 | "limit": 1 | ||
| 1019 | } | ||
| 1020 | |||
| 1021 | =head4 参数说明: | ||
| 1022 | |||
| 1023 | 参数 类型 是否必须 说明 | ||
| 1024 | access_token 是 调用接口凭证 | ||
| 1025 | docid string 是 文档的docid | ||
| 1026 | sheet_id string 是 Smartsheet 子表ID | ||
| 1027 | view_ids string[] 否 需要查询的视图 ID 数组 | ||
| 1028 | offset uint32 否 偏移量,初始值为 0 | ||
| 1029 | limit uint32 否 分页大小 , 每页返回多少条数据;当不填写该参数或将该参数设置为 0 时,如果总数大于 1000,一次性返回 1000 个视图,当总数小于 1000 时,返回全部视图;limit 最大值为 1000 | ||
| 1030 | |||
| 1031 | =head4 权限说明: | ||
| 1032 | |||
| 1033 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 1034 | |||
| 1035 | =head3 RETURN 返回结果: | ||
| 1036 | |||
| 1037 | { | ||
| 1038 | "errcode": 0, | ||
| 1039 | "errmsg": "ok", | ||
| 1040 | "total": 2, | ||
| 1041 | "has_more": true, | ||
| 1042 | "next": 1, | ||
| 1043 | "views": [ | ||
| 1044 | ] | ||
| 1045 | } | ||
| 1046 | |||
| 1047 | =head4 RETURN 参数说明: | ||
| 1048 | |||
| 1049 | 参数 类型 说明 | ||
| 1050 | errcode int32 错误码 | ||
| 1051 | errmsg string 错误码说明 | ||
| 1052 | total uint32 符合筛选条件的视图总数 | ||
| 1053 | has_more bool 是否还有更多项 | ||
| 1054 | next uint32 下次下一个搜索结果的偏移量 | ||
| 1055 | views Object[](View) 视图数据 | ||
| 1056 | |||
| 1057 | =head4 参数详细说明 | ||
| 1058 | |||
| 1059 | L<https://developer.work.weixin.qq.com/document/path/99913#参数详细说明> | ||
| 1060 | |||
| 1061 | =cut | ||
| 1062 | |||
| 1063 | sub get_views { | ||
| 1064 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 1065 | my $access_token = $_[0]; | ||
| 1066 | my $json = $_[1]; | ||
| 1067 | my $ua = LWP::UserAgent->new; | ||
| 1068 | $ua->timeout(30); | ||
| 1069 | $ua->env_proxy; | ||
| 1070 | |||
| 1071 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/smartsheet/get_views?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 1072 | if ($response->is_success) { | ||
| 1073 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 1074 | } | ||
| 1075 | |||
| 1076 | } | ||
| 1077 | return 0; | ||
| 1078 | } | ||
| 1079 | |||
| 1080 | =head2 get_fields(access_token, hash); | ||
| 1081 | |||
| 1082 | 查询字段 | ||
| 1083 | 最后更新:2024/05/30 | ||
| 1084 | |||
| 1085 | =head2 SYNOPSIS | ||
| 1086 | |||
| 1087 | L<https://developer.work.weixin.qq.com/document/path/99914> | ||
| 1088 | |||
| 1089 | =head3 请求说明: | ||
| 1090 | |||
| 1091 | 本接口用于获取智能表中某个子表下字段信息,该接口可以完成下面三种功能:获取全部字段信息、依据字段名获取对应字段、依据字段 ID 获取对应字段信息。 | ||
| 1092 | |||
| 1093 | =head4 请求包结构体为: | ||
| 1094 | |||
| 1095 | { | ||
| 1096 | "docid": "DOCID", | ||
| 1097 | "sheet_id": "SHEETID", | ||
| 1098 | "offset": 0, | ||
| 1099 | "limit": 10 | ||
| 1100 | } | ||
| 1101 | |||
| 1102 | =head4 参数说明: | ||
| 1103 | |||
| 1104 | 参数 类型 是否必须 说明 | ||
| 1105 | access_token 是 调用接口凭证 | ||
| 1106 | docid string 是 文档的docid | ||
| 1107 | sheet_id string 是 表格ID | ||
| 1108 | view_id string 否 视图 ID | ||
| 1109 | field_ids string [] 否 由字段 ID 组成的 JSON 数组 | ||
| 1110 | field_titles string [] 否 由字段标题组成的 JSON 数组 | ||
| 1111 | offset int 否 偏移量,初始值为 0 | ||
| 1112 | limit int 否 分页大小 , 每页返回多少条数据;当不填写该参数或将该参数设置为 0 时,如果总数大于 1000,一次性返回 1000 个字段,当总数小于 1000 时,返回全部字段;limit 最大值为 1000 | ||
| 1113 | |||
| 1114 | =head4 权限说明: | ||
| 1115 | |||
| 1116 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 1117 | |||
| 1118 | =head3 RETURN 返回结果: | ||
| 1119 | |||
| 1120 | { | ||
| 1121 | "errcode": 0, | ||
| 1122 | "errmsg": "ok", | ||
| 1123 | "total": 1, | ||
| 1124 | "fields": [{ | ||
| 1125 | "field_id": "ID1", | ||
| 1126 | "field_title": "TITLE1", | ||
| 1127 | "field_type": "FIELD_TYPE_TEXT" | ||
| 1128 | }] | ||
| 1129 | } | ||
| 1130 | |||
| 1131 | =head4 RETURN 参数说明: | ||
| 1132 | |||
| 1133 | 参数 类型 说明 | ||
| 1134 | errcode int32 错误码 | ||
| 1135 | errmsg string 错误码说明 | ||
| 1136 | total Object 字段总数 | ||
| 1137 | fields object [](Field) 字段详情 | ||
| 1138 | |||
| 1139 | =head4 参数详细说明 | ||
| 1140 | |||
| 1141 | L<https://developer.work.weixin.qq.com/document/path/99914#参数详细说明> | ||
| 1142 | |||
| 1143 | =cut | ||
| 1144 | |||
| 1145 | sub get_fields { | ||
| 1146 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 1147 | my $access_token = $_[0]; | ||
| 1148 | my $json = $_[1]; | ||
| 1149 | my $ua = LWP::UserAgent->new; | ||
| 1150 | $ua->timeout(30); | ||
| 1151 | $ua->env_proxy; | ||
| 1152 | |||
| 1153 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/smartsheet/get_fields?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 1154 | if ($response->is_success) { | ||
| 1155 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 1156 | } | ||
| 1157 | |||
| 1158 | } | ||
| 1159 | return 0; | ||
| 1160 | } | ||
| 1161 | |||
| 1162 | =head2 get_records(access_token, hash); | ||
| 1163 | |||
| 1164 | 查询记录 | ||
| 1165 | 最后更新:2024/05/30 | ||
| 1166 | |||
| 1167 | =head2 SYNOPSIS | ||
| 1168 | |||
| 1169 | L<https://developer.work.weixin.qq.com/document/path/99914> | ||
| 1170 | |||
| 1171 | =head3 请求说明: | ||
| 1172 | |||
| 1173 | 本接口用于获取 Smartsheet 中某个子表下记录信息,该接口可以完成下面三种功能:获取全部记录信息、依据字段名和记录 ID 获取对应记录、对记录进行排序。 | ||
| 1174 | |||
| 1175 | =head4 请求包结构体为: | ||
| 1176 | |||
| 1177 | { | ||
| 1178 | "docid": "DOCID", | ||
| 1179 | "sheet_id": "123Abc", | ||
| 1180 | "view_id": "vCRl8n", | ||
| 1181 | "record_ids": [ | ||
| 1182 | ], | ||
| 1183 | "key_type": "CELL_VALUE_KEY_TYPE_FIELD_TITLE", | ||
| 1184 | "field_titles": [ | ||
| 1185 | ], | ||
| 1186 | "field_ids": [ | ||
| 1187 | ], | ||
| 1188 | "sort": [ | ||
| 1189 | ], | ||
| 1190 | "offset": 0, | ||
| 1191 | "limit": 100 | ||
| 1192 | } | ||
| 1193 | |||
| 1194 | =head4 参数说明: | ||
| 1195 | |||
| 1196 | 参数 类型 是否必须 说明 | ||
| 1197 | access_token 是 调用接口凭证 | ||
| 1198 | docid string 是 文档的docid | ||
| 1199 | sheet_id string 是 Smartsheet 子表ID | ||
| 1200 | view_id string 否 视图 ID | ||
| 1201 | record_ids string[] 否 由记录 ID 组成的 JSON 数组 | ||
| 1202 | key_type string(CellValueKeyType) 否 返回记录中单元格的key类型 | ||
| 1203 | field_titles string[] 否 返回指定列,由字段标题组成的 JSON 数组 ,key_type 为 CELL_VALUE_KEY_TYPE_FIELD_TITLE 时有效 | ||
| 1204 | field_ids string[] 否 返回指定列,由字段 ID 组成的 JSON 数组 ,key_type 为 CELL_VALUE_KEY_TYPE_FIELD_ID 时有效 | ||
| 1205 | sort Object[](Sort) 否 对返回记录进行排序 | ||
| 1206 | offset uint32 否 偏移量,初始值为 0 | ||
| 1207 | limit uint32 否 分页大小 , 每页返回多少条数据;当不填写该参数或将该参数设置为 0 时,如果总数大于 1000,一次性返回 1000 行记录,当总数小于 1000 时,返回全部记录;limit 最大值为 1000 | ||
| 1208 | |||
| 1209 | =head4 权限说明: | ||
| 1210 | |||
| 1211 | 自建应用需配置到“可调用应用”列表中的应用secret所获取的accesstoken来调用(accesstoken如何获取?) | ||
| 1212 | |||
| 1213 | =head3 RETURN 返回结果: | ||
| 1214 | |||
| 1215 | { | ||
| 1216 | "errcode": 0, | ||
| 1217 | "errmsg": "ok" | ||
| 1218 | } | ||
| 1219 | |||
| 1220 | =head4 RETURN 参数说明: | ||
| 1221 | |||
| 1222 | 参数 类型 说明 | ||
| 1223 | errcode int32 错误码 | ||
| 1224 | errmsg string 错误码说明 | ||
| 1225 | total uint32 符合筛选条件的视图总数 | ||
| 1226 | has_more bool 是否还有更多项 | ||
| 1227 | next uint32 下次下一个搜索结果的偏移量 | ||
| 1228 | records Object[](Record) 由查询记录的具体内容组成的 JSON 数组 | ||
| 1229 | |||
| 1230 | =head4 参数详细说明 | ||
| 1231 | |||
| 1232 | L<https://developer.work.weixin.qq.com/document/path/99915#参数详细说明> | ||
| 1233 | |||
| 1234 | =cut | ||
| 1235 | |||
| 1236 | sub get_records { | ||
| 1237 | if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { | ||
| 1238 | my $access_token = $_[0]; | ||
| 1239 | my $json = $_[1]; | ||
| 1240 | my $ua = LWP::UserAgent->new; | ||
| 1241 | $ua->timeout(30); | ||
| 1242 | $ua->env_proxy; | ||
| 1243 | |||
| 1244 | my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/wedoc/smartsheet/get_records?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json'); | ||
| 1245 | if ($response->is_success) { | ||
| 1246 | return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); | ||
| 1247 | } | ||
| 1248 | |||
| 1249 | } | ||
| 1250 | return 0; | ||
| 1251 | } | ||
| 1252 | |||
| 1253 | 1; | ||
| 1254 | __END__ |