import json
from typing import Any

class CreateImage:

    extra_fields: dict[str, Any]

    def __init__(
        self,
        device_id: int = 0,
        device_name: str = '',
        local_file_path: str = '',
        height: int = 0,
        width: int = 0,
        start_time: int = 0,
        start_time_ms: int = 0,
        image_status: int = 0,
        image_type_id: int = 0,
        **kwargs: Any
    ):
        self.device_id = device_id
        self.device_name = device_name
        self.local_file_path = local_file_path
        self.height = height
        self.width = width
        self.start_time = start_time
        self.start_time_ms = start_time_ms
        self.image_status = image_status
        self.image_type_id = image_type_id

        camel_to_snake = {
            "deviceID": "device_id",
            "deviceName": "device_name",
            "localFilePath": "local_file_path",
            "height": "height",
            "width": "width",
            "startTime": "start_time",
            "startTimeMs": "start_time_ms",
            "imageStatus": "image_status",
            "imageTypeID": "image_type_id"
        }

        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,
            "deviceName": self.device_name,
            "localFilePath": self.local_file_path,
            "height": self.height,
            "width": self.width,
            "startTime": self.start_time,
            "startTimeMs": self.start_time_ms,
            "imageStatus": self.image_status,
            "imageTypeID": self.image_type_id
        }

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