charitable
/
vendor
/
square
/
square
/
src
/
Legacy
/
Models
/
BatchRetrieveInventoryChangesResponse.php
BatchRetrieveInventoryChangesResponse.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at vendor/square/square/src/Legacy/Models/BatchRetrieveInventoryChangesResponse.php
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Square\Legacy\Models; |
| 6 | |
| 7 | use stdClass; |
| 8 | |
| 9 | class BatchRetrieveInventoryChangesResponse implements \JsonSerializable |
| 10 | { |
| 11 | /** |
| 12 | * @var Error[]|null |
| 13 | */ |
| 14 | private $errors; |
| 15 | |
| 16 | /** |
| 17 | * @var InventoryChange[]|null |
| 18 | */ |
| 19 | private $changes; |
| 20 | |
| 21 | /** |
| 22 | * @var string|null |
| 23 | */ |
| 24 | private $cursor; |
| 25 | |
| 26 | /** |
| 27 | * Returns Errors. |
| 28 | * Any errors that occurred during the request. |
| 29 | * |
| 30 | * @return Error[]|null |
| 31 | */ |
| 32 | public function getErrors(): ?array |
| 33 | { |
| 34 | return $this->errors; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Sets Errors. |
| 39 | * Any errors that occurred during the request. |
| 40 | * |
| 41 | * @maps errors |
| 42 | * |
| 43 | * @param Error[]|null $errors |
| 44 | */ |
| 45 | public function setErrors(?array $errors): void |
| 46 | { |
| 47 | $this->errors = $errors; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Returns Changes. |
| 52 | * The current calculated inventory changes for the requested objects |
| 53 | * and locations. |
| 54 | * |
| 55 | * @return InventoryChange[]|null |
| 56 | */ |
| 57 | public function getChanges(): ?array |
| 58 | { |
| 59 | return $this->changes; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Sets Changes. |
| 64 | * The current calculated inventory changes for the requested objects |
| 65 | * and locations. |
| 66 | * |
| 67 | * @maps changes |
| 68 | * |
| 69 | * @param InventoryChange[]|null $changes |
| 70 | */ |
| 71 | public function setChanges(?array $changes): void |
| 72 | { |
| 73 | $this->changes = $changes; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Returns Cursor. |
| 78 | * The pagination cursor to be used in a subsequent request. If unset, |
| 79 | * this is the final response. |
| 80 | * See the [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination) guide for |
| 81 | * more information. |
| 82 | */ |
| 83 | public function getCursor(): ?string |
| 84 | { |
| 85 | return $this->cursor; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Sets Cursor. |
| 90 | * The pagination cursor to be used in a subsequent request. If unset, |
| 91 | * this is the final response. |
| 92 | * See the [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination) guide for |
| 93 | * more information. |
| 94 | * |
| 95 | * @maps cursor |
| 96 | */ |
| 97 | public function setCursor(?string $cursor): void |
| 98 | { |
| 99 | $this->cursor = $cursor; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Encode this object to JSON |
| 104 | * |
| 105 | * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields |
| 106 | * are set. (default: false) |
| 107 | * |
| 108 | * @return array|stdClass |
| 109 | */ |
| 110 | #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1) |
| 111 | public function jsonSerialize(bool $asArrayWhenEmpty = false) |
| 112 | { |
| 113 | $json = []; |
| 114 | if (isset($this->errors)) { |
| 115 | $json['errors'] = $this->errors; |
| 116 | } |
| 117 | if (isset($this->changes)) { |
| 118 | $json['changes'] = $this->changes; |
| 119 | } |
| 120 | if (isset($this->cursor)) { |
| 121 | $json['cursor'] = $this->cursor; |
| 122 | } |
| 123 | $json = array_filter($json, function ($val) { |
| 124 | return $val !== null; |
| 125 | }); |
| 126 | |
| 127 | return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json; |
| 128 | } |
| 129 | } |
| 130 |