package at.procon.eventhub.processing.service;

import at.procon.eventhub.dto.EventHubEventDto;
import at.procon.eventhub.persistence.EventHubEventReadRepository;
import at.procon.eventhub.processing.model.UnifiedEventSourceFamily;
import at.procon.eventhub.processing.model.UnifiedVehicleEventsRequest;
import java.util.List;
import org.springframework.stereotype.Component;

@Component
public class YellowFoxDbUnifiedVehicleEventSource implements UnifiedVehicleEventSource {

    private final EventHubEventReadRepository repository;

    public YellowFoxDbUnifiedVehicleEventSource(EventHubEventReadRepository repository) {
        this.repository = repository;
    }

    @Override
    public boolean supports(UnifiedVehicleEventsRequest request) {
        return request.sourceFamily() == UnifiedEventSourceFamily.YELLOWFOX_DB;
    }

    @Override
    public List<EventHubEventDto> loadVehicleEvents(UnifiedVehicleEventsRequest request) {
        return repository.findEventsByVehicle(request, "YELLOWFOX", List.of("TELEMATICS_PLATFORM"));
    }
}
