charitable
/
vendor
/
square
/
square
/
src
/
Legacy
/
Models
/
ListWebhookSubscriptionsResponse.php
ListWebhookSubscriptionsResponse.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13.1, at vendor/square/square/src/Legacy/Models/ListWebhookSubscriptionsResponse.php
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Square\Legacy\Models; |
| 6 | |
| 7 | use stdClass; |
| 8 | |
| 9 | /** |
| 10 | * Defines the fields that are included in the response body of |
| 11 | * a request to the [ListWebhookSubscriptions]($e/WebhookSubscriptions/ListWebhookSubscriptions) |
| 12 | * endpoint. |
| 13 | * |
| 14 | * Note: if there are errors processing the request, the subscriptions field will not be |
| 15 | * present. |
| 16 | */ |
| 17 | class ListWebhookSubscriptionsResponse implements \JsonSerializable |
| 18 | { |
| 19 | /** |
| 20 | * @var Error[]|null |
| 21 | */ |
| 22 | private $errors; |
| 23 | |
| 24 | /** |
| 25 | * @var WebhookSubscription[]|null |
| 26 | */ |
| 27 | private $subscriptions; |
| 28 | |
| 29 | /** |
| 30 | * @var string|null |
| 31 | */ |
| 32 | private $cursor; |
| 33 | |
| 34 | /** |
| 35 | * Returns Errors. |
| 36 | * Information on errors encountered during the request. |
| 37 | * |
| 38 | * @return Error[]|null |
| 39 | */ |
| 40 | public function getErrors(): ?array |
| 41 | { |
| 42 | return $this->errors; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Sets Errors. |
| 47 | * Information on errors encountered during the request. |
| 48 | * |
| 49 | * @maps errors |
| 50 | * |
| 51 | * @param Error[]|null $errors |
| 52 | */ |
| 53 | public function setErrors(?array $errors): void |
| 54 | { |
| 55 | $this->errors = $errors; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Returns Subscriptions. |
| 60 | * The requested list of [Subscription](entity:WebhookSubscription)s. |
| 61 | * |
| 62 | * @return WebhookSubscription[]|null |
| 63 | */ |
| 64 | public function getSubscriptions(): ?array |
| 65 | { |
| 66 | return $this->subscriptions; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Sets Subscriptions. |
| 71 | * The requested list of [Subscription](entity:WebhookSubscription)s. |
| 72 | * |
| 73 | * @maps subscriptions |
| 74 | * |
| 75 | * @param WebhookSubscription[]|null $subscriptions |
| 76 | */ |
| 77 | public function setSubscriptions(?array $subscriptions): void |
| 78 | { |
| 79 | $this->subscriptions = $subscriptions; |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Returns Cursor. |
| 84 | * The pagination cursor to be used in a subsequent request. If empty, |
| 85 | * this is the final response. |
| 86 | * |
| 87 | * For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api- |
| 88 | * patterns/pagination). |
| 89 | */ |
| 90 | public function getCursor(): ?string |
| 91 | { |
| 92 | return $this->cursor; |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Sets Cursor. |
| 97 | * The pagination cursor to be used in a subsequent request. If empty, |
| 98 | * this is the final response. |
| 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->subscriptions)) { |
| 126 | $json['subscriptions'] = $this->subscriptions; |
| 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 |