charitable
/
vendor
/
square
/
square
/
src
/
Legacy
/
Models
/
DeleteSubscriptionActionResponse.php
DeleteSubscriptionActionResponse.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at vendor/square/square/src/Legacy/Models/DeleteSubscriptionActionResponse.php
| 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 of the |
| 11 | * [DeleteSubscriptionAction]($e/Subscriptions/DeleteSubscriptionAction) |
| 12 | * endpoint. |
| 13 | */ |
| 14 | class DeleteSubscriptionActionResponse implements \JsonSerializable |
| 15 | { |
| 16 | /** |
| 17 | * @var Error[]|null |
| 18 | */ |
| 19 | private $errors; |
| 20 | |
| 21 | /** |
| 22 | * @var Subscription|null |
| 23 | */ |
| 24 | private $subscription; |
| 25 | |
| 26 | /** |
| 27 | * Returns Errors. |
| 28 | * Errors encountered during the request. |
| 29 | * |
| 30 | * @return Error[]|null |
| 31 | */ |
| 32 | public function getErrors(): ?array |
| 33 | { |
| 34 | return $this->errors; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Sets Errors. |
| 39 | * Errors encountered during the request. |
| 40 | * |
| 41 | * @maps errors |
| 42 | * |
| 43 | * @param Error[]|null $errors |
| 44 | */ |
| 45 | public function setErrors(?array $errors): void |
| 46 | { |
| 47 | $this->errors = $errors; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Returns Subscription. |
| 52 | * Represents a subscription purchased by a customer. |
| 53 | * |
| 54 | * For more information, see |
| 55 | * [Manage Subscriptions](https://developer.squareup.com/docs/subscriptions-api/manage-subscriptions). |
| 56 | */ |
| 57 | public function getSubscription(): ?Subscription |
| 58 | { |
| 59 | return $this->subscription; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Sets Subscription. |
| 64 | * Represents a subscription purchased by a customer. |
| 65 | * |
| 66 | * For more information, see |
| 67 | * [Manage Subscriptions](https://developer.squareup.com/docs/subscriptions-api/manage-subscriptions). |
| 68 | * |
| 69 | * @maps subscription |
| 70 | */ |
| 71 | public function setSubscription(?Subscription $subscription): void |
| 72 | { |
| 73 | $this->subscription = $subscription; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Encode this object to JSON |
| 78 | * |
| 79 | * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields |
| 80 | * are set. (default: false) |
| 81 | * |
| 82 | * @return array|stdClass |
| 83 | */ |
| 84 | #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1) |
| 85 | public function jsonSerialize(bool $asArrayWhenEmpty = false) |
| 86 | { |
| 87 | $json = []; |
| 88 | if (isset($this->errors)) { |
| 89 | $json['errors'] = $this->errors; |
| 90 | } |
| 91 | if (isset($this->subscription)) { |
| 92 | $json['subscription'] = $this->subscription; |
| 93 | } |
| 94 | $json = array_filter($json, function ($val) { |
| 95 | return $val !== null; |
| 96 | }); |
| 97 | |
| 98 | return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json; |
| 99 | } |
| 100 | } |
| 101 |