charitable
/
vendor
/
square
/
square
/
src
/
Legacy
/
Models
/
ListMerchantCustomAttributesResponse.php
ListMerchantCustomAttributesResponse.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at vendor/square/square/src/Legacy/Models/ListMerchantCustomAttributesResponse.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 | * [ListMerchantCustomAttributes]($e/MerchantCustomAttributes/ListMerchantCustomAttributes) response. |
| 12 | * Either `custom_attributes`, an empty object, or `errors` is present in the response. If additional |
| 13 | * results are available, the `cursor` field is also present along with `custom_attributes`. |
| 14 | */ |
| 15 | class ListMerchantCustomAttributesResponse implements \JsonSerializable |
| 16 | { |
| 17 | /** |
| 18 | * @var CustomAttribute[]|null |
| 19 | */ |
| 20 | private $customAttributes; |
| 21 | |
| 22 | /** |
| 23 | * @var string|null |
| 24 | */ |
| 25 | private $cursor; |
| 26 | |
| 27 | /** |
| 28 | * @var Error[]|null |
| 29 | */ |
| 30 | private $errors; |
| 31 | |
| 32 | /** |
| 33 | * Returns Custom Attributes. |
| 34 | * The retrieved custom attributes. If `with_definitions` was set to `true` in the request, |
| 35 | * the custom attribute definition is returned in the `definition` field of each custom attribute. |
| 36 | * If no custom attributes are found, Square returns an empty object (`{}`). |
| 37 | * |
| 38 | * @return CustomAttribute[]|null |
| 39 | */ |
| 40 | public function getCustomAttributes(): ?array |
| 41 | { |
| 42 | return $this->customAttributes; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Sets Custom Attributes. |
| 47 | * The retrieved custom attributes. If `with_definitions` was set to `true` in the request, |
| 48 | * the custom attribute definition is returned in the `definition` field of each custom attribute. |
| 49 | * If no custom attributes are found, Square returns an empty object (`{}`). |
| 50 | * |
| 51 | * @maps custom_attributes |
| 52 | * |
| 53 | * @param CustomAttribute[]|null $customAttributes |
| 54 | */ |
| 55 | public function setCustomAttributes(?array $customAttributes): void |
| 56 | { |
| 57 | $this->customAttributes = $customAttributes; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Returns Cursor. |
| 62 | * The cursor to use in your next call to this endpoint to retrieve the next page of results |
| 63 | * for your original request. This field is present only if the request succeeded and additional |
| 64 | * results are available. For more information, see [Pagination](https://developer.squareup. |
| 65 | * com/docs/build-basics/common-api-patterns/pagination). |
| 66 | */ |
| 67 | public function getCursor(): ?string |
| 68 | { |
| 69 | return $this->cursor; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Sets Cursor. |
| 74 | * The cursor to use in your next call to this endpoint to retrieve the next page of results |
| 75 | * for your original request. This field is present only if the request succeeded and additional |
| 76 | * results are available. For more information, see [Pagination](https://developer.squareup. |
| 77 | * com/docs/build-basics/common-api-patterns/pagination). |
| 78 | * |
| 79 | * @maps cursor |
| 80 | */ |
| 81 | public function setCursor(?string $cursor): void |
| 82 | { |
| 83 | $this->cursor = $cursor; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Returns Errors. |
| 88 | * Any errors that occurred during the request. |
| 89 | * |
| 90 | * @return Error[]|null |
| 91 | */ |
| 92 | public function getErrors(): ?array |
| 93 | { |
| 94 | return $this->errors; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Sets Errors. |
| 99 | * Any errors that occurred during the request. |
| 100 | * |
| 101 | * @maps errors |
| 102 | * |
| 103 | * @param Error[]|null $errors |
| 104 | */ |
| 105 | public function setErrors(?array $errors): void |
| 106 | { |
| 107 | $this->errors = $errors; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Encode this object to JSON |
| 112 | * |
| 113 | * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields |
| 114 | * are set. (default: false) |
| 115 | * |
| 116 | * @return array|stdClass |
| 117 | */ |
| 118 | #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1) |
| 119 | public function jsonSerialize(bool $asArrayWhenEmpty = false) |
| 120 | { |
| 121 | $json = []; |
| 122 | if (isset($this->customAttributes)) { |
| 123 | $json['custom_attributes'] = $this->customAttributes; |
| 124 | } |
| 125 | if (isset($this->cursor)) { |
| 126 | $json['cursor'] = $this->cursor; |
| 127 | } |
| 128 | if (isset($this->errors)) { |
| 129 | $json['errors'] = $this->errors; |
| 130 | } |
| 131 | $json = array_filter($json, function ($val) { |
| 132 | return $val !== null; |
| 133 | }); |
| 134 | |
| 135 | return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json; |
| 136 | } |
| 137 | } |
| 138 |