diff --git a/README.md b/README.md index 5f6f2c2..78c37d0 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ Vrácení prázného záznamu, pokud neexistuje ve Flexibee (bez vyhození výji ``` $evidenceItem = $client->findById($evidenceItemId, $uriParameters); $evidenceItem = $client->findByCode($evidenceItemCode, $uriParameters); +$evidenceItem = $client->findLastInEvidence($evidenceItemCode, $uriParameters); ``` ## Sumace diff --git a/src/Client.php b/src/Client.php index 939af77..0275869 100644 --- a/src/Client.php +++ b/src/Client.php @@ -480,4 +480,18 @@ public function getPdfById(int $id, array $uriParameters): Response ); } + public function findLastInEvidence(bool $fullDetail): Response + { + return $this->httpClient->request( + $this->queryBuilder->createUriByEvidenceOnly( + ['order' => 'id', 'limit' => 1, 'detail' => $fullDetail ? 'full' : 'summary'], + ), + Method::get(Method::GET), + [], + [], + [], + $this->config, + ); + } + } diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 34aa481..094fa20 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -250,6 +250,21 @@ public function testSearchInEvidence(): void $client->searchInEvidence('kod neq \'JAN\'', []); } + public function testFindLastInEvidence(): void + { + $client = new Client( + Config::HOST, + Config::COMPANY, + Config::USERNAME, + Config::PASSWORD, + 'faktura-vydana', + false, + null, + ); + $result = $client->findLastInEvidence(true); + Assert::assertCount(1, $result->getData()['faktura-vydana']); + } + public function testSearchInEvidenceWithInvalidUrl(): void { $client = new Client(