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 / LoyaltyReward.php

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

310 lines 7.1 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 a contract to redeem loyalty points for a [reward tier]($m/LoyaltyProgramRewardTier)
11 * discount. Loyalty rewards can be in an ISSUED, REDEEMED, or DELETED state.
12 * For more information, see [Manage loyalty rewards](https://developer.squareup.com/docs/loyalty-
13 * api/loyalty-rewards).
14 */
15 class LoyaltyReward implements \JsonSerializable
16 {
17 /**
18 * @var string|null
19 */
20 private $id;
21
22 /**
23 * @var string|null
24 */
25 private $status;
26
27 /**
28 * @var string
29 */
30 private $loyaltyAccountId;
31
32 /**
33 * @var string
34 */
35 private $rewardTierId;
36
37 /**
38 * @var int|null
39 */
40 private $points;
41
42 /**
43 * @var array
44 */
45 private $orderId = [];
46
47 /**
48 * @var string|null
49 */
50 private $createdAt;
51
52 /**
53 * @var string|null
54 */
55 private $updatedAt;
56
57 /**
58 * @var string|null
59 */
60 private $redeemedAt;
61
62 /**
63 * @param string $loyaltyAccountId
64 * @param string $rewardTierId
65 */
66 public function __construct(string $loyaltyAccountId, string $rewardTierId)
67 {
68 $this->loyaltyAccountId = $loyaltyAccountId;
69 $this->rewardTierId = $rewardTierId;
70 }
71
72 /**
73 * Returns Id.
74 * The Square-assigned ID of the loyalty reward.
75 */
76 public function getId(): ?string
77 {
78 return $this->id;
79 }
80
81 /**
82 * Sets Id.
83 * The Square-assigned ID of the loyalty reward.
84 *
85 * @maps id
86 */
87 public function setId(?string $id): void
88 {
89 $this->id = $id;
90 }
91
92 /**
93 * Returns Status.
94 * The status of the loyalty reward.
95 */
96 public function getStatus(): ?string
97 {
98 return $this->status;
99 }
100
101 /**
102 * Sets Status.
103 * The status of the loyalty reward.
104 *
105 * @maps status
106 */
107 public function setStatus(?string $status): void
108 {
109 $this->status = $status;
110 }
111
112 /**
113 * Returns Loyalty Account Id.
114 * The Square-assigned ID of the [loyalty account](entity:LoyaltyAccount) to which the reward belongs.
115 */
116 public function getLoyaltyAccountId(): string
117 {
118 return $this->loyaltyAccountId;
119 }
120
121 /**
122 * Sets Loyalty Account Id.
123 * The Square-assigned ID of the [loyalty account](entity:LoyaltyAccount) to which the reward belongs.
124 *
125 * @required
126 * @maps loyalty_account_id
127 */
128 public function setLoyaltyAccountId(string $loyaltyAccountId): void
129 {
130 $this->loyaltyAccountId = $loyaltyAccountId;
131 }
132
133 /**
134 * Returns Reward Tier Id.
135 * The Square-assigned ID of the [reward tier](entity:LoyaltyProgramRewardTier) used to create the
136 * reward.
137 */
138 public function getRewardTierId(): string
139 {
140 return $this->rewardTierId;
141 }
142
143 /**
144 * Sets Reward Tier Id.
145 * The Square-assigned ID of the [reward tier](entity:LoyaltyProgramRewardTier) used to create the
146 * reward.
147 *
148 * @required
149 * @maps reward_tier_id
150 */
151 public function setRewardTierId(string $rewardTierId): void
152 {
153 $this->rewardTierId = $rewardTierId;
154 }
155
156 /**
157 * Returns Points.
158 * The number of loyalty points used for the reward.
159 */
160 public function getPoints(): ?int
161 {
162 return $this->points;
163 }
164
165 /**
166 * Sets Points.
167 * The number of loyalty points used for the reward.
168 *
169 * @maps points
170 */
171 public function setPoints(?int $points): void
172 {
173 $this->points = $points;
174 }
175
176 /**
177 * Returns Order Id.
178 * The Square-assigned ID of the [order](entity:Order) to which the reward is attached.
179 */
180 public function getOrderId(): ?string
181 {
182 if (count($this->orderId) == 0) {
183 return null;
184 }
185 return $this->orderId['value'];
186 }
187
188 /**
189 * Sets Order Id.
190 * The Square-assigned ID of the [order](entity:Order) to which the reward is attached.
191 *
192 * @maps order_id
193 */
194 public function setOrderId(?string $orderId): void
195 {
196 $this->orderId['value'] = $orderId;
197 }
198
199 /**
200 * Unsets Order Id.
201 * The Square-assigned ID of the [order](entity:Order) to which the reward is attached.
202 */
203 public function unsetOrderId(): void
204 {
205 $this->orderId = [];
206 }
207
208 /**
209 * Returns Created At.
210 * The timestamp when the reward was created, in RFC 3339 format.
211 */
212 public function getCreatedAt(): ?string
213 {
214 return $this->createdAt;
215 }
216
217 /**
218 * Sets Created At.
219 * The timestamp when the reward was created, in RFC 3339 format.
220 *
221 * @maps created_at
222 */
223 public function setCreatedAt(?string $createdAt): void
224 {
225 $this->createdAt = $createdAt;
226 }
227
228 /**
229 * Returns Updated At.
230 * The timestamp when the reward was last updated, in RFC 3339 format.
231 */
232 public function getUpdatedAt(): ?string
233 {
234 return $this->updatedAt;
235 }
236
237 /**
238 * Sets Updated At.
239 * The timestamp when the reward was last updated, in RFC 3339 format.
240 *
241 * @maps updated_at
242 */
243 public function setUpdatedAt(?string $updatedAt): void
244 {
245 $this->updatedAt = $updatedAt;
246 }
247
248 /**
249 * Returns Redeemed At.
250 * The timestamp when the reward was redeemed, in RFC 3339 format.
251 */
252 public function getRedeemedAt(): ?string
253 {
254 return $this->redeemedAt;
255 }
256
257 /**
258 * Sets Redeemed At.
259 * The timestamp when the reward was redeemed, in RFC 3339 format.
260 *
261 * @maps redeemed_at
262 */
263 public function setRedeemedAt(?string $redeemedAt): void
264 {
265 $this->redeemedAt = $redeemedAt;
266 }
267
268 /**
269 * Encode this object to JSON
270 *
271 * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields
272 * are set. (default: false)
273 *
274 * @return array|stdClass
275 */
276 #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1)
277 public function jsonSerialize(bool $asArrayWhenEmpty = false)
278 {
279 $json = [];
280 if (isset($this->id)) {
281 $json['id'] = $this->id;
282 }
283 if (isset($this->status)) {
284 $json['status'] = $this->status;
285 }
286 $json['loyalty_account_id'] = $this->loyaltyAccountId;
287 $json['reward_tier_id'] = $this->rewardTierId;
288 if (isset($this->points)) {
289 $json['points'] = $this->points;
290 }
291 if (!empty($this->orderId)) {
292 $json['order_id'] = $this->orderId['value'];
293 }
294 if (isset($this->createdAt)) {
295 $json['created_at'] = $this->createdAt;
296 }
297 if (isset($this->updatedAt)) {
298 $json['updated_at'] = $this->updatedAt;
299 }
300 if (isset($this->redeemedAt)) {
301 $json['redeemed_at'] = $this->redeemedAt;
302 }
303 $json = array_filter($json, function ($val) {
304 return $val !== null;
305 });
306
307 return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json;
308 }
309 }
310