CreateNote creates a note in the server
(ctx context.DnoteCtx, bookUUID, content string)
| 432 | |
| 433 | // CreateNote creates a note in the server |
| 434 | func 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 | |
| 457 | type updateNotePayload struct { |
| 458 | BookUUID *string `json:"book_uuid"` |
no test coverage detected