-
Notifications
You must be signed in to change notification settings - Fork 2
/
voice_actor.go
90 lines (75 loc) · 2.08 KB
/
voice_actor.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package wanikaniapi
import (
"strconv"
)
//////////////////////////////////////////////////////////////////////////////
//
//
//
// Exported functions
//
//
//
//////////////////////////////////////////////////////////////////////////////
// VoiceActorGet retrieves a specific voice_actor by its ID.
func (c *Client) VoiceActorGet(params *VoiceActorGetParams) (*VoiceActor, error) {
obj := &VoiceActor{}
err := c.request("GET", "/v2/voice_actors/"+strconv.Itoa(int(*params.ID)), params, nil, obj)
return obj, err
}
// VoiceActorList returns a collection of all voice actors, ordered by
// ascending CreatedAt, 500 at a time.
func (c *Client) VoiceActorList(params *VoiceActorListParams) (*VoiceActorPage, error) {
obj := &VoiceActorPage{}
err := c.request("GET", "/v2/voice_actors", params, nil, obj)
return obj, err
}
//////////////////////////////////////////////////////////////////////////////
//
//
//
// Exported constants/types
//
//
//
//////////////////////////////////////////////////////////////////////////////
// VoiceActor represents a voice actor used for vocabulary reading
// pronunciation audio.
type VoiceActor struct {
Object
Data *VoiceActorData `json:"data"`
}
// VoiceActorData contains core data of VoiceActor.
type VoiceActorData struct {
Description string `json:"description"`
Gender string `json:"gender"`
Name string `json:"name"`
}
// VoiceActorGetParams are parameters for VoiceActorGet.
type VoiceActorGetParams struct {
Params
ID *WKID
}
// VoiceActorListParams are parameters for VoiceActorList.
type VoiceActorListParams struct {
ListParams
Params
IDs []WKID
UpdatedAfter *WKTime
}
// EncodeToQuery encodes parametes to a query string.
func (p *VoiceActorListParams) EncodeToQuery() string {
values := p.encodeToURLValues()
if p.IDs != nil {
values.Add("ids", joinIDs(p.IDs, ","))
}
if p.UpdatedAfter != nil {
values.Add("updated_after", p.UpdatedAfter.Encode())
}
return values.Encode()
}
// VoiceActorPage represents a single page of VoiceActors.
type VoiceActorPage struct {
PageObject
Data []*VoiceActor `json:"data"`
}