MCPcopy
hub / github.com/larksuite/cli / FetchDriveMeta

Function FetchDriveMeta

shortcuts/common/drive_meta.go:13–45  ·  view source on GitHub ↗

FetchDriveMeta looks up document metadata via the drive metas batch_query API.

(runtime *RuntimeContext, token, docType string, withURL bool)

Source from the content-addressed store, hash-verified

11
12// FetchDriveMeta looks up document metadata via the drive metas batch_query API.
13func FetchDriveMeta(runtime *RuntimeContext, token, docType string, withURL bool) (DriveMeta, error) {
14 body := map[string]interface{}{
15 "request_docs": []map[string]interface{}{
16 {
17 "doc_token": token,
18 "doc_type": docType,
19 },
20 },
21 }
22 if withURL {
23 body["with_url"] = true
24 }
25
26 data, err := runtime.CallAPITyped(
27 "POST",
28 "/open-apis/drive/v1/metas/batch_query",
29 nil,
30 body,
31 )
32 if err != nil {
33 return DriveMeta{}, err
34 }
35
36 metas := GetSlice(data, "metas")
37 if len(metas) == 0 {
38 return DriveMeta{}, nil
39 }
40 meta, _ := metas[0].(map[string]interface{})
41 return DriveMeta{
42 Title: GetString(meta, "title"),
43 URL: GetString(meta, "url"),
44 }, nil
45}
46
47// FetchDriveMetaTitle looks up the document title via the drive metas batch_query API.
48func FetchDriveMetaTitle(runtime *RuntimeContext, token, docType string) (string, error) {

Callers 3

FetchDriveMetaTitleFunction · 0.85
FetchDriveMetaURLFunction · 0.85

Calls 3

GetSliceFunction · 0.85
GetStringFunction · 0.85
CallAPITypedMethod · 0.80

Tested by

no test coverage detected