-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcards.go
50 lines (40 loc) · 880 Bytes
/
cards.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
package anki
func (c *Client) FindCards(query string) ([]int, error) {
var cardIds []int
if err := c.sendRequest(ankiRequest{
Action: "findCards",
Version: c.minVersion,
Params: map[string]interface{}{
"query": query,
},
}, &cardIds); err != nil {
return nil, err
}
return cardIds, nil
}
func (c *Client) Suspended(cardId int) (bool, error) {
var res bool
if err := c.sendRequest(ankiRequest{
Action: "suspended",
Version: c.minVersion,
Params: map[string]interface{}{
"cardId": cardId,
},
}, &res); err != nil {
return false, err
}
return res, nil
}
func (c *Client) Suspend(cardIds []int) (bool, error) {
var res bool
if err := c.sendRequest(ankiRequest{
Action: "suspend",
Version: c.minVersion,
Params: map[string]interface{}{
"cards": cardIds,
},
}, &res); err != nil {
return false, err
}
return res, nil
}