feat: Add FromBlockIndex/PageSize to GetRevision

This commit is contained in:
James Houlahan
2023-02-25 13:48:42 +01:00
committed by James
parent f7d9b1a479
commit 5ff1e40eaf

View File

@@ -2,6 +2,8 @@ package proton
import ( import (
"context" "context"
"fmt"
"strconv"
"github.com/go-resty/resty/v2" "github.com/go-resty/resty/v2"
) )
@@ -20,13 +22,25 @@ func (c *Client) ListRevisions(ctx context.Context, shareID, linkID string) ([]R
return res.Revisions, nil return res.Revisions, nil
} }
func (c *Client) GetRevision(ctx context.Context, shareID, linkID, revisionID string) (Revision, error) { func (c *Client) GetRevision(ctx context.Context, shareID, linkID, revisionID string, fromBlock, pageSize int) (Revision, error) {
if fromBlock < 1 {
return Revision{}, fmt.Errorf("fromBlock must be greater than 0")
} else if pageSize < 1 {
return Revision{}, fmt.Errorf("pageSize must be greater than 0")
}
var res struct { var res struct {
Revision Revision Revision Revision
} }
if err := c.do(ctx, func(r *resty.Request) (*resty.Response, error) { if err := c.do(ctx, func(r *resty.Request) (*resty.Response, error) {
return r.SetResult(&res).Get("/drive/shares/" + shareID + "/files/" + linkID + "/revisions/" + revisionID) return r.
SetQueryParams(map[string]string{
"FromBlockIndex": strconv.Itoa(fromBlock),
"PageSize": strconv.Itoa(pageSize),
}).
SetResult(&res).
Get("/drive/shares/" + shareID + "/files/" + linkID + "/revisions/" + revisionID)
}); err != nil { }); err != nil {
return Revision{}, err return Revision{}, err
} }