<?php

namespace ModulesGarden\HostingQuotaNotifications\App\Libs\Cron\Notifications;


use \ModulesGarden\HostingQuotaNotifications\App\Libs\Cron\Notifications\Actions\SendNotification;
use \ModulesGarden\HostingQuotaNotifications\App\Libs\Cron\Notifications\Actions\Service;
use \ModulesGarden\HostingQuotaNotifications\App\Libs\Cron\Notifications\Actions\OpenTicket;
use \ModulesGarden\HostingQuotaNotifications\App\Libs\Cron\Notifications\Actions\SaveActions;


/**
 * Description of Actions
 *
 * @author Artur Pilch <artur.pi@modulesgarden.com>
 */
class Actions
{
    private $data;

    public function run($data)
    {
        $this->data = $data;
        
        $this->sendNotification();

        $this->service();

        $this->openTicket();

        $this->saveNotification();

    }

    private function sendNotification()
    {
        $sendNotification        = new SendNotification($this->data);
        $this->data['emailSend'] = $sendNotification->run();
    }

    private function service()
    {
        $hostingAction = new Service($this->data);
        $hostingAction->run();
    }

    private function openTicket()
    {
        $openTicket                   = new OpenTicket($this->data);
        $this->data['openedTicketId'] = $openTicket->run();
        $this->data['alreadyOpen']    = $openTicket->isAlreadyOpen();
    }

    private function saveNotification()
    {
        $saveAction = new SaveActions($this->data);
        $saveAction->run();
    }
}
