2015-07-06 12:24:35 -04:00
|
|
|
package jsonapi
|
|
|
|
|
2016-09-13 01:12:42 -04:00
|
|
|
const clientIDAnnotation = "client-id"
|
|
|
|
|
|
|
|
// OnePayload is used to represent a generic JSON API payload where a single
|
|
|
|
// resource (Node) was included as an {} in the "data" key
|
2015-07-10 12:07:12 -04:00
|
|
|
type OnePayload struct {
|
|
|
|
Data *Node `json:"data"`
|
|
|
|
Included []*Node `json:"included,omitempty"`
|
2015-07-06 14:57:20 -04:00
|
|
|
Links *map[string]string `json:"links,omitempty"`
|
2015-07-06 12:24:35 -04:00
|
|
|
}
|
|
|
|
|
2016-09-13 01:12:42 -04:00
|
|
|
// ManyPayload is used to represent a generic JSON API payload where many
|
|
|
|
// resources (Nodes) were included in an [] in the "data" key
|
2015-07-10 12:07:12 -04:00
|
|
|
type ManyPayload struct {
|
|
|
|
Data []*Node `json:"data"`
|
|
|
|
Included []*Node `json:"included,omitempty"`
|
2015-07-07 12:52:38 -04:00
|
|
|
Links *map[string]string `json:"links,omitempty"`
|
|
|
|
}
|
|
|
|
|
2016-09-13 01:12:42 -04:00
|
|
|
// Node is used to represent a generic JSON API Resource
|
2015-07-10 12:07:12 -04:00
|
|
|
type Node struct {
|
2015-07-06 12:24:35 -04:00
|
|
|
Type string `json:"type"`
|
2016-07-05 21:32:15 -04:00
|
|
|
ID string `json:"id"`
|
|
|
|
ClientID string `json:"client-id,omitempty"`
|
2015-07-06 12:24:35 -04:00
|
|
|
Attributes map[string]interface{} `json:"attributes,omitempty"`
|
2015-07-08 12:34:37 -04:00
|
|
|
Relationships map[string]interface{} `json:"relationships,omitempty"`
|
2015-07-06 12:24:35 -04:00
|
|
|
}
|
2015-07-06 20:04:26 -04:00
|
|
|
|
2016-09-13 01:12:42 -04:00
|
|
|
// RelationshipOneNode is used to represent a generic has one JSON API relation
|
2015-07-10 12:07:12 -04:00
|
|
|
type RelationshipOneNode struct {
|
|
|
|
Data *Node `json:"data"`
|
2015-07-06 20:04:26 -04:00
|
|
|
Links *map[string]string `json:"links,omitempty"`
|
|
|
|
}
|
|
|
|
|
2016-09-13 01:12:42 -04:00
|
|
|
// RelationshipManyNode is used to represent a generic has many JSON API
|
|
|
|
// relation
|
2015-07-10 12:07:12 -04:00
|
|
|
type RelationshipManyNode struct {
|
|
|
|
Data []*Node `json:"data"`
|
2015-07-06 20:04:26 -04:00
|
|
|
Links *map[string]string `json:"links,omitempty"`
|
|
|
|
}
|