UpdateNote updates a note in the server
(ctx context.DnoteCtx, uuid, bookUUID, content string)
| 467 | |
| 468 | // UpdateNote updates a note in the server |
| 469 | func 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 |
| 494 | type DeleteNoteResp struct { |
no test coverage detected