From 13069b57389c8726d001084951e46a48927d1b2a Mon Sep 17 00:00:00 2001 From: Tomas Smetka Date: Sat, 27 Dec 2025 19:45:26 +0100 Subject: [PATCH 1/4] Add LICENSE and update metadata --- LICENSE | 21 +++++++++++++++++++++ README.md | 6 +++++- composer.json | 8 +++++++- 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c4de03f --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Pobo + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 94db89b..efb7a21 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # Pobo PHP SDK +[![Tests](https://github.com/pobo-builder/php-sdk/actions/workflows/tests.yml/badge.svg)](https://github.com/pobo-builder/php-sdk/actions/workflows/tests.yml) +[![Latest Stable Version](https://poser.pugx.org/pobo-builder/php-sdk/v/stable)](https://packagist.org/packages/pobo-builder/php-sdk) +[![License](https://poser.pugx.org/pobo-builder/php-sdk/license)](https://packagist.org/packages/pobo-builder/php-sdk) + Official PHP SDK for [Pobo API V2](https://api.pobo.space) - product content management and webhooks. ## Requirements @@ -11,7 +15,7 @@ Official PHP SDK for [Pobo API V2](https://api.pobo.space) - product content man ## Installation ```bash -composer require pobo/php-sdk +composer require pobo-builder/php-sdk ``` ## Quick Start diff --git a/composer.json b/composer.json index c56090d..7f18bac 100644 --- a/composer.json +++ b/composer.json @@ -10,12 +10,18 @@ "ecommerce", "product-content" ], + "homepage": "https://github.com/pobo-builder/php-sdk", "authors": [ { "name": "Pobo", - "email": "support@pobo.cz" + "email": "support@pobo.cz", + "homepage": "https://pobo.cz" } ], + "support": { + "issues": "https://github.com/pobo-builder/php-sdk/issues", + "source": "https://github.com/pobo-builder/php-sdk" + }, "require": { "php": "^8.1", "ext-curl": "*", From 3ad1baaac42487660c8ff34b103cbe0bed7cd6c0 Mon Sep 17 00:00:00 2001 From: Tomas Smetka Date: Sat, 27 Dec 2025 19:47:15 +0100 Subject: [PATCH 2/4] Change e-mail --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7f18bac..2564fce 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "authors": [ { "name": "Pobo", - "email": "support@pobo.cz", + "email": "tomas@pobo.cz", "homepage": "https://pobo.cz" } ], From 75b342f63f64ba6c3c00c7d140a5c40e2edd7c79 Mon Sep 17 00:00:00 2001 From: Tomas Smetka Date: Sat, 27 Dec 2025 19:49:56 +0100 Subject: [PATCH 3/4] Fix PHP 8.1 compatibility - use readonly properties instead of readonly class --- src/DTO/Category.php | 24 ++++++++++++------------ src/DTO/ImportResult.php | 16 ++++++++-------- src/DTO/LocalizedString.php | 4 ++-- src/DTO/PaginatedResponse.php | 10 +++++----- src/DTO/Parameter.php | 8 ++++---- src/DTO/ParameterValue.php | 6 +++--- src/DTO/Product.php | 34 +++++++++++++++++----------------- src/DTO/WebhookPayload.php | 8 ++++---- 8 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/DTO/Category.php b/src/DTO/Category.php index e0e6eb9..a1a0e57 100644 --- a/src/DTO/Category.php +++ b/src/DTO/Category.php @@ -4,23 +4,23 @@ namespace Pobo\Sdk\DTO; -readonly class Category +final class Category { /** * @param array $images */ public function __construct( - public string $id, - public bool $isVisible, - public LocalizedString $name, - public LocalizedString $url, - public ?LocalizedString $description = null, - public ?LocalizedString $seoTitle = null, - public ?LocalizedString $seoDescription = null, - public array $images = [], - public ?string $guid = null, - public ?\DateTimeInterface $createdAt = null, - public ?\DateTimeInterface $updatedAt = null, + public readonly string $id, + public readonly bool $isVisible, + public readonly LocalizedString $name, + public readonly LocalizedString $url, + public readonly ?LocalizedString $description = null, + public readonly ?LocalizedString $seoTitle = null, + public readonly ?LocalizedString $seoDescription = null, + public readonly array $images = [], + public readonly ?string $guid = null, + public readonly ?\DateTimeInterface $createdAt = null, + public readonly ?\DateTimeInterface $updatedAt = null, ) { } diff --git a/src/DTO/ImportResult.php b/src/DTO/ImportResult.php index dc32ebf..4ed85da 100644 --- a/src/DTO/ImportResult.php +++ b/src/DTO/ImportResult.php @@ -4,19 +4,19 @@ namespace Pobo\Sdk\DTO; -readonly class ImportResult +final class ImportResult { /** * @param array}> $errors */ public function __construct( - public bool $success, - public int $imported, - public int $updated, - public int $skipped, - public array $errors = [], - public ?int $valuesImported = null, - public ?int $valuesUpdated = null, + public readonly bool $success, + public readonly int $imported, + public readonly int $updated, + public readonly int $skipped, + public readonly array $errors = [], + public readonly ?int $valuesImported = null, + public readonly ?int $valuesUpdated = null, ) { } diff --git a/src/DTO/LocalizedString.php b/src/DTO/LocalizedString.php index e44b768..13ed2d5 100644 --- a/src/DTO/LocalizedString.php +++ b/src/DTO/LocalizedString.php @@ -6,13 +6,13 @@ use Pobo\Sdk\Enum\Language; -readonly class LocalizedString +final class LocalizedString { /** * @param array $values */ public function __construct( - private array $values, + private readonly array $values, ) { } diff --git a/src/DTO/PaginatedResponse.php b/src/DTO/PaginatedResponse.php index a6c2a62..56cfcf1 100644 --- a/src/DTO/PaginatedResponse.php +++ b/src/DTO/PaginatedResponse.php @@ -4,16 +4,16 @@ namespace Pobo\Sdk\DTO; -readonly class PaginatedResponse +final class PaginatedResponse { /** * @param array $data */ public function __construct( - public array $data, - public int $currentPage, - public int $perPage, - public int $total, + public readonly array $data, + public readonly int $currentPage, + public readonly int $perPage, + public readonly int $total, ) { } diff --git a/src/DTO/Parameter.php b/src/DTO/Parameter.php index 54824c0..6ff0761 100644 --- a/src/DTO/Parameter.php +++ b/src/DTO/Parameter.php @@ -4,15 +4,15 @@ namespace Pobo\Sdk\DTO; -readonly class Parameter +final class Parameter { /** * @param array $values */ public function __construct( - public int $id, - public string $name, - public array $values, + public readonly int $id, + public readonly string $name, + public readonly array $values, ) { } diff --git a/src/DTO/ParameterValue.php b/src/DTO/ParameterValue.php index e9a57c0..b45a94b 100644 --- a/src/DTO/ParameterValue.php +++ b/src/DTO/ParameterValue.php @@ -4,11 +4,11 @@ namespace Pobo\Sdk\DTO; -readonly class ParameterValue +final class ParameterValue { public function __construct( - public int $id, - public string $value, + public readonly int $id, + public readonly string $value, ) { } diff --git a/src/DTO/Product.php b/src/DTO/Product.php index 8e09015..3060aa7 100644 --- a/src/DTO/Product.php +++ b/src/DTO/Product.php @@ -4,7 +4,7 @@ namespace Pobo\Sdk\DTO; -readonly class Product +final class Product { /** * @param array $images @@ -13,22 +13,22 @@ * @param array}> $categories */ public function __construct( - public string $id, - public bool $isVisible, - public LocalizedString $name, - public LocalizedString $url, - public ?LocalizedString $shortDescription = null, - public ?LocalizedString $description = null, - public ?LocalizedString $seoTitle = null, - public ?LocalizedString $seoDescription = null, - public array $images = [], - public array $categoriesIds = [], - public array $parametersIds = [], - public ?string $guid = null, - public ?bool $isLoaded = null, - public array $categories = [], - public ?\DateTimeInterface $createdAt = null, - public ?\DateTimeInterface $updatedAt = null, + public readonly string $id, + public readonly bool $isVisible, + public readonly LocalizedString $name, + public readonly LocalizedString $url, + public readonly ?LocalizedString $shortDescription = null, + public readonly ?LocalizedString $description = null, + public readonly ?LocalizedString $seoTitle = null, + public readonly ?LocalizedString $seoDescription = null, + public readonly array $images = [], + public readonly array $categoriesIds = [], + public readonly array $parametersIds = [], + public readonly ?string $guid = null, + public readonly ?bool $isLoaded = null, + public readonly array $categories = [], + public readonly ?\DateTimeInterface $createdAt = null, + public readonly ?\DateTimeInterface $updatedAt = null, ) { } diff --git a/src/DTO/WebhookPayload.php b/src/DTO/WebhookPayload.php index f6d4938..e8f3dc6 100644 --- a/src/DTO/WebhookPayload.php +++ b/src/DTO/WebhookPayload.php @@ -6,12 +6,12 @@ use Pobo\Sdk\Enum\WebhookEvent; -readonly class WebhookPayload +final class WebhookPayload { public function __construct( - public WebhookEvent $event, - public \DateTimeInterface $timestamp, - public int $eshopId, + public readonly WebhookEvent $event, + public readonly \DateTimeInterface $timestamp, + public readonly int $eshopId, ) { } From ce64d86936c5bf8d3634fb757e4c9de49d421aac Mon Sep 17 00:00:00 2001 From: Tomas Smetka Date: Sat, 27 Dec 2025 19:54:21 +0100 Subject: [PATCH 4/4] Fix README --- README.md | 143 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 87 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index efb7a21..87c4e2a 100644 --- a/README.md +++ b/README.md @@ -63,16 +63,35 @@ Import categories second (no dependencies). ```php use Pobo\Sdk\DTO\Category; use Pobo\Sdk\DTO\LocalizedString; +use Pobo\Sdk\Enum\Language; -$category = new Category( - id: 'CAT-001', - isVisible: true, - name: LocalizedString::create('Electronics'), - url: LocalizedString::create('https://example.com/electronics'), - description: LocalizedString::create('

All electronics

'), -); - -$result = $client->importCategories([$category]); +$categories = [ + new Category( + id: 'CAT-001', + isVisible: true, + name: LocalizedString::create('Electronics') + ->withTranslation(Language::CS, 'Elektronika') + ->withTranslation(Language::SK, 'Elektronika'), + url: LocalizedString::create('https://example.com/electronics') + ->withTranslation(Language::CS, 'https://example.com/cs/elektronika') + ->withTranslation(Language::SK, 'https://example.com/sk/elektronika'), + description: LocalizedString::create('

All electronics

'), + images: ['https://example.com/images/electronics.jpg'], + ), + new Category( + id: 'CAT-002', + isVisible: true, + name: LocalizedString::create('Phones') + ->withTranslation(Language::CS, 'Telefony') + ->withTranslation(Language::SK, 'Telefóny'), + url: LocalizedString::create('https://example.com/phones') + ->withTranslation(Language::CS, 'https://example.com/cs/telefony') + ->withTranslation(Language::SK, 'https://example.com/sk/telefony'), + ), +]; + +$result = $client->importCategories($categories); +echo sprintf('Imported: %d, Updated: %d', $result->imported, $result->updated); ``` ### Import Products @@ -84,35 +103,47 @@ use Pobo\Sdk\DTO\Product; use Pobo\Sdk\DTO\LocalizedString; use Pobo\Sdk\Enum\Language; -// Using DTO objects -$product = new Product( - id: 'PROD-001', - isVisible: true, - name: LocalizedString::create('iPhone 15') - ->withTranslation(Language::SK, 'iPhone 15') - ->withTranslation(Language::EN, 'iPhone 15'), - url: LocalizedString::create('https://example.com/iphone-15') - ->withTranslation(Language::SK, 'https://example.com/sk/iphone-15'), - shortDescription: LocalizedString::create('Latest iPhone model'), - images: [ - 'https://example.com/images/iphone-1.jpg', - 'https://example.com/images/iphone-2.jpg', - ], - categoriesIds: ['CAT-001', 'CAT-002'], - parametersIds: [1, 2, 3], -); - -$result = $client->importProducts([$product]); - -// Or using arrays -$result = $client->importProducts([ - [ - 'id' => 'PROD-002', - 'is_visible' => true, - 'name' => ['default' => 'Samsung Galaxy S24'], - 'url' => ['default' => 'https://example.com/samsung-s24'], - ], -]); +$products = [ + new Product( + id: 'PROD-001', + isVisible: true, + name: LocalizedString::create('iPhone 15') + ->withTranslation(Language::CS, 'iPhone 15') + ->withTranslation(Language::SK, 'iPhone 15'), + url: LocalizedString::create('https://example.com/iphone-15') + ->withTranslation(Language::CS, 'https://example.com/cs/iphone-15') + ->withTranslation(Language::SK, 'https://example.com/sk/iphone-15'), + shortDescription: LocalizedString::create('Latest iPhone model') + ->withTranslation(Language::CS, 'Nejnovější model iPhone') + ->withTranslation(Language::SK, 'Najnovší model iPhone'), + images: [ + 'https://example.com/images/iphone-1.jpg', + 'https://example.com/images/iphone-2.jpg', + ], + categoriesIds: ['CAT-001', 'CAT-002'], + parametersIds: [1, 2], + ), + new Product( + id: 'PROD-002', + isVisible: true, + name: LocalizedString::create('Samsung Galaxy S24') + ->withTranslation(Language::CS, 'Samsung Galaxy S24') + ->withTranslation(Language::SK, 'Samsung Galaxy S24'), + url: LocalizedString::create('https://example.com/samsung-s24') + ->withTranslation(Language::CS, 'https://example.com/cs/samsung-s24') + ->withTranslation(Language::SK, 'https://example.com/sk/samsung-s24'), + shortDescription: LocalizedString::create('Flagship Android phone') + ->withTranslation(Language::CS, 'Vlajková loď Android') + ->withTranslation(Language::SK, 'Vlajková loď Android'), + images: [ + 'https://example.com/images/samsung-1.jpg', + ], + categoriesIds: ['CAT-001', 'CAT-002'], + parametersIds: [1, 3], + ), +]; + +$result = $client->importProducts($products); if ($result->hasErrors() === true) { foreach ($result->errors as $error) { @@ -252,28 +283,28 @@ $name->toArray(); // ['default' => '...', 'cs' => '...', ...] ### Supported Languages -| Code | Language | -|------|----------| +| Code | Language | +|-----------|--------------------| | `default` | Default (required) | -| `cs` | Czech | -| `sk` | Slovak | -| `en` | English | -| `de` | German | -| `pl` | Polish | -| `hu` | Hungarian | +| `cs` | Czech | +| `sk` | Slovak | +| `en` | English | +| `de` | German | +| `pl` | Polish | +| `hu` | Hungarian | ## Limits -| Limit | Value | -|-------|-------| -| Max items per import request | 100 | -| Max items per export page | 100 | -| Product/Category ID length | 255 chars | -| Name length | 250 chars | -| URL length | 255 chars | -| Image URL length | 650 chars | -| Description length | 65,000 chars | -| SEO description length | 500 chars | +| Limit | Value | +|------------------------------|--------------| +| Max items per import request | 100 | +| Max items per export page | 100 | +| Product/Category ID length | 255 chars | +| Name length | 250 chars | +| URL length | 255 chars | +| Image URL length | 650 chars | +| Description length | 65,000 chars | +| SEO description length | 500 chars | ## License