from dataclasses import dataclass

@dataclass
class Device:
    access_key: str
    device_type: str
    name: str


    def to_dict(self):
        return {
                'access_key': self.access_key,
                'type': self.device_type,
                'name': self.name
               }


    def convert(device_from_db) -> Device:
        return Device(*device_from_db)


@dataclass
class SimCard:
    phone_number: str
    device_access_key: str


    def to_dict(self):
        return {
                'phone_number': self.phone_number,
                'device_access_key': self.device_access_key
               }


    def convert(sim_from_db) -> SimCard:
        return SimCard(*sim_from_db)


@dataclass
class SmsMessage:
    content: str
    ts_received: int
    ts_sent: int
    msg_type: str
    local_phone_number: str
    remote_phone_number: str

    def to_dict(self):
        return {
                'content': self.content,
                'ts_received': self.ts_received,
                'ts_sent': self.ts_sent,
                'msg_type': self.msg_type,
                'local_phone_number': self.local_phone_number,
                'remote_phone_number': self.remote_phone_number
               }


    def convert(sms_from_db) -> SmsMessage:
        return SmsMessage(*sms_from_db)


@dataclass
class QueuedSmsMessage:
    content: str
    sender_access_key: str
    local_phone_number: str
    remote_phone_number: str

    def to_dict(self):
        return {
                'content': self.content,
                'sender_access_key': self.sender_access_key,
                'local_phone_number': self.local_phone_number,
                'remote_phone_number': self.remote_phone_number
               }


    def convert(sms_from_db) -> QueuedSmsMessage:
        return QueuedSmsMessage(*sms_from_db)
