forked from mfcochauxlaberge/jsonapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathidentifiers.go
More file actions
44 lines (33 loc) · 699 Bytes
/
identifiers.go
File metadata and controls
44 lines (33 loc) · 699 Bytes
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package jsonapi
import "encoding/json"
// NewIdentifiers ...
func NewIdentifiers(t string, ids []string) Identifiers {
identifiers := []Identifier{}
for _, id := range ids {
identifiers = append(identifiers, Identifier{
Type: t,
ID: id,
})
}
return identifiers
}
// Identifiers ...
type Identifiers []Identifier
// IDs ...
func (i Identifiers) IDs() []string {
ids := []string{}
for _, id := range i {
ids = append(ids, id.ID)
}
return ids
}
// Identifier ...
type Identifier struct {
ID string `json:"id"`
Type string `json:"type"`
}
// MarshalIdentifiers ...
func MarshalIdentifiers(ids []string, toOne bool) json.RawMessage {
raw := ""
return []byte(raw)
}