Skip to content

Commit

Permalink
solved #36 Client - support find last item from evidence
Browse files Browse the repository at this point in the history
  • Loading branch information
pekral committed Nov 18, 2020
1 parent 1b99134 commit 557905c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}

}
15 changes: 15 additions & 0 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 557905c

Please sign in to comment.