Bases: AttrsInstance
Base model for all models
from_payload(payload)
classmethod
Create a model from a payload
Parameters:
Name |
Type |
Description |
Default |
payload |
Dict[str, Any]
|
The payload to create the model from.
|
required
|
Returns:
Type |
Description |
BaseModel
|
The model created from the payload.
|
Source code in pokelance/models/_base.py
Python |
---|
| @classmethod
def from_payload(cls, payload: t.Dict[str, t.Any]) -> "BaseModel":
"""Create a model from a payload
Parameters
----------
payload: typing.Dict[str, Any]
The payload to create the model from.
Returns
-------
BaseModel
The model created from the payload.
"""
return cls(raw=payload)
|
to_dict()
Convert the model to a dict
Returns:
Source code in pokelance/models/_base.py
Python |
---|
| def to_dict(self) -> t.Dict[str, t.Any]:
"""Convert the model to a dict
Returns
-------
typing.Dict[str, Any]
The model as a dict.
"""
return attrs.asdict(self)
|