From 07bbac56372bfb705a0b089c91480373a6c79e85 Mon Sep 17 00:00:00 2001 From: Michael Woodward Date: Tue, 13 Feb 2024 11:29:14 +0000 Subject: [PATCH] fix!: Consistent naming for Adjustment totals obj (#33) BREAKING CHANGE: Any existing typing for TotalAdjustments will cause a class not found error until refactored to AdjustmentTotals --- src/Entities/Adjustment.php | 6 +++--- .../Shared/{TotalAdjustments.php => AdjustmentTotals.php} | 2 +- src/Entities/Subscription/SubscriptionAdjustmentPreview.php | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) rename src/Entities/Shared/{TotalAdjustments.php => AdjustmentTotals.php} (97%) diff --git a/src/Entities/Adjustment.php b/src/Entities/Adjustment.php index 2cac3a7..a2e3c4f 100644 --- a/src/Entities/Adjustment.php +++ b/src/Entities/Adjustment.php @@ -14,9 +14,9 @@ use Paddle\SDK\Entities\Adjustment\AdjustmentItem; use Paddle\SDK\Entities\Shared\Action; use Paddle\SDK\Entities\Shared\AdjustmentStatus; +use Paddle\SDK\Entities\Shared\AdjustmentTotals; use Paddle\SDK\Entities\Shared\CurrencyCode; use Paddle\SDK\Entities\Shared\PayoutTotalsAdjustment; -use Paddle\SDK\Entities\Shared\TotalAdjustments; class Adjustment implements Entity { @@ -36,7 +36,7 @@ protected function __construct( public CurrencyCode $currencyCode, public AdjustmentStatus $status, public array $items, - public TotalAdjustments $totals, + public AdjustmentTotals $totals, public PayoutTotalsAdjustment|null $payoutTotals, public \DateTimeInterface $createdAt, public \DateTimeInterface|null $updatedAt, @@ -56,7 +56,7 @@ public static function from(array $data): self currencyCode: CurrencyCode::from($data['currency_code']), status: AdjustmentStatus::from($data['status']), items: array_map(fn (array $item) => AdjustmentItem::from($item), $data['items']), - totals: TotalAdjustments::from($data['totals']), + totals: AdjustmentTotals::from($data['totals']), payoutTotals: isset($data['payout_totals']) ? PayoutTotalsAdjustment::from($data['payout_totals']) : null, createdAt: DateTime::from($data['created_at']), updatedAt: DateTime::from($data['updated_at']), diff --git a/src/Entities/Shared/TotalAdjustments.php b/src/Entities/Shared/AdjustmentTotals.php similarity index 97% rename from src/Entities/Shared/TotalAdjustments.php rename to src/Entities/Shared/AdjustmentTotals.php index 8baafe5..dbde26e 100644 --- a/src/Entities/Shared/TotalAdjustments.php +++ b/src/Entities/Shared/AdjustmentTotals.php @@ -11,7 +11,7 @@ namespace Paddle\SDK\Entities\Shared; -class TotalAdjustments +class AdjustmentTotals { public function __construct( public string $subtotal, diff --git a/src/Entities/Subscription/SubscriptionAdjustmentPreview.php b/src/Entities/Subscription/SubscriptionAdjustmentPreview.php index 2f022cc..204c80d 100644 --- a/src/Entities/Subscription/SubscriptionAdjustmentPreview.php +++ b/src/Entities/Subscription/SubscriptionAdjustmentPreview.php @@ -4,7 +4,7 @@ namespace Paddle\SDK\Entities\Subscription; -use Paddle\SDK\Entities\Shared\TotalAdjustments; +use Paddle\SDK\Entities\Shared\AdjustmentTotals; class SubscriptionAdjustmentPreview { @@ -14,7 +14,7 @@ class SubscriptionAdjustmentPreview public function __construct( public string $transactionId, public array $items, - public TotalAdjustments $totals, + public AdjustmentTotals $totals, ) { } @@ -23,7 +23,7 @@ public static function from(array $data): self return new self( transactionId: $data['transaction_id'], items: array_map(fn (array $item) => SubscriptionAdjustmentItem::from($item), $data['items']), - totals: TotalAdjustments::from($data['totals']), + totals: AdjustmentTotals::from($data['totals']), ); } }