<?php

namespace App\Modules\WebContactMessage\Application\ListAllExcel;

use App\Modules\Shared\Domain\DateEnd;
use App\Modules\Shared\Domain\DateStart;
use App\Modules\Shared\Domain\DateTimeEnd;
use App\Modules\Shared\Domain\DateTimeStart;
use App\Modules\WebContactMessage\Domain\ListAllExcelWebContactMessage;
use App\Modules\WebContactMessage\Domain\WebContactMessageRepository;
use App\Modules\WebContactMessage\Domain\WebContactMessageStatus;

final class WebContactMessageAllExcelLister
{
    public function __construct(private WebContactMessageRepository $repository) {}

    public function __invoke(
        DateStart $dateStart,
        DateEnd $dateEnd,
        string $dateBy,
        bool $allStatus,
        bool $allWebPages,
        bool $allAdminAssigners,
        bool $allAdmins,
        bool $allWebChannels,
        bool $allPackages,
        bool $allTours,
        array $webContactMessageStatuses,
        array $idWebPages,
        array $idAdminAssigners,
        array $idAdmins,
        array $idWebChannels,
        array $idPackages,
        array $idTours
    ): ListAllExcelWebContactMessageQueryResponse {
        return new ListAllExcelWebContactMessageQueryResponse($this->repository->search(new ListAllExcelWebContactMessage(
            new DateTimeStart($dateStart . ' 00:00:00'),
            new DateTimeEnd($dateEnd . ' 23:59:59'),
            $dateBy,
            $allStatus,
            array_map(fn($status) => new WebContactMessageStatus($status), $webContactMessageStatuses),
            $allWebPages,
            $idWebPages,
            $allAdminAssigners,
            $idAdminAssigners,
            $allAdmins,
            $idAdmins,
            $allWebChannels,
            $idWebChannels,
            $allPackages,
            $idPackages,
            $allTours,
            $idTours
        )));
    }
}
