Skip to content

Commit

Permalink
Merge pull request #157 from Sysix/feature/print-layouts
Browse files Browse the repository at this point in the history
Feature/print layouts
  • Loading branch information
Sysix authored May 21, 2024
2 parents 25bc9d3 + 753df58 commit 202ba2e
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ $response = $api->paymentCondition()->getAll();
$response = $api->postingCategory()->getAll();
```

### Print Layouts Endpoint
```php
$response = $api->printLayout()->getAll();
```

### Profile Endpoint
```php
$response = $api->profile()->get();
Expand Down
6 changes: 6 additions & 0 deletions src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Sysix\LexOffice\Clients\Payment;
use Sysix\LexOffice\Clients\PaymentCondition;
use Sysix\LexOffice\Clients\PostingCategory;
use Sysix\LexOffice\Clients\PrintLayout;
use Sysix\LexOffice\Clients\Profile;
use Sysix\LexOffice\Clients\Quotation;
use Sysix\LexOffice\Clients\RecurringTemplate;
Expand Down Expand Up @@ -149,6 +150,11 @@ public function postingCategory(): PostingCategory
return new PostingCategory($this);
}

public function printLayout(): PrintLayout
{
return new PrintLayout($this);
}

public function profile(): Profile
{
return new Profile($this);
Expand Down
19 changes: 19 additions & 0 deletions src/Clients/PrintLayout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace Sysix\LexOffice\Clients;

use Psr\Http\Message\ResponseInterface;
use Sysix\LexOffice\BaseClient;

class PrintLayout extends BaseClient
{
protected string $resource = 'print-layouts';

public function getAll(): ResponseInterface
{
return $this->api->newRequest('GET', $this->resource)
->getResponse();
}
}
2 changes: 1 addition & 1 deletion src/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static function createStream(mixed $content): StreamInterface
public static function createMultipartStream(array $content, string $boundary = null): MultipartStream
{
$stream = [];
$boundary = $boundary ?: '--lexoffice';
$boundary = !is_null($boundary) && $boundary !== '' ? $boundary : '--lexoffice';

foreach ($content as $key => $value) {
$stream[] = [
Expand Down
2 changes: 2 additions & 0 deletions tests/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Sysix\LexOffice\Clients\Payment;
use Sysix\LexOffice\Clients\PaymentCondition;
use Sysix\LexOffice\Clients\PostingCategory;
use Sysix\LexOffice\Clients\PrintLayout;
use Sysix\LexOffice\Clients\Profile;
use Sysix\LexOffice\Clients\Quotation;
use Sysix\LexOffice\Clients\RecurringTemplate;
Expand Down Expand Up @@ -52,6 +53,7 @@ public function testClients(): void
$this->assertInstanceOf(Payment::class, $stub->payment());
$this->assertInstanceOf(PaymentCondition::class, $stub->paymentCondition());
$this->assertInstanceOf(PostingCategory::class, $stub->postingCategory());
$this->assertInstanceOf(PrintLayout::class, $stub->printLayout());
$this->assertInstanceOf(Profile::class, $stub->profile());
$this->assertInstanceOf(Quotation::class, $stub->quotation());
$this->assertInstanceOf(RecurringTemplate::class, $stub->recurringTemplate());
Expand Down
27 changes: 27 additions & 0 deletions tests/Clients/PrintLayoutTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace Sysix\LexOffice\Tests\Clients;

use Psr\Http\Message\ResponseInterface;
use Sysix\LexOffice\Clients\PrintLayout;
use Sysix\LexOffice\Tests\TestClient;

class PrintLayoutTest extends TestClient
{
public function testGetAll(): void
{
[$api, $stub] = $this->createClientMockObject(PrintLayout::class);

$response = $stub->getAll();

$this->assertInstanceOf(ResponseInterface::class, $response);

$this->assertEquals('GET', $api->getRequest()->getMethod());
$this->assertEquals(
$api->apiUrl . '/v1/print-layouts',
$api->getRequest()->getUri()->__toString()
);
}
}

0 comments on commit 202ba2e

Please sign in to comment.