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

Function UpdateNote

pkg/cli/client/client.go:469–491  ·  view source on GitHub ↗

UpdateNote updates a note in the server

(ctx context.DnoteCtx, uuid, bookUUID, content string)

Source from the content-addressed store, hash-verified

467
468// UpdateNote updates a note in the server
469func UpdateNote(ctx context.DnoteCtx, uuid, bookUUID, content string) (UpdateNoteResp, error) {
470 payload := updateNotePayload{
471 BookUUID: &bookUUID,
472 Body: &content,
473 }
474 b, err := json.Marshal(payload)
475 if err != nil {
476 return UpdateNoteResp{}, errors.Wrap(err, "marshaling payload")
477 }
478
479 endpoint := fmt.Sprintf("/v3/notes/%s", uuid)
480 res, err := doAuthorizedReq(ctx, "PATCH", endpoint, string(b), nil)
481 if err != nil {
482 return UpdateNoteResp{}, errors.Wrap(err, "patching a note to the server")
483 }
484
485 var resp UpdateNoteResp
486 if err := json.NewDecoder(res.Body).Decode(&resp); err != nil {
487 return UpdateNoteResp{}, errors.Wrap(err, "decoding payload")
488 }
489
490 return resp, nil
491}
492
493// DeleteNoteResp is the response from remove note api
494type DeleteNoteResp struct {

Callers 1

sendNotesFunction · 0.92

Calls 1

doAuthorizedReqFunction · 0.85

Tested by

no test coverage detected