From 00d1704806c9a2257c5497cab082983aa07cff20 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 20 Aug 2024 15:42:49 +0100 Subject: [PATCH 1/4] CreateDiscount and UpdateDiscount Ops are missing Custom Data #57 --- src/Entities/Discount.php | 9 ++++++--- src/Resources/Discounts/Operations/CreateDiscount.php | 9 ++++++--- src/Resources/Discounts/Operations/UpdateDiscount.php | 11 +++++++---- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/Entities/Discount.php b/src/Entities/Discount.php index 40cfdb7..3d26d6f 100644 --- a/src/Entities/Discount.php +++ b/src/Entities/Discount.php @@ -11,10 +11,11 @@ namespace Paddle\SDK\Entities; -use Paddle\SDK\Entities\Discount\DiscountStatus; -use Paddle\SDK\Entities\Discount\DiscountType; -use Paddle\SDK\Entities\Shared\CurrencyCode; +use Paddle\SDK\Entities\Shared\CustomData; use Paddle\SDK\Entities\Shared\ImportMeta; +use Paddle\SDK\Entities\Shared\CurrencyCode; +use Paddle\SDK\Entities\Discount\DiscountType; +use Paddle\SDK\Entities\Discount\DiscountStatus; class Discount implements Entity { @@ -35,6 +36,7 @@ private function __construct( public int $timesUsed, public \DateTimeInterface $createdAt, public \DateTimeInterface $updatedAt, + public CustomData|null $customData, public ImportMeta|null $importMeta, ) { } @@ -58,6 +60,7 @@ public static function from(array $data): self timesUsed: $data['times_used'], createdAt: DateTime::from($data['created_at']), updatedAt: DateTime::from($data['updated_at']), + customData: isset($data['custom_data']) ? new CustomData($data['custom_data']) : null, importMeta: isset($data['import_meta']) ? ImportMeta::from($data['import_meta']) : null, ); } diff --git a/src/Resources/Discounts/Operations/CreateDiscount.php b/src/Resources/Discounts/Operations/CreateDiscount.php index 8c9b611..34401d8 100644 --- a/src/Resources/Discounts/Operations/CreateDiscount.php +++ b/src/Resources/Discounts/Operations/CreateDiscount.php @@ -4,10 +4,11 @@ namespace Paddle\SDK\Resources\Discounts\Operations; -use Paddle\SDK\Entities\Discount\DiscountType; -use Paddle\SDK\Entities\Shared\CurrencyCode; -use Paddle\SDK\FiltersUndefined; use Paddle\SDK\Undefined; +use Paddle\SDK\FiltersUndefined; +use Paddle\SDK\Entities\Shared\CustomData; +use Paddle\SDK\Entities\Shared\CurrencyCode; +use Paddle\SDK\Entities\Discount\DiscountType; class CreateDiscount implements \JsonSerializable { @@ -28,6 +29,7 @@ public function __construct( public readonly int|Undefined|null $usageLimit = new Undefined(), public readonly array|Undefined|null $restrictTo = new Undefined(), public readonly string|Undefined|null $expiresAt = new Undefined(), + public readonly CustomData|Undefined|null $customData = new Undefined(), ) { } @@ -45,6 +47,7 @@ public function jsonSerialize(): array 'usage_limit' => $this->usageLimit, 'restrict_to' => $this->restrictTo, 'expires_at' => $this->expiresAt, + 'custom_data' => $this->customData, ]); } } diff --git a/src/Resources/Discounts/Operations/UpdateDiscount.php b/src/Resources/Discounts/Operations/UpdateDiscount.php index 7378394..483da4b 100644 --- a/src/Resources/Discounts/Operations/UpdateDiscount.php +++ b/src/Resources/Discounts/Operations/UpdateDiscount.php @@ -4,11 +4,12 @@ namespace Paddle\SDK\Resources\Discounts\Operations; -use Paddle\SDK\Entities\Discount\DiscountStatus; -use Paddle\SDK\Entities\Discount\DiscountType; -use Paddle\SDK\Entities\Shared\CurrencyCode; -use Paddle\SDK\FiltersUndefined; use Paddle\SDK\Undefined; +use Paddle\SDK\FiltersUndefined; +use Paddle\SDK\Entities\Shared\CustomData; +use Paddle\SDK\Entities\Shared\CurrencyCode; +use Paddle\SDK\Entities\Discount\DiscountType; +use Paddle\SDK\Entities\Discount\DiscountStatus; class UpdateDiscount implements \JsonSerializable { @@ -30,6 +31,7 @@ public function __construct( public readonly array|Undefined|null $restrictTo = new Undefined(), public readonly string|Undefined|null $expiresAt = new Undefined(), public readonly DiscountStatus|Undefined $status = new Undefined(), + public readonly CustomData|Undefined|null $customData = new Undefined(), ) { } @@ -48,6 +50,7 @@ public function jsonSerialize(): array 'restrict_to' => $this->restrictTo, 'expires_at' => $this->expiresAt, 'status' => $this->status, + 'custom_data' => $this->customData, ]); } } From 522776bed4ab1f652518a0b8182d2cf1a3c7e850 Mon Sep 17 00:00:00 2001 From: dutypro <38077637+dutypro@users.noreply.github.com> Date: Tue, 20 Aug 2024 17:11:29 +0100 Subject: [PATCH 2/4] Update src/Entities/Discount.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Víctor Fernández Saborit --- src/Entities/Discount.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Entities/Discount.php b/src/Entities/Discount.php index 3d26d6f..e53fe4e 100644 --- a/src/Entities/Discount.php +++ b/src/Entities/Discount.php @@ -11,11 +11,11 @@ namespace Paddle\SDK\Entities; +use Paddle\SDK\Entities\Discount\DiscountStatus; +use Paddle\SDK\Entities\Discount\DiscountType; +use Paddle\SDK\Entities\Shared\CurrencyCode; use Paddle\SDK\Entities\Shared\CustomData; use Paddle\SDK\Entities\Shared\ImportMeta; -use Paddle\SDK\Entities\Shared\CurrencyCode; -use Paddle\SDK\Entities\Discount\DiscountType; -use Paddle\SDK\Entities\Discount\DiscountStatus; class Discount implements Entity { From 481a6d9c667a0c7448af78863c3a91c6d73308af Mon Sep 17 00:00:00 2001 From: dutypro <38077637+dutypro@users.noreply.github.com> Date: Tue, 20 Aug 2024 17:11:35 +0100 Subject: [PATCH 3/4] Update src/Resources/Discounts/Operations/CreateDiscount.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Víctor Fernández Saborit --- src/Resources/Discounts/Operations/CreateDiscount.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Resources/Discounts/Operations/CreateDiscount.php b/src/Resources/Discounts/Operations/CreateDiscount.php index 34401d8..2b5867d 100644 --- a/src/Resources/Discounts/Operations/CreateDiscount.php +++ b/src/Resources/Discounts/Operations/CreateDiscount.php @@ -4,11 +4,11 @@ namespace Paddle\SDK\Resources\Discounts\Operations; -use Paddle\SDK\Undefined; -use Paddle\SDK\FiltersUndefined; -use Paddle\SDK\Entities\Shared\CustomData; -use Paddle\SDK\Entities\Shared\CurrencyCode; use Paddle\SDK\Entities\Discount\DiscountType; +use Paddle\SDK\Entities\Shared\CurrencyCode; +use Paddle\SDK\Entities\Shared\CustomData; +use Paddle\SDK\FiltersUndefined; +use Paddle\SDK\Undefined; class CreateDiscount implements \JsonSerializable { From 217693ab4bbf6e23304fc80c968074ba79249115 Mon Sep 17 00:00:00 2001 From: dutypro <38077637+dutypro@users.noreply.github.com> Date: Tue, 20 Aug 2024 17:11:40 +0100 Subject: [PATCH 4/4] Update src/Resources/Discounts/Operations/UpdateDiscount.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Víctor Fernández Saborit --- src/Resources/Discounts/Operations/UpdateDiscount.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Resources/Discounts/Operations/UpdateDiscount.php b/src/Resources/Discounts/Operations/UpdateDiscount.php index 483da4b..c5d5302 100644 --- a/src/Resources/Discounts/Operations/UpdateDiscount.php +++ b/src/Resources/Discounts/Operations/UpdateDiscount.php @@ -4,12 +4,12 @@ namespace Paddle\SDK\Resources\Discounts\Operations; -use Paddle\SDK\Undefined; -use Paddle\SDK\FiltersUndefined; -use Paddle\SDK\Entities\Shared\CustomData; -use Paddle\SDK\Entities\Shared\CurrencyCode; -use Paddle\SDK\Entities\Discount\DiscountType; use Paddle\SDK\Entities\Discount\DiscountStatus; +use Paddle\SDK\Entities\Discount\DiscountType; +use Paddle\SDK\Entities\Shared\CurrencyCode; +use Paddle\SDK\Entities\Shared\CustomData; +use Paddle\SDK\FiltersUndefined; +use Paddle\SDK\Undefined; class UpdateDiscount implements \JsonSerializable {