-
Notifications
You must be signed in to change notification settings - Fork 45
/
query.go
30 lines (26 loc) · 886 Bytes
/
query.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package types
import (
"encoding/json"
)
// PostQueryResponse represents the data of a post that is returned to user upon a query
type PostQueryResponse struct {
Post
PollAnswers []UserAnswer `json:"poll_answers,omitempty" yaml:"poll_answers,omitempty"`
Reactions []PostReaction `json:"reactions" yaml:"reactions,omitempty"`
Children []string `json:"children" yaml:"children"`
}
func NewPostResponse(
post Post, pollAnswers []UserAnswer, reactions []PostReaction, children []string,
) PostQueryResponse {
return PostQueryResponse{
Post: post,
PollAnswers: pollAnswers,
Reactions: reactions,
Children: children,
}
}
// MarshalJSON implements json.Marshaler as Amino does not respect default json composition
func (response PostQueryResponse) MarshalJSON() ([]byte, error) {
type temp PostQueryResponse
return json.Marshal(temp(response))
}