1
+ // This package implements an http client for resource and pokemon APIs from pokeAPI
1
2
package pokemon
2
3
4
+ // Resource is the resources available for an endpoint
3
5
type Resource struct {
4
6
Count int `json:"count"`
5
7
Next string `json:"next"`
6
8
Previous string `json:"previous"`
7
9
Results []Result `json:"results"`
8
10
}
11
+
12
+ // Result is a single API resource
9
13
type Result struct {
10
14
Url string `json:"url"`
11
15
Name string `json:"name"`
12
16
}
13
17
18
+ // Pokemon holds a single pokemon data
14
19
type Pokemon struct {
15
20
ID int `json:"id"`
16
21
Name string `json:"name"`
@@ -32,72 +37,112 @@ type Pokemon struct {
32
37
Stats []PokemonStat `json:"stats"`
33
38
Types []PokemonType `json:"types"`
34
39
}
35
- type Ability struct {
36
- Name string `json:"name"`
37
- URL string `json:"url"`
38
- }
40
+
41
+ // PokemonAbility is a single pokemon ability
39
42
type PokemonAbility struct {
40
43
IsHidden bool `json:"is_hidden"`
41
44
Slot int `json:"slot"`
42
45
Ability Ability `json:"ability"`
43
46
}
44
- type Form struct {
47
+
48
+ // Ability is an API resource
49
+ type Ability struct {
45
50
Name string `json:"name"`
46
51
URL string `json:"url"`
47
52
}
48
- type Version struct {
53
+
54
+ // Form is a named API resource
55
+ type Form struct {
49
56
Name string `json:"name"`
50
57
URL string `json:"url"`
51
58
}
59
+
60
+ // GameIndex is a single game index
52
61
type GameIndex struct {
53
62
GameIndex int `json:"game_index"`
54
63
Version Version `json:"version"`
55
64
}
65
+
66
+ // Version is a named API resource
67
+ type Version struct {
68
+ Name string `json:"name"`
69
+ URL string `json:"url"`
70
+ }
71
+
72
+ // Item is a named API resource
73
+ type Item struct {
74
+ Name string `json:"name"`
75
+ URL string `json:"url"`
76
+ }
77
+
78
+ // PokemonHeldItem is a single Pokemon item
56
79
type PokemonHeldItem struct {
57
80
Item Item `json:"item"`
58
81
VersionDetails PokemonHeldItemVersion `json:"version_details"`
59
82
}
83
+
84
+ // PokemonHeldItemVersion hold the information about the held item version
60
85
type PokemonHeldItemVersion struct {
61
86
Version Version `json:"version"`
62
87
Rarity int `json:"rarity"`
63
88
}
64
- type Move struct {
65
- Name string `json:"name"`
66
- URL string `json:"url"`
67
- }
68
- type Item struct {
69
- Name string `json:"name"`
70
- URL string `json:"url"`
71
- }
89
+
90
+ // MoveLearnMethod is a named API resource
72
91
type MoveLearnMethod struct {
73
92
Name string `json:"name"`
74
93
URL string `json:"url"`
75
94
}
95
+
96
+ // VersionGroup is a named API resource
76
97
type VersionGroup struct {
77
98
Name string `json:"name"`
78
99
URL string `json:"url"`
79
100
}
101
+
102
+ // PokemonMoveVersion holds the details about the pokemon move versions
80
103
type PokemonMoveVersion struct {
81
104
MoveLearnMethod MoveLearnMethod `json:"move_learn_method"`
82
105
VersionGroup VersionGroup `json:"version_group"`
83
106
LevelLearnedAt int `json:"level_learned_at"`
84
107
}
108
+
109
+ // Move is a named API resource
110
+ type Move struct {
111
+ Name string `json:"name"`
112
+ URL string `json:"url"`
113
+ }
114
+
115
+ // PokemonMove is a single pokemon move
85
116
type PokemonMove struct {
86
117
Move Move `json:"move"`
87
118
VersionGroupDetails []PokemonMoveVersion `json:"version_group_details"`
88
119
}
120
+
121
+ // Type is a named API resource
122
+ type Type struct {
123
+ Name string `json:"name"`
124
+ URL string `json:"url"`
125
+ }
126
+
127
+ // PokemonType is a single pokemon type
128
+ type PokemonType struct {
129
+ Slot int `json:"slot"`
130
+ Type Type `json:"type"`
131
+ }
132
+
133
+ // Generation is a named API resource
89
134
type Generation struct {
90
135
Name string `json:"name"`
91
136
URL string `json:"url"`
92
137
}
138
+
139
+ // PokemonTypePast is a single pokemon past type
93
140
type PokemonTypePast struct {
94
141
Generation Generation `json:"generation"`
95
142
Types []PokemonType `json:"types"`
96
143
}
97
- type Species struct {
98
- Name string `json:"name"`
99
- URL string `json:"url"`
100
- }
144
+
145
+ // PokemonSprites holds the details about single pokemon sprites
101
146
type PokemonSprites struct {
102
147
FrontDefault string `json:"front_default"`
103
148
FrontShiny string `json:"front_shiny"`
@@ -108,24 +153,28 @@ type PokemonSprites struct {
108
153
BackFemale string `json:"back_female"`
109
154
BackShinyFemale string `json:"back_shiny_female"`
110
155
}
156
+
157
+ // PokemonCries holds the details about single pokemon cries
158
+ type PokemonCries struct {
159
+ Latest string `json:"latest"`
160
+ Legacy string `json:"legacy"`
161
+ }
162
+
163
+ // Species is a named API resource
164
+ type Species struct {
165
+ Name string `json:"name"`
166
+ URL string `json:"url"`
167
+ }
168
+
169
+ // Stat is a named API resource
111
170
type Stat struct {
112
171
Name string `json:"name"`
113
172
URL string `json:"url"`
114
173
}
174
+
175
+ // PokemonStat holds the details about single pokemon stats
115
176
type PokemonStat struct {
116
177
Stat Stat `json:"stat"`
117
178
BaseStat int `json:"base_stat"`
118
179
Effort int `json:"effort"`
119
180
}
120
- type Type struct {
121
- Name string `json:"name"`
122
- URL string `json:"url"`
123
- }
124
- type PokemonType struct {
125
- Slot int `json:"slot"`
126
- Type Type `json:"type"`
127
- }
128
- type PokemonCries struct {
129
- Latest string `json:"latest"`
130
- Legacy string `json:"legacy"`
131
- }
0 commit comments