| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Square\Legacy\Models; |
| 6 |
|
| 7 |
use stdClass; |
| 8 |
|
| 9 |
/** |
| 10 |
* Defines output parameters in a response from the |
| 11 |
* [ListSubscriptionEvents]($e/Subscriptions/ListSubscriptionEvents). |
| 12 |
*/ |
| 13 |
class ListSubscriptionEventsResponse implements \JsonSerializable |
| 14 |
{ |
| 15 |
/** |
| 16 |
* @var Error[]|null |
| 17 |
*/ |
| 18 |
private $errors; |
| 19 |
|
| 20 |
/** |
| 21 |
* @var SubscriptionEvent[]|null |
| 22 |
*/ |
| 23 |
private $subscriptionEvents; |
| 24 |
|
| 25 |
/** |
| 26 |
* @var string|null |
| 27 |
*/ |
| 28 |
private $cursor; |
| 29 |
|
| 30 |
/** |
| 31 |
* Returns Errors. |
| 32 |
* Errors encountered during the request. |
| 33 |
* |
| 34 |
* @return Error[]|null |
| 35 |
*/ |
| 36 |
public function getErrors(): ?array |
| 37 |
{ |
| 38 |
return $this->errors; |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Sets Errors. |
| 43 |
* Errors encountered during the request. |
| 44 |
* |
| 45 |
* @maps errors |
| 46 |
* |
| 47 |
* @param Error[]|null $errors |
| 48 |
*/ |
| 49 |
public function setErrors(?array $errors): void |
| 50 |
{ |
| 51 |
$this->errors = $errors; |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Returns Subscription Events. |
| 56 |
* The retrieved subscription events. |
| 57 |
* |
| 58 |
* @return SubscriptionEvent[]|null |
| 59 |
*/ |
| 60 |
public function getSubscriptionEvents(): ?array |
| 61 |
{ |
| 62 |
return $this->subscriptionEvents; |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* Sets Subscription Events. |
| 67 |
* The retrieved subscription events. |
| 68 |
* |
| 69 |
* @maps subscription_events |
| 70 |
* |
| 71 |
* @param SubscriptionEvent[]|null $subscriptionEvents |
| 72 |
*/ |
| 73 |
public function setSubscriptionEvents(?array $subscriptionEvents): void |
| 74 |
{ |
| 75 |
$this->subscriptionEvents = $subscriptionEvents; |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* Returns Cursor. |
| 80 |
* When the total number of resulting subscription events exceeds the limit of a paged response, |
| 81 |
* the response includes a cursor for you to use in a subsequent request to fetch the next set of |
| 82 |
* events. |
| 83 |
* If the cursor is unset, the response contains the last page of the results. |
| 84 |
* |
| 85 |
* For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api- |
| 86 |
* patterns/pagination). |
| 87 |
*/ |
| 88 |
public function getCursor(): ?string |
| 89 |
{ |
| 90 |
return $this->cursor; |
| 91 |
} |
| 92 |
|
| 93 |
/** |
| 94 |
* Sets Cursor. |
| 95 |
* When the total number of resulting subscription events exceeds the limit of a paged response, |
| 96 |
* the response includes a cursor for you to use in a subsequent request to fetch the next set of |
| 97 |
* events. |
| 98 |
* If the cursor is unset, the response contains the last page of the results. |
| 99 |
* |
| 100 |
* For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api- |
| 101 |
* patterns/pagination). |
| 102 |
* |
| 103 |
* @maps cursor |
| 104 |
*/ |
| 105 |
public function setCursor(?string $cursor): void |
| 106 |
{ |
| 107 |
$this->cursor = $cursor; |
| 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->errors)) { |
| 123 |
$json['errors'] = $this->errors; |
| 124 |
} |
| 125 |
if (isset($this->subscriptionEvents)) { |
| 126 |
$json['subscription_events'] = $this->subscriptionEvents; |
| 127 |
} |
| 128 |
if (isset($this->cursor)) { |
| 129 |
$json['cursor'] = $this->cursor; |
| 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 |
|