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

Function CreateNote

pkg/cli/client/client.go:434–455  ·  view source on GitHub ↗

CreateNote creates a note in the server

(ctx context.DnoteCtx, bookUUID, content string)

Source from the content-addressed store, hash-verified

432
433// CreateNote creates a note in the server
434func CreateNote(ctx context.DnoteCtx, bookUUID, content string) (CreateNoteResp, error) {
435 payload := CreateNotePayload{
436 BookUUID: bookUUID,
437 Body: content,
438 }
439 b, err := json.Marshal(payload)
440 if err != nil {
441 return CreateNoteResp{}, errors.Wrap(err, "marshaling payload")
442 }
443
444 res, err := doAuthorizedReq(ctx, "POST", "/v3/notes", string(b), nil)
445 if err != nil {
446 return CreateNoteResp{}, errors.Wrap(err, "posting a book to the server")
447 }
448
449 var resp CreateNoteResp
450 if err := json.NewDecoder(res.Body).Decode(&resp); err != nil {
451 return CreateNoteResp{}, errors.Wrap(err, "decoding payload")
452 }
453
454 return resp, nil
455}
456
457type updateNotePayload struct {
458 BookUUID *string `json:"book_uuid"`

Callers 1

sendNotesFunction · 0.92

Calls 1

doAuthorizedReqFunction · 0.85

Tested by

no test coverage detected