Skip to content

Commit

Permalink
refactor: new logic for serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
Orkuncakilkaya committed Aug 9, 2024
1 parent ee54f5b commit 1840ba6
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 326 deletions.
17 changes: 15 additions & 2 deletions run_checks.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,45 @@

try {
list($result, $response) = $client->getVisits($visitor_id);
if($result->getVisitorId() !== $visitor_id) {
throw new Exception('Argument visitorId is not equal to deserialized getVisitorId');
}
fwrite(STDOUT, sprintf("Got visits: %s \n", $response->getBody()->getContents()));
} catch (Exception $e) {
fwrite(STDERR, sprintf("Exception when calling FingerprintApi->getVisits: %s\n", $e->getMessage()));
exit(1);
}

try {
/** @var $result \Fingerprint\ServerAPI\Model\EventResponse */
list($result, $response) = $client->getEvent($request_id);
if($result->getProducts()->getIdentification()->getData()->getRequestId() !== $request_id) {
throw new Exception('Argument requestId is not equal to deserialized getRequestId');
}
fwrite(STDOUT, sprintf("\n\nGot event: %s \n", $response->getBody()->getContents()));
} catch (Exception $e) {
fwrite(STDERR, sprintf("\n\nException when calling FingerprintApi->getVisits: %s\n", $e->getMessage()));
exit(1);
}

$eventPromise = $client->getEventAsync($request_id);
$eventPromise->then(function ($tuple) {
$eventPromise->then(function ($tuple) use($request_id) {
list($result, $response) = $tuple;
if($result->getProducts()->getIdentification()->getData()->getRequestId() !== $request_id) {
throw new Exception('Argument requestId is not equal to deserialized getRequestId');
}
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) {
$visitsPromise->then(function($tuple) use($visitor_id) {
list($result, $response) = $tuple;
if($result->getVisitorId() !== $visitor_id) {
throw new Exception('Argument visitorId is not equal to deserialized getVisitorId');
}
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()));
Expand Down
Loading

0 comments on commit 1840ba6

Please sign in to comment.