Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/print layouts #157

Merged
merged 3 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
);
}
}
Loading