Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for Create/Delete file revisions #161

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions link_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,23 @@ func (c *Client) UpdateRevision(ctx context.Context, shareID, linkID, revisionID
return r.SetBody(req).Put("/drive/shares/" + shareID + "/files/" + linkID + "/revisions/" + revisionID)
})
}

func (c *Client) DeleteRevision(ctx context.Context, shareID, linkID, revisionID string) error {
return c.do(ctx, func(r *resty.Request) (*resty.Response, error) {
return r.Delete("/drive/shares/" + shareID + "/files/" + linkID + "/revisions/" + revisionID)
})
}

func (c *Client) CreateRevision(ctx context.Context, shareID, linkID string) (CreateRevisionRes, error) {
var res struct {
Revision CreateRevisionRes
}

if err := c.do(ctx, func(r *resty.Request) (*resty.Response, error) {
return r.SetResult(&res).Post("/drive/shares/" + shareID + "/files/" + linkID + "/revisions")
}); err != nil {
return CreateRevisionRes{}, err
}

return res.Revision, nil
}
4 changes: 4 additions & 0 deletions link_file_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ type CreateFileRes struct {
RevisionID string // Encrypted Revision ID
}

type CreateRevisionRes struct {
ID string // Encrypted Revision ID
}

type UpdateRevisionReq struct {
BlockList []BlockToken
State RevisionState
Expand Down