feat(bookstack-api-d2c): implement Pages Create and Update

Add PageCreateRequest and PageUpdateRequest types. Implement Create()
and Update() on PagesService with proper error handling. Add tests
including bad request validation.
This commit is contained in:
Oliver Jakoubek 2026-01-30 09:53:44 +01:00
commit 970699afe2
5 changed files with 111 additions and 5 deletions

View file

@ -36,6 +36,26 @@ func (s *PagesService) Get(ctx context.Context, id int) (*Page, error) {
return &page, nil
}
// Create creates a new page.
func (s *PagesService) Create(ctx context.Context, req *PageCreateRequest) (*Page, error) {
var page Page
err := s.client.do(ctx, "POST", "/api/pages", req, &page)
if err != nil {
return nil, err
}
return &page, nil
}
// Update updates an existing page.
func (s *PagesService) Update(ctx context.Context, id int, req *PageUpdateRequest) (*Page, error) {
var page Page
err := s.client.do(ctx, "PUT", fmt.Sprintf("/api/pages/%d", id), req, &page)
if err != nil {
return nil, err
}
return &page, nil
}
// ExportMarkdown exports a page as markdown.
func (s *PagesService) ExportMarkdown(ctx context.Context, id int) ([]byte, error) {
return s.client.doRaw(ctx, "GET", fmt.Sprintf("/api/pages/%d/export/markdown", id))