<?php

namespace App\Classes\Modules\Transactions\ControllersLogic;


use App\Classes\Modules\Transactions\Processors\ApproveShippingInvoiceTransactionProcessor;
use App\Classes\Notifications\InvoiceIssuedEmail;
use Illuminate\Http\Request;


use Illuminate\Http\JsonResponse;
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
use App\Classes\ValueObjects\Constants\DocumentType;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\Modules\Documents\Services\CreatesFiles;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Documents\Services\CreatesDocument;
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
use App\Classes\Modules\Transactions\ControllersLogic\Document;

class ApproveShippingInvoiceTransactionLogic extends AbstractControllerLogic
{

    /**
     * @return array
     */
    protected function notification():array {
        return [
            'title' => 'Shipping Invoice Status',
            'message' => 'You have successfully updated the shipping invoice status'
        ];
    }

    /** @var FetchesPackingList */
    private $fetchesPackingList;

    /** @var ApproveShippingInvoiceTransactionProcessor */
    private $approveShippingInvoiceTransactionProcessor;

    /**
     * @param FetchesPackingList $fetchesPackingList
     * @param ApproveShippingInvoiceTransactionProcessor $approveShippingInvoiceTransactionProcessor
     */
    public function __construct(FetchesPackingList $fetchesPackingList, ApproveShippingInvoiceTransactionProcessor $approveShippingInvoiceTransactionProcessor)
    {
        $this->fetchesPackingList = $fetchesPackingList;
        $this->approveShippingInvoiceTransactionProcessor = $approveShippingInvoiceTransactionProcessor;
    }

    /**
     * @param Request $request
     * @return JsonResponse
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function logic(Request $request) : JsonResponse
    {
        $packing_list = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
        $this->approveShippingInvoiceTransactionProcessor->execute($packing_list);

        return $this->response([]);
    }

}
