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.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 1.7.0.9 All 211 releases
charitable / vendor / square / square / src / Legacy / Models / SubscriptionPhase.php

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

266 lines 7.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 * Describes a phase in a subscription plan variation. For more information, see [Subscription Plans
11 * and Variations](https://developer.squareup.com/docs/subscriptions-api/plans-and-variations).
12 */
13 class SubscriptionPhase implements \JsonSerializable
14 {
15 /**
16 * @var array
17 */
18 private $uid = [];
19
20 /**
21 * @var string
22 */
23 private $cadence;
24
25 /**
26 * @var array
27 */
28 private $periods = [];
29
30 /**
31 * @var Money|null
32 */
33 private $recurringPriceMoney;
34
35 /**
36 * @var array
37 */
38 private $ordinal = [];
39
40 /**
41 * @var SubscriptionPricing|null
42 */
43 private $pricing;
44
45 /**
46 * @param string $cadence
47 */
48 public function __construct(string $cadence)
49 {
50 $this->cadence = $cadence;
51 }
52
53 /**
54 * Returns Uid.
55 * The Square-assigned ID of the subscription phase. This field cannot be changed after a
56 * `SubscriptionPhase` is created.
57 */
58 public function getUid(): ?string
59 {
60 if (count($this->uid) == 0) {
61 return null;
62 }
63 return $this->uid['value'];
64 }
65
66 /**
67 * Sets Uid.
68 * The Square-assigned ID of the subscription phase. This field cannot be changed after a
69 * `SubscriptionPhase` is created.
70 *
71 * @maps uid
72 */
73 public function setUid(?string $uid): void
74 {
75 $this->uid['value'] = $uid;
76 }
77
78 /**
79 * Unsets Uid.
80 * The Square-assigned ID of the subscription phase. This field cannot be changed after a
81 * `SubscriptionPhase` is created.
82 */
83 public function unsetUid(): void
84 {
85 $this->uid = [];
86 }
87
88 /**
89 * Returns Cadence.
90 * Determines the billing cadence of a [Subscription]($m/Subscription)
91 */
92 public function getCadence(): string
93 {
94 return $this->cadence;
95 }
96
97 /**
98 * Sets Cadence.
99 * Determines the billing cadence of a [Subscription]($m/Subscription)
100 *
101 * @required
102 * @maps cadence
103 */
104 public function setCadence(string $cadence): void
105 {
106 $this->cadence = $cadence;
107 }
108
109 /**
110 * Returns Periods.
111 * The number of `cadence`s the phase lasts. If not set, the phase never ends. Only the last phase can
112 * be indefinite. This field cannot be changed after a `SubscriptionPhase` is created.
113 */
114 public function getPeriods(): ?int
115 {
116 if (count($this->periods) == 0) {
117 return null;
118 }
119 return $this->periods['value'];
120 }
121
122 /**
123 * Sets Periods.
124 * The number of `cadence`s the phase lasts. If not set, the phase never ends. Only the last phase can
125 * be indefinite. This field cannot be changed after a `SubscriptionPhase` is created.
126 *
127 * @maps periods
128 */
129 public function setPeriods(?int $periods): void
130 {
131 $this->periods['value'] = $periods;
132 }
133
134 /**
135 * Unsets Periods.
136 * The number of `cadence`s the phase lasts. If not set, the phase never ends. Only the last phase can
137 * be indefinite. This field cannot be changed after a `SubscriptionPhase` is created.
138 */
139 public function unsetPeriods(): void
140 {
141 $this->periods = [];
142 }
143
144 /**
145 * Returns Recurring Price Money.
146 * Represents an amount of money. `Money` fields can be signed or unsigned.
147 * Fields that do not explicitly define whether they are signed or unsigned are
148 * considered unsigned and can only hold positive amounts. For signed fields, the
149 * sign of the value indicates the purpose of the money transfer. See
150 * [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-
151 * monetary-amounts)
152 * for more information.
153 */
154 public function getRecurringPriceMoney(): ?Money
155 {
156 return $this->recurringPriceMoney;
157 }
158
159 /**
160 * Sets Recurring Price Money.
161 * Represents an amount of money. `Money` fields can be signed or unsigned.
162 * Fields that do not explicitly define whether they are signed or unsigned are
163 * considered unsigned and can only hold positive amounts. For signed fields, the
164 * sign of the value indicates the purpose of the money transfer. See
165 * [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-
166 * monetary-amounts)
167 * for more information.
168 *
169 * @maps recurring_price_money
170 */
171 public function setRecurringPriceMoney(?Money $recurringPriceMoney): void
172 {
173 $this->recurringPriceMoney = $recurringPriceMoney;
174 }
175
176 /**
177 * Returns Ordinal.
178 * The position this phase appears in the sequence of phases defined for the plan, indexed from 0. This
179 * field cannot be changed after a `SubscriptionPhase` is created.
180 */
181 public function getOrdinal(): ?int
182 {
183 if (count($this->ordinal) == 0) {
184 return null;
185 }
186 return $this->ordinal['value'];
187 }
188
189 /**
190 * Sets Ordinal.
191 * The position this phase appears in the sequence of phases defined for the plan, indexed from 0. This
192 * field cannot be changed after a `SubscriptionPhase` is created.
193 *
194 * @maps ordinal
195 */
196 public function setOrdinal(?int $ordinal): void
197 {
198 $this->ordinal['value'] = $ordinal;
199 }
200
201 /**
202 * Unsets Ordinal.
203 * The position this phase appears in the sequence of phases defined for the plan, indexed from 0. This
204 * field cannot be changed after a `SubscriptionPhase` is created.
205 */
206 public function unsetOrdinal(): void
207 {
208 $this->ordinal = [];
209 }
210
211 /**
212 * Returns Pricing.
213 * Describes the pricing for the subscription.
214 */
215 public function getPricing(): ?SubscriptionPricing
216 {
217 return $this->pricing;
218 }
219
220 /**
221 * Sets Pricing.
222 * Describes the pricing for the subscription.
223 *
224 * @maps pricing
225 */
226 public function setPricing(?SubscriptionPricing $pricing): void
227 {
228 $this->pricing = $pricing;
229 }
230
231 /**
232 * Encode this object to JSON
233 *
234 * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields
235 * are set. (default: false)
236 *
237 * @return array|stdClass
238 */
239 #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1)
240 public function jsonSerialize(bool $asArrayWhenEmpty = false)
241 {
242 $json = [];
243 if (!empty($this->uid)) {
244 $json['uid'] = $this->uid['value'];
245 }
246 $json['cadence'] = $this->cadence;
247 if (!empty($this->periods)) {
248 $json['periods'] = $this->periods['value'];
249 }
250 if (isset($this->recurringPriceMoney)) {
251 $json['recurring_price_money'] = $this->recurringPriceMoney;
252 }
253 if (!empty($this->ordinal)) {
254 $json['ordinal'] = $this->ordinal['value'];
255 }
256 if (isset($this->pricing)) {
257 $json['pricing'] = $this->pricing;
258 }
259 $json = array_filter($json, function ($val) {
260 return $val !== null;
261 });
262
263 return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json;
264 }
265 }
266