package com.unicorn.hgzero.stt.event;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * 녹음 관련 이벤트 정의
 */
public class RecordingEvent {
    
    /**
     * 녹음 시작 이벤트
     */
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class RecordingStarted {
        private String eventId;
        private String eventType;
        private String recordingId;
        private String meetingId;
        private String sessionId;
        private String startedBy;
        private LocalDateTime startTime;
        private String language;
        private LocalDateTime eventTime;
        
        public static RecordingStarted of(String recordingId, String meetingId, String sessionId, 
                                        String startedBy, String language) {
            return RecordingStarted.builder()
                    .eventId(java.util.UUID.randomUUID().toString())
                    .eventType("RecordingStarted")
                    .recordingId(recordingId)
                    .meetingId(meetingId)
                    .sessionId(sessionId)
                    .startedBy(startedBy)
                    .startTime(LocalDateTime.now())
                    .language(language)
                    .eventTime(LocalDateTime.now())
                    .build();
        }
    }
    
    /**
     * 녹음 중지 이벤트
     */
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class RecordingStopped {
        private String eventId;
        private String eventType;
        private String recordingId;
        private String meetingId;
        private String stoppedBy;
        private LocalDateTime startTime;
        private LocalDateTime endTime;
        private Integer duration;
        private LocalDateTime eventTime;

        public static RecordingStopped of(String recordingId, String meetingId, String stoppedBy,
                                        LocalDateTime startTime, Integer duration) {
            return RecordingStopped.builder()
                    .eventId(java.util.UUID.randomUUID().toString())
                    .eventType("RecordingStopped")
                    .recordingId(recordingId)
                    .meetingId(meetingId)
                    .stoppedBy(stoppedBy)
                    .startTime(startTime)
                    .endTime(LocalDateTime.now())
                    .duration(duration)
                    .eventTime(LocalDateTime.now())
                    .build();
        }
    }
    
    /**
     * 녹음 실패 이벤트
     */
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class RecordingFailed {
        private String eventId;
        private String eventType;
        private String recordingId;
        private String meetingId;
        private String errorCode;
        private String errorMessage;
        private LocalDateTime eventTime;
        
        public static RecordingFailed of(String recordingId, String meetingId, String errorCode, String errorMessage) {
            return RecordingFailed.builder()
                    .eventId(java.util.UUID.randomUUID().toString())
                    .eventType("RecordingFailed")
                    .recordingId(recordingId)
                    .meetingId(meetingId)
                    .errorCode(errorCode)
                    .errorMessage(errorMessage)
                    .eventTime(LocalDateTime.now())
                    .build();
        }
    }
}