charitable
/
vendor
/
square
/
square
/
src
/
Legacy
/
Models
/
RetrieveOrderCustomAttributeDefinitionResponse.php
RetrieveOrderCustomAttributeDefinitionResponse.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at vendor/square/square/src/Legacy/Models/RetrieveOrderCustomAttributeDefinitionResponse.php
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Square\Legacy\Models; |
| 6 | |
| 7 | use stdClass; |
| 8 | |
| 9 | /** |
| 10 | * Represents a response from getting an order custom attribute definition. |
| 11 | */ |
| 12 | class RetrieveOrderCustomAttributeDefinitionResponse implements \JsonSerializable |
| 13 | { |
| 14 | /** |
| 15 | * @var CustomAttributeDefinition|null |
| 16 | */ |
| 17 | private $customAttributeDefinition; |
| 18 | |
| 19 | /** |
| 20 | * @var Error[]|null |
| 21 | */ |
| 22 | private $errors; |
| 23 | |
| 24 | /** |
| 25 | * Returns Custom Attribute Definition. |
| 26 | * Represents a definition for custom attribute values. A custom attribute definition |
| 27 | * specifies the key, visibility, schema, and other properties for a custom attribute. |
| 28 | */ |
| 29 | public function getCustomAttributeDefinition(): ?CustomAttributeDefinition |
| 30 | { |
| 31 | return $this->customAttributeDefinition; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Sets Custom Attribute Definition. |
| 36 | * Represents a definition for custom attribute values. A custom attribute definition |
| 37 | * specifies the key, visibility, schema, and other properties for a custom attribute. |
| 38 | * |
| 39 | * @maps custom_attribute_definition |
| 40 | */ |
| 41 | public function setCustomAttributeDefinition(?CustomAttributeDefinition $customAttributeDefinition): void |
| 42 | { |
| 43 | $this->customAttributeDefinition = $customAttributeDefinition; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Returns Errors. |
| 48 | * Any errors that occurred during the request. |
| 49 | * |
| 50 | * @return Error[]|null |
| 51 | */ |
| 52 | public function getErrors(): ?array |
| 53 | { |
| 54 | return $this->errors; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Sets Errors. |
| 59 | * Any errors that occurred during the request. |
| 60 | * |
| 61 | * @maps errors |
| 62 | * |
| 63 | * @param Error[]|null $errors |
| 64 | */ |
| 65 | public function setErrors(?array $errors): void |
| 66 | { |
| 67 | $this->errors = $errors; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Encode this object to JSON |
| 72 | * |
| 73 | * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields |
| 74 | * are set. (default: false) |
| 75 | * |
| 76 | * @return array|stdClass |
| 77 | */ |
| 78 | #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1) |
| 79 | public function jsonSerialize(bool $asArrayWhenEmpty = false) |
| 80 | { |
| 81 | $json = []; |
| 82 | if (isset($this->customAttributeDefinition)) { |
| 83 | $json['custom_attribute_definition'] = $this->customAttributeDefinition; |
| 84 | } |
| 85 | if (isset($this->errors)) { |
| 86 | $json['errors'] = $this->errors; |
| 87 | } |
| 88 | $json = array_filter($json, function ($val) { |
| 89 | return $val !== null; |
| 90 | }); |
| 91 | |
| 92 | return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json; |
| 93 | } |
| 94 | } |
| 95 |