← All changes
|
src/Subscriptions/DataTransferObjects/SubscriptionQueryData.php
+12
-21
4.16.3
→
2.22.0
View file →
| @@ -5,9 +5,8 @@ | ||
| 5 | 5 | use DateTime; |
| 6 | 6 | use Give\Framework\Support\Facades\DateTime\Temporal; |
| 7 | 7 | use Give\Framework\Support\ValueObjects\Money; |
| 8 | 8 | use Give\Subscriptions\Models\Subscription; |
| 9 | -use Give\Subscriptions\ValueObjects\SubscriptionMode; | |
| 10 | 9 | use Give\Subscriptions\ValueObjects\SubscriptionPeriod; |
| 11 | 10 | use Give\Subscriptions\ValueObjects\SubscriptionStatus; |
| 12 | 11 | |
| 13 | 12 | /** |
| @@ -12,12 +11,11 @@ | ||
| 12 | 11 | |
| 13 | 12 | /** |
| 14 | 13 | * Class SubscriptionObjectData |
| 15 | 14 | * |
| 16 | - * @since 4.11.0 add campaign_id prop | |
| 17 | 15 | * @since 2.19.6 |
| 18 | 16 | */ |
| 19 | -final class SubscriptionQueryData | |
| 17 | +class SubscriptionQueryData | |
| 20 | 18 | { |
| 21 | 19 | /** |
| 22 | 20 | * @var int |
| 23 | 21 | */ |
| @@ -28,9 +26,9 @@ | ||
| 28 | 26 | public $createdAt; |
| 29 | 27 | /** |
| 30 | 28 | * @var DateTime |
| 31 | 29 | */ |
| 32 | - public $renewsAt; | |
| 30 | + public $expiresAt; | |
| 33 | 31 | /** |
| 34 | 32 | * @var string |
| 35 | 33 | */ |
| 36 | 34 | public $status; |
| @@ -54,12 +52,8 @@ | ||
| 54 | 52 | * @var string |
| 55 | 53 | */ |
| 56 | 54 | public $transactionId; |
| 57 | 55 | /** |
| 58 | - * @var SubscriptionMode | |
| 59 | - */ | |
| 60 | - public $mode; | |
| 61 | - /** | |
| 62 | 56 | * @var Money |
| 63 | 57 | */ |
| 64 | 58 | public $amount; |
| 65 | 59 | /** |
| @@ -77,26 +71,24 @@ | ||
| 77 | 71 | /** |
| 78 | 72 | * @var int |
| 79 | 73 | */ |
| 80 | 74 | public $donationFormId; |
| 81 | - /** | |
| 82 | - * @var int | |
| 83 | - */ | |
| 84 | - public $campaignId; | |
| 85 | 75 | |
| 86 | 76 | /** |
| 87 | 77 | * Convert data from Subscription Object to Subscription Model |
| 88 | 78 | * |
| 89 | 79 | * @since 2.19.6 |
| 80 | + * | |
| 81 | + * @return self | |
| 90 | 82 | */ |
| 91 | - public static function fromObject($subscriptionQueryObject): self | |
| 83 | + public static function fromObject($subscriptionQueryObject) | |
| 92 | 84 | { |
| 93 | 85 | $self = new static(); |
| 94 | 86 | |
| 95 | 87 | $self->id = (int)$subscriptionQueryObject->id; |
| 96 | 88 | $self->createdAt = Temporal::toDateTime($subscriptionQueryObject->createdAt); |
| 97 | - $self->renewsAt = isset($subscriptionQueryObject->renewsAt) ? Temporal::toDateTime( | |
| 98 | - $subscriptionQueryObject->renewsAt | |
| 89 | + $self->expiresAt = isset($subscriptionQueryObject->expiration) ? Temporal::toDateTime( | |
| 90 | + $subscriptionQueryObject->expiration | |
| 99 | 91 | ) : null; |
| 100 | 92 | $self->donorId = (int)$subscriptionQueryObject->donorId; |
| 101 | 93 | $self->period = new SubscriptionPeriod($subscriptionQueryObject->period); |
| 102 | 94 | $self->frequency = (int)$subscriptionQueryObject->frequency; |
| @@ -101,17 +93,14 @@ | ||
| 101 | 93 | $self->period = new SubscriptionPeriod($subscriptionQueryObject->period); |
| 102 | 94 | $self->frequency = (int)$subscriptionQueryObject->frequency; |
| 103 | 95 | $self->installments = (int)$subscriptionQueryObject->installments; |
| 104 | 96 | $self->transactionId = $subscriptionQueryObject->transactionId; |
| 105 | - $self->mode = new SubscriptionMode($subscriptionQueryObject->mode); | |
| 106 | - $self->amount = Money::fromDecimal($subscriptionQueryObject->amount, $subscriptionQueryObject->currency ?? give_get_currency()); | |
| 107 | - $self->feeAmountRecovered = Money::fromDecimal($subscriptionQueryObject->feeAmount, | |
| 108 | - $subscriptionQueryObject->currency ?? give_get_currency()); | |
| 97 | + $self->amount = Money::fromDecimal($subscriptionQueryObject->amount, $subscriptionQueryObject->currency); | |
| 98 | + $self->feeAmountRecovered = Money::fromDecimal($subscriptionQueryObject->feeAmount, $subscriptionQueryObject->currency); | |
| 109 | 99 | $self->status = new SubscriptionStatus($subscriptionQueryObject->status); |
| 110 | 100 | $self->gatewayId = $subscriptionQueryObject->gatewayId; |
| 111 | 101 | $self->gatewaySubscriptionId = $subscriptionQueryObject->gatewaySubscriptionId; |
| 112 | 102 | $self->donationFormId = (int)$subscriptionQueryObject->donationFormId; |
| 113 | - $self->campaignId = (int)$subscriptionQueryObject->campaignId; | |
| 114 | 103 | |
| 115 | 104 | return $self; |
| 116 | 105 | } |
| 117 | 106 | |
| @@ -116,10 +105,12 @@ | ||
| 116 | 105 | } |
| 117 | 106 | |
| 118 | 107 | /** |
| 119 | 108 | * Convert DTO to Subscription |
| 109 | + * | |
| 110 | + * @return Subscription | |
| 120 | 111 | */ |
| 121 | - public function toSubscription(): Subscription | |
| 112 | + public function toSubscription() | |
| 122 | 113 | { |
| 123 | 114 | $attributes = get_object_vars($this); |
| 124 | 115 | |
| 125 | 116 | return new Subscription($attributes); |