From 3a58a3817e34d788b8378f0014e3ce374d9c1d41 Mon Sep 17 00:00:00 2001 From: James Houlahan Date: Sun, 26 Feb 2023 16:27:54 +0100 Subject: [PATCH] feat: ListChildren ShowAll query parameter --- boolean.go | 16 ++++++++++++++++ link_folder.go | 3 ++- link_types.go | 11 +++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/boolean.go b/boolean.go index 0f15f6d..c4cb5c8 100644 --- a/boolean.go +++ b/boolean.go @@ -36,3 +36,19 @@ func (b Bool) MarshalJSON() ([]byte, error) { return json.Marshal(v) } + +func (b Bool) String() string { + if b { + return "true" + } + + return "false" +} + +func (b Bool) FormatURL() string { + if b { + return "1" + } + + return "0" +} diff --git a/link_folder.go b/link_folder.go index 5a17a8b..dc0da9b 100644 --- a/link_folder.go +++ b/link_folder.go @@ -9,7 +9,7 @@ import ( "github.com/go-resty/resty/v2" ) -func (c *Client) ListChildren(ctx context.Context, shareID, linkID string) ([]Link, error) { +func (c *Client) ListChildren(ctx context.Context, shareID, linkID string, all bool) ([]Link, error) { var res struct { Links []Link } @@ -22,6 +22,7 @@ func (c *Client) ListChildren(ctx context.Context, shareID, linkID string) ([]Li SetQueryParams(map[string]string{ "Page": strconv.Itoa(page), "PageSize": strconv.Itoa(maxPageSize), + "ShowAll": Bool(all).FormatURL(), }). SetResult(&res). Get("/drive/shares/" + shareID + "/folders/" + linkID + "/children") diff --git a/link_types.go b/link_types.go index f50c107..387f240 100644 --- a/link_types.go +++ b/link_types.go @@ -21,6 +21,7 @@ type Link struct { Name string // Encrypted file name Hash string // HMAC of name encrypted with parent hash key Size int64 + State LinkState MIMEType string CreateTime int64 // Link creation time @@ -35,6 +36,16 @@ type Link struct { FolderProperties *FolderProperties } +type LinkState int + +const ( + LinkStateDraft LinkState = iota + LinkStateActive + LinkStateTrashed + LinkStateDeleted + LinkStateRestoring +) + func (l Link) GetName(parentNodeKR, addrKR *crypto.KeyRing) (string, error) { encName, err := crypto.NewPGPMessageFromArmored(l.Name) if err != nil {