MCPcopy Index your code
hub / github.com/dnote/dnote / UpdateBook

Function UpdateBook

pkg/cli/client/client.go:355–376  ·  view source on GitHub ↗

UpdateBook updates a book in the server

(ctx context.DnoteCtx, label, uuid string)

Source from the content-addressed store, hash-verified

353
354// UpdateBook updates a book in the server
355func UpdateBook(ctx context.DnoteCtx, label, uuid string) (UpdateBookResp, error) {
356 payload := updateBookPayload{
357 Name: &label,
358 }
359 b, err := json.Marshal(payload)
360 if err != nil {
361 return UpdateBookResp{}, errors.Wrap(err, "marshaling payload")
362 }
363
364 endpoint := fmt.Sprintf("/v3/books/%s", uuid)
365 res, err := doAuthorizedReq(ctx, "PATCH", endpoint, string(b), nil)
366 if err != nil {
367 return UpdateBookResp{}, errors.Wrap(err, "posting a book to the server")
368 }
369
370 var resp UpdateBookResp
371 if err := json.NewDecoder(res.Body).Decode(&resp); err != nil {
372 return resp, errors.Wrap(err, "decoding payload")
373 }
374
375 return resp, nil
376}
377
378// DeleteBookResp is the response from create book api
379type DeleteBookResp struct {

Callers 1

sendBooksFunction · 0.92

Calls 1

doAuthorizedReqFunction · 0.85

Tested by

no test coverage detected