Item
item
¶
Item
¶
Bases: AsyncBaseExtension[Item]
Extension for item related endpoints.
Source code in pokelance/ext/_base.py
get_item
¶
Gets a item from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Item | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/item.py
def get_item(self, name: str | int) -> models.Item | None:
"""Gets a item from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Item | None
The cached model or None.
Examples
--------
```python
item = client.item.get_item("master-ball")
if item:
print(item)
```"""
route = Endpoint.get_item(name)
self._validate_resource(self._cache_group.item, name, route)
return self._cache_group.item.get(route, None)
fetch_item
async
¶
Fetches a item from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Item
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/item.py
async def fetch_item(self, name: str | int) -> models.Item:
"""Fetches a item from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Item
The fetched model.
Examples
--------
```python
item = await client.item.fetch_item("master-ball")
print(item)
```"""
route = Endpoint.get_item(name)
self._validate_resource(self._cache_group.item, name, route)
data = await self._client.request(route)
return self._cache_group.item.setdefault(route, self._cache_group.item.from_payload(data))
get_item_attribute
¶
get_item_attribute(name: str | int) -> ItemAttribute | None
Gets a item attribute from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
ItemAttribute | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/item.py
def get_item_attribute(self, name: str | int) -> models.ItemAttribute | None:
"""Gets a item attribute from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.ItemAttribute | None
The cached model or None.
Examples
--------
```python
attribute = client.item.get_item_attribute("countable")
if attribute:
print(attribute)
```"""
route = Endpoint.get_item_attribute(name)
self._validate_resource(self._cache_group.item_attribute, name, route)
return self._cache_group.item_attribute.get(route, None)
fetch_item_attribute
async
¶
fetch_item_attribute(name: str | int) -> ItemAttribute
Fetches a item attribute from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
ItemAttribute
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/item.py
async def fetch_item_attribute(self, name: str | int) -> models.ItemAttribute:
"""Fetches a item attribute from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.ItemAttribute
The fetched model.
Examples
--------
```python
attribute = await client.item.fetch_item_attribute("countable")
print(attribute)
```"""
route = Endpoint.get_item_attribute(name)
self._validate_resource(self._cache_group.item_attribute, name, route)
data = await self._client.request(route)
return self._cache_group.item_attribute.setdefault(route, self._cache_group.item_attribute.from_payload(data))
get_item_category
¶
get_item_category(name: str | int) -> ItemCategory | None
Gets a item category from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
ItemCategory | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/item.py
def get_item_category(self, name: str | int) -> models.ItemCategory | None:
"""Gets a item category from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.ItemCategory | None
The cached model or None.
Examples
--------
```python
category = client.item.get_item_category("stat-boosts")
if category:
print(category)
```"""
route = Endpoint.get_item_category(name)
self._validate_resource(self._cache_group.item_category, name, route)
return self._cache_group.item_category.get(route, None)
fetch_item_category
async
¶
fetch_item_category(name: str | int) -> ItemCategory
Fetches a item category from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
ItemCategory
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/item.py
async def fetch_item_category(self, name: str | int) -> models.ItemCategory:
"""Fetches a item category from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.ItemCategory
The fetched model.
Examples
--------
```python
category = await client.item.fetch_item_category("stat-boosts")
print(category)
```"""
route = Endpoint.get_item_category(name)
self._validate_resource(self._cache_group.item_category, name, route)
data = await self._client.request(route)
return self._cache_group.item_category.setdefault(route, self._cache_group.item_category.from_payload(data))
get_item_fling_effect
¶
get_item_fling_effect(
name: str | int,
) -> ItemFlingEffect | None
Gets a item fling effect from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
ItemFlingEffect | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/item.py
def get_item_fling_effect(self, name: str | int) -> models.ItemFlingEffect | None:
"""Gets a item fling effect from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.ItemFlingEffect | None
The cached model or None.
Examples
--------
```python
effect = client.item.get_item_fling_effect("badly-poison")
if effect:
print(effect)
```"""
route = Endpoint.get_item_fling_effect(name)
self._validate_resource(self._cache_group.item_fling_effect, name, route)
return self._cache_group.item_fling_effect.get(route, None)
fetch_item_fling_effect
async
¶
fetch_item_fling_effect(name: str | int) -> ItemFlingEffect
Fetches a item fling effect from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
ItemFlingEffect
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/item.py
async def fetch_item_fling_effect(self, name: str | int) -> models.ItemFlingEffect:
"""Fetches a item fling effect from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.ItemFlingEffect
The fetched model.
Examples
--------
```python
effect = await client.item.fetch_item_fling_effect("badly-poison")
print(effect)
```"""
route = Endpoint.get_item_fling_effect(name)
self._validate_resource(self._cache_group.item_fling_effect, name, route)
data = await self._client.request(route)
return self._cache_group.item_fling_effect.setdefault(
route, self._cache_group.item_fling_effect.from_payload(data)
)
get_item_pocket
¶
get_item_pocket(name: str | int) -> ItemPocket | None
Gets a item pocket from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
ItemPocket | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/item.py
def get_item_pocket(self, name: str | int) -> models.ItemPocket | None:
"""Gets a item pocket from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.ItemPocket | None
The cached model or None.
Examples
--------
```python
pocket = client.item.get_item_pocket("misc")
if pocket:
print(pocket)
```"""
route = Endpoint.get_item_pocket(name)
self._validate_resource(self._cache_group.item_pocket, name, route)
return self._cache_group.item_pocket.get(route, None)
fetch_item_pocket
async
¶
fetch_item_pocket(name: str | int) -> ItemPocket
Fetches a item pocket from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
ItemPocket
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/item.py
async def fetch_item_pocket(self, name: str | int) -> models.ItemPocket:
"""Fetches a item pocket from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.ItemPocket
The fetched model.
Examples
--------
```python
pocket = await client.item.fetch_item_pocket("misc")
print(pocket)
```"""
route = Endpoint.get_item_pocket(name)
self._validate_resource(self._cache_group.item_pocket, name, route)
data = await self._client.request(route)
return self._cache_group.item_pocket.setdefault(route, self._cache_group.item_pocket.from_payload(data))
get_currency
¶
Gets a currency from the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Currency | None
|
The cached model or None. |
Examples:
Source code in pokelance/ext/_async/item.py
def get_currency(self, name: str | int) -> models.Currency | None:
"""Gets a currency from the cache.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Currency | None
The cached model or None.
Examples
--------
```python
currency = client.item.get_currency("money")
if currency:
print(currency)
```"""
route = Endpoint.get_currency(name)
self._validate_resource(self._cache_group.currency, name, route)
return self._cache_group.currency.get(route, None)
fetch_currency
async
¶
Fetches a currency from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | int
|
The name or id. |
required |
Returns:
| Type | Description |
|---|---|
Currency
|
The fetched model. |
Examples:
Source code in pokelance/ext/_async/item.py
async def fetch_currency(self, name: str | int) -> models.Currency:
"""Fetches a currency from the API.
Parameters
----------
name : str | int
The name or id.
Returns
-------
models.Currency
The fetched model.
Examples
--------
```python
currency = await client.item.fetch_currency("money")
print(currency)
```"""
route = Endpoint.get_currency(name)
self._validate_resource(self._cache_group.currency, name, route)
data = await self._client.request(route)
return self._cache_group.currency.setdefault(route, self._cache_group.currency.from_payload(data))
setup
¶
setup(lance: PokeLanceAsyncClient) -> None