-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubrace.go
39 lines (35 loc) · 1.45 KB
/
subrace.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
package go5e
type Subrace struct {
Id string `json:"_id"`
Index string `json:"index"`
Name string `json:"name"`
Race NamedAPIResource `json:"race"`
Desc string `json:"desc"`
AbilityBonuses []NamedAPIResource `json:"ability_bonuses"`
StartingProficiencies []NamedAPIResource `json:"starting_proficiencies"`
StartingProficiencyOptions NamedChoice `json:"starting_proficiency_options"`
Languages []NamedAPIResource `json:"languages"`
LanguageDesc string `json:"language_desc"`
LanguageOptions NamedChoice `json:"language_options"`
RacialTraits []NamedAPIResource `json:"racial_traits"`
RacialTraitOptions NamedChoice `json:"racial_trait_options"`
Url string `json:"url"`
}
func GetSubrace(index string) (Subrace, error) {
var ret Subrace
err := doRequestAndUnmarshal("subraces/"+index, &ret)
if err != nil {
return ret, err
}
return ret, nil
}
func GetSubraceByUrl(url string) (Subrace, error) {
var ret Subrace
err := doRequestRawAndUnmarshal(url, ret)
return ret, err
}
func SearchSubraceByName(query string) (NamedAPIResourceList, error) {
var ret NamedAPIResourceList
err := doRequestAndUnmarshal("subraces/?name="+query, &ret)
return ret, err
}