package infrastructure.adapter.output;

import application.port.output.IMaintenanceCheckPort;
import com.banesco.common.infraestructure.utils.MaintenanceUtil;
import infrastructure.config.AccountAvailabilityConfig;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@ApplicationScoped
public class MaintenanceCheckAdapter implements IMaintenanceCheckPort {

    private final AccountAvailabilityConfig availabilityConfig;

    @Inject
    MaintenanceCheckAdapter(AccountAvailabilityConfig paymentAvailabilityConfig) {
        this.availabilityConfig = paymentAvailabilityConfig;
    }

    @Override
    public Boolean isUnderMaintenance(String requestId) {
        return MaintenanceUtil.isDateInRange(requestId, availabilityConfig.begin(), availabilityConfig.finish());
    }
}