-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes_test.go
52 lines (40 loc) · 1.02 KB
/
types_test.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2020 Pieoneers Software Incorporated. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package client_test
import (
"github.com/pieoneers/jsonapi-go"
)
type Book struct {
ID string `json:"-"`
Title string `json:"title"`
Year string `json:"year"`
ValidationErrors []*jsonapi.ErrorObject `json:"-"`
}
func (b Book) GetID() string {
return b.ID
}
func (b Book) GetType() string {
return "books"
}
func (b Book) SetType(string) error {
return nil
}
func (b Book) GetData() interface{} {
return b
}
func (b *Book) SetID(id string) error {
b.ID = id
return nil
}
func (b *Book) SetData(to func(target interface{}) error) error {
return to(b)
}
func (b *Book) SetErrors(errors []*jsonapi.ErrorObject) error {
b.ValidationErrors = errors
return nil
}
type Books []Book
func (b *Books) SetData(to func(target interface{}) error) error {
return to(b)
}