import json
from typing import Any

class CreateStream:

    extra_fields: dict[str, Any]

    def __init__(
        self,
        device_id: int = 0,
        stream_type: str = '',
        event_id: int = 0,
        stream_name: str = '',
        stream_path: str = '',
        stream_description: str = '',
        publish_url: str = '',
        read_url: str = '',
        action_type: str = '',
        **kwargs: Any
    ):
        self.device_id = device_id
        self.stream_type = stream_type
        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.action_type = action_type

        camel_to_snake = {
            "deviceID": "device_id",
            "streamType": "stream_type",
            "eventID": "event_id",
            "streamName": "stream_name",
            "streamPath": "stream_path",
            "streamDescription": "stream_description",
            "publishURL": "publish_url",
            "readURL": "read_url",
            "actionType": "action_type",
        }

        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 {
            "deviceID": self.device_id,
            "streamType": self.stream_type,
            "eventID": self.event_id,
            "streamName": self.stream_name,
            "streamPath": self.stream_path,
            "streamDescription": self.stream_description,
            "publishURL": self.publish_url,
            "readURL": self.read_url,
            "actionType": self.action_type,
        }

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