automationStorage = $automationStorage; $this->automationStatisticsStorage = $automationStatisticsStorage; $this->automationMapper = $automationMapper; $this->automationTimeSpanController = $automationTimeSpanController; } public function handle(Request $request): Response { //@ToDo Get the automation flow data $automation = $this->automationStorage->getAutomation(absint($request->getParam('id'))); if (!$automation) { throw new NotFoundException(__('Automation not found', 'mailpoet')); } $query = Query::fromRequest($request); $automations = $this->automationTimeSpanController->getAutomationsInTimespan($automation, $query->getAfter(), $query->getBefore()); if (!count($automations)) { throw new NotFoundException(__('The automation did not exist in the selected time span', 'mailpoet')); } $automation = end($automations); $shortStatistics = $this->automationStatisticsStorage->getAutomationStats( $automation->getId(), null, $query->getAfter(), $query->getBefore() ); $data = [ 'automation' => $this->automationMapper->buildAutomation($automation, $shortStatistics), ]; return new Response($data); } public static function getRequestSchema(): array { return [ 'id' => Builder::integer()->required(), 'query' => Query::getRequestSchema(), ]; } }