package QQ::weixin::work::wedoc::smartsheet; =encoding utf8 =head1 Name QQ::weixin::work::wedoc::smartsheet =head1 DESCRIPTION æ™ºèƒ½è¡¨æ ¼ =cut use strict; use base qw(QQ::weixin::work::wedoc); use Encode; use LWP::UserAgent; use JSON; use utf8; our $VERSION = '0.12'; our @EXPORT = qw/ add_sheet delete_sheet update_sheet add_view delete_views update_view add_fields delete_fields update_fields add_records delete_records update_records/; =head1 FUNCTION ç¼–è¾‘æ™ºèƒ½è¡¨æ ¼å†…å®¹ =head2 add_sheet(access_token, hash); æ·»åŠ å表 最åŽæ›´æ–°ï¼š2024/05/30 =head2 SYNOPSIS L<https://developer.work.weixin.qq.com/document/path/99896> =head3 请求说明: 本接å£ç”¨äºŽåœ¨è¡¨æ ¼çš„æŸä¸ªä½ç½®æ·»åŠ 一个智能表,该智能表ä¸å˜åœ¨è§†å›¾ã€è®°å½•å’Œå—段,å¯ä»¥ä½¿ç”¨ API 在该智能表ä¸æ·»åŠ 视图ã€è®°å½•å’Œå—段。 =head4 请求包结构体为: { "docid": "DOCID", "properties": { "title": "智能表", "index": 3 } } =head4 å‚数说明: å‚æ•° 类型 是å¦å¿…é¡» 说明 access_token 是 调用接å£å‡è¯ docid string 是 文档的docid properties object å¦ æ™ºèƒ½è¡¨å±žæ€§ properties.title string å¦ æ™ºèƒ½è¡¨æ ‡é¢˜ properties.index int32 å¦ æ™ºèƒ½è¡¨ä¸‹æ ‡ =head4 æƒé™è¯´æ˜Žï¼š 自建应用需é…置到“å¯è°ƒç”¨åº”用â€åˆ—表ä¸çš„应用secret所获å–çš„accesstokenæ¥è°ƒç”¨ï¼ˆaccesstoken如何获å–?) =head3 RETURN 返回结果: { "errcode": 0, "errmsg": "ok", "properties": { "title": "智能表", "index": 3, "sheet_id": "123abc" } } =head4 RETURN å‚数说明: å‚æ•° 类型 说明 errcode int32 错误ç errmsg string 错误ç 说明 properties object 智能表属性 properties.sheet_id string 智能表 ID,创建å表时生æˆçš„ 6 ä½éšæœº ID properties.title string æ™ºèƒ½è¡¨æ ‡é¢˜ properties.index int32 æ™ºèƒ½è¡¨ä¸‹æ ‡ =cut sub add_sheet { if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { my $access_token = $_[0]; my $json = $_[1]; my $ua = LWP::UserAgent->new; $ua->timeout(30); $ua->env_proxy; 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'); if ($response->is_success) { return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); } } return 0; } =head2 delete_sheet(access_token, hash); åˆ é™¤å表 最åŽæ›´æ–°ï¼š2024/05/30 =head2 SYNOPSIS L<https://developer.work.weixin.qq.com/document/path/99899> =head3 请求说明: 本接å£ç”¨äºŽåˆ é™¤åœ¨çº¿è¡¨æ ¼ä¸çš„æŸä¸ªæ™ºèƒ½è¡¨ã€‚ =head4 请求包结构体为: { "docid": "DOCID", "sheet_id": "123Abc" } =head4 å‚数说明: å‚æ•° 类型 是å¦å¿…é¡» 说明 access_token 是 调用接å£å‡è¯ docid string 是 文档的docid sheet_id string 是 åˆ é™¤çš„Smartsheet å表 ID =head4 æƒé™è¯´æ˜Žï¼š 自建应用需é…置到“å¯è°ƒç”¨åº”用â€åˆ—表ä¸çš„应用secret所获å–çš„accesstokenæ¥è°ƒç”¨ï¼ˆaccesstoken如何获å–?) =head3 RETURN 返回结果: { "errcode": 0, "errmsg": "ok" } =head4 RETURN å‚数说明: å‚æ•° 类型 说明 errcode int32 错误ç errmsg string 错误ç 说明 =cut sub delete_sheet { if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { my $access_token = $_[0]; my $json = $_[1]; my $ua = LWP::UserAgent->new; $ua->timeout(30); $ua->env_proxy; 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'); if ($response->is_success) { return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); } } return 0; } =head2 update_sheet(access_token, hash); æ›´æ–°å表 最åŽæ›´æ–°ï¼š2024/05/30 =head2 SYNOPSIS L<https://developer.work.weixin.qq.com/document/path/99898> =head3 请求说明: 本接å£ç”¨äºŽä¿®æ”¹è¡¨æ ¼ä¸æŸä¸ªåè¡¨çš„æ ‡é¢˜ã€‚ =head4 请求包结构体为: { "docid": "DOCID", "properties": { "sheet_id": "123abc", "title": "XXXX" } } =head4 å‚数说明: å‚æ•° 类型 是å¦å¿…é¡» 说明 access_token 是 调用接å£å‡è¯ docid string 是 文档的docid properties.sheet_id string 是 å表 ID properties.title string å¦ åè¡¨æ ‡é¢˜ =head4 æƒé™è¯´æ˜Žï¼š 自建应用需é…置到“å¯è°ƒç”¨åº”用â€åˆ—表ä¸çš„应用secret所获å–çš„accesstokenæ¥è°ƒç”¨ï¼ˆaccesstoken如何获å–?) =head3 RETURN 返回结果: { "errcode": 0, "errmsg": "ok" } =head4 RETURN å‚数说明: å‚æ•° 类型 说明 errcode int32 错误ç errmsg string 错误ç 说明 =cut sub update_sheet { if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { my $access_token = $_[0]; my $json = $_[1]; my $ua = LWP::UserAgent->new; $ua->timeout(30); $ua->env_proxy; 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'); if ($response->is_success) { return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); } } return 0; } =head2 add_view(access_token, hash); æ·»åŠ è§†å›¾ 最åŽæ›´æ–°ï¼š2024/05/30 =head2 SYNOPSIS L<https://developer.work.weixin.qq.com/document/path/99900> =head3 请求说明: 本接å£ç”¨äºŽåœ¨ Smartsheet ä¸çš„æŸä¸ªåè¡¨é‡Œæ·»åŠ ä¸€ä¸ªæ–°è§†å›¾ã€‚å•è¡¨æœ€å¤šå…许有200个视图。 =head4 请求包结构体为: { "docid": "DOCID", "sheet_id": "123Abc", "view_title": "XXX", "view_type": "VIEW_TYPE_GRID" } =head4 å‚数说明: å‚æ•° 类型 是å¦å¿…é¡» 说明 access_token 是 调用接å£å‡è¯ docid string 是 文档的docid sheet_id string 是 Smartsheet å表ID view_title string 是 è§†å›¾æ ‡é¢˜ view_type string 是 视图类型。è§ViewType property_gantt obect(GanttViewProperty) å¦ ç”˜ç‰¹è§†å›¾å±žæ€§,æ·»åŠ ç”˜ç‰¹å›¾æ—¶å¿…å¡« property_calendar object(CalendarViewProperty) å¦ æ—¥åŽ†è§†å›¾å±žæ€§ï¼Œæ·»åŠ æ—¥åŽ†è§†å›¾æ—¶å¿…å¡« =head4 æƒé™è¯´æ˜Žï¼š 自建应用需é…置到“å¯è°ƒç”¨åº”用â€åˆ—表ä¸çš„应用secret所获å–çš„accesstokenæ¥è°ƒç”¨ï¼ˆaccesstoken如何获å–?) =head3 RETURN 返回结果: { "errcode": 0, "errmsg": "ok", "view": { "view_id": "vFYZUS", "view_title": "XXX", "view_type": "VIEW_TYPE_GRID" } } =head4 RETURN å‚数说明: å‚æ•° 类型 说明 errcode int32 错误ç errmsg string 错误ç 说明 view object(View) æ·»åŠ è§†å›¾å“应 =head4 å‚数详细说明 L<https://developer.work.weixin.qq.com/document/path/99900#å‚数详细说明> =cut sub add_view { if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { my $access_token = $_[0]; my $json = $_[1]; my $ua = LWP::UserAgent->new; $ua->timeout(30); $ua->env_proxy; 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'); if ($response->is_success) { return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); } } return 0; } =head2 delete_views(access_token, hash); åˆ é™¤è§†å›¾ 最åŽæ›´æ–°ï¼š2024/05/30 =head2 SYNOPSIS L<https://developer.work.weixin.qq.com/document/path/99901> =head3 请求说明: 本接å£ç”¨äºŽåœ¨ smartsheet ä¸çš„æŸä¸ªåè¡¨é‡Œåˆ é™¤è‹¥å¹²ä¸ªè§†å›¾ã€‚ =head4 请求包结构体为: { "docid": "DOCID", "sheet_id": "123Abc", "view_ids": [ "VIEWID1", "VIEWID2" ] } =head4 å‚数说明: å‚æ•° 类型 是å¦å¿…é¡» 说明 access_token 是 调用接å£å‡è¯ docid string 是 文档的docid sheet_id string 是 Smartsheet å表ID view_ids string[] 是 è¦åˆ 除的视图ID列表 =head4 æƒé™è¯´æ˜Žï¼š 自建应用需é…置到“å¯è°ƒç”¨åº”用â€åˆ—表ä¸çš„应用secret所获å–çš„accesstokenæ¥è°ƒç”¨ï¼ˆaccesstoken如何获å–?) =head3 RETURN 返回结果: { "errcode": 0, "errmsg": "ok" } =head4 RETURN å‚数说明: å‚æ•° 类型 说明 errcode int32 错误ç errmsg string 错误ç 说明 =cut sub delete_views { if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { my $access_token = $_[0]; my $json = $_[1]; my $ua = LWP::UserAgent->new; $ua->timeout(30); $ua->env_proxy; 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'); if ($response->is_success) { return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); } } return 0; } =head2 update_view(access_token, hash); 更新视图 最åŽæ›´æ–°ï¼š2024/05/30 =head2 SYNOPSIS L<https://developer.work.weixin.qq.com/document/path/99902> =head3 请求说明: 本接å£ç”¨äºŽåœ¨ Smartsheet ä¸çš„æŸä¸ªåè¡¨é‡Œæ·»åŠ ä¸€ä¸ªæ–°è§†å›¾ã€‚ =head4 请求包结构体为: { "docid": "DOCID", "sheet_id": "123Abc", "view_id": "VIEWID", "view_title": "XXX", "property": { } } =head4 å‚数说明: å‚æ•° 类型 是å¦å¿…é¡» 说明 access_token 是 调用接å£å‡è¯ docid string 是 文档的docid sheet_id string 是 Smartsheet å表ID view_id string 是 视图ID view_title string å¦ è§†å›¾æ ‡é¢˜ property object(ViewProperty) å¦ è§†å›¾çš„æŽ’åº/过滤/分组é…置,详è§ViewProperty =head4 æƒé™è¯´æ˜Žï¼š 自建应用需é…置到“å¯è°ƒç”¨åº”用â€åˆ—表ä¸çš„应用secret所获å–çš„accesstokenæ¥è°ƒç”¨ï¼ˆaccesstoken如何获å–?) =head3 RETURN 返回结果: { "errcode": 0, "errmsg": "ok", "view": { } } =head4 RETURN å‚数说明: å‚æ•° 类型 说明 errcode int32 错误ç errmsg string 错误ç 说明 view object(View) æ›´æ–°æˆåŠŸçš„视图内容 =head4 å‚数详细说明 L<https://developer.work.weixin.qq.com/document/path/99902#å‚数详细说明> =cut sub update_view { if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { my $access_token = $_[0]; my $json = $_[1]; my $ua = LWP::UserAgent->new; $ua->timeout(30); $ua->env_proxy; 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'); if ($response->is_success) { return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); } } return 0; } =head2 add_fields(access_token, hash); æ·»åŠ å—段 最åŽæ›´æ–°ï¼š2024/05/30 =head2 SYNOPSIS L<https://developer.work.weixin.qq.com/document/path/99904> =head3 请求说明: 本接å£ç”¨äºŽåœ¨æ™ºèƒ½è¡¨ä¸çš„æŸä¸ªåè¡¨é‡Œæ·»åŠ ä¸€åˆ—æˆ–å¤šåˆ—æ–°å—段。å•è¡¨æœ€å¤šå…许有150个å—段。 =head4 请求包结构体为: { "docid": "DOCID", "sheet_id": "SHEETID", "fields": [{ "field_title": "TITLE", "field_type": "FIELD_TYPE_TEXT" }] } =head4 å‚数说明: å‚æ•° 类型 是å¦å¿…é¡» 说明 access_token 是 调用接å£å‡è¯ docid string 是 文档的docid sheet_id string 是 è¡¨æ ¼ID fields object [] (AddFiled) 是 å—段详情 =head4 æƒé™è¯´æ˜Žï¼š 自建应用需é…置到“å¯è°ƒç”¨åº”用â€åˆ—表ä¸çš„应用secret所获å–çš„accesstokenæ¥è°ƒç”¨ï¼ˆaccesstoken如何获å–?) =head3 RETURN 返回结果: { "errcode": 0, "errmsg": "ok", "fields": [{ "field_id": "FIELDID", "field_title": "TITLE", "field_type": "FIELD_TYPE_TEXT" }] } =head4 RETURN å‚数说明: å‚æ•° 类型 说明 errcode int32 错误ç errmsg string 错误ç 说明 fields object [] (Filed) å—段详情 =head4 å‚数详细说明 L<https://developer.work.weixin.qq.com/document/path/99904#å‚数详细说明> =cut sub add_fields { if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { my $access_token = $_[0]; my $json = $_[1]; my $ua = LWP::UserAgent->new; $ua->timeout(30); $ua->env_proxy; 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'); if ($response->is_success) { return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); } } return 0; } =head2 delete_fields(access_token, hash); æ·»åŠ å—段 最åŽæ›´æ–°ï¼š2024/05/30 =head2 SYNOPSIS L<https://developer.work.weixin.qq.com/document/path/99905> =head3 请求说明: 本接å£ç”¨äºŽåˆ 除智能表ä¸çš„æŸä¸ªå表里的一列或多列å—段。 =head4 请求包结构体为: { "docid": "DOCID", "sheet_id": "SHEETID", "field_ids": [ "FIELDID" ] } =head4 å‚数说明: å‚æ•° 类型 是å¦å¿…é¡» 说明 access_token 是 调用接å£å‡è¯ docid string 是 文档的docid sheet_id string 是 è¡¨æ ¼ID field_ids string[] 是 需è¦åˆ 除的å—段id列表 =head4 æƒé™è¯´æ˜Žï¼š 自建应用需é…置到“å¯è°ƒç”¨åº”用â€åˆ—表ä¸çš„应用secret所获å–çš„accesstokenæ¥è°ƒç”¨ï¼ˆaccesstoken如何获å–?) =head3 RETURN 返回结果: { "errcode": 0, "errmsg": "ok" } =head4 RETURN å‚数说明: å‚æ•° 类型 说明 errcode int32 错误ç errmsg string 错误ç 说明 =cut sub delete_fields { if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { my $access_token = $_[0]; my $json = $_[1]; my $ua = LWP::UserAgent->new; $ua->timeout(30); $ua->env_proxy; 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'); if ($response->is_success) { return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); } } return 0; } =head2 update_fields(access_token, hash); æ›´æ–°å—段 最åŽæ›´æ–°ï¼š2024/05/30 =head2 SYNOPSIS L<https://developer.work.weixin.qq.com/document/path/99906> =head3 请求说明: 本接å£ç”¨äºŽæ›´æ–°æ™ºèƒ½ä¸çš„æŸä¸ªå表里的一个或多个å—æ®µçš„æ ‡é¢˜å’Œå—段属性信æ¯ã€‚ æ³¨æ„ è¯¥æŽ¥å£åªèƒ½æ›´æ–°å—段åã€å—段属性,ä¸èƒ½æ›´æ–°å—段类型。 =head4 请求包结构体为: { "docid": "DOCID", "sheet_id": "SHEETID", "fields": [{ "field_id": "FIELD_ID", "field_title": "TITLE", "field_type": "FIELD_TYPE_TEXT" }] } =head4 å‚数说明: å‚æ•° 类型 是å¦å¿…é¡» 说明 access_token 是 调用接å£å‡è¯ docid string 是 文档的docid sheet_id string 是 è¡¨æ ¼ID fields object [](UpdateField) 是 å—段详情 =head4 æƒé™è¯´æ˜Žï¼š 自建应用需é…置到“å¯è°ƒç”¨åº”用â€åˆ—表ä¸çš„应用secret所获å–çš„accesstokenæ¥è°ƒç”¨ï¼ˆaccesstoken如何获å–?) =head3 RETURN 返回结果: { "errcode": 0, "errmsg": "ok", "fields": [{ "field_id": "FIELDID", "field_title": "TITLE", "field_type": "FIELD_TYPE_TEXT" }] } =head4 RETURN å‚数说明: å‚æ•° 类型 说明 errcode int32 错误ç errmsg string 错误ç 说明 fields object [] (Filed) å—段详情 =head4 å‚数详细说明 L<https://developer.work.weixin.qq.com/document/path/99906#å‚数详细说明> =cut sub update_fields { if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { my $access_token = $_[0]; my $json = $_[1]; my $ua = LWP::UserAgent->new; $ua->timeout(30); $ua->env_proxy; 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'); if ($response->is_success) { return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); } } return 0; } =head2 add_records(access_token, hash); æ·»åŠ è®°å½• 最åŽæ›´æ–°ï¼š2024/05/30 =head2 SYNOPSIS L<https://developer.work.weixin.qq.com/document/path/99907> =head3 请求说明: 本接å£ç”¨äºŽåœ¨ Smartsheet ä¸çš„æŸä¸ªåè¡¨é‡Œæ·»åŠ ä¸€è¡Œæˆ–å¤šè¡Œæ–°è®°å½•ã€‚å•è¡¨æœ€å¤šå…许有40000行记录。 æ³¨æ„ ä¸èƒ½é€šè¿‡æ·»åŠ 记录接å£ç»™åˆ›å»ºæ—¶é—´ã€æœ€åŽç¼–辑时间ã€åˆ›å»ºäººå’Œæœ€åŽç¼–辑人四ç§ç±»åž‹çš„å—æ®µæ·»åŠ è®°å½•ã€‚ =head4 请求包结构体为: { "docid": "DOCID", "sheet_id": "123Abc", "key_type": "CELL_VALUE_KEY_TYPE_FIELD_TITLE", "records": [{ "values": { "FILED_TITLE": [{ "type": "text", "text": "文本内容" }] } }] } =head4 å‚数说明: å‚æ•° 类型 是å¦å¿…é¡» 说明 access_token 是 调用接å£å‡è¯ docid string 是 文档的docid sheet_id string 是 Smartsheet å表ID key_type string(CellValueKeyType) å¦ è¿”å›žè®°å½•ä¸å•å…ƒæ ¼çš„keyç±»åž‹ï¼Œé»˜è®¤ç”¨æ ‡é¢˜ records Object[](AddRecord) 是 需è¦æ·»åŠ 的记录的具体内容组æˆçš„ JSON 数组 =head4 æƒé™è¯´æ˜Žï¼š 自建应用需é…置到“å¯è°ƒç”¨åº”用â€åˆ—表ä¸çš„应用secret所获å–çš„accesstokenæ¥è°ƒç”¨ï¼ˆaccesstoken如何获å–?) =head3 RETURN 返回结果: { "errcode": 0, "errmsg": "ok", "records": [ ] } =head4 RETURN å‚数说明: å‚æ•° 类型 说明 errcode int32 错误ç errmsg string 错误ç 说明 records Object[](CommonRecord) ç”±æ·»åŠ æˆåŠŸçš„记录的具体内容组æˆçš„ JSON 数组 =head4 å‚数详细说明 L<https://developer.work.weixin.qq.com/document/path/99904#å‚数详细说明> =cut sub add_records { if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { my $access_token = $_[0]; my $json = $_[1]; my $ua = LWP::UserAgent->new; $ua->timeout(30); $ua->env_proxy; 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'); if ($response->is_success) { return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); } } return 0; } =head2 delete_records(access_token, hash); æ·»åŠ å—段 最åŽæ›´æ–°ï¼š2024/05/30 =head2 SYNOPSIS L<https://developer.work.weixin.qq.com/document/path/99908> =head3 请求说明: 本接å£ç”¨äºŽåˆ 除 Smartsheet çš„æŸä¸ªå表ä¸çš„一行或多行记录。 =head4 请求包结构体为: { "docid": "DOCID", "sheet_id": "123Abc", "record_ids": [ "re9IqD", "rpS0P9" ] } =head4 å‚数说明: å‚æ•° 类型 是å¦å¿…é¡» 说明 access_token 是 调用接å£å‡è¯ docid string 是 文档的docid sheet_id string 是 Smartsheet å表ID record_ids string[] 是 è¦åˆ 除的记录 ID =head4 æƒé™è¯´æ˜Žï¼š 自建应用需é…置到“å¯è°ƒç”¨åº”用â€åˆ—表ä¸çš„应用secret所获å–çš„accesstokenæ¥è°ƒç”¨ï¼ˆaccesstoken如何获å–?) =head3 RETURN 返回结果: { "errcode": 0, "errmsg": "ok" } =head4 RETURN å‚数说明: å‚æ•° 类型 说明 errcode int32 错误ç errmsg string 错误ç 说明 =cut sub delete_records { if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { my $access_token = $_[0]; my $json = $_[1]; my $ua = LWP::UserAgent->new; $ua->timeout(30); $ua->env_proxy; 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'); if ($response->is_success) { return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); } } return 0; } =head2 update_records(access_token, hash); 更新记录 最åŽæ›´æ–°ï¼š2024/05/30 =head2 SYNOPSIS L<https://developer.work.weixin.qq.com/document/path/99909> =head3 请求说明: 本接å£ç”¨äºŽæ›´æ–° Smartsheet ä¸çš„æŸä¸ªå表里的一行或多行记录。 æ³¨æ„ ä¸èƒ½é€šè¿‡æ›´æ–°è®°å½•æŽ¥å£ç»™åˆ›å»ºæ—¶é—´ã€æœ€åŽç¼–辑时间ã€åˆ›å»ºäººå’Œæœ€åŽç¼–辑人四ç§ç±»åž‹çš„å—段更新记录。 =head4 请求包结构体为: { "docid": "DOCID", "sheet_id": "123Abc", "key_type": "CELL_VALUE_KEY_TYPE_FIELD_TITLE", "records": [ ] } =head4 å‚数说明: å‚æ•° 类型 是å¦å¿…é¡» 说明 access_token 是 调用接å£å‡è¯ docid string 是 文档的docid sheet_id string 是 Smartsheet å表ID key_type string(CellValueKeyType) å¦ è¿”å›žè®°å½•ä¸å•å…ƒæ ¼çš„key类型 records Object[](UpdateRecord) 是 由需è¦æ›´æ–°çš„记录组æˆçš„ JSON 数组 =head4 æƒé™è¯´æ˜Žï¼š 自建应用需é…置到“å¯è°ƒç”¨åº”用â€åˆ—表ä¸çš„应用secret所获å–çš„accesstokenæ¥è°ƒç”¨ï¼ˆaccesstoken如何获å–?) =head3 RETURN 返回结果: { "errcode": 0, "errmsg": "ok", "records": [ ] } =head4 RETURN å‚数说明: å‚æ•° 类型 说明 errcode int32 错误ç errmsg string 错误ç 说明 records Object[](CommonRecord) 由更新æˆåŠŸçš„记录的具体内容组æˆçš„ JSON 数组 =head4 å‚数详细说明 L<https://developer.work.weixin.qq.com/document/path/99909#å‚数详细说明> =cut sub update_records { if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { my $access_token = $_[0]; my $json = $_[1]; my $ua = LWP::UserAgent->new; $ua->timeout(30); $ua->env_proxy; 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'); if ($response->is_success) { return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); } } return 0; } =head1 FUNCTION 获å–æ™ºèƒ½è¡¨æ ¼æ•°æ® =head2 get_sheet(access_token, hash); 查询å表 最åŽæ›´æ–°ï¼š2024/06/13 =head2 SYNOPSIS L<https://developer.work.weixin.qq.com/document/path/99911> =head3 请求说明: 本接å£ç”¨äºŽæŸ¥è¯¢ä¸€ç¯‡åœ¨çº¿è¡¨æ ¼ä¸å…¨éƒ¨æ™ºèƒ½è¡¨ä¿¡æ¯ã€‚ =head4 请求包结构体为: { "docid": "DOCID", "sheet_id": "xxx" } =head4 å‚数说明: å‚æ•° 类型 是å¦å¿…é¡» 说明 access_token 是 调用接å£å‡è¯ docid string 是 文档的docid sheet_id string å¦ æŒ‡å®šå表ID查询 =head4 æƒé™è¯´æ˜Žï¼š 自建应用需é…置到“å¯è°ƒç”¨åº”用â€åˆ—表ä¸çš„应用secret所获å–çš„accesstokenæ¥è°ƒç”¨ï¼ˆaccesstoken如何获å–?) =head3 RETURN 返回结果: { "errcode": 0, "errmsg": "ok", "sheet_list": [ { "sheet_id": "123Abc", "title": "XXXX", "is_visible": true } ] } =head4 RETURN å‚数说明: å‚æ•° 类型 说明 errcode int32 错误ç errmsg string 错误ç 说明 sheet_list object[] æ™ºèƒ½è¡¨ä¿¡æ¯ sheet_list.sheet_id string å表id sheet_list.title string å表å称 sheet_list.is_visible bool å表是å¦å¯è§ =cut sub get_sheet { if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { my $access_token = $_[0]; my $json = $_[1]; my $ua = LWP::UserAgent->new; $ua->timeout(30); $ua->env_proxy; 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'); if ($response->is_success) { return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); } } return 0; } =head2 get_views(access_token, hash); 查询视图 最åŽæ›´æ–°ï¼š2024/05/30 =head2 SYNOPSIS L<https://developer.work.weixin.qq.com/document/path/99913> =head3 请求说明: 本接å£ç”¨äºŽèŽ·å– Smartsheet ä¸æŸä¸ªå表里全部视图信æ¯ã€‚ =head4 请求包结构体为: { "docid": "DOCID", "sheet_id": "ezPcdA", "view_ids": [ "vPpw9C", "vfM2tt" ], "offset": 0, "limit": 1 } =head4 å‚数说明: å‚æ•° 类型 是å¦å¿…é¡» 说明 access_token 是 调用接å£å‡è¯ docid string 是 文档的docid sheet_id string 是 Smartsheet å表ID view_ids string[] å¦ éœ€è¦æŸ¥è¯¢çš„视图 ID 数组 offset uint32 å¦ å移é‡ï¼Œåˆå§‹å€¼ä¸º 0 limit uint32 å¦ åˆ†é¡µå¤§å° , æ¯é¡µè¿”回多少æ¡æ•°æ®ï¼›å½“ä¸å¡«å†™è¯¥å‚数或将该å‚数设置为 0 时,如果总数大于 1000,一次性返回 1000 个视图,当总数å°äºŽ 1000 时,返回全部视图;limit 最大值为 1000 =head4 æƒé™è¯´æ˜Žï¼š 自建应用需é…置到“å¯è°ƒç”¨åº”用â€åˆ—表ä¸çš„应用secret所获å–çš„accesstokenæ¥è°ƒç”¨ï¼ˆaccesstoken如何获å–?) =head3 RETURN 返回结果: { "errcode": 0, "errmsg": "ok", "total": 2, "has_more": true, "next": 1, "views": [ ] } =head4 RETURN å‚数说明: å‚æ•° 类型 说明 errcode int32 错误ç errmsg string 错误ç 说明 total uint32 符åˆç›é€‰æ¡ä»¶çš„视图总数 has_more bool 是å¦è¿˜æœ‰æ›´å¤šé¡¹ next uint32 下次下一个æœç´¢ç»“果的åç§»é‡ views Object[](View) è§†å›¾æ•°æ® =head4 å‚数详细说明 L<https://developer.work.weixin.qq.com/document/path/99913#å‚数详细说明> =cut sub get_views { if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { my $access_token = $_[0]; my $json = $_[1]; my $ua = LWP::UserAgent->new; $ua->timeout(30); $ua->env_proxy; 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'); if ($response->is_success) { return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); } } return 0; } =head2 get_fields(access_token, hash); 查询å—段 最åŽæ›´æ–°ï¼š2024/05/30 =head2 SYNOPSIS L<https://developer.work.weixin.qq.com/document/path/99914> =head3 请求说明: 本接å£ç”¨äºŽèŽ·å–智能表ä¸æŸä¸ªå表下å—段信æ¯ï¼Œè¯¥æŽ¥å£å¯ä»¥å®Œæˆä¸‹é¢ä¸‰ç§åŠŸèƒ½ï¼šèŽ·å–全部å—段信æ¯ã€ä¾æ®å—段å获å–对应å—段ã€ä¾æ®å—段 ID 获å–对应å—段信æ¯ã€‚ =head4 请求包结构体为: { "docid": "DOCID", "sheet_id": "SHEETID", "offset": 0, "limit": 10 } =head4 å‚数说明: å‚æ•° 类型 是å¦å¿…é¡» 说明 access_token 是 调用接å£å‡è¯ docid string 是 文档的docid sheet_id string 是 è¡¨æ ¼ID view_id string å¦ è§†å›¾ ID field_ids string [] å¦ ç”±å—段 ID 组æˆçš„ JSON 数组 field_titles string [] å¦ ç”±å—æ®µæ ‡é¢˜ç»„æˆçš„ JSON 数组 offset int å¦ å移é‡ï¼Œåˆå§‹å€¼ä¸º 0 limit int å¦ åˆ†é¡µå¤§å° , æ¯é¡µè¿”回多少æ¡æ•°æ®ï¼›å½“ä¸å¡«å†™è¯¥å‚数或将该å‚数设置为 0 时,如果总数大于 1000,一次性返回 1000 个å—段,当总数å°äºŽ 1000 时,返回全部å—段;limit 最大值为 1000 =head4 æƒé™è¯´æ˜Žï¼š 自建应用需é…置到“å¯è°ƒç”¨åº”用â€åˆ—表ä¸çš„应用secret所获å–çš„accesstokenæ¥è°ƒç”¨ï¼ˆaccesstoken如何获å–?) =head3 RETURN 返回结果: { "errcode": 0, "errmsg": "ok", "total": 1, "fields": [{ "field_id": "ID1", "field_title": "TITLE1", "field_type": "FIELD_TYPE_TEXT" }] } =head4 RETURN å‚数说明: å‚æ•° 类型 说明 errcode int32 错误ç errmsg string 错误ç 说明 total Object å—段总数 fields object [](Field) å—段详情 =head4 å‚数详细说明 L<https://developer.work.weixin.qq.com/document/path/99914#å‚数详细说明> =cut sub get_fields { if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { my $access_token = $_[0]; my $json = $_[1]; my $ua = LWP::UserAgent->new; $ua->timeout(30); $ua->env_proxy; 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'); if ($response->is_success) { return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); } } return 0; } =head2 get_records(access_token, hash); 查询记录 最åŽæ›´æ–°ï¼š2024/05/30 =head2 SYNOPSIS L<https://developer.work.weixin.qq.com/document/path/99914> =head3 请求说明: 本接å£ç”¨äºŽèŽ·å– Smartsheet ä¸æŸä¸ªå表下记录信æ¯ï¼Œè¯¥æŽ¥å£å¯ä»¥å®Œæˆä¸‹é¢ä¸‰ç§åŠŸèƒ½ï¼šèŽ·å–全部记录信æ¯ã€ä¾æ®å—段å和记录 ID 获å–对应记录ã€å¯¹è®°å½•è¿›è¡ŒæŽ’åºã€‚ =head4 请求包结构体为: { "docid": "DOCID", "sheet_id": "123Abc", "view_id": "vCRl8n", "record_ids": [ ], "key_type": "CELL_VALUE_KEY_TYPE_FIELD_TITLE", "field_titles": [ ], "field_ids": [ ], "sort": [ ], "offset": 0, "limit": 100 } =head4 å‚数说明: å‚æ•° 类型 是å¦å¿…é¡» 说明 access_token 是 调用接å£å‡è¯ docid string 是 文档的docid sheet_id string 是 Smartsheet å表ID view_id string å¦ è§†å›¾ ID record_ids string[] å¦ ç”±è®°å½• ID 组æˆçš„ JSON 数组 key_type string(CellValueKeyType) å¦ è¿”å›žè®°å½•ä¸å•å…ƒæ ¼çš„key类型 field_titles string[] å¦ è¿”å›žæŒ‡å®šåˆ—ï¼Œç”±å—æ®µæ ‡é¢˜ç»„æˆçš„ JSON 数组 ,key_type 为 CELL_VALUE_KEY_TYPE_FIELD_TITLE 时有效 field_ids string[] å¦ è¿”å›žæŒ‡å®šåˆ—ï¼Œç”±å—段 ID 组æˆçš„ JSON 数组 ,key_type 为 CELL_VALUE_KEY_TYPE_FIELD_ID 时有效 sort Object[](Sort) å¦ å¯¹è¿”å›žè®°å½•è¿›è¡ŒæŽ’åº offset uint32 å¦ å移é‡ï¼Œåˆå§‹å€¼ä¸º 0 limit uint32 å¦ åˆ†é¡µå¤§å° , æ¯é¡µè¿”回多少æ¡æ•°æ®ï¼›å½“ä¸å¡«å†™è¯¥å‚数或将该å‚数设置为 0 时,如果总数大于 1000,一次性返回 1000 行记录,当总数å°äºŽ 1000 时,返回全部记录;limit 最大值为 1000 =head4 æƒé™è¯´æ˜Žï¼š 自建应用需é…置到“å¯è°ƒç”¨åº”用â€åˆ—表ä¸çš„应用secret所获å–çš„accesstokenæ¥è°ƒç”¨ï¼ˆaccesstoken如何获å–?) =head3 RETURN 返回结果: { "errcode": 0, "errmsg": "ok" } =head4 RETURN å‚数说明: å‚æ•° 类型 说明 errcode int32 错误ç errmsg string 错误ç 说明 total uint32 符åˆç›é€‰æ¡ä»¶çš„视图总数 has_more bool 是å¦è¿˜æœ‰æ›´å¤šé¡¹ next uint32 下次下一个æœç´¢ç»“果的åç§»é‡ records Object[](Record) 由查询记录的具体内容组æˆçš„ JSON 数组 =head4 å‚数详细说明 L<https://developer.work.weixin.qq.com/document/path/99915#å‚数详细说明> =cut sub get_records { if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) { my $access_token = $_[0]; my $json = $_[1]; my $ua = LWP::UserAgent->new; $ua->timeout(30); $ua->env_proxy; 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'); if ($response->is_success) { return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1}); } } return 0; } 1; __END__