feat: implemented explore command
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user