contest
pokelance.ext.contest
⚓︎
Contest(client)
⚓︎
Bases: BaseExtension
Extension for contest related endpoints.
Attributes:
Name | Type | Description |
---|---|---|
cache |
Contest
|
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_contest_effect(id_)
async
⚓︎
Fetches a contest effect from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_ |
int
|
The name or id of the contest effect. |
required |
Returns:
Type | Description |
---|---|
ContestEffect
|
The contest effect if it exists in the API, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the contest effect is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... effect = await client.contest.fetch_contest_effect(1)
... print(effect.appeal)
... await client.close()
>>> asyncio.run(main())
4
Source code in pokelance/ext/contest.py
fetch_contest_type(name)
async
⚓︎
Fetches a contest type from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the contest type. |
required |
Returns:
Type | Description |
---|---|
ContestType
|
The contest type if it exists in the API, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the contest type is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... type_ = await client.contest.fetch_contest_type("cool")
... print(type_.name)
... await client.close()
>>> asyncio.run(main())
cool
Source code in pokelance/ext/contest.py
fetch_super_contest_effect(id_)
async
⚓︎
Fetches a super contest effect from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_ |
int
|
The name or id of the super contest effect. |
required |
Returns:
Type | Description |
---|---|
SuperContestEffect
|
The super contest effect if it exists in the API, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the super contest effect is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> import asyncio
>>> client = PokeLance()
>>> async def main() -> None:
... effect = await client.contest.fetch_super_contest_effect(1)
... print(effect.appeal)
... await client.close()
>>> asyncio.run(main())
2
Source code in pokelance/ext/contest.py
get_contest_effect(id_)
⚓︎
Gets a contest effect from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_ |
int
|
The name or id of the contest effect. |
required |
Returns:
Type | Description |
---|---|
Optional[ContestEffect]
|
The contest effect if it exists in the cache, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the contest effect is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> effect = client.contest.get_contest_effect(1) # None if not cached
>>> effect.appeal
4
Source code in pokelance/ext/contest.py
get_contest_type(name)
⚓︎
Gets a contest type from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Union[str, int]
|
The name or id of the contest type. |
required |
Returns:
Type | Description |
---|---|
Optional[ContestType]
|
The contest type if it exists in the cache, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the contest type is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> type_ = client.contest.get_contest_type("cool") # None if not cached
>>> type_.name
'cool'
Source code in pokelance/ext/contest.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_super_contest_effect(id_)
⚓︎
Gets a super contest effect from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_ |
int
|
The name or id of the super contest effect. |
required |
Returns:
Type | Description |
---|---|
Optional[SuperContestEffect]
|
The super contest effect if it exists in the cache, else None. |
Raises:
Type | Description |
---|---|
ResourceNotFound
|
The name or id of the super contest effect is invalid. |
Examples:
>>> from pokelance import PokeLance
>>> client = PokeLance()
>>> effect = client.contest.get_super_contest_effect(1)
>>> effect.appeal
2
Source code in pokelance/ext/contest.py
setup()
async
⚓︎
Sets up the extension.