import json
from typing import Any

class CreateAudioClip:

    extra_fields: dict[str, Any]

    def __init__(
        self,
        device_id: int = 0,
        device_name: str = '',
        local_file_path: str = '',
        start_time: int = 0,
        start_time_ms: int = 0,
        clip_length_in_seconds: float = 0.0,
        audio_clip_status: int = 0,
        audio_clip_type_id: int = 0,
        audio_clip_parameters: str = '',
        **kwargs: Any
    ):
        self.device_id = device_id
        self.device_name = device_name
        self.local_file_path = local_file_path
        self.start_time = start_time
        self.start_time_ms = start_time_ms
        self.clip_length_in_seconds = clip_length_in_seconds
        self.audio_clip_status = audio_clip_status
        self.audio_clip_type_id = audio_clip_type_id
        self.audio_clip_parameters = audio_clip_parameters

        camel_to_snake = {
            "deviceID": "device_id",
            "deviceName": "device_name",
            "localFilePath": "local_file_path",
            "startTime": "start_time",
            "startTimeMs": "start_time_ms",
            "clipLengthInSeconds": "clip_length_in_seconds",
            "audioClipStatus": "audio_clip_status",
            "audioClipTypeID": "audio_clip_type_id",
            "audioClipParameters": "audio_clip_parameters"
        }

        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,
            "startTime": self.start_time,
            "startTimeMs": self.start_time_ms,
            "clipLengthInSeconds": self.clip_length_in_seconds,
            "audioClipStatus": self.audio_clip_status,
            "audioClipTypeID": self.audio_clip_type_id,
            "audioClipParameters": self.audio_clip_parameters
        }

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