'Retrieved Segment', 'message' => 'You have successfully retrieved a list of Segment' ]; } /** @var CanListStandardSegments */ private $canListStandardSegments; /** @var ListsSegments */ private $listsSegments; /** * ListStandardSegmentLogic constructor. * @param CanListStandardSegments $canListStandardSegments * @param ListsSegments $listsSegments */ public function __construct(CanListStandardSegments $canListStandardSegments, ListsSegments $listsSegments) { $this->canListStandardSegments = $canListStandardSegments; $this->listsSegments = $listsSegments; } /** * @param Request $request * @return JsonResponse * @throws ErrorException */ public function logic(Request $request) : JsonResponse { try { $this->canListStandardSegments->passes(); $query = $this->listsSegments->execute(['id' => 1]); return $this->collectionResponse(SegmentResource::collection($query)); } catch (\Exception $exception){ throw new ErrorException($exception->getMessage(), $exception->getCode()); } } }