From d5a187fae794c7d3c90defbc6357c47b4d4c958c Mon Sep 17 00:00:00 2001 From: Sysix Date: Tue, 21 May 2024 22:35:19 +0200 Subject: [PATCH 1/3] add print-layouts endpoint --- src/Clients/PrintLayout.php | 19 +++++++++++++++++++ tests/Clients/PrintLayoutTest.php | 27 +++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 src/Clients/PrintLayout.php create mode 100644 tests/Clients/PrintLayoutTest.php diff --git a/src/Clients/PrintLayout.php b/src/Clients/PrintLayout.php new file mode 100644 index 0000000..8c7ba23 --- /dev/null +++ b/src/Clients/PrintLayout.php @@ -0,0 +1,19 @@ +api->newRequest('GET', $this->resource) + ->getResponse(); + } +} diff --git a/tests/Clients/PrintLayoutTest.php b/tests/Clients/PrintLayoutTest.php new file mode 100644 index 0000000..5cd7972 --- /dev/null +++ b/tests/Clients/PrintLayoutTest.php @@ -0,0 +1,27 @@ +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() + ); + } +} From 3d8040afd97c1b0f28e44b3cdf4560065aba7190 Mon Sep 17 00:00:00 2001 From: Sysix Date: Tue, 21 May 2024 22:40:04 +0200 Subject: [PATCH 2/3] add print layouts Api method + readme --- README.md | 5 +++++ src/Api.php | 6 ++++++ tests/ApiTest.php | 2 ++ 3 files changed, 13 insertions(+) diff --git a/README.md b/README.md index febb85a..686546f 100644 --- a/README.md +++ b/README.md @@ -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(); diff --git a/src/Api.php b/src/Api.php index bd83a41..677f884 100644 --- a/src/Api.php +++ b/src/Api.php @@ -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; @@ -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); diff --git a/tests/ApiTest.php b/tests/ApiTest.php index d01ff01..e8ce60c 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -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; @@ -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()); From 753df58ffe0876bc3d635880444f97696d8f9343 Mon Sep 17 00:00:00 2001 From: Sysix Date: Tue, 21 May 2024 22:44:02 +0200 Subject: [PATCH 3/3] fix RiskyTruthyFalsyComparison --- src/Utils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utils.php b/src/Utils.php index 35eb4ab..a669f58 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -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[] = [