From 6343975e77ca30a29a880a9fd0f5484985c3f09c Mon Sep 17 00:00:00 2001 From: Maximilian Ruta Date: Sat, 12 Nov 2022 18:21:51 +0100 Subject: [PATCH] For some installations the OroCRM user is optional --- src/OroApiClient.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/OroApiClient.php b/src/OroApiClient.php index 15acd71..4aeee4a 100644 --- a/src/OroApiClient.php +++ b/src/OroApiClient.php @@ -48,7 +48,7 @@ class OroApiClient */ protected string $apiEndpoint; - protected string $user; + protected ?string $user = null; /** * @var AuthorizationEndpoint @@ -194,9 +194,9 @@ public function setUser(string $user): OroApiClient } /** - * @return string + * @return null|string */ - public function getUser(): string + public function getUser(): ?string { return $this->user; } @@ -273,7 +273,11 @@ public function performHttpCallAuthorization(string $httpMethod, string $apiMeth */ public function performHttpCall(string $httpMethod, string $apiMethod, string $httpBody = null): ?stdClass { - $url = $this->apiEndpoint . "/" . $this->user . "/" . $apiMethod; + if ($this->user !== null) { + $url = $this->apiEndpoint . "/" . $this->user . "/" . $apiMethod; + } else { + $url = $this->apiEndpoint . "/" . $apiMethod; + } return $this->performHttpCallToFullUrl($httpMethod, $url, $httpBody); }