Game
game
¶
Game
¶
Bases: SyncBaseExtension[Game]
Extension for game related endpoints.
Source code in pokelance/ext/_base.py
get_generation
¶
get_generation(name: str | int) -> Generation | None
Gets a generation from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Generation | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/sync/game.py
def get_generation(self, name: str | int) -> models.Generation | None:
"""Gets a generation from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Generation | None
The cached model or None.
Examples
--------
```python
generation = client.game.get_generation("generation-i")
if generation:
print(generation)
```"""
route = Endpoint.get_generation(name)
self._validate_resource(self._cache_group.generation, name, route)
return self._cache_group.generation.get(route, None)
fetch_generation
¶
fetch_generation(name: str | int) -> Generation
Fetches a generation from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Generation
|
The fetched model. |
Examples:
Source code in pokelance/ext/sync/game.py
def fetch_generation(self, name: str | int) -> models.Generation:
"""Fetches a generation from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Generation
The fetched model.
Examples
--------
```python
generation = client.game.fetch_generation("generation-i")
print(generation)
```"""
route = Endpoint.get_generation(name)
self._validate_resource(self._cache_group.generation, name, route)
data = self._client.request(route)
return self._cache_group.generation.setdefault(route, self._cache_group.generation.from_payload(data))
get_pokedex
¶
Gets a pokedex from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Pokedex | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/sync/game.py
def get_pokedex(self, name: str | int) -> models.Pokedex | None:
"""Gets a pokedex from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Pokedex | None
The cached model or None.
Examples
--------
```python
pokedex = client.game.get_pokedex("national")
if pokedex:
print(pokedex)
```"""
route = Endpoint.get_pokedex(name)
self._validate_resource(self._cache_group.pokedex, name, route)
return self._cache_group.pokedex.get(route, None)
fetch_pokedex
¶
Fetches a pokedex from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Pokedex
|
The fetched model. |
Examples:
Source code in pokelance/ext/sync/game.py
def fetch_pokedex(self, name: str | int) -> models.Pokedex:
"""Fetches a pokedex from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Pokedex
The fetched model.
Examples
--------
```python
pokedex = client.game.fetch_pokedex("national")
print(pokedex)
```"""
route = Endpoint.get_pokedex(name)
self._validate_resource(self._cache_group.pokedex, name, route)
data = self._client.request(route)
return self._cache_group.pokedex.setdefault(route, self._cache_group.pokedex.from_payload(data))
get_version
¶
Gets a version from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Version | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/sync/game.py
def get_version(self, name: str | int) -> models.Version | None:
"""Gets a version from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Version | None
The cached model or None.
Examples
--------
```python
version = client.game.get_version("red")
if version:
print(version)
```"""
route = Endpoint.get_version(name)
self._validate_resource(self._cache_group.version, name, route)
return self._cache_group.version.get(route, None)
fetch_version
¶
Fetches a version from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Version
|
The fetched model. |
Examples:
Source code in pokelance/ext/sync/game.py
def fetch_version(self, name: str | int) -> models.Version:
"""Fetches a version from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Version
The fetched model.
Examples
--------
```python
version = client.game.fetch_version("red")
print(version)
```"""
route = Endpoint.get_version(name)
self._validate_resource(self._cache_group.version, name, route)
data = self._client.request(route)
return self._cache_group.version.setdefault(route, self._cache_group.version.from_payload(data))
get_version_group
¶
get_version_group(name: str | int) -> VersionGroup | None
Gets a version group from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
VersionGroup | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/sync/game.py
def get_version_group(self, name: str | int) -> models.VersionGroup | None:
"""Gets a version group from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.VersionGroup | None
The cached model or None.
Examples
--------
```python
group = client.game.get_version_group("red-blue")
if group:
print(group)
```"""
route = Endpoint.get_version_group(name)
self._validate_resource(self._cache_group.version_group, name, route)
return self._cache_group.version_group.get(route, None)
fetch_version_group
¶
fetch_version_group(name: str | int) -> VersionGroup
Fetches a version group from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
VersionGroup
|
The fetched model. |
Examples:
Source code in pokelance/ext/sync/game.py
def fetch_version_group(self, name: str | int) -> models.VersionGroup:
"""Fetches a version group from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.VersionGroup
The fetched model.
Examples
--------
```python
group = client.game.fetch_version_group("red-blue")
print(group)
```"""
route = Endpoint.get_version_group(name)
self._validate_resource(self._cache_group.version_group, name, route)
data = self._client.request(route)
return self._cache_group.version_group.setdefault(route, self._cache_group.version_group.from_payload(data))
setup
¶
setup(lance: PokeLanceSyncClient) -> None