Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: introduce async method and wip inline types #100

Merged
merged 15 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions run_checks.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@
exit(1);
}

$eventPromise = $client->getEventAsync($request_id);
$eventPromise->then(function ($tuple) {
list($result, $response) = $tuple;
fwrite(STDOUT, sprintf("\n\nGot async event: %s \n", $response->getBody()->getContents()));
}, function($exception) {
fwrite(STDERR, sprintf("\n\nException when calling FingerprintApi->getVisits: %s\n", $exception->getMessage()));
exit(1);
})->wait();

$visitsPromise = $client->getVisitsAsync($visitor_id);
$visitsPromise->then(function($tuple) {
list($result, $response) = $tuple;
fwrite(STDOUT, sprintf("\n\nGot async visits: %s \n", $response->getBody()->getContents()));
}, function ($exception) {
fwrite(STDERR, sprintf("\n\nException when calling FingerprintApi->getVisits: %s\n", $exception->getMessage()));
exit(1);
})->wait();

// Enable the deprecated ArrayAccess return type warning again if needed
error_reporting(error_reporting() | E_DEPRECATED);

Expand Down
264 changes: 223 additions & 41 deletions src/Api/FingerprintApi.php

Large diffs are not rendered by default.

29 changes: 6 additions & 23 deletions src/ApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

namespace Fingerprint\ServerAPI;

use Psr\Http\Message\ResponseInterface;

/**
* ApiException Class Doc Comment.
*
Expand All @@ -39,38 +41,19 @@
*/
class ApiException extends \Exception
{
/**
* The deserialized response object.
*/
protected $responseObject;
protected ResponseInterface $responseObject;

/**
* Constructor.
*
* @param string $message Error message
* @param int $code HTTP status code
*/
public function __construct($message = '', $code = 0)
public function __construct(?string $message = '', ?int $code = 0)
{
parent::__construct($message, $code);
}

/**
* Sets the deseralized response object (during deserialization).
*
* @param mixed $obj Deserialized response object
*/
public function setResponseObject($obj)
public function setResponseObject(ResponseInterface $obj): void
{
$this->responseObject = $obj;
}

/**
* Gets the deseralized response object (during deserialization).
*
* @return mixed the deserialized response object
*/
public function getResponseObject()
public function getResponseObject(): ResponseInterface
{
return $this->responseObject;
}
Expand Down
Loading
Loading