Skip to content

Commit 9bfaeaf

Browse files
adamzelyczslischka
authored andcommitted
#19 Allow to pass API parameters in the Invoices::getPdf
1 parent bb330f0 commit 9bfaeaf

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/Fapi/FapiClient/EndPoints/Invoices.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@ public function __construct(FapiRestClient $client)
2727
$this->resources = 'invoices';
2828
}
2929

30-
public function getPdf(int $id)
30+
/**
31+
* @param int $id
32+
* @param mixed[] $parameters
33+
* @return string|null
34+
*/
35+
public function getPdf(int $id, array $parameters = [])
3136
{
32-
return $this->client->getInvoicePdf($id);
37+
return $this->client->getInvoicePdf($id, $parameters);
3338
}
3439

3540
/**

src/Fapi/FapiClient/Rest/FapiRestClient.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,18 @@ public function generateQrCode(int $id): array
223223

224224
/**
225225
* @param int $id
226+
* @param mixed[] $parameters
226227
* @return string|null
227228
*/
228-
public function getInvoicePdf(int $id)
229+
public function getInvoicePdf(int $id, array $parameters = [])
229230
{
230-
$httpResponse = $this->sendHttpRequest(HttpMethod::GET, '/invoices/' . $id . '.pdf');
231+
$path = '/invoices/' . $id . '.pdf';
232+
233+
if ($parameters) {
234+
$path .= '?' . $this->formatUrlParameters($parameters);
235+
}
236+
237+
$httpResponse = $this->sendHttpRequest(HttpMethod::GET, $path);
231238

232239
if ($httpResponse->getStatusCode() === HttpStatusCode::S200_OK) {
233240
return (string) $httpResponse->getBody();

0 commit comments

Comments
 (0)