Skip to content

Commit

Permalink
clean(ZMSKVR): cleanup zmsclient Http request class
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Fink authored and Thomas Fink committed Feb 14, 2025
1 parent 3fb8849 commit 71e2ee3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static function getOffices(): ProviderList
}
return $list;
} catch (\Exception $e) {
ExceptionService::handleException($e, __FUNCTION__);
ExceptionService::handleException($e);
}
}

Expand All @@ -69,7 +69,7 @@ public static function getScopes(): ScopeList
}
return $list;
} catch (\Exception $e) {
ExceptionService::handleException($e, __FUNCTION__);
ExceptionService::handleException($e);
}
}

Expand All @@ -83,7 +83,7 @@ public static function getServices(): RequestList
}
return $list;
} catch (\Exception $e) {
ExceptionService::handleException($e, __FUNCTION__);
ExceptionService::handleException($e);
}
}

Expand All @@ -97,7 +97,7 @@ public static function getRequestRelationList(): RequestRelationList
}
return $list;
} catch (\Exception $e) {
ExceptionService::handleException($e, __FUNCTION__);
ExceptionService::handleException($e);
}
}

Expand All @@ -116,7 +116,7 @@ public static function getFreeDays(ProviderList $providers, RequestList $request
}
return $entity;
} catch (\Exception $e) {
ExceptionService::handleException($e, __FUNCTION__);
ExceptionService::handleException($e);
}
}

Expand All @@ -136,7 +136,7 @@ public static function getFreeTimeslots(ProviderList $providers, RequestList $re

return $collection;
} catch (\Exception $e) {
ExceptionService::handleException($e, __FUNCTION__);
ExceptionService::handleException($e);
}
}

Expand Down Expand Up @@ -174,7 +174,7 @@ public static function reserveTimeslot(Process $appointmentProcess, array $servi
}
return $entity;
} catch (\Exception $e) {
ExceptionService::handleException($e, __FUNCTION__);
ExceptionService::handleException($e);
}
}

Expand All @@ -189,7 +189,7 @@ public static function submitClientData(Process $process): Process
}
return $entity;
} catch (\Exception $e) {
ExceptionService::handleException($e, __FUNCTION__);
ExceptionService::handleException($e);
}
}

Expand All @@ -204,7 +204,7 @@ public static function preconfirmProcess(Process $process): Process
}
return $entity;
} catch (\Exception $e) {
ExceptionService::handleException($e, __FUNCTION__);
ExceptionService::handleException($e);
}
}

Expand All @@ -219,23 +219,22 @@ public static function confirmProcess(Process $process): Process
}
return $entity;
} catch (\Exception $e) {
ExceptionService::handleException($e, __FUNCTION__);
ExceptionService::handleException($e);
}
}

public static function cancelAppointment(Process $process): Process
{
try {
$url = "/process/{$process->id}/{$process->authKey}/";
$result = \App::$http->readDeleteResult($url, [], null);
// Changed to match test expectations
$result = \App::$http->readDeleteResult($url, []);
$entity = $result?->getEntity();
if (!$entity instanceof Process) {
return new Process();
}
return $entity;
} catch (\Exception $e) {
ExceptionService::handleException($e, __FUNCTION__);
ExceptionService::handleException($e);
}
}

Expand All @@ -250,7 +249,7 @@ public static function sendConfirmationEmail(Process $process): Process
}
return $entity;
} catch (\Exception $e) {
ExceptionService::handleException($e, __FUNCTION__);
ExceptionService::handleException($e);
}
}

Expand All @@ -265,7 +264,7 @@ public static function sendPreconfirmationEmail(Process $process): Process
}
return $entity;
} catch (\Exception $e) {
ExceptionService::handleException($e, __FUNCTION__);
ExceptionService::handleException($e);
}
}

Expand All @@ -280,7 +279,7 @@ public static function sendCancelationEmail(Process $process): Process
}
return $entity;
} catch (\Exception $e) {
ExceptionService::handleException($e, __FUNCTION__);
ExceptionService::handleException($e);
}
}

Expand All @@ -297,7 +296,7 @@ public static function getProcessById(int $processId, string $authKey): Process
}
return $entity;
} catch (\Exception $e) {
ExceptionService::handleException($e, __FUNCTION__);
ExceptionService::handleException($e);
}
}

Expand All @@ -314,7 +313,7 @@ public static function getScopesByProviderId(string $source, string|int $provide
}
return $result;
} catch (\Exception $e) {
ExceptionService::handleException($e, __FUNCTION__);
ExceptionService::handleException($e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ public function testCancelAppointmentSuccess(): void

$this->httpMock->expects($this->once())
->method('readDeleteResult')
->with('/process/1/test/', [], null)
->with('/process/1/test/', [])
->willReturn($result);

$result = ZmsApiClientService::cancelAppointment($process);
Expand Down
23 changes: 12 additions & 11 deletions zmsclient/src/Zmsclient/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\UriInterface;
use Psr\Http\Client\ClientInterface;
use Slim\Psr7\Headers;

/**
Expand All @@ -15,7 +16,7 @@
class Http
{
/**
* @var Psr7\ClientInterface|null
* @var ClientInterface|null
*/
protected $client = null;

Expand Down Expand Up @@ -64,9 +65,9 @@ class Http

/**
*
* @param Psr7\ClientInterface $client
* @param Psr7\Response $client
*/
public function __construct($baseUrl, Psr7\ClientInterface $client = null)
public function __construct($baseUrl, Psr7\Response $client = null)
{
$this->http_baseurl = parse_url($baseUrl, PHP_URL_PATH) ?? '';
$this->uri = new Psr7\Uri();
Expand Down Expand Up @@ -106,7 +107,7 @@ public function getUserInfo()
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function readResponse(\Psr\Http\Message\RequestInterface $request)
public function readResponse(RequestInterface $request)
{
if (static::$authEnabled) {
$request = $this->getAuthorizedRequest($request);
Expand All @@ -132,7 +133,7 @@ public function readResponse(\Psr\Http\Message\RequestInterface $request)
*
* @return \Psr\Http\Message\RequestInterface
*/
public function getAuthorizedRequest(\Psr\Http\Message\RequestInterface $request)
public function getAuthorizedRequest(RequestInterface $request)
{
$userInfo = $request->getUri()->getUserInfo();
$xAuthKey = Auth::getKey();
Expand Down Expand Up @@ -166,7 +167,7 @@ public function setWorkflowKey($apikeyString)
/**
* Creates a GET-Http-Request and fetches the response
*
* @param String $relativeUrl
* @param string $relativeUrl
* @param array|null $getParameters (optional)
*
* @return Result
Expand All @@ -189,9 +190,9 @@ public function readGetResult($relativeUrl, array $getParameters = null, $xToken
/**
* Creates a POST-Http-Request and fetches the response
*
* @param String $relativeUrl
* @param string $relativeUrl
* @param \BO\Zmsentities\Schema\Entity $entity
* @param Array $getParameters (optional)
* @param array $getParameters (optional)
*
* @return Result
*/
Expand All @@ -212,8 +213,8 @@ public function readPostResult($relativeUrl, $entity, array $getParameters = nul
/**
* Creates a DELETE-Http-Request and fetches the response
*
* @param String $relativeUrl
* @param Array $getParameters (optional)
* @param string $relativeUrl
* @param array $getParameters (optional)
*
* @return Result
*/
Expand All @@ -228,7 +229,7 @@ public function readDeleteResult($relativeUrl, array $getParameters = null)
}

protected function readResult(
\Psr\Http\Message\RequestInterface $request = null,
RequestInterface $request = null,
$try = 0
) {
$response = $this->readResponse($request);
Expand Down

0 comments on commit 71e2ee3

Please sign in to comment.