| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Square\Legacy\Models; |
| 6 |
|
| 7 |
use stdClass; |
| 8 |
|
| 9 |
/** |
| 10 |
* Represents details about an `ADJUST_DECREMENT` [gift card activity type]($m/GiftCardActivityType). |
| 11 |
*/ |
| 12 |
class GiftCardActivityAdjustDecrement implements \JsonSerializable |
| 13 |
{ |
| 14 |
/** |
| 15 |
* @var Money |
| 16 |
*/ |
| 17 |
private $amountMoney; |
| 18 |
|
| 19 |
/** |
| 20 |
* @var string |
| 21 |
*/ |
| 22 |
private $reason; |
| 23 |
|
| 24 |
/** |
| 25 |
* @param Money $amountMoney |
| 26 |
* @param string $reason |
| 27 |
*/ |
| 28 |
public function __construct(Money $amountMoney, string $reason) |
| 29 |
{ |
| 30 |
$this->amountMoney = $amountMoney; |
| 31 |
$this->reason = $reason; |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Returns Amount Money. |
| 36 |
* Represents an amount of money. `Money` fields can be signed or unsigned. |
| 37 |
* Fields that do not explicitly define whether they are signed or unsigned are |
| 38 |
* considered unsigned and can only hold positive amounts. For signed fields, the |
| 39 |
* sign of the value indicates the purpose of the money transfer. See |
| 40 |
* [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with- |
| 41 |
* monetary-amounts) |
| 42 |
* for more information. |
| 43 |
*/ |
| 44 |
public function getAmountMoney(): Money |
| 45 |
{ |
| 46 |
return $this->amountMoney; |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Sets Amount Money. |
| 51 |
* Represents an amount of money. `Money` fields can be signed or unsigned. |
| 52 |
* Fields that do not explicitly define whether they are signed or unsigned are |
| 53 |
* considered unsigned and can only hold positive amounts. For signed fields, the |
| 54 |
* sign of the value indicates the purpose of the money transfer. See |
| 55 |
* [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with- |
| 56 |
* monetary-amounts) |
| 57 |
* for more information. |
| 58 |
* |
| 59 |
* @required |
| 60 |
* @maps amount_money |
| 61 |
*/ |
| 62 |
public function setAmountMoney(Money $amountMoney): void |
| 63 |
{ |
| 64 |
$this->amountMoney = $amountMoney; |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* Returns Reason. |
| 69 |
* Indicates the reason for deducting money from a [gift card]($m/GiftCard). |
| 70 |
*/ |
| 71 |
public function getReason(): string |
| 72 |
{ |
| 73 |
return $this->reason; |
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* Sets Reason. |
| 78 |
* Indicates the reason for deducting money from a [gift card]($m/GiftCard). |
| 79 |
* |
| 80 |
* @required |
| 81 |
* @maps reason |
| 82 |
*/ |
| 83 |
public function setReason(string $reason): void |
| 84 |
{ |
| 85 |
$this->reason = $reason; |
| 86 |
} |
| 87 |
|
| 88 |
/** |
| 89 |
* Encode this object to JSON |
| 90 |
* |
| 91 |
* @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields |
| 92 |
* are set. (default: false) |
| 93 |
* |
| 94 |
* @return array|stdClass |
| 95 |
*/ |
| 96 |
#[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1) |
| 97 |
public function jsonSerialize(bool $asArrayWhenEmpty = false) |
| 98 |
{ |
| 99 |
$json = []; |
| 100 |
$json['amount_money'] = $this->amountMoney; |
| 101 |
$json['reason'] = $this->reason; |
| 102 |
$json = array_filter($json, function ($val) { |
| 103 |
return $val !== null; |
| 104 |
}); |
| 105 |
|
| 106 |
return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json; |
| 107 |
} |
| 108 |
} |
| 109 |
|