| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Square\Legacy\Models; |
| 6 |
|
| 7 |
use stdClass; |
| 8 |
|
| 9 |
class SearchTerminalCheckoutsRequest implements \JsonSerializable |
| 10 |
{ |
| 11 |
/** |
| 12 |
* @var TerminalCheckoutQuery|null |
| 13 |
*/ |
| 14 |
private $query; |
| 15 |
|
| 16 |
/** |
| 17 |
* @var string|null |
| 18 |
*/ |
| 19 |
private $cursor; |
| 20 |
|
| 21 |
/** |
| 22 |
* @var int|null |
| 23 |
*/ |
| 24 |
private $limit; |
| 25 |
|
| 26 |
/** |
| 27 |
* Returns Query. |
| 28 |
*/ |
| 29 |
public function getQuery(): ?TerminalCheckoutQuery |
| 30 |
{ |
| 31 |
return $this->query; |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Sets Query. |
| 36 |
* |
| 37 |
* @maps query |
| 38 |
*/ |
| 39 |
public function setQuery(?TerminalCheckoutQuery $query): void |
| 40 |
{ |
| 41 |
$this->query = $query; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Returns Cursor. |
| 46 |
* A pagination cursor returned by a previous call to this endpoint. |
| 47 |
* Provide this cursor to retrieve the next set of results for the original query. |
| 48 |
* See [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination) |
| 49 |
* for more information. |
| 50 |
*/ |
| 51 |
public function getCursor(): ?string |
| 52 |
{ |
| 53 |
return $this->cursor; |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Sets Cursor. |
| 58 |
* A pagination cursor returned by a previous call to this endpoint. |
| 59 |
* Provide this cursor to retrieve the next set of results for the original query. |
| 60 |
* See [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination) |
| 61 |
* for more information. |
| 62 |
* |
| 63 |
* @maps cursor |
| 64 |
*/ |
| 65 |
public function setCursor(?string $cursor): void |
| 66 |
{ |
| 67 |
$this->cursor = $cursor; |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* Returns Limit. |
| 72 |
* Limits the number of results returned for a single request. |
| 73 |
*/ |
| 74 |
public function getLimit(): ?int |
| 75 |
{ |
| 76 |
return $this->limit; |
| 77 |
} |
| 78 |
|
| 79 |
/** |
| 80 |
* Sets Limit. |
| 81 |
* Limits the number of results returned for a single request. |
| 82 |
* |
| 83 |
* @maps limit |
| 84 |
*/ |
| 85 |
public function setLimit(?int $limit): void |
| 86 |
{ |
| 87 |
$this->limit = $limit; |
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* Encode this object to JSON |
| 92 |
* |
| 93 |
* @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields |
| 94 |
* are set. (default: false) |
| 95 |
* |
| 96 |
* @return array|stdClass |
| 97 |
*/ |
| 98 |
#[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1) |
| 99 |
public function jsonSerialize(bool $asArrayWhenEmpty = false) |
| 100 |
{ |
| 101 |
$json = []; |
| 102 |
if (isset($this->query)) { |
| 103 |
$json['query'] = $this->query; |
| 104 |
} |
| 105 |
if (isset($this->cursor)) { |
| 106 |
$json['cursor'] = $this->cursor; |
| 107 |
} |
| 108 |
if (isset($this->limit)) { |
| 109 |
$json['limit'] = $this->limit; |
| 110 |
} |
| 111 |
$json = array_filter($json, function ($val) { |
| 112 |
return $val !== null; |
| 113 |
}); |
| 114 |
|
| 115 |
return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json; |
| 116 |
} |
| 117 |
} |
| 118 |
|