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->getRecordService()->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->getRecordService()->isApiKeyValid($params['apiKey'])) { throw new NotFound(); } $allowOrigin = $this->getConfig()->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->getRecordService() ->generateNewApiKeyForEntity($data->id) ->getValueMap(); } public function getActionSmtpAccountDataList(): array { if (!$this->getUser()->isAdmin()) { throw new Forbidden(); } return $this->getServiceFactory() ->create('LeadCapture') ->getSmtpAccountDataList(); } }