hd2api.models.ABC package¶
Submodules¶
hd2api.models.ABC.model module¶
- class hd2api.models.ABC.model.BaseApiModel(*, retrieved_at: datetime | None = None, time_delta: timedelta | None = None, **data)¶
Bases:
BaseModelBase model class for everything returend by the api. Features the retrieved_at and time_delta fields.
- get(attr, default=None)¶
- get_time_delta(other: BaseApiModel) timedelta | None¶
Calculate the time difference between the retrieved_at times of two BaseApiModel instances.
- Parameters:
other (BaseApiModel) – The other instance of BaseApiModel to compare with.
- Returns:
The time difference if both retrieved_at values are not None, otherwise None.
- Return type:
Optional[timedelta]
- model_config = {'extra': 'allow'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- set(attr, new=None)¶
- class hd2api.models.ABC.model.HealthMixin¶
Bases:
object- health_percent()¶
Calculate the health percentage based on current health and maximum health.
- Returns:
The health percentage rounded to three decimal places.
- Return type: