<?php

namespace Signteer\Core\Listener\Signup;

use Signteer\Core\Event\Signup\SignupCreated;
use Signteer\Core\Event\Signup\SignupDeleted;
use Signteer\Core\Action\Signup\SendConfirmationEmailToVolunteer;
use Signteer\Core\Action\Signup\SendUnassignConfirmationEmailToVolunteer;

final class NotifyVolunteer
{
    public $sendConfirmationEmailToVolunteerAction = SendConfirmationEmailToVolunteer::class;
    public $sendUnassignConfirmationEmailToVolunteerAction = SendUnassignConfirmationEmailToVolunteer::class;

    public function onCreate(SignupCreated $event)
    {
        $signupId = $event->getId();
        ($this->sendConfirmationEmailToVolunteerAction)($signupId);
    }

    public function onDelete(SignupDeleted $event)
    {
        $signupId = $event->getId();
        $taskId = $event->getTaskId();
        $volunteerId = $event->getVolunteerId();
        ($this->sendUnassignConfirmationEmailToVolunteerAction)($signupId, $taskId, $volunteerId);
    }
}
