. */ namespace OrangeHRM\Installer\Util\Service; use GuzzleHttp\Client; use OrangeHRM\Config\Config; use OrangeHRM\Installer\Util\Logger; use Throwable; class DataRegistrationService { private Client $httpClient; /** * @return Client */ private function getHttpClient(): Client { return $this->httpClient ??= new Client(['base_uri' => Config::REGISTRATION_URL]); } /** * @param array $body * @return bool */ public function sendRegistrationData(array $body): bool { try { if (Config::PRODUCT_MODE === Config::MODE_PROD) { $headers = ['Accept' => 'application/json']; $this->getHttpClient()->post( '/', [ 'form_params' => $body, 'headers' => $headers ] ); return true; } return false; } catch (Throwable $exception) { Logger::getLogger()->error($exception->getMessage()); Logger::getLogger()->error($exception->getTraceAsString()); return false; } } }