Skip to content
This repository was archived by the owner on Aug 26, 2025. It is now read-only.

Commit 2a435ff

Browse files
committed
Adds invoice pdf download
1 parent 7cee2b4 commit 2a435ff

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Api/Api.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,14 @@ private function createJsonBody(array $parameters): ?string
117117
* @return mixed
118118
* @throws DomainException
119119
*/
120-
protected function handleResponse(ResponseInterface $response, string $class)
120+
protected function handleResponse(ResponseInterface $response, ?string $class = null)
121121
{
122122
$this->handleErrors($response);
123123

124+
if (null === $class) {
125+
return $response->getBody()->__toString();
126+
}
127+
124128
$response = $this->hydrator->hydrate($response, $class);
125129

126130
if ($response instanceof Collection) {

src/Api/InvoiceApi.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ public function invoice(int $id): Invoice
2121
return $this->handleResponse($response, InvoiceFactory::class);
2222
}
2323

24+
/**
25+
* @see https://apidocs.cuentica.com/versions/latest_release/#customer-id
26+
* @throws DomainException
27+
* @throws ClientExceptionInterface
28+
*/
29+
public function pdf(int $id): string
30+
{
31+
$response = $this->httpGet('/invoice/'.$id.'/pdf');
32+
33+
return $this->handleResponse($response);
34+
}
35+
2436
/**
2537
* @see https://apidocs.cuentica.com/versions/latest_release/#customer
2638
* @throws DomainException

0 commit comments

Comments
 (0)