charitable
/
vendor
/
square
/
square
/
src
/
Legacy
/
Models
/
LoyaltyProgramAccrualRuleVisitData.php
LoyaltyProgramAccrualRuleVisitData.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at vendor/square/square/src/Legacy/Models/LoyaltyProgramAccrualRuleVisitData.php
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Square\Legacy\Models; |
| 6 | |
| 7 | use stdClass; |
| 8 | |
| 9 | /** |
| 10 | * Represents additional data for rules with the `VISIT` accrual type. |
| 11 | */ |
| 12 | class LoyaltyProgramAccrualRuleVisitData implements \JsonSerializable |
| 13 | { |
| 14 | /** |
| 15 | * @var Money|null |
| 16 | */ |
| 17 | private $minimumAmountMoney; |
| 18 | |
| 19 | /** |
| 20 | * @var string |
| 21 | */ |
| 22 | private $taxMode; |
| 23 | |
| 24 | /** |
| 25 | * @param string $taxMode |
| 26 | */ |
| 27 | public function __construct(string $taxMode) |
| 28 | { |
| 29 | $this->taxMode = $taxMode; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Returns Minimum Amount Money. |
| 34 | * Represents an amount of money. `Money` fields can be signed or unsigned. |
| 35 | * Fields that do not explicitly define whether they are signed or unsigned are |
| 36 | * considered unsigned and can only hold positive amounts. For signed fields, the |
| 37 | * sign of the value indicates the purpose of the money transfer. See |
| 38 | * [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with- |
| 39 | * monetary-amounts) |
| 40 | * for more information. |
| 41 | */ |
| 42 | public function getMinimumAmountMoney(): ?Money |
| 43 | { |
| 44 | return $this->minimumAmountMoney; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Sets Minimum Amount Money. |
| 49 | * Represents an amount of money. `Money` fields can be signed or unsigned. |
| 50 | * Fields that do not explicitly define whether they are signed or unsigned are |
| 51 | * considered unsigned and can only hold positive amounts. For signed fields, the |
| 52 | * sign of the value indicates the purpose of the money transfer. See |
| 53 | * [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with- |
| 54 | * monetary-amounts) |
| 55 | * for more information. |
| 56 | * |
| 57 | * @maps minimum_amount_money |
| 58 | */ |
| 59 | public function setMinimumAmountMoney(?Money $minimumAmountMoney): void |
| 60 | { |
| 61 | $this->minimumAmountMoney = $minimumAmountMoney; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Returns Tax Mode. |
| 66 | * Indicates how taxes should be treated when calculating the purchase amount used for loyalty points |
| 67 | * accrual. |
| 68 | * This setting applies only to `SPEND` accrual rules or `VISIT` accrual rules that have a minimum |
| 69 | * spend requirement. |
| 70 | */ |
| 71 | public function getTaxMode(): string |
| 72 | { |
| 73 | return $this->taxMode; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Sets Tax Mode. |
| 78 | * Indicates how taxes should be treated when calculating the purchase amount used for loyalty points |
| 79 | * accrual. |
| 80 | * This setting applies only to `SPEND` accrual rules or `VISIT` accrual rules that have a minimum |
| 81 | * spend requirement. |
| 82 | * |
| 83 | * @required |
| 84 | * @maps tax_mode |
| 85 | */ |
| 86 | public function setTaxMode(string $taxMode): void |
| 87 | { |
| 88 | $this->taxMode = $taxMode; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Encode this object to JSON |
| 93 | * |
| 94 | * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields |
| 95 | * are set. (default: false) |
| 96 | * |
| 97 | * @return array|stdClass |
| 98 | */ |
| 99 | #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1) |
| 100 | public function jsonSerialize(bool $asArrayWhenEmpty = false) |
| 101 | { |
| 102 | $json = []; |
| 103 | if (isset($this->minimumAmountMoney)) { |
| 104 | $json['minimum_amount_money'] = $this->minimumAmountMoney; |
| 105 | } |
| 106 | $json['tax_mode'] = $this->taxMode; |
| 107 | $json = array_filter($json, function ($val) { |
| 108 | return $val !== null; |
| 109 | }); |
| 110 | |
| 111 | return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json; |
| 112 | } |
| 113 | } |
| 114 |