berry
pokelance.ext.berry
⚓︎
Berry(client)
⚓︎
Bases: BaseExtension
Extension for berry related endpoints.
Attributes:
Name | Type | Description |
---|---|---|
cache |
Berry
|
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_berry(name)
async
⚓︎
Fetches a berry from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the berry. |
required |
Returns:
Type | Description |
---|---|
Berry
|
The berry if it exists in the API, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the berry is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... berry = await client.berry.fetch_berry("cheri")
... print(berry.name)
... await client.close()
>>> asyncio.run(main())
'cheri'
Source code in pokelance/ext/berry.py
fetch_berry_firmness(name)
async
⚓︎
Fetches a berry firmness from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the berry firmness. |
required |
Returns:
Type | Description |
---|---|
BerryFirmness
|
The berry firmness if it exists in the API, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the berry firmness is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... berry_firmness = await client.berry.fetch_berry_firmness("very-soft")
... print(berry_firmness.name)
... await client.close()
>>> asyncio.run(main())
'very-soft'
Source code in pokelance/ext/berry.py
fetch_berry_flavor(name)
async
⚓︎
Fetches a berry flavor from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the berry flavor. |
required |
Returns:
Type | Description |
---|---|
BerryFlavor
|
The berry flavor if it exists in the API, else raises ResourceNotFound. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the berry flavor is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... berry_flavor = await client.berry.fetch_berry_flavor("spicy")
... print(berry_flavor.name)
... await client.close()
>>> asyncio.run(main())
'spicy'
Source code in pokelance/ext/berry.py
get_berry(name)
⚓︎
Gets a berry from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the berry. |
required |
Returns:
Type | Description |
---|---|
Optional[Berry]
|
The berry if it exists in the cache, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the berry is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> berry = client.berry.get_berry("cheri") # None if not cached
>>> berry.name
'cheri'
Source code in pokelance/ext/berry.py
get_berry_firmness(name)
⚓︎
Gets a berry firmness from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the berry firmness. |
required |
Returns:
Type | Description |
---|---|
Optional[BerryFirmness]
|
The berry firmness if it exists in the cache, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the berry firmness is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> berry_firmness = client.berry.get_berry_firmness("very-soft") # None if not cached
>>> berry_firmness.name
'very-soft'
Source code in pokelance/ext/berry.py
get_berry_flavor(name)
⚓︎
Gets a berry flavor from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the berry flavor. |
required |
Returns:
Type | Description |
---|---|
Optional[BerryFlavor]
|
The berry flavor if it exists in the cache, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the berry flavor is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> berry_flavor = client.berry.get_berry_flavor("spicy") # None if not cached
>>> berry_flavor.name
'spicy'
Source code in pokelance/ext/berry.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
setup()
async
⚓︎
Sets up the extension.