Skip to content

Commit 202ba2e

Browse files
authored
Merge pull request #157 from Sysix/feature/print-layouts
Feature/print layouts
2 parents 25bc9d3 + 753df58 commit 202ba2e

File tree

6 files changed

+60
-1
lines changed

6 files changed

+60
-1
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ $response = $api->paymentCondition()->getAll();
183183
$response = $api->postingCategory()->getAll();
184184
```
185185

186+
### Print Layouts Endpoint
187+
```php
188+
$response = $api->printLayout()->getAll();
189+
```
190+
186191
### Profile Endpoint
187192
```php
188193
$response = $api->profile()->get();

src/Api.php

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Sysix\LexOffice\Clients\Payment;
2525
use Sysix\LexOffice\Clients\PaymentCondition;
2626
use Sysix\LexOffice\Clients\PostingCategory;
27+
use Sysix\LexOffice\Clients\PrintLayout;
2728
use Sysix\LexOffice\Clients\Profile;
2829
use Sysix\LexOffice\Clients\Quotation;
2930
use Sysix\LexOffice\Clients\RecurringTemplate;
@@ -149,6 +150,11 @@ public function postingCategory(): PostingCategory
149150
return new PostingCategory($this);
150151
}
151152

153+
public function printLayout(): PrintLayout
154+
{
155+
return new PrintLayout($this);
156+
}
157+
152158
public function profile(): Profile
153159
{
154160
return new Profile($this);

src/Clients/PrintLayout.php

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Sysix\LexOffice\Clients;
6+
7+
use Psr\Http\Message\ResponseInterface;
8+
use Sysix\LexOffice\BaseClient;
9+
10+
class PrintLayout extends BaseClient
11+
{
12+
protected string $resource = 'print-layouts';
13+
14+
public function getAll(): ResponseInterface
15+
{
16+
return $this->api->newRequest('GET', $this->resource)
17+
->getResponse();
18+
}
19+
}

src/Utils.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static function createStream(mixed $content): StreamInterface
8686
public static function createMultipartStream(array $content, string $boundary = null): MultipartStream
8787
{
8888
$stream = [];
89-
$boundary = $boundary ?: '--lexoffice';
89+
$boundary = !is_null($boundary) && $boundary !== '' ? $boundary : '--lexoffice';
9090

9191
foreach ($content as $key => $value) {
9292
$stream[] = [

tests/ApiTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Sysix\LexOffice\Clients\Payment;
2020
use Sysix\LexOffice\Clients\PaymentCondition;
2121
use Sysix\LexOffice\Clients\PostingCategory;
22+
use Sysix\LexOffice\Clients\PrintLayout;
2223
use Sysix\LexOffice\Clients\Profile;
2324
use Sysix\LexOffice\Clients\Quotation;
2425
use Sysix\LexOffice\Clients\RecurringTemplate;
@@ -52,6 +53,7 @@ public function testClients(): void
5253
$this->assertInstanceOf(Payment::class, $stub->payment());
5354
$this->assertInstanceOf(PaymentCondition::class, $stub->paymentCondition());
5455
$this->assertInstanceOf(PostingCategory::class, $stub->postingCategory());
56+
$this->assertInstanceOf(PrintLayout::class, $stub->printLayout());
5557
$this->assertInstanceOf(Profile::class, $stub->profile());
5658
$this->assertInstanceOf(Quotation::class, $stub->quotation());
5759
$this->assertInstanceOf(RecurringTemplate::class, $stub->recurringTemplate());

tests/Clients/PrintLayoutTest.php

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Sysix\LexOffice\Tests\Clients;
6+
7+
use Psr\Http\Message\ResponseInterface;
8+
use Sysix\LexOffice\Clients\PrintLayout;
9+
use Sysix\LexOffice\Tests\TestClient;
10+
11+
class PrintLayoutTest extends TestClient
12+
{
13+
public function testGetAll(): void
14+
{
15+
[$api, $stub] = $this->createClientMockObject(PrintLayout::class);
16+
17+
$response = $stub->getAll();
18+
19+
$this->assertInstanceOf(ResponseInterface::class, $response);
20+
21+
$this->assertEquals('GET', $api->getRequest()->getMethod());
22+
$this->assertEquals(
23+
$api->apiUrl . '/v1/print-layouts',
24+
$api->getRequest()->getUri()->__toString()
25+
);
26+
}
27+
}

0 commit comments

Comments
 (0)