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

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

100 lines 2.7 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 [CreateLoyaltyPromotion]($e/Loyalty/CreateLoyaltyPromotion) response.
11 * Either `loyalty_promotion` or `errors` is present in the response.
12 */
13 class CreateLoyaltyPromotionResponse implements \JsonSerializable
14 {
15 /**
16 * @var Error[]|null
17 */
18 private $errors;
19
20 /**
21 * @var LoyaltyPromotion|null
22 */
23 private $loyaltyPromotion;
24
25 /**
26 * Returns Errors.
27 * Any errors that occurred during the request.
28 *
29 * @return Error[]|null
30 */
31 public function getErrors(): ?array
32 {
33 return $this->errors;
34 }
35
36 /**
37 * Sets Errors.
38 * Any errors that occurred during the request.
39 *
40 * @maps errors
41 *
42 * @param Error[]|null $errors
43 */
44 public function setErrors(?array $errors): void
45 {
46 $this->errors = $errors;
47 }
48
49 /**
50 * Returns Loyalty Promotion.
51 * Represents a promotion for a [loyalty program]($m/LoyaltyProgram). Loyalty promotions enable buyers
52 * to earn extra points on top of those earned from the base program.
53 *
54 * A loyalty program can have a maximum of 10 loyalty promotions with an `ACTIVE` or `SCHEDULED` status.
55 */
56 public function getLoyaltyPromotion(): ?LoyaltyPromotion
57 {
58 return $this->loyaltyPromotion;
59 }
60
61 /**
62 * Sets Loyalty Promotion.
63 * Represents a promotion for a [loyalty program]($m/LoyaltyProgram). Loyalty promotions enable buyers
64 * to earn extra points on top of those earned from the base program.
65 *
66 * A loyalty program can have a maximum of 10 loyalty promotions with an `ACTIVE` or `SCHEDULED` status.
67 *
68 * @maps loyalty_promotion
69 */
70 public function setLoyaltyPromotion(?LoyaltyPromotion $loyaltyPromotion): void
71 {
72 $this->loyaltyPromotion = $loyaltyPromotion;
73 }
74
75 /**
76 * Encode this object to JSON
77 *
78 * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields
79 * are set. (default: false)
80 *
81 * @return array|stdClass
82 */
83 #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1)
84 public function jsonSerialize(bool $asArrayWhenEmpty = false)
85 {
86 $json = [];
87 if (isset($this->errors)) {
88 $json['errors'] = $this->errors;
89 }
90 if (isset($this->loyaltyPromotion)) {
91 $json['loyalty_promotion'] = $this->loyaltyPromotion;
92 }
93 $json = array_filter($json, function ($val) {
94 return $val !== null;
95 });
96
97 return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json;
98 }
99 }
100