Contest
contest
¶
Contest
¶
Bases: SyncBaseExtension[Contest]
Extension for contest related endpoints.
Source code in pokelance/ext/_base.py
get_contest_type
¶
get_contest_type(name: str | int) -> ContestType | None
Gets a contest type from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
ContestType | None
|
The cached model or None. |
Examples:
contest_type_data = client.contest.get_contest_type("cool")
if contest_type_data:
print(contest_type_data)
Source code in pokelance/ext/sync/contest.py
def get_contest_type(self, name: str | int) -> models.ContestType | None:
"""Gets a contest type from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.ContestType | None
The cached model or None.
Examples
--------
```python
contest_type_data = client.contest.get_contest_type("cool")
if contest_type_data:
print(contest_type_data)
```"""
route = Endpoint.get_contest_type(name)
self._validate_resource(self._cache_group.contest_type, name, route)
return self._cache_group.contest_type.get(route, None)
fetch_contest_type
¶
fetch_contest_type(name: str | int) -> ContestType
Fetches a contest type from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
ContestType
|
The fetched model. |
Examples:
Source code in pokelance/ext/sync/contest.py
def fetch_contest_type(self, name: str | int) -> models.ContestType:
"""Fetches a contest type from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.ContestType
The fetched model.
Examples
--------
```python
contest_type_data = client.contest.fetch_contest_type("cool")
print(contest_type_data)
```"""
route = Endpoint.get_contest_type(name)
self._validate_resource(self._cache_group.contest_type, name, route)
data = self._client.request(route)
return self._cache_group.contest_type.setdefault(route, self._cache_group.contest_type.from_payload(data))
get_contest_effect
¶
get_contest_effect(id: int) -> ContestEffect | None
Gets a contest effect from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
The resource id. |
required |
Returns:
| Type | Description |
|---|---|
ContestEffect | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/sync/contest.py
def get_contest_effect(self, id: int) -> models.ContestEffect | None:
"""Gets a contest effect from the cache.
Parameters
----------
id : int
The resource id.
Returns
-------
models.ContestEffect | None
The cached model or None.
Examples
--------
```python
effect = client.contest.get_contest_effect(1)
if effect:
print(effect)
```"""
route = Endpoint.get_contest_effect(id)
self._validate_resource(self._cache_group.contest_effect, id, route)
return self._cache_group.contest_effect.get(route, None)
fetch_contest_effect
¶
fetch_contest_effect(id: int) -> ContestEffect
Fetches a contest effect from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
The resource id. |
required |
Returns:
| Type | Description |
|---|---|
ContestEffect
|
The fetched model. |
Examples:
Source code in pokelance/ext/sync/contest.py
def fetch_contest_effect(self, id: int) -> models.ContestEffect:
"""Fetches a contest effect from the API.
Parameters
----------
id : int
The resource id.
Returns
-------
models.ContestEffect
The fetched model.
Examples
--------
```python
effect = client.contest.fetch_contest_effect(1)
print(effect)
```"""
route = Endpoint.get_contest_effect(id)
self._validate_resource(self._cache_group.contest_effect, id, route)
data = self._client.request(route)
return self._cache_group.contest_effect.setdefault(route, self._cache_group.contest_effect.from_payload(data))
get_super_contest_effect
¶
get_super_contest_effect(
id: int,
) -> SuperContestEffect | None
Gets a super contest effect from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
The resource id. |
required |
Returns:
| Type | Description |
|---|---|
SuperContestEffect | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/sync/contest.py
def get_super_contest_effect(self, id: int) -> models.SuperContestEffect | None:
"""Gets a super contest effect from the cache.
Parameters
----------
id : int
The resource id.
Returns
-------
models.SuperContestEffect | None
The cached model or None.
Examples
--------
```python
effect = client.contest.get_super_contest_effect(1)
if effect:
print(effect)
```"""
route = Endpoint.get_super_contest_effect(id)
self._validate_resource(self._cache_group.super_contest_effect, id, route)
return self._cache_group.super_contest_effect.get(route, None)
fetch_super_contest_effect
¶
fetch_super_contest_effect(id: int) -> SuperContestEffect
Fetches a super contest effect from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
The resource id. |
required |
Returns:
| Type | Description |
|---|---|
SuperContestEffect
|
The fetched model. |
Examples:
Source code in pokelance/ext/sync/contest.py
def fetch_super_contest_effect(self, id: int) -> models.SuperContestEffect:
"""Fetches a super contest effect from the API.
Parameters
----------
id : int
The resource id.
Returns
-------
models.SuperContestEffect
The fetched model.
Examples
--------
```python
effect = client.contest.fetch_super_contest_effect(1)
print(effect)
```"""
route = Endpoint.get_super_contest_effect(id)
self._validate_resource(self._cache_group.super_contest_effect, id, route)
data = self._client.request(route)
return self._cache_group.super_contest_effect.setdefault(
route, self._cache_group.super_contest_effect.from_payload(data)
)
setup
¶
setup(lance: PokeLanceSyncClient) -> None