2023-04-13 23:25:49 +02:00
|
|
|
from typing import Dict
|
2023-04-09 18:13:50 +02:00
|
|
|
|
|
|
|
from pyhon import const
|
|
|
|
|
|
|
|
|
|
|
|
class HonDevice:
|
2024-02-09 20:37:53 +01:00
|
|
|
def __init__(self, mobile_id: str = "") -> None:
|
2023-04-13 23:25:49 +02:00
|
|
|
self._app_version: str = const.APP_VERSION
|
|
|
|
self._os_version: int = const.OS_VERSION
|
|
|
|
self._os: str = const.OS
|
|
|
|
self._device_model: str = const.DEVICE_MODEL
|
2024-02-09 20:37:53 +01:00
|
|
|
self._mobile_id: str = mobile_id or const.MOBILE_ID
|
2023-04-09 18:13:50 +02:00
|
|
|
|
|
|
|
@property
|
2023-04-13 23:25:49 +02:00
|
|
|
def app_version(self) -> str:
|
2023-04-09 18:13:50 +02:00
|
|
|
return self._app_version
|
|
|
|
|
|
|
|
@property
|
2023-04-13 23:25:49 +02:00
|
|
|
def os_version(self) -> int:
|
2023-04-09 18:13:50 +02:00
|
|
|
return self._os_version
|
|
|
|
|
|
|
|
@property
|
2023-07-12 19:36:32 +02:00
|
|
|
def os_type(self) -> str:
|
2023-04-09 18:13:50 +02:00
|
|
|
return self._os
|
|
|
|
|
|
|
|
@property
|
2023-04-13 23:25:49 +02:00
|
|
|
def device_model(self) -> str:
|
2023-04-09 18:13:50 +02:00
|
|
|
return self._device_model
|
|
|
|
|
|
|
|
@property
|
2023-04-13 23:25:49 +02:00
|
|
|
def mobile_id(self) -> str:
|
2023-04-09 18:13:50 +02:00
|
|
|
return self._mobile_id
|
|
|
|
|
2023-06-28 19:02:11 +02:00
|
|
|
def get(self, mobile: bool = False) -> Dict[str, str | int]:
|
|
|
|
result: Dict[str, str | int] = {
|
2023-04-09 20:55:36 +02:00
|
|
|
"appVersion": self.app_version,
|
|
|
|
"mobileId": self.mobile_id,
|
2023-07-12 19:36:32 +02:00
|
|
|
"os": self.os_type,
|
2023-04-15 00:29:24 +02:00
|
|
|
"osVersion": self.os_version,
|
2023-04-09 20:55:36 +02:00
|
|
|
"deviceModel": self.device_model,
|
|
|
|
}
|
2023-06-28 19:02:11 +02:00
|
|
|
if mobile:
|
|
|
|
result |= {"mobileOs": result.pop("os", "")}
|
|
|
|
return result
|