| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Square\Legacy\Models; |
| 6 |
|
| 7 |
use stdClass; |
| 8 |
|
| 9 |
class ListDevicesRequest implements \JsonSerializable |
| 10 |
{ |
| 11 |
/** |
| 12 |
* @var array |
| 13 |
*/ |
| 14 |
private $cursor = []; |
| 15 |
|
| 16 |
/** |
| 17 |
* @var string|null |
| 18 |
*/ |
| 19 |
private $sortOrder; |
| 20 |
|
| 21 |
/** |
| 22 |
* @var array |
| 23 |
*/ |
| 24 |
private $limit = []; |
| 25 |
|
| 26 |
/** |
| 27 |
* @var array |
| 28 |
*/ |
| 29 |
private $locationId = []; |
| 30 |
|
| 31 |
/** |
| 32 |
* Returns Cursor. |
| 33 |
* A pagination cursor returned by a previous call to this endpoint. |
| 34 |
* Provide this cursor to retrieve the next set of results for the original query. |
| 35 |
* See [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination) |
| 36 |
* for more information. |
| 37 |
*/ |
| 38 |
public function getCursor(): ?string |
| 39 |
{ |
| 40 |
if (count($this->cursor) == 0) { |
| 41 |
return null; |
| 42 |
} |
| 43 |
return $this->cursor['value']; |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Sets Cursor. |
| 48 |
* A pagination cursor returned by a previous call to this endpoint. |
| 49 |
* Provide this cursor to retrieve the next set of results for the original query. |
| 50 |
* See [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination) |
| 51 |
* for more information. |
| 52 |
* |
| 53 |
* @maps cursor |
| 54 |
*/ |
| 55 |
public function setCursor(?string $cursor): void |
| 56 |
{ |
| 57 |
$this->cursor['value'] = $cursor; |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Unsets Cursor. |
| 62 |
* A pagination cursor returned by a previous call to this endpoint. |
| 63 |
* Provide this cursor to retrieve the next set of results for the original query. |
| 64 |
* See [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination) |
| 65 |
* for more information. |
| 66 |
*/ |
| 67 |
public function unsetCursor(): void |
| 68 |
{ |
| 69 |
$this->cursor = []; |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* Returns Sort Order. |
| 74 |
* The order (e.g., chronological or alphabetical) in which results from a request are returned. |
| 75 |
*/ |
| 76 |
public function getSortOrder(): ?string |
| 77 |
{ |
| 78 |
return $this->sortOrder; |
| 79 |
} |
| 80 |
|
| 81 |
/** |
| 82 |
* Sets Sort Order. |
| 83 |
* The order (e.g., chronological or alphabetical) in which results from a request are returned. |
| 84 |
* |
| 85 |
* @maps sort_order |
| 86 |
*/ |
| 87 |
public function setSortOrder(?string $sortOrder): void |
| 88 |
{ |
| 89 |
$this->sortOrder = $sortOrder; |
| 90 |
} |
| 91 |
|
| 92 |
/** |
| 93 |
* Returns Limit. |
| 94 |
* The number of results to return in a single page. |
| 95 |
*/ |
| 96 |
public function getLimit(): ?int |
| 97 |
{ |
| 98 |
if (count($this->limit) == 0) { |
| 99 |
return null; |
| 100 |
} |
| 101 |
return $this->limit['value']; |
| 102 |
} |
| 103 |
|
| 104 |
/** |
| 105 |
* Sets Limit. |
| 106 |
* The number of results to return in a single page. |
| 107 |
* |
| 108 |
* @maps limit |
| 109 |
*/ |
| 110 |
public function setLimit(?int $limit): void |
| 111 |
{ |
| 112 |
$this->limit['value'] = $limit; |
| 113 |
} |
| 114 |
|
| 115 |
/** |
| 116 |
* Unsets Limit. |
| 117 |
* The number of results to return in a single page. |
| 118 |
*/ |
| 119 |
public function unsetLimit(): void |
| 120 |
{ |
| 121 |
$this->limit = []; |
| 122 |
} |
| 123 |
|
| 124 |
/** |
| 125 |
* Returns Location Id. |
| 126 |
* If present, only returns devices at the target location. |
| 127 |
*/ |
| 128 |
public function getLocationId(): ?string |
| 129 |
{ |
| 130 |
if (count($this->locationId) == 0) { |
| 131 |
return null; |
| 132 |
} |
| 133 |
return $this->locationId['value']; |
| 134 |
} |
| 135 |
|
| 136 |
/** |
| 137 |
* Sets Location Id. |
| 138 |
* If present, only returns devices at the target location. |
| 139 |
* |
| 140 |
* @maps location_id |
| 141 |
*/ |
| 142 |
public function setLocationId(?string $locationId): void |
| 143 |
{ |
| 144 |
$this->locationId['value'] = $locationId; |
| 145 |
} |
| 146 |
|
| 147 |
/** |
| 148 |
* Unsets Location Id. |
| 149 |
* If present, only returns devices at the target location. |
| 150 |
*/ |
| 151 |
public function unsetLocationId(): void |
| 152 |
{ |
| 153 |
$this->locationId = []; |
| 154 |
} |
| 155 |
|
| 156 |
/** |
| 157 |
* Encode this object to JSON |
| 158 |
* |
| 159 |
* @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields |
| 160 |
* are set. (default: false) |
| 161 |
* |
| 162 |
* @return array|stdClass |
| 163 |
*/ |
| 164 |
#[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1) |
| 165 |
public function jsonSerialize(bool $asArrayWhenEmpty = false) |
| 166 |
{ |
| 167 |
$json = []; |
| 168 |
if (!empty($this->cursor)) { |
| 169 |
$json['cursor'] = $this->cursor['value']; |
| 170 |
} |
| 171 |
if (isset($this->sortOrder)) { |
| 172 |
$json['sort_order'] = $this->sortOrder; |
| 173 |
} |
| 174 |
if (!empty($this->limit)) { |
| 175 |
$json['limit'] = $this->limit['value']; |
| 176 |
} |
| 177 |
if (!empty($this->locationId)) { |
| 178 |
$json['location_id'] = $this->locationId['value']; |
| 179 |
} |
| 180 |
$json = array_filter($json, function ($val) { |
| 181 |
return $val !== null; |
| 182 |
}); |
| 183 |
|
| 184 |
return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json; |
| 185 |
} |
| 186 |
} |
| 187 |
|