feat: implemented explore command

This commit is contained in:
Stevan Freeborn
2026-07-28 08:18:48 -05:00
parent 68b34ec28f
commit 017ac7a7bb
3 changed files with 64 additions and 5 deletions
+32 -1
View File
@@ -160,12 +160,43 @@ type Location struct {
Url string `json:"url"`
}
type Pokemon struct {
Name string `json:"name"`
}
type PokemonEncounter struct {
Pokemon Pokemon `json:"pokemon"`
}
type LocationArea struct {
PokemonEncounters []PokemonEncounter `json:"pokemon_encounters"`
}
type locationsEndpoint struct {
path string
client *Client
}
func (le *locationsEndpoint) Get(offset int) (Page[Location], error) {
func (le *locationsEndpoint) Get(name string) (LocationArea, error) {
var area LocationArea
requestUrl := fmt.Sprintf("%s/%s", le.path, name)
req, err := le.client.NewRequest(http.MethodGet, requestUrl, map[string]string{}, nil)
if err != nil {
return area, err
}
err = le.client.doWithJsonResponse(req, &area)
if err != nil {
return area, err
}
return area, nil
}
func (le *locationsEndpoint) List(offset int) (Page[Location], error) {
const limit int = 20
var page Page[Location]