getRouteParams(); $data = $request->getParsedBody(); if (empty($params['apiKey'])) { throw new BadRequest('No API key provided.'); } if (empty($data)) { throw new BadRequest('No payload provided.'); } $allowOrigin = $this->config->get('leadCaptureAllowOrigin', '*'); $response->setHeader('Access-Control-Allow-Origin', $allowOrigin); $this->getLeadCaptureService()->leadCapture($params['apiKey'], $data); return true; } public function optionsActionLeadCapture(Request $request, Response $response): bool { $params = $request->getRouteParams(); if (empty($params['apiKey'])) { throw new BadRequest('No API key provided.'); } if (!$this->getLeadCaptureService()->isApiKeyValid($params['apiKey'])) { throw new NotFound(); } $allowOrigin = $this->config->get('leadCaptureAllowOrigin', '*'); $response->setHeader('Access-Control-Allow-Headers', 'Content-Type, Accept'); $response->setHeader('Access-Control-Allow-Origin', $allowOrigin); $response->setHeader('Access-Control-Allow-Methods', 'POST'); return true; } public function postActionGenerateNewApiKey(Request $request): StdClass { $data = $request->getParsedBody(); if (empty($data->id)) { throw new BadRequest(); } return $this->getLeadCaptureService() ->generateNewApiKeyForEntity($data->id) ->getValueMap(); } public function getActionSmtpAccountDataList(): array { if (!$this->getUser()->isAdmin()) { throw new Forbidden(); } return $this->getLeadCaptureService()->getSmtpAccountDataList(); } private function getLeadCaptureService(): Service { /** @var Service */ return $this->getRecordService(); } }