<?php
/**
 * Created by PhpStorm.
 * User: mhmj
 * Date: 18/06/2019
 * Time: 10:10 AM
 */

namespace App\Classes\Modules\ControllersLogic\Orders;


use App\Classes\Modules\ControllerLogic\Exceptions\InternalServerErrorException;
use App\Classes\Modules\Orders\Services\DeletesOrderSchedule;
use App\Classes\ValueObjects\Constants\HttpStatus;
use Illuminate\Http\JsonResponse;

class DeleteOrderScheduleLogic
{
    /** @var  DeletesOrderSchedule */
    private $deletesOrderSchedule;

    /**
     * DeleteOrderScheduleLogic constructor.
     * @param DeletesOrderSchedule $deletesOrderSchedule
     */
    public function __construct(DeletesOrderSchedule $deletesOrderSchedule)
    {
        $this->deletesOrderSchedule = $deletesOrderSchedule;
    }


    public function execute(String $scheduleId){

        try{
            return $this->deletesOrderSchedule->execute($scheduleId);
            return new JsonResponse([],HttpStatus::REQUEST_ACCEPTED);

        }catch(\Exception $exception){
            throw new InternalServerErrorException("Failed to delete schedule because {$exception->getMessage()}");
        }

    }
}