-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathendpoints.go
48 lines (44 loc) · 1002 Bytes
/
endpoints.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
package go5e
import (
"errors"
)
const baseURL = "https://www.dnd5eapi.co/api/"
// Get all endpoints as a string slice
func Endpoints() []string {
return []string{
"ability-scores",
"classes",
"conditions",
"damage-types",
"equipment-categories",
"equipment",
"features",
"languages",
"magic-schools",
"monsters",
"proficiencies",
"races",
"skills",
"spellcasting",
"spells",
"starting-equipment",
"subclasses",
"subraces",
"traits",
"weapon-properties",
}
}
// Get the full list for an endpoint
func GetResourceList(endpoint string) (NamedAPIResourceList, error) {
var ret NamedAPIResourceList
if endpoint == "starting-equipment" {
// ಠ_ಠ
// The indices for this field are type int instead of string.
return ret, errors.New("Not implemented due to an API issue with indexing.")
} else if endpoint == "spellcasting" {
return ret, errors.New("Not implemented")
} else {
err := doRequestAndUnmarshal(endpoint, &ret)
return ret, err
}
}