Skip to content

Commit 77418d4

Browse files
committed
Fix: Comment sideload has a different format from the main entity
The response from direct requests to `v3/comments.json` and sideloads are different. This requires different types for each scenario.
1 parent 81d7ce8 commit 77418d4

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

projects/comment.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,29 @@ type Comment struct {
8383
DeletedAt *time.Time `json:"dateDeleted"`
8484
}
8585

86+
// CommentSideload contains minimal information about a comment, used for
87+
// sideloading in other API responses.
88+
type CommentSideload struct {
89+
// ID is the unique identifier of the comment.
90+
ID int64 `json:"id"`
91+
92+
// Body is the body of the comment.
93+
Body string `json:"title"`
94+
95+
// Object is the relationship to the object (task, milestone, project) that
96+
// this comment is associated with.
97+
Object twapi.Relationship `json:"object"`
98+
99+
// Project is the relationship to the project that this comment belongs to.
100+
Project twapi.Relationship `json:"project"`
101+
102+
// PostedBy is the ID of the user who posted the comment.
103+
PostedBy *twapi.Relationship `json:"postedBy"`
104+
105+
// PostedAt is the date and time when the comment was posted.
106+
PostedAt *time.Time `json:"postedDateTime"`
107+
}
108+
86109
// CommentUpdateRequestPath contains the path parameters for creating a
87110
// comment.
88111
type CommentCreateRequestPath struct {

projects/search.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ type SearchResponse struct {
220220
// Comments contains the comments associated with the search results.
221221
//
222222
// The key is the string representation of the comment ID.
223-
Comments map[string]Comment `json:"comments,omitempty"`
223+
Comments map[string]CommentSideload `json:"comments,omitempty"`
224224
// Companies contains the companies associated with the search results.
225225
//
226226
// The key is the string representation of the company ID.

0 commit comments

Comments
 (0)