import json
from typing import Any

class Stream:

    extra_fields: dict[str, Any]

    def __init__(
        self,
        key: int = 0,
        user_id: int = 0,
        device_id: int = 0,
        stream_type_id: int = 0,
        event_id: int = 0,
        stream_name: str = '',
        stream_path: str = '',
        stream_description: str = '',
        publish_url: str = '',
        read_url: str = '',
        last_activity_date: str = '',
        action_type_id: int = 0,
        creation_date: str = '',
        created_by: int = 0,
        last_modified_date: str = '',
        last_modified_by: int = 0,
        **kwargs: Any
    ):
        self.key = key
        self.user_id = user_id
        self.device_id = device_id
        self.stream_type_id = stream_type_id
        self.event_id = event_id
        self.stream_name = stream_name
        self.stream_path = stream_path
        self.stream_description = stream_description
        self.publish_url = publish_url
        self.read_url = read_url
        self.last_activity_date = last_activity_date
        self.action_type_id = action_type_id
        self.creation_date = creation_date
        self.created_by = created_by
        self.last_modified_date = last_modified_date
        self.last_modified_by = last_modified_by

        camel_to_snake = {
            "userID": "user_id",
            "deviceID": "device_id",
            "streamTypeID": "stream_type_id",
            "eventID": "event_id",
            "streamName": "stream_name",
            "streamPath": "stream_path",
            "streamDescription": "stream_description",
            "publishURL": "publish_url",
            "readURL": "read_url",
            "lastActivityDate": "last_activity_date",
            "actionTypeID": "action_type_id",
            "creationDate": "creation_date",
            "createdBy": "created_by",
            "lastModifiedDate": "last_modified_date",
            "lastModifiedBy": "last_modified_by",
        }

        for camel_key, snake_key in camel_to_snake.items():
            if camel_key in kwargs:
                setattr(self, snake_key, kwargs.pop(camel_key))

        self.extra_fields = kwargs

        if kwargs:
            print(f"Extra fields: {kwargs}")

    def to_dict(self):
        return {
            "key": self.key,
            "userID": self.user_id,
            "deviceID": self.device_id,
            "streamTypeID": self.stream_type_id,
            "eventID": self.event_id,
            "streamName": self.stream_name,
            "streamPath": self.stream_path,
            "streamDescription": self.stream_description,
            "publishURL": self.publish_url,
            "readURL": self.read_url,
            "lastActivityDate": self.last_activity_date,
            "actionTypeID": self.action_type_id,
            "creationDate": self.creation_date,
            "createdBy": self.created_by,
            "lastModifiedDate": self.last_modified_date,
            "lastModifiedBy": self.last_modified_by
        }

    def to_json(self):
        return json.dumps(self.to_dict())
