Fix Notes API parameter format for Create and Update
The Checkvist API expects nested JSON parameters in the format
{"comment": {"comment": "text"}} but the code was sending flat
{"comment": "text"}, causing 400 Bad Request errors.
Changes:
- Add noteCommentWrapper struct for nested JSON format
- Update createNoteRequest and updateNoteRequest to use wrapper
- Update Create and Update methods to use nested structure
- Update tests to verify nested format
Fixes: checkvist-api-awg
This commit is contained in:
parent
9145157ba7
commit
c95825dc88
3 changed files with 17 additions and 11 deletions
|
|
@ -63,14 +63,14 @@ func TestNotes_Create(t *testing.T) {
|
|||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
t.Fatalf("failed to decode request: %v", err)
|
||||
}
|
||||
if req.Comment != "New note content" {
|
||||
t.Errorf("expected comment 'New note content', got %s", req.Comment)
|
||||
if req.Comment.Comment != "New note content" {
|
||||
t.Errorf("expected comment 'New note content', got %s", req.Comment.Comment)
|
||||
}
|
||||
|
||||
response := Note{
|
||||
ID: 600,
|
||||
TaskID: 101,
|
||||
Comment: req.Comment,
|
||||
Comment: req.Comment.Comment,
|
||||
CreatedAt: NewAPITime(time.Now()),
|
||||
UpdatedAt: NewAPITime(time.Now()),
|
||||
}
|
||||
|
|
@ -111,14 +111,14 @@ func TestNotes_Update(t *testing.T) {
|
|||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
t.Fatalf("failed to decode request: %v", err)
|
||||
}
|
||||
if req.Comment != "Updated comment" {
|
||||
t.Errorf("expected comment 'Updated comment', got %s", req.Comment)
|
||||
if req.Comment.Comment != "Updated comment" {
|
||||
t.Errorf("expected comment 'Updated comment', got %s", req.Comment.Comment)
|
||||
}
|
||||
|
||||
response := Note{
|
||||
ID: 501,
|
||||
TaskID: 101,
|
||||
Comment: req.Comment,
|
||||
Comment: req.Comment.Comment,
|
||||
UpdatedAt: NewAPITime(time.Now()),
|
||||
}
|
||||
json.NewEncoder(w).Encode(response)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue