@@ -5,6 +5,8 @@ import "fmt"
5
5
// Payloader is used to encapsulate the One and Many payload types
6
6
type Payloader interface {
7
7
clearIncluded ()
8
+ GetIncluded () []* Node
9
+ SetIncluded ([]* Node )
8
10
}
9
11
10
12
// OnePayload is used to represent a generic JSON API payload where a single
@@ -20,6 +22,16 @@ func (p *OnePayload) clearIncluded() {
20
22
p .Included = []* Node {}
21
23
}
22
24
25
+ //GetIncluded returns current included items
26
+ func (p * OnePayload ) GetIncluded () []* Node {
27
+ return p .Included
28
+ }
29
+
30
+ //SetIncluded updates included
31
+ func (p * OnePayload ) SetIncluded (newIncluded []* Node ) {
32
+ p .Included = newIncluded
33
+ }
34
+
23
35
// ManyPayload is used to represent a generic JSON API payload where many
24
36
// resources (Nodes) were included in an [] in the "data" key
25
37
type ManyPayload struct {
@@ -33,6 +45,16 @@ func (p *ManyPayload) clearIncluded() {
33
45
p .Included = []* Node {}
34
46
}
35
47
48
+ //SetIncluded updates included
49
+ func (p * ManyPayload ) SetIncluded (newIncluded []* Node ) {
50
+ p .Included = newIncluded
51
+ }
52
+
53
+ //GetIncluded returns current included items
54
+ func (p * ManyPayload ) GetIncluded () []* Node {
55
+ return p .Included
56
+ }
57
+
36
58
// Node is used to represent a generic JSON API Resource
37
59
type Node struct {
38
60
Type string `json:"type"`
@@ -46,15 +68,15 @@ type Node struct {
46
68
47
69
// RelationshipOneNode is used to represent a generic has one JSON API relation
48
70
type RelationshipOneNode struct {
49
- Data * Node `json:"data"`
71
+ Data * Node `json:"data,omitempty "`
50
72
Links * Links `json:"links,omitempty"`
51
73
Meta * Meta `json:"meta,omitempty"`
52
74
}
53
75
54
76
// RelationshipManyNode is used to represent a generic has many JSON API
55
77
// relation
56
78
type RelationshipManyNode struct {
57
- Data []* Node `json:"data"`
79
+ Data []* Node `json:"data,omitempty "`
58
80
Links * Links `json:"links,omitempty"`
59
81
Meta * Meta `json:"meta,omitempty"`
60
82
}
0 commit comments