FetchDriveMeta looks up document metadata via the drive metas batch_query API.
(runtime *RuntimeContext, token, docType string, withURL bool)
| 11 | |
| 12 | // FetchDriveMeta looks up document metadata via the drive metas batch_query API. |
| 13 | func 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. |
| 48 | func FetchDriveMetaTitle(runtime *RuntimeContext, token, docType string) (string, error) { |
no test coverage detected