package at.procon.eventhub.processing.service;

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

@Component
public class YellowFoxDbUnifiedDriverEventSource implements UnifiedDriverEventSource {

    private final EventHubEventReadRepository repository;

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

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

    @Override
    public List<EventHubEventDto> loadDriverEvents(UnifiedDriverEventsRequest request) {
        return repository.findEvents(request, "YELLOWFOX", List.of("TELEMATICS_PLATFORM"));
    }
}
