Skip to content

Commit

Permalink
Created new Service to retrieve document pdf base64 stream
Browse files Browse the repository at this point in the history
  • Loading branch information
vekkon committed Jan 14, 2024
1 parent a784218 commit a710c73
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Service/DocumentService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Vin\ShopwareSdk\Service;

class DocumentService extends ApiService
{
private const DOCUMENT_DOWNLOAD_ENDPOINT = '/api/_action/document/%s/%s?download=1';
private const INVOICE_DOCUMENT_CREATE_ENDPOINT = '/api/_action/document/invoice/create';

public function downloadDocumentPdfByIdAndDeepLink($documentId, $documentDeeplink)
{
$path = sprintf(self::DOCUMENT_DOWNLOAD_ENDPOINT, $documentId, $documentDeeplink);

$response = $this->httpClient->get(
$this->getFullUrl($path),
[
'headers' => $this->getBasicHeaders(),
]
);

return $response->getBody()->getContents();
}
}

0 comments on commit a710c73

Please sign in to comment.