location
pokelance.ext.location
⚓︎
Location(client)
⚓︎
Bases: BaseExtension
Extension for location related endpoints.
Attributes:
Name | Type | Description |
---|---|---|
cache |
Location
|
The cache for this extension. |
Initializes the extension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client |
HttpClient
|
The client to use for requests. |
required |
Source code in pokelance/ext/_base.py
Python | |
---|---|
fetch_location(name)
async
⚓︎
Fetches a location from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the location. |
required |
Returns:
Type | Description |
---|---|
Location
|
The location if it exists in the API, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the location is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... location = await client.location.fetch_location(1)
... print(location.name)
... await client.close()
>>> asyncio.run(main())
canalave-city
Source code in pokelance/ext/location.py
fetch_location_area(name)
async
⚓︎
Fetches a location area from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the location area. |
required |
Returns:
Type | Description |
---|---|
LocationArea
|
The location area if it exists in the API, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the location area is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... location_area = await client.location.fetch_location_area(1)
... print(location_area.name)
... await client.close()
>>> asyncio.run(main())
canalave-city-area
Source code in pokelance/ext/location.py
fetch_pal_park_area(name)
async
⚓︎
Fetches a pal park area from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the pal park area. |
required |
Returns:
Type | Description |
---|---|
PalParkArea
|
The pal park area if it exists in the API, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the pal park area is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... pal_park_area = await client.location.fetch_pal_park_area(1)
... print(pal_park_area.name)
... await client.close()
>>> asyncio.run(main())
forest
Source code in pokelance/ext/location.py
fetch_region(name)
async
⚓︎
Fetches a region from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the region. |
required |
Returns:
Type | Description |
---|---|
Region
|
The region if it exists in the API, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the region is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... region = await client.location.fetch_region(1)
... print(region.name)
... await client.close()
>>> asyncio.run(main())
kanto
Source code in pokelance/ext/location.py
get_location(name)
⚓︎
Gets a location from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the location. |
required |
Returns:
Type | Description |
---|---|
Optional[Location]
|
The location if it exists in the cache, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the item pocket is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> location = client.location.get_location(1)
>>> location.name
'canalave-city'
Source code in pokelance/ext/location.py
get_location_area(name)
⚓︎
Gets a location area from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the location area. |
required |
Returns:
Type | Description |
---|---|
Optional[LocationArea]
|
The location area if it exists in the cache, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the location area is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> location_area = client.location.get_location_area(1)
>>> location_area.name
'canalave-city-area'
Source code in pokelance/ext/location.py
get_message(case, data)
staticmethod
⚓︎
Gets the error message for a resource not found error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
case |
str
|
The case to use for the error message. |
required |
data |
Set[str]
|
The data to use for the error message. |
required |
Returns:
Type | Description |
---|---|
str
|
The error message. |
Source code in pokelance/ext/_base.py
get_pal_park_area(name)
⚓︎
Gets a pal park area from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the pal park area. |
required |
Returns:
Type | Description |
---|---|
Optional[PalParkArea]
|
The pal park area if it exists in the cache, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the pal park area is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> pal_park_area = client.location.get_pal_park_area(1)
>>> pal_park_area.name
'forest'
Source code in pokelance/ext/location.py
get_region(name)
⚓︎
Gets a region from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the region. |
required |
Returns:
Type | Description |
---|---|
Optional[Region]
|
The region if it exists in the cache, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the region is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> region = client.location.get_region(1)
>>> region.name
'kanto'
Source code in pokelance/ext/location.py
setup()
async
⚓︎
Sets up the extension.