-
Notifications
You must be signed in to change notification settings - Fork 0
/
card-pools.go
41 lines (33 loc) · 969 Bytes
/
card-pools.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
package nrdb
import (
"fmt"
"time"
)
type CardPool struct {
Document[CardPoolAttributes, CardPoolRelationships]
}
type CardPoolAttributes struct {
Name string `json:"name"`
CardCycleIDs []string `json:"card_cycles_ids"`
CardSetIDs []string `json:"card_set_ids"`
CardIDs []string `json:"card_ids"`
NumCards int `json:"num_cards"`
UpdatedAt time.Time `json:"updated_at"`
}
type CardPoolRelationships struct {
CardCycles *Relationship `json:"card_cycles"`
CardSets *Relationship `json:"card_sets"`
Cards *Relationship `json:"cards"`
Format *Relationship `json:"format"`
Snapshots *Relationship `json:"snapshots"`
}
func (doc CardPool) String() string {
return fmt.Sprintf("%s (%s)", doc.Attributes.Name, doc.ID)
}
func (cl client) CardPools() ([]*CardPool, error) {
var res Response[[]*CardPool]
if err := cl.nrdbReq("card_pools", &res, nil); err != nil {
return nil, err
}
return res.Data, nil
}