from dataclasses import dataclass, field
import time

from events.types.payload import Payload


@dataclass
class Event:
    type: str
    payload: Payload
    timestamp: float = field(default_factory=time.time)

    def to_dict(self):
        return {
            'type': self.type,
            'payload': self.payload.data,
            'timestamp': self.timestamp
        }