diff --git a/.changeset/hip-experts-wink.md b/.changeset/hip-experts-wink.md new file mode 100644 index 0000000..18b7d61 --- /dev/null +++ b/.changeset/hip-experts-wink.md @@ -0,0 +1,5 @@ +--- +"fingerprint-pro-server-api-php-sdk": patch +--- + +Mark nullable types as an optional, will fix #123 diff --git a/src/Model/SeenAt.php b/src/Model/SeenAt.php index f6b4148..dcfc08f 100644 --- a/src/Model/SeenAt.php +++ b/src/Model/SeenAt.php @@ -202,7 +202,7 @@ public function valid(): bool /** * Gets global. */ - public function getGlobal(): \DateTime + public function getGlobal(): ?\DateTime { return $this->container['global']; } @@ -214,7 +214,7 @@ public function getGlobal(): \DateTime * * @return $this */ - public function setGlobal(\DateTime $global): self + public function setGlobal(?\DateTime $global): self { $this->container['global'] = $global; @@ -224,7 +224,7 @@ public function setGlobal(\DateTime $global): self /** * Gets subscription. */ - public function getSubscription(): \DateTime + public function getSubscription(): ?\DateTime { return $this->container['subscription']; } @@ -236,7 +236,7 @@ public function getSubscription(): \DateTime * * @return $this */ - public function setSubscription(\DateTime $subscription): self + public function setSubscription(?\DateTime $subscription): self { $this->container['subscription'] = $subscription; diff --git a/template/model_generic.mustache b/template/model_generic.mustache index 34b3bcf..b7abd04 100644 --- a/template/model_generic.mustache +++ b/template/model_generic.mustache @@ -248,7 +248,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa * Gets {{name}} * @return {{^required}}?{{/required}}{{datatype}} */ - public function {{getter}}(): {{^required}}?{{/required}}{{^isListContainer}}{{^isMapContainer}}{{^isDouble}}{{datatype}}{{/isDouble}}{{/isMapContainer}}{{/isListContainer}}{{#isListContainer}}array{{/isListContainer}}{{#isMapContainer}}array{{/isMapContainer}}{{#isDouble}}float{{/isDouble}} + public function {{getter}}(): {{^required}}?{{/required}}{{#required}}{{#nullable}}?{{/nullable}}{{/required}}{{^isListContainer}}{{^isMapContainer}}{{^isDouble}}{{datatype}}{{/isDouble}}{{/isMapContainer}}{{/isListContainer}}{{#isListContainer}}array{{/isListContainer}}{{#isMapContainer}}array{{/isMapContainer}}{{#isDouble}}float{{/isDouble}} { return $this->container['{{name}}']; } @@ -260,7 +260,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa * * @return $this */ - public function {{setter}}({{^required}}?{{/required}}{{^isListContainer}}{{^isMapContainer}}{{^isDouble}}{{datatype}}{{/isDouble}}{{/isMapContainer}}{{/isListContainer}}{{#isListContainer}}array{{/isListContainer}}{{#isMapContainer}}array{{/isMapContainer}}{{#isDouble}}float{{/isDouble}} ${{name}}): self + public function {{setter}}({{^required}}?{{/required}}{{#required}}{{#nullable}}?{{/nullable}}{{/required}}{{^isListContainer}}{{^isMapContainer}}{{^isDouble}}{{datatype}}{{/isDouble}}{{/isMapContainer}}{{/isListContainer}}{{#isListContainer}}array{{/isListContainer}}{{#isMapContainer}}array{{/isMapContainer}}{{#isDouble}}float{{/isDouble}} ${{name}}): self { {{#isEnum}} $allowedValues = $this->{{getter}}AllowableValues(); diff --git a/test/FingerprintApiTest.php b/test/FingerprintApiTest.php index aec3f7c..48e8ac0 100644 --- a/test/FingerprintApiTest.php +++ b/test/FingerprintApiTest.php @@ -198,6 +198,17 @@ public function testGetEventRawResponse() $this->assertEquals($mockedResult, \GuzzleHttp\json_decode($response->getBody()->getContents())); } + public function testGetEventNullableSeenAt() + { + $this->mockHandler->reset(); + $this->mockHandler->append($this->getMockResponse(self::MOCK_REQUEST_ID)); + + list($event, $response) = $this->fingerprint_api->getEvent(self::MOCK_REQUEST_ID); + $products = $event->getProducts(); + $seenAt = $products->getIdentification()->getData()->getLastSeenAt(); + $this->assertEquals(null, $seenAt->getGlobal()); + } + public function testGetVisitsRawResponse() { $this->mockHandler->reset();