PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 1.7.0.9 All 211 releases
charitable / vendor / square / square / src / Legacy / Models / CreateGiftCardResponse.php

CreateGiftCardResponse.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at vendor/square/square/src/Legacy/Models/CreateGiftCardResponse.php

95 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Square\Legacy\Models;
6
7 use stdClass;
8
9 /**
10 * A response that contains a `GiftCard`. The response might contain a set of `Error` objects if the
11 * request
12 * resulted in errors.
13 */
14 class CreateGiftCardResponse implements \JsonSerializable
15 {
16 /**
17 * @var Error[]|null
18 */
19 private $errors;
20
21 /**
22 * @var GiftCard|null
23 */
24 private $giftCard;
25
26 /**
27 * Returns Errors.
28 * Any errors that occurred 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 * Any errors that occurred 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 Gift Card.
52 * Represents a Square gift card.
53 */
54 public function getGiftCard(): ?GiftCard
55 {
56 return $this->giftCard;
57 }
58
59 /**
60 * Sets Gift Card.
61 * Represents a Square gift card.
62 *
63 * @maps gift_card
64 */
65 public function setGiftCard(?GiftCard $giftCard): void
66 {
67 $this->giftCard = $giftCard;
68 }
69
70 /**
71 * Encode this object to JSON
72 *
73 * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields
74 * are set. (default: false)
75 *
76 * @return array|stdClass
77 */
78 #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1)
79 public function jsonSerialize(bool $asArrayWhenEmpty = false)
80 {
81 $json = [];
82 if (isset($this->errors)) {
83 $json['errors'] = $this->errors;
84 }
85 if (isset($this->giftCard)) {
86 $json['gift_card'] = $this->giftCard;
87 }
88 $json = array_filter($json, function ($val) {
89 return $val !== null;
90 });
91
92 return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json;
93 }
94 }
95