PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / vendor / square / square / src / Legacy / Models / SubscriptionAction.php

SubscriptionAction.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at vendor/square/square/src/Legacy/Models/SubscriptionAction.php

253 lines 6.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Square\Legacy\Models;
6
7 use stdClass;
8
9 /**
10 * Represents an action as a pending change to a subscription.
11 */
12 class SubscriptionAction implements \JsonSerializable
13 {
14 /**
15 * @var string|null
16 */
17 private $id;
18
19 /**
20 * @var string|null
21 */
22 private $type;
23
24 /**
25 * @var array
26 */
27 private $effectiveDate = [];
28
29 /**
30 * @var array
31 */
32 private $monthlyBillingAnchorDate = [];
33
34 /**
35 * @var array
36 */
37 private $phases = [];
38
39 /**
40 * @var array
41 */
42 private $newPlanVariationId = [];
43
44 /**
45 * Returns Id.
46 * The ID of an action scoped to a subscription.
47 */
48 public function getId(): ?string
49 {
50 return $this->id;
51 }
52
53 /**
54 * Sets Id.
55 * The ID of an action scoped to a subscription.
56 *
57 * @maps id
58 */
59 public function setId(?string $id): void
60 {
61 $this->id = $id;
62 }
63
64 /**
65 * Returns Type.
66 * Supported types of an action as a pending change to a subscription.
67 */
68 public function getType(): ?string
69 {
70 return $this->type;
71 }
72
73 /**
74 * Sets Type.
75 * Supported types of an action as a pending change to a subscription.
76 *
77 * @maps type
78 */
79 public function setType(?string $type): void
80 {
81 $this->type = $type;
82 }
83
84 /**
85 * Returns Effective Date.
86 * The `YYYY-MM-DD`-formatted date when the action occurs on the subscription.
87 */
88 public function getEffectiveDate(): ?string
89 {
90 if (count($this->effectiveDate) == 0) {
91 return null;
92 }
93 return $this->effectiveDate['value'];
94 }
95
96 /**
97 * Sets Effective Date.
98 * The `YYYY-MM-DD`-formatted date when the action occurs on the subscription.
99 *
100 * @maps effective_date
101 */
102 public function setEffectiveDate(?string $effectiveDate): void
103 {
104 $this->effectiveDate['value'] = $effectiveDate;
105 }
106
107 /**
108 * Unsets Effective Date.
109 * The `YYYY-MM-DD`-formatted date when the action occurs on the subscription.
110 */
111 public function unsetEffectiveDate(): void
112 {
113 $this->effectiveDate = [];
114 }
115
116 /**
117 * Returns Monthly Billing Anchor Date.
118 * The new billing anchor day value, for a `CHANGE_BILLING_ANCHOR_DATE` action.
119 */
120 public function getMonthlyBillingAnchorDate(): ?int
121 {
122 if (count($this->monthlyBillingAnchorDate) == 0) {
123 return null;
124 }
125 return $this->monthlyBillingAnchorDate['value'];
126 }
127
128 /**
129 * Sets Monthly Billing Anchor Date.
130 * The new billing anchor day value, for a `CHANGE_BILLING_ANCHOR_DATE` action.
131 *
132 * @maps monthly_billing_anchor_date
133 */
134 public function setMonthlyBillingAnchorDate(?int $monthlyBillingAnchorDate): void
135 {
136 $this->monthlyBillingAnchorDate['value'] = $monthlyBillingAnchorDate;
137 }
138
139 /**
140 * Unsets Monthly Billing Anchor Date.
141 * The new billing anchor day value, for a `CHANGE_BILLING_ANCHOR_DATE` action.
142 */
143 public function unsetMonthlyBillingAnchorDate(): void
144 {
145 $this->monthlyBillingAnchorDate = [];
146 }
147
148 /**
149 * Returns Phases.
150 * A list of Phases, to pass phase-specific information used in the swap.
151 *
152 * @return Phase[]|null
153 */
154 public function getPhases(): ?array
155 {
156 if (count($this->phases) == 0) {
157 return null;
158 }
159 return $this->phases['value'];
160 }
161
162 /**
163 * Sets Phases.
164 * A list of Phases, to pass phase-specific information used in the swap.
165 *
166 * @maps phases
167 *
168 * @param Phase[]|null $phases
169 */
170 public function setPhases(?array $phases): void
171 {
172 $this->phases['value'] = $phases;
173 }
174
175 /**
176 * Unsets Phases.
177 * A list of Phases, to pass phase-specific information used in the swap.
178 */
179 public function unsetPhases(): void
180 {
181 $this->phases = [];
182 }
183
184 /**
185 * Returns New Plan Variation Id.
186 * The target subscription plan variation that a subscription switches to, for a `SWAP_PLAN` action.
187 */
188 public function getNewPlanVariationId(): ?string
189 {
190 if (count($this->newPlanVariationId) == 0) {
191 return null;
192 }
193 return $this->newPlanVariationId['value'];
194 }
195
196 /**
197 * Sets New Plan Variation Id.
198 * The target subscription plan variation that a subscription switches to, for a `SWAP_PLAN` action.
199 *
200 * @maps new_plan_variation_id
201 */
202 public function setNewPlanVariationId(?string $newPlanVariationId): void
203 {
204 $this->newPlanVariationId['value'] = $newPlanVariationId;
205 }
206
207 /**
208 * Unsets New Plan Variation Id.
209 * The target subscription plan variation that a subscription switches to, for a `SWAP_PLAN` action.
210 */
211 public function unsetNewPlanVariationId(): void
212 {
213 $this->newPlanVariationId = [];
214 }
215
216 /**
217 * Encode this object to JSON
218 *
219 * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields
220 * are set. (default: false)
221 *
222 * @return array|stdClass
223 */
224 #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1)
225 public function jsonSerialize(bool $asArrayWhenEmpty = false)
226 {
227 $json = [];
228 if (isset($this->id)) {
229 $json['id'] = $this->id;
230 }
231 if (isset($this->type)) {
232 $json['type'] = $this->type;
233 }
234 if (!empty($this->effectiveDate)) {
235 $json['effective_date'] = $this->effectiveDate['value'];
236 }
237 if (!empty($this->monthlyBillingAnchorDate)) {
238 $json['monthly_billing_anchor_date'] = $this->monthlyBillingAnchorDate['value'];
239 }
240 if (!empty($this->phases)) {
241 $json['phases'] = $this->phases['value'];
242 }
243 if (!empty($this->newPlanVariationId)) {
244 $json['new_plan_variation_id'] = $this->newPlanVariationId['value'];
245 }
246 $json = array_filter($json, function ($val) {
247 return $val !== null;
248 });
249
250 return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json;
251 }
252 }
253