from typing import (
    Dict,
)


class DeviceStatus:
    def __init__(
        self,
        _id,        # type: str
        name,       # type: str
        _type,      # type: str
        status,     # type: bool
        operator,   # type: str
        time,       # type: str
    ):
        # type: (...) -> None

        self.status = status
        self.id = _id
        self.name = name
        self.type = _type
        self.operator = operator
        self.time = time

    @classmethod
    def from_json(
        cls,
        device_data,    # type: Dict
    ):
        # type: (...) -> DeviceStatus

        status = device_data["enabled"]
        name = device_data["deviceName"]
        _type = device_data["deviceType"]
        time = device_data["lastUpdateTime"]
        operator = device_data["lastUpdateOperator"]
        _id = name + '-' + _type

        return cls(_id, name, _type, status, operator, time)
