<?php

namespace App\Classes\Modules\Rewards\ControllersLogic;


use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Rewards\Services\ListsRewards;
use App\Http\Resources\RewardDetailsResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class ListRewardsDetailsLogic extends AbstractControllerLogic
{

    /**
     * @return array
     */
    protected function notification():array {
        return [
            'title' => 'Retrieved Rewards Details',
            'message' => 'You have successfully retrieved a list of Rewards Details'
        ];
    }

    /** @var ListsRewards */
    private $listsRewards;

    /**
     * ListRewardsDetailsLogic constructor.
     * @param ListsRewards $listsRewards
     */
    public function __construct(ListsRewards $listsRewards)
    {
        $this->listsRewards = $listsRewards;
    }

    /**
     * @param Request $request
     * @return JsonResponse
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function logic(Request $request) : JsonResponse
    {
        $query = $this->listsRewards->execute($this->listsRewards->deserializeFilters($request->input('filters')));

        return $this->collectionResponse(RewardDetailsResource::collection($query));
    }

}
