/
species.go
141 lines (118 loc) · 3.59 KB
/
species.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package main
import (
"errors"
)
// Species represents the return content from the pokemon-species endpoint
type Species struct {
BaseHappiness int `json:"base_happiness"`
CaptureRate int `json:"capture_rate"`
Color color `json:"color"`
EggGroups []eggGroups `json:"egg_groups"`
EvolutionChain evolutionChain `json:"evolution_chain"`
EvolvesFromSpecies evolvesFromSpecies `json:"evolves_from_species"`
FlavorTextEntries flavorTextEntries `json:"flavor_text_entries"`
FormDescriptions []interface{} `json:"form_descriptions"`
FormsSwitchable bool `json:"forms_switchable"`
GenderRate int `json:"gender_rate"`
Genera []genera `json:"genera"`
Generation generation `json:"generation"`
GrowthRate growthRate `json:"growth_rate"`
Habitat habitat `json:"habitat"`
HasGenderDifferences bool `json:"has_gender_differences"`
HatchCounter int `json:"hatch_counter"`
ID int `json:"id"`
IsBaby bool `json:"is_baby"`
Name string `json:"name"`
Names []names `json:"names"`
Order int `json:"order"`
PalParkEncounters []palParkEncounters `json:"pal_park_encounters"`
PokedexNumbers []pokedexNumbers `json:"pokedex_numbers"`
Shape shape `json:"shape"`
Varieties []varieties `json:"varieties"`
}
type color struct {
Name string `json:"name"`
URL string `json:"url"`
}
type eggGroups struct {
Name string `json:"name"`
URL string `json:"url"`
}
type evolutionChain struct {
URL string `json:"url"`
}
type evolvesFromSpecies struct {
Name string `json:"name"`
URL string `json:"url"`
}
type language struct {
Name string `json:"name"`
URL string `json:"url"`
}
type version struct {
Name string `json:"name"`
URL string `json:"url"`
}
type flavorTextEntry struct {
FlavorText string `json:"flavor_text"`
Language language `json:"language"`
Version version `json:"version"`
}
type flavorTextEntries []flavorTextEntry
func (f flavorTextEntries) Select(l, v string) (flavorTextEntry, error) {
for _, i := range f {
if i.Language.Name == l && i.Version.Name == v {
return i, nil
}
}
return flavorTextEntry{}, errors.New("no results")
}
type genera struct {
Genus string `json:"genus"`
Language language `json:"language"`
}
type generation struct {
Name string `json:"name"`
URL string `json:"url"`
}
type growthRate struct {
Name string `json:"name"`
URL string `json:"url"`
}
type habitat struct {
Name string `json:"name"`
URL string `json:"url"`
}
type names struct {
Language language `json:"language"`
Name string `json:"name"`
}
type area struct {
Name string `json:"name"`
URL string `json:"url"`
}
type palParkEncounters struct {
Area area `json:"area"`
BaseScore int `json:"base_score"`
Rate int `json:"rate"`
}
type pokedex struct {
Name string `json:"name"`
URL string `json:"url"`
}
type pokedexNumbers struct {
EntryNumber int `json:"entry_number"`
Pokedex pokedex `json:"pokedex"`
}
type shape struct {
Name string `json:"name"`
URL string `json:"url"`
}
type pokemon struct {
Name string `json:"name"`
URL string `json:"url"`
}
type varieties struct {
IsDefault bool `json:"is_default"`
Pokemon pokemon `json:"pokemon"`
}