charitable
/
vendor
/
square
/
square
/
src
/
Legacy
/
Models
/
RetrieveMerchantCustomAttributeDefinitionRequest.php
RetrieveMerchantCustomAttributeDefinitionRequest.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at vendor/square/square/src/Legacy/Models/RetrieveMerchantCustomAttributeDefinitionRequest.php
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Square\Legacy\Models; |
| 6 | |
| 7 | use stdClass; |
| 8 | |
| 9 | /** |
| 10 | * Represents a |
| 11 | * [RetrieveMerchantCustomAttributeDefinition]($e/MerchantCustomAttributes/RetrieveMerchantCustomAttrib |
| 12 | * uteDefinition) request. |
| 13 | */ |
| 14 | class RetrieveMerchantCustomAttributeDefinitionRequest implements \JsonSerializable |
| 15 | { |
| 16 | /** |
| 17 | * @var int|null |
| 18 | */ |
| 19 | private $version; |
| 20 | |
| 21 | /** |
| 22 | * Returns Version. |
| 23 | * The current version of the custom attribute definition, which is used for strongly consistent |
| 24 | * reads to guarantee that you receive the most up-to-date data. When included in the request, |
| 25 | * Square returns the specified version or a higher version if one exists. If the specified version |
| 26 | * is higher than the current version, Square returns a `BAD_REQUEST` error. |
| 27 | */ |
| 28 | public function getVersion(): ?int |
| 29 | { |
| 30 | return $this->version; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Sets Version. |
| 35 | * The current version of the custom attribute definition, which is used for strongly consistent |
| 36 | * reads to guarantee that you receive the most up-to-date data. When included in the request, |
| 37 | * Square returns the specified version or a higher version if one exists. If the specified version |
| 38 | * is higher than the current version, Square returns a `BAD_REQUEST` error. |
| 39 | * |
| 40 | * @maps version |
| 41 | */ |
| 42 | public function setVersion(?int $version): void |
| 43 | { |
| 44 | $this->version = $version; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Encode this object to JSON |
| 49 | * |
| 50 | * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields |
| 51 | * are set. (default: false) |
| 52 | * |
| 53 | * @return array|stdClass |
| 54 | */ |
| 55 | #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1) |
| 56 | public function jsonSerialize(bool $asArrayWhenEmpty = false) |
| 57 | { |
| 58 | $json = []; |
| 59 | if (isset($this->version)) { |
| 60 | $json['version'] = $this->version; |
| 61 | } |
| 62 | $json = array_filter($json, function ($val) { |
| 63 | return $val !== null; |
| 64 | }); |
| 65 | |
| 66 | return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json; |
| 67 | } |
| 68 | } |
| 69 |