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