From 6405f8b150ff63a57d049c97a485415de2ef870f Mon Sep 17 00:00:00 2001 From: Stefan Supheert Date: Tue, 16 Sep 2025 15:59:54 +0200 Subject: [PATCH 1/6] Add listuserpackages and deleteuserpackages --- src/Api/PackageApi.php | 25 ++++ src/Domain/AccountPackage.php | 67 +++++++++ src/Domain/Currency.php | 49 ++++++ src/Domain/DomainProduct.php | 58 ++++++++ src/Domain/Package.php | 139 ++++++++++++++++++ src/Domain/PackagePrice.php | 52 +++++++ src/Domain/ProductSupplier.php | 40 +++++ .../Api/PackageApi/DeleteUserPackageTest.php | 20 +++ tests/Api/PackageApi/ListUserPackageTest.php | 20 +++ tests/Api/data/user-packages-get.json | 103 +++++++++++++ 10 files changed, 573 insertions(+) create mode 100644 src/Domain/AccountPackage.php create mode 100644 src/Domain/Currency.php create mode 100644 src/Domain/DomainProduct.php create mode 100644 src/Domain/Package.php create mode 100644 src/Domain/PackagePrice.php create mode 100644 src/Domain/ProductSupplier.php create mode 100644 tests/Api/PackageApi/DeleteUserPackageTest.php create mode 100644 tests/Api/PackageApi/ListUserPackageTest.php create mode 100644 tests/Api/data/user-packages-get.json diff --git a/src/Api/PackageApi.php b/src/Api/PackageApi.php index 6f7ceb9..7bf9a5e 100644 --- a/src/Api/PackageApi.php +++ b/src/Api/PackageApi.php @@ -3,6 +3,8 @@ namespace SandwaveIo\BaseKit\Api; use SandwaveIo\BaseKit\Api\Interfaces\PackagesApiInterface; +use SandwaveIo\BaseKit\Domain\AccountPackage; +use SandwaveIo\BaseKit\Exceptions\UnexpectedValueException; final class PackageApi extends AbstractApi implements PackagesApiInterface { @@ -23,4 +25,27 @@ public function addUserPackage( $this->client->post("users/{$userRef}/account-packages", $payload); } + + /** + * @param int $userRef + * + * @return AccountPackage[] + */ + public function listUserPackages(int $userRef): array + { + $response = $this->client->get("users/{$userRef}/account-packages")->json(); + if (! array_key_exists('accountPackages', $response)) { + throw new UnexpectedValueException('No account packages was provided by BaseKit.'); + } + return AccountPackage::fromArray($response['accountPackages']); + } + + /** + * @param int $userRef + * @param int $accountPackageRef + */ + public function deleteUserPackage(int $userRef, int $accountPackageRef): void + { + $this->client->delete("users/{$userRef}/account-packages/{$accountPackageRef}"); + } } diff --git a/src/Domain/AccountPackage.php b/src/Domain/AccountPackage.php new file mode 100644 index 0000000..4f7e72d --- /dev/null +++ b/src/Domain/AccountPackage.php @@ -0,0 +1,67 @@ + $this->ref, + 'startDateTime' => $this->startDateTime, + 'endDateTime' => $this->endDateTime, + 'update' => $this->update, + 'deleteOnExpiry' => $this->deleteOnExpiry, + 'isFree' => $this->isFree, + 'billingPeriodMonths' => $this->billingPeriodMonths, + 'isActive' => $this->isActive, + 'package' => $this->package, + 'templateGroupRef' => $this->templateGroupRef, + 'displayOrder' => $this->displayOrder, + ]; + } + + /** + * @inheritDoc + */ + public static function fromArray(array $json) + { + $sitePackages = []; + + foreach ($json as $sitePackage) { + $sitePackages[] = new AccountPackage( + ref: $sitePackage['ref'], + startDateTime: $sitePackage['startDateTime'], + endDateTime: $sitePackage['endDateTime'], + update: $sitePackage['update'], + deleteOnExpiry: $sitePackage['deleteOnExpiry'], + isFree: $sitePackage['isFree'], + billingPeriodMonths: $sitePackage['billingPeriodMonths'], + isActive: $sitePackage['isActive'], + package: Package::fromArray($sitePackage['package']), + templateGroupRef: $sitePackage['templateGroupRef'], + displayOrder: $sitePackage['displayOrder'], + ); + } + + return $sitePackages; + } +} diff --git a/src/Domain/Currency.php b/src/Domain/Currency.php new file mode 100644 index 0000000..ed64cb6 --- /dev/null +++ b/src/Domain/Currency.php @@ -0,0 +1,49 @@ + $this->ref, + 'name' => $this->name, + 'alphaCode' => $this->alphaCode, + 'numCode' => $this->numCode, + 'htmlCode' => $this->htmlCode, + 'currencyRate' => $this->currencyRate, + 'paypal' => $this->paypal, + ]; + } + + /** + * @inheritDoc + */ + public static function fromArray(array $json) + { + return new Currency( + ref: $json['ref'], + name: $json['name'], + alphaCode: $json['alphaCode'], + numCode: $json['numCode'], + htmlCode: $json['htmlCode'], + currencyRate: $json['currencyRate'], + paypal: $json['paypal'], + ); + } +} diff --git a/src/Domain/DomainProduct.php b/src/Domain/DomainProduct.php new file mode 100644 index 0000000..7dd35a2 --- /dev/null +++ b/src/Domain/DomainProduct.php @@ -0,0 +1,58 @@ + $this->domainSuffix, + 'name' => $this->name, + 'description' => $this->description, + 'frequencyMonths' => $this->frequencyMonths, + 'active' => $this->active, + 'availableAsFreeDomain' => $this->availableAsFreeDomain, + 'requireCustomContactDetails' => $this->requireCustomContactDetails, + 'renewalActive' => $this->renewalActive, + 'ref' => $this->ref, + 'productSupplier' => $this->productSupplier, + ]; + } + + /** + * @inheritDoc + */ + public static function fromArray(array $json) + { + return new DomainProduct( + domainSuffix: $json['domainSuffix'], + name: $json['name'], + description: $json['description'], + frequencyMonths: $json['frequencyMonths'], + active: $json['active'], + availableAsFreeDomain: $json['availableAsFreeDomain'], + requireCustomContactDetails: $json['requireCustomContactDetails'], + renewalActive: $json['renewalActive'], + ref: $json['ref'], + productSupplier: ProductSupplier::fromArray($json['productSupplier']), + ); + } +} diff --git a/src/Domain/Package.php b/src/Domain/Package.php new file mode 100644 index 0000000..116b214 --- /dev/null +++ b/src/Domain/Package.php @@ -0,0 +1,139 @@ + $this->ref, + 'name' => $this->name, + 'active' => $this->active, + 'global' => $this->global, + 'urlID' => $this->urlID, + 'notifyMarketing' => $this->notifyMarketing, + 'productType' => $this->productType, + 'type' => $this->type, + 'contentType' => $this->contentType, + 'offerRebillMonths' => $this->offerRebillMonths, + 'offerRebillActive' => $this->offerRebillActive, + 'trialDays' => $this->trialDays, + 'requirePurchasedDomain' => $this->requirePurchasedDomain, + 'allowMultiplePurchase' => $this->allowMultiplePurchase, + 'showInStore' => $this->showInStore, + 'showInTemplatePicker' => $this->showInTemplatePicker, + 'bannerHTML' => $this->bannerHTML, + 'affiliateLink' => $this->affiliateLink, + 'flowName' => $this->flowName, + 'metadata' => $this->metadata, + 'brandRef' => $this->brandRef, + 'brandName' => $this->brandName, + 'defaultCurrencyRef' => $this->defaultCurrencyRef, + 'currencyCode' => $this->currencyCode, + 'currencyName' => $this->currencyName, + 'currencyTitle' => $this->currencyTitle, + 'defaultCampaignRef' => $this->defaultCampaignRef, + 'capabilities' => $this->capabilities, + 'templateGroupRef' => $this->templateGroupRef, + 'templateGroup' => $this->templateGroup, + 'displayOrder' => $this->displayOrder, + 'domainProduct' => $this->domainProduct, + 'prices' => $this->prices, + 'plugins' => $this->plugins, + ]; + } + + /** + * @inheritDoc + */ + public static function fromArray(array $json) + { + return new Package( + ref: $json['ref'], + name: $json['name'], + active: $json['active'], + global: $json['global'], + urlID: $json['urlID'], + notifyMarketing: $json['notifyMarketing'], + productType: $json['productType'], + type: $json['type'], + contentType: $json['contentType'], + offerRebillMonths: $json['offerRebillMonths'], + offerRebillActive: $json['offerRebillActive'], + trialDays: $json['trialDays'], + imageURL: $json['imageURL'], + requirePurchasedDomain: $json['requirePurchasedDomain'], + allowMultiplePurchase: $json['allowMultiplePurchase'], + showInStore: $json['showInStore'], + showInTemplatePicker: $json['showInTemplatePicker'], + bannerHTML: $json['bannerHTML'], + affiliateLink: $json['affiliateLink'], + flowName: $json['flowName'], + metadata: $json['metadata'], + brandRef: $json['brandRef'], + brandName: $json['brandName'], + defaultCurrencyRef: $json['defaultCurrencyRef'], + currencyCode: $json['currencyCode'], + currencyName: $json['currencyName'], + currencyTitle: $json['currencyTitle'], + defaultCampaignRef: $json['defaultCampaignRef'], + capabilities: $json['capabilities'], + templateGroupRef: $json['templateGroupRef'], + templateGroup: $json['templateGroup'], + displayOrder: $json['displayOrder'], + domainProduct: DomainProduct::fromArray($json['domainProduct']), + prices: PackagePrice::fromArray($json['prices']), + plugins: $json['plugins'], + ); + } +} diff --git a/src/Domain/PackagePrice.php b/src/Domain/PackagePrice.php new file mode 100644 index 0000000..4d6d8df --- /dev/null +++ b/src/Domain/PackagePrice.php @@ -0,0 +1,52 @@ + $this->price, + 'offerPrice' => $this->offerPrice, + 'billingPeriodMonths' => $this->billingPeriodMonths, + 'ref' => $this->ref, + 'currency' => $this->currency, + 'formattedPrice' => $this->formattedPrice, + ]; + } + + /** + * @inheritDoc + */ + public static function fromArray(array $json) + { + $packagePrices = []; + + foreach ($json as $packagePrice) { + $packagePrices[] = new PackagePrice( + price: $packagePrice['price'], + offerPrice: $packagePrice['offerPrice'], + billingPeriodMonths: $packagePrice['billingPeriodMonths'], + ref: $packagePrice['ref'], + currency: Currency::fromArray($packagePrice['currency']), + formattedPrice: $packagePrice['formattedPrice'], + ); + } + + return $packagePrices; + } +} diff --git a/src/Domain/ProductSupplier.php b/src/Domain/ProductSupplier.php new file mode 100644 index 0000000..3851a5e --- /dev/null +++ b/src/Domain/ProductSupplier.php @@ -0,0 +1,40 @@ + $this->name, + 'description' => $this->description, + 'className' => $this->className, + 'ref' => $this->ref, + ]; + } + + /** + * @inheritDoc + */ + public static function fromArray(array $json) + { + return new ProductSupplier( + name: $json['name'], + description: $json['description'], + className: $json['className'], + ref: $json['ref'], + ); + } +} diff --git a/tests/Api/PackageApi/DeleteUserPackageTest.php b/tests/Api/PackageApi/DeleteUserPackageTest.php new file mode 100644 index 0000000..2e92df9 --- /dev/null +++ b/tests/Api/PackageApi/DeleteUserPackageTest.php @@ -0,0 +1,20 @@ +packageApi->deleteUserPackage(12345, 567); + } +} diff --git a/tests/Api/PackageApi/ListUserPackageTest.php b/tests/Api/PackageApi/ListUserPackageTest.php new file mode 100644 index 0000000..0e84272 --- /dev/null +++ b/tests/Api/PackageApi/ListUserPackageTest.php @@ -0,0 +1,20 @@ +packageApi->listUserPackages(12345); + } +} diff --git a/tests/Api/data/user-packages-get.json b/tests/Api/data/user-packages-get.json new file mode 100644 index 0000000..1ef8f25 --- /dev/null +++ b/tests/Api/data/user-packages-get.json @@ -0,0 +1,103 @@ +{ + "accountPackages": [ + { + "ref": 3, + "startDateTime": { + "date": "2023-08-23 14:57:48.704403", + "timezone_type": 3, + "timezone": "Europe/London" + }, + "endDateTime": { + "date": "2023-08-23 14:57:48.704403", + "timezone_type": 3, + "timezone": "Europe/London" + }, + "update": { + "date": "2023-08-23 14:57:48.704403", + "timezone_type": 3, + "timezone": "Europe/London" + }, + "deleteOnExpiry": 1, + "isFree": true, + "billingPeriodMonths": 1, + "isActive": true, + "package": { + "ref": 12, + "name": "Test Package", + "active": 1, + "global": 1, + "urlID": "basic", + "notifyMarketing": "N", + "productType": "add-on", + "type": "standard", + "contentType": "domain", + "offerRebillMonths": 3, + "offerRebillActive": 1, + "trialDays": 30, + "imageURL": "https://example.com/image.jpg", + "requirePurchasedDomain": true, + "allowMultiplePurchase": true, + "showInStore": true, + "showInTemplatePicker": true, + "bannerHTML": "
Test
", + "affiliateLink": "https://example.com/affiliate", + "flowName": "classic", + "metadata": [], + "brandRef": 23, + "brandName": "Test Brand", + "defaultCurrencyRef": 23, + "currencyCode": "GBP", + "currencyName": "Pound Sterling", + "currencyTitle": "GBP Pound Sterling", + "defaultCampaignRef": 45, + "capabilities": { + "imageCredits": 10, + "genericUseButtonUrl": "https://example.com" + }, + "templateGroupRef": 13, + "templateGroup": {}, + "displayOrder": 999, + "domainProduct": { + "domainSuffix": ".com", + "name": ".co.uk Domains 1 Year", + "description": "1 year .co.uk domain registration", + "frequencyMonths": 12, + "active": 1, + "availableAsFreeDomain": 1, + "requireCustomContactDetails": true, + "renewalActive": 1, + "ref": 12, + "productSupplier": { + "name": "123 Reg", + "description": "123 Reg description", + "className": "123reg", + "ref": 17 + } + }, + "prices": [ + { + "price": "10.00", + "offerPrice": "string", + "billingPeriodMonths": 1, + "ref": 123, + "currency": { + "ref": 34, + "name": "US Dollar", + "alphaCode": "USD", + "numCode": "840", + "htmlCode": "$", + "currencyRate": 1, + "paypal": 1 + }, + "formattedPrice": "$10.00" + } + ], + "plugins": [ + 0 + ] + }, + "templateGroupRef": null, + "displayOrder": null + } + ] +} From 4cdeac8b0ab3fce12cb2432b8fb3d3bc92b13a9a Mon Sep 17 00:00:00 2001 From: Stefan Supheert Date: Tue, 16 Sep 2025 16:42:06 +0200 Subject: [PATCH 2/6] test --- tests/Api/PackageApi/ListUserPackageTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/Api/PackageApi/ListUserPackageTest.php b/tests/Api/PackageApi/ListUserPackageTest.php index 0e84272..4e10638 100644 --- a/tests/Api/PackageApi/ListUserPackageTest.php +++ b/tests/Api/PackageApi/ListUserPackageTest.php @@ -2,7 +2,14 @@ namespace SandwaveIo\BaseKit\Tests\Api\PackageApi; +use PHPUnit\Framework\Assert; use PHPUnit\Framework\TestCase; +use SandwaveIo\BaseKit\Domain\AccountHolder; +use SandwaveIo\BaseKit\Domain\AccountPackage; +use SandwaveIo\BaseKit\Domain\Currency; +use SandwaveIo\BaseKit\Domain\DomainProduct; +use SandwaveIo\BaseKit\Domain\Package; +use SandwaveIo\BaseKit\Domain\PackagePrice; use SandwaveIo\BaseKit\Tests\Helpers\MockedClientFactory; final class ListUserPackageTest extends TestCase @@ -16,5 +23,17 @@ public function testListUserPackage(): void ); $userPackages = $client->packageApi->listUserPackages(12345); + + Assert::assertInstanceOf(AccountPackage::class, $userPackages[0]); + Assert::assertSame(3, $userPackages[0]->ref); + Assert::assertInstanceOf(Package::class, $userPackages[0]->package); + Assert::assertSame("Test Package", $userPackages[0]->package->name); + Assert::assertInstanceOf(DomainProduct::class, $userPackages[0]->package->domainProduct); + Assert::assertSame(".com", $userPackages[0]->package->domainProduct->domainSuffix); + Assert::assertInstanceOf(PackagePrice::class, $userPackages[0]->package->prices[0]); + Assert::assertSame("10.00", $userPackages[0]->package->prices[0]->price); + Assert::assertInstanceOf(Currency::class, $userPackages[0]->package->prices[0]->currency); + Assert::assertSame("US Dollar", $userPackages[0]->package->prices[0]->currency->name); + Assert::assertSame(0, $userPackages[0]->package->plugins[0]); } } From 2c4b6e83ae233533efd43723b0286fcc4e940ae0 Mon Sep 17 00:00:00 2001 From: Stefan Supheert Date: Tue, 16 Sep 2025 17:45:29 +0200 Subject: [PATCH 3/6] stan --- src/Api/Interfaces/PackagesApiInterface.php | 14 ++++++++++++++ src/Api/PackageApi.php | 2 +- src/Domain/AccountPackage.php | 7 ++++++- src/Domain/Package.php | 2 +- src/Domain/PackagePrice.php | 2 +- tests/Api/PackageApi/ListUserPackageTest.php | 9 ++++----- 6 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/Api/Interfaces/PackagesApiInterface.php b/src/Api/Interfaces/PackagesApiInterface.php index 42a5488..4175745 100644 --- a/src/Api/Interfaces/PackagesApiInterface.php +++ b/src/Api/Interfaces/PackagesApiInterface.php @@ -2,6 +2,8 @@ namespace SandwaveIo\BaseKit\Api\Interfaces; +use SandwaveIo\BaseKit\Domain\AccountPackage; + interface PackagesApiInterface { public function addUserPackage( @@ -9,4 +11,16 @@ public function addUserPackage( int $packageRef, int $billingFrequency ): void; + + /** + * @return AccountPackage[] + */ + public function listUserPackages( + int $userRef + ): array; + + public function deleteUserPackage( + int $userRef, + int $accountPackageRef + ): void; } diff --git a/src/Api/PackageApi.php b/src/Api/PackageApi.php index 7bf9a5e..5381835 100644 --- a/src/Api/PackageApi.php +++ b/src/Api/PackageApi.php @@ -37,7 +37,7 @@ public function listUserPackages(int $userRef): array if (! array_key_exists('accountPackages', $response)) { throw new UnexpectedValueException('No account packages was provided by BaseKit.'); } - return AccountPackage::fromArray($response['accountPackages']); + return AccountPackage::fromArray($response['accountPackages']); // @phpstan-ignore-line } /** diff --git a/src/Domain/AccountPackage.php b/src/Domain/AccountPackage.php index 4f7e72d..adf96da 100644 --- a/src/Domain/AccountPackage.php +++ b/src/Domain/AccountPackage.php @@ -4,6 +4,11 @@ final class AccountPackage implements DomainObjectInterface { + /** + * @param array $startDateTime + * @param array $endDateTime + * @param array $update + */ public function __construct( public int $ref, public array $startDateTime, @@ -62,6 +67,6 @@ public static function fromArray(array $json) ); } - return $sitePackages; + return $sitePackages; // @phpstan-ignore-line } } diff --git a/src/Domain/Package.php b/src/Domain/Package.php index 116b214..87bb58d 100644 --- a/src/Domain/Package.php +++ b/src/Domain/Package.php @@ -132,7 +132,7 @@ public static function fromArray(array $json) templateGroup: $json['templateGroup'], displayOrder: $json['displayOrder'], domainProduct: DomainProduct::fromArray($json['domainProduct']), - prices: PackagePrice::fromArray($json['prices']), + prices: PackagePrice::fromArray($json['prices']), // @phpstan-ignore-line plugins: $json['plugins'], ); } diff --git a/src/Domain/PackagePrice.php b/src/Domain/PackagePrice.php index 4d6d8df..9e3949b 100644 --- a/src/Domain/PackagePrice.php +++ b/src/Domain/PackagePrice.php @@ -47,6 +47,6 @@ public static function fromArray(array $json) ); } - return $packagePrices; + return $packagePrices; // @phpstan-ignore-line } } diff --git a/tests/Api/PackageApi/ListUserPackageTest.php b/tests/Api/PackageApi/ListUserPackageTest.php index 4e10638..7fc80e7 100644 --- a/tests/Api/PackageApi/ListUserPackageTest.php +++ b/tests/Api/PackageApi/ListUserPackageTest.php @@ -4,7 +4,6 @@ use PHPUnit\Framework\Assert; use PHPUnit\Framework\TestCase; -use SandwaveIo\BaseKit\Domain\AccountHolder; use SandwaveIo\BaseKit\Domain\AccountPackage; use SandwaveIo\BaseKit\Domain\Currency; use SandwaveIo\BaseKit\Domain\DomainProduct; @@ -27,13 +26,13 @@ public function testListUserPackage(): void Assert::assertInstanceOf(AccountPackage::class, $userPackages[0]); Assert::assertSame(3, $userPackages[0]->ref); Assert::assertInstanceOf(Package::class, $userPackages[0]->package); - Assert::assertSame("Test Package", $userPackages[0]->package->name); + Assert::assertSame('Test Package', $userPackages[0]->package->name); Assert::assertInstanceOf(DomainProduct::class, $userPackages[0]->package->domainProduct); - Assert::assertSame(".com", $userPackages[0]->package->domainProduct->domainSuffix); + Assert::assertSame('.com', $userPackages[0]->package->domainProduct->domainSuffix); Assert::assertInstanceOf(PackagePrice::class, $userPackages[0]->package->prices[0]); - Assert::assertSame("10.00", $userPackages[0]->package->prices[0]->price); + Assert::assertSame('10.00', $userPackages[0]->package->prices[0]->price); Assert::assertInstanceOf(Currency::class, $userPackages[0]->package->prices[0]->currency); - Assert::assertSame("US Dollar", $userPackages[0]->package->prices[0]->currency->name); + Assert::assertSame('US Dollar', $userPackages[0]->package->prices[0]->currency->name); Assert::assertSame(0, $userPackages[0]->package->plugins[0]); } } From ae9e5985092d01a441416708f16887fe1edea702 Mon Sep 17 00:00:00 2001 From: Stefan Supheert Date: Wed, 17 Sep 2025 14:18:08 +0200 Subject: [PATCH 4/6] s --- src/Domain/PackagePrice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Domain/PackagePrice.php b/src/Domain/PackagePrice.php index 9e3949b..34ffec0 100644 --- a/src/Domain/PackagePrice.php +++ b/src/Domain/PackagePrice.php @@ -22,7 +22,7 @@ public function toArray(): array return [ 'price' => $this->price, 'offerPrice' => $this->offerPrice, - 'billingPeriodMonths' => $this->billingPeriodMonths, + 'billingPeriodMonth' => $this->billingPeriodMonths, 'ref' => $this->ref, 'currency' => $this->currency, 'formattedPrice' => $this->formattedPrice, From 4b4c12eeb57bbf275bfe4295d2f1e4a3a350503f Mon Sep 17 00:00:00 2001 From: Stefan Supheert Date: Wed, 17 Sep 2025 14:18:32 +0200 Subject: [PATCH 5/6] readd --- src/Domain/PackagePrice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Domain/PackagePrice.php b/src/Domain/PackagePrice.php index 34ffec0..9e3949b 100644 --- a/src/Domain/PackagePrice.php +++ b/src/Domain/PackagePrice.php @@ -22,7 +22,7 @@ public function toArray(): array return [ 'price' => $this->price, 'offerPrice' => $this->offerPrice, - 'billingPeriodMonth' => $this->billingPeriodMonths, + 'billingPeriodMonths' => $this->billingPeriodMonths, 'ref' => $this->ref, 'currency' => $this->currency, 'formattedPrice' => $this->formattedPrice, From 8a4fa6e31c06f5818bbd6cabf74a6527f0a53eb8 Mon Sep 17 00:00:00 2001 From: Stefan Supheert Date: Fri, 19 Sep 2025 13:26:25 +0200 Subject: [PATCH 6/6] toarray objects --- src/Domain/AccountPackage.php | 2 +- src/Domain/DomainProduct.php | 2 +- src/Domain/Package.php | 2 +- src/Domain/PackagePrice.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Domain/AccountPackage.php b/src/Domain/AccountPackage.php index adf96da..f7c967f 100644 --- a/src/Domain/AccountPackage.php +++ b/src/Domain/AccountPackage.php @@ -38,7 +38,7 @@ public function toArray(): array 'isFree' => $this->isFree, 'billingPeriodMonths' => $this->billingPeriodMonths, 'isActive' => $this->isActive, - 'package' => $this->package, + 'package' => $this->package->toArray(), 'templateGroupRef' => $this->templateGroupRef, 'displayOrder' => $this->displayOrder, ]; diff --git a/src/Domain/DomainProduct.php b/src/Domain/DomainProduct.php index 7dd35a2..ce10a75 100644 --- a/src/Domain/DomainProduct.php +++ b/src/Domain/DomainProduct.php @@ -33,7 +33,7 @@ public function toArray(): array 'requireCustomContactDetails' => $this->requireCustomContactDetails, 'renewalActive' => $this->renewalActive, 'ref' => $this->ref, - 'productSupplier' => $this->productSupplier, + 'productSupplier' => $this->productSupplier !== null ? $this->productSupplier->toArray() : [], ]; } diff --git a/src/Domain/Package.php b/src/Domain/Package.php index 87bb58d..de37d33 100644 --- a/src/Domain/Package.php +++ b/src/Domain/Package.php @@ -87,7 +87,7 @@ public function toArray(): array 'templateGroupRef' => $this->templateGroupRef, 'templateGroup' => $this->templateGroup, 'displayOrder' => $this->displayOrder, - 'domainProduct' => $this->domainProduct, + 'domainProduct' => $this->domainProduct !== null ? $this->domainProduct->toArray() : [], 'prices' => $this->prices, 'plugins' => $this->plugins, ]; diff --git a/src/Domain/PackagePrice.php b/src/Domain/PackagePrice.php index 9e3949b..77d3533 100644 --- a/src/Domain/PackagePrice.php +++ b/src/Domain/PackagePrice.php @@ -24,7 +24,7 @@ public function toArray(): array 'offerPrice' => $this->offerPrice, 'billingPeriodMonths' => $this->billingPeriodMonths, 'ref' => $this->ref, - 'currency' => $this->currency, + 'currency' => $this->currency->toArray(), 'formattedPrice' => $this->formattedPrice, ]; }