-
Notifications
You must be signed in to change notification settings - Fork 0
/
illustrators.go
58 lines (45 loc) · 1.15 KB
/
illustrators.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
53
54
55
56
57
58
package nrdb
import (
"fmt"
"time"
)
func (cl client) Illustrator(illustratorID string) (*Illustrator, error) {
var res Response[Illustrator]
if err := cl.nrdbReq(fmt.Sprintf("illustrators/%s", illustratorID), &res, nil); err != nil {
return nil, err
}
return &res.Data, nil
}
func (cl client) Illustrators() ([]*Illustrator, error) {
var res Response[[]*Illustrator]
if err := cl.nrdbReq("illustrators", &res, nil); err != nil {
return nil, err
}
return res.Data, nil
}
type Illustrator struct {
Document[IllustratorAttributes, IllustratorRelationships]
}
func (doc Illustrator) String() string {
return fmt.Sprintf("%s (%s)", doc.Attributes.Name, doc.ID)
}
func (doc Illustrator) Name() string {
if doc.Attributes == nil {
return ""
}
return doc.Attributes.Name
}
func (doc Illustrator) NumPrintings() int {
if doc.Attributes == nil {
return 0
}
return doc.Attributes.NumPrintings
}
type IllustratorAttributes struct {
Name string `json:"name"`
NumPrintings int `json:"num_printings"`
UpdatedAt time.Time `json:"updated_at"`
}
type IllustratorRelationships struct {
Printings *Relationship `json:"printings"`
}