charitable
/
vendor
/
square
/
square
/
src
/
Legacy
/
Models
/
UpdateWebhookSubscriptionSignatureKeyResponse.php
UpdateWebhookSubscriptionSignatureKeyResponse.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at vendor/square/square/src/Legacy/Models/UpdateWebhookSubscriptionSignatureKeyResponse.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 |
| 12 | * [UpdateWebhookSubscriptionSignatureKey]($e/WebhookSubscriptions/UpdateWebhookSubscriptionSignatureKe |
| 13 | * y) endpoint. |
| 14 | * |
| 15 | * Note: If there are errors processing the request, the [Subscription]($m/WebhookSubscription) is not |
| 16 | * present. |
| 17 | */ |
| 18 | class UpdateWebhookSubscriptionSignatureKeyResponse implements \JsonSerializable |
| 19 | { |
| 20 | /** |
| 21 | * @var Error[]|null |
| 22 | */ |
| 23 | private $errors; |
| 24 | |
| 25 | /** |
| 26 | * @var string|null |
| 27 | */ |
| 28 | private $signatureKey; |
| 29 | |
| 30 | /** |
| 31 | * Returns Errors. |
| 32 | * Information on 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 | * Information on 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 Signature Key. |
| 56 | * The new Square-generated signature key used to validate the origin of the webhook event. |
| 57 | */ |
| 58 | public function getSignatureKey(): ?string |
| 59 | { |
| 60 | return $this->signatureKey; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Sets Signature Key. |
| 65 | * The new Square-generated signature key used to validate the origin of the webhook event. |
| 66 | * |
| 67 | * @maps signature_key |
| 68 | */ |
| 69 | public function setSignatureKey(?string $signatureKey): void |
| 70 | { |
| 71 | $this->signatureKey = $signatureKey; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Encode this object to JSON |
| 76 | * |
| 77 | * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields |
| 78 | * are set. (default: false) |
| 79 | * |
| 80 | * @return array|stdClass |
| 81 | */ |
| 82 | #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1) |
| 83 | public function jsonSerialize(bool $asArrayWhenEmpty = false) |
| 84 | { |
| 85 | $json = []; |
| 86 | if (isset($this->errors)) { |
| 87 | $json['errors'] = $this->errors; |
| 88 | } |
| 89 | if (isset($this->signatureKey)) { |
| 90 | $json['signature_key'] = $this->signatureKey; |
| 91 | } |
| 92 | $json = array_filter($json, function ($val) { |
| 93 | return $val !== null; |
| 94 | }); |
| 95 | |
| 96 | return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json; |
| 97 | } |
| 98 | } |
| 99 |