PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13.1
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13.1
1.8.13.1 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 All 212 releases
charitable / vendor / square / square / src / Legacy / Models / CatalogQuickAmount.php

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

192 lines 4.7 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 * Represents a Quick Amount in the Catalog.
11 */
12 class CatalogQuickAmount implements \JsonSerializable
13 {
14 /**
15 * @var string
16 */
17 private $type;
18
19 /**
20 * @var Money
21 */
22 private $amount;
23
24 /**
25 * @var array
26 */
27 private $score = [];
28
29 /**
30 * @var array
31 */
32 private $ordinal = [];
33
34 /**
35 * @param string $type
36 * @param Money $amount
37 */
38 public function __construct(string $type, Money $amount)
39 {
40 $this->type = $type;
41 $this->amount = $amount;
42 }
43
44 /**
45 * Returns Type.
46 * Determines the type of a specific Quick Amount.
47 */
48 public function getType(): string
49 {
50 return $this->type;
51 }
52
53 /**
54 * Sets Type.
55 * Determines the type of a specific Quick Amount.
56 *
57 * @required
58 * @maps type
59 */
60 public function setType(string $type): void
61 {
62 $this->type = $type;
63 }
64
65 /**
66 * Returns Amount.
67 * Represents an amount of money. `Money` fields can be signed or unsigned.
68 * Fields that do not explicitly define whether they are signed or unsigned are
69 * considered unsigned and can only hold positive amounts. For signed fields, the
70 * sign of the value indicates the purpose of the money transfer. See
71 * [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-
72 * monetary-amounts)
73 * for more information.
74 */
75 public function getAmount(): Money
76 {
77 return $this->amount;
78 }
79
80 /**
81 * Sets Amount.
82 * Represents an amount of money. `Money` fields can be signed or unsigned.
83 * Fields that do not explicitly define whether they are signed or unsigned are
84 * considered unsigned and can only hold positive amounts. For signed fields, the
85 * sign of the value indicates the purpose of the money transfer. See
86 * [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-
87 * monetary-amounts)
88 * for more information.
89 *
90 * @required
91 * @maps amount
92 */
93 public function setAmount(Money $amount): void
94 {
95 $this->amount = $amount;
96 }
97
98 /**
99 * Returns Score.
100 * Describes the ranking of the Quick Amount provided by machine learning model, in the range [0, 100].
101 * MANUAL type amount will always have score = 100.
102 */
103 public function getScore(): ?int
104 {
105 if (count($this->score) == 0) {
106 return null;
107 }
108 return $this->score['value'];
109 }
110
111 /**
112 * Sets Score.
113 * Describes the ranking of the Quick Amount provided by machine learning model, in the range [0, 100].
114 * MANUAL type amount will always have score = 100.
115 *
116 * @maps score
117 */
118 public function setScore(?int $score): void
119 {
120 $this->score['value'] = $score;
121 }
122
123 /**
124 * Unsets Score.
125 * Describes the ranking of the Quick Amount provided by machine learning model, in the range [0, 100].
126 * MANUAL type amount will always have score = 100.
127 */
128 public function unsetScore(): void
129 {
130 $this->score = [];
131 }
132
133 /**
134 * Returns Ordinal.
135 * The order in which this Quick Amount should be displayed.
136 */
137 public function getOrdinal(): ?int
138 {
139 if (count($this->ordinal) == 0) {
140 return null;
141 }
142 return $this->ordinal['value'];
143 }
144
145 /**
146 * Sets Ordinal.
147 * The order in which this Quick Amount should be displayed.
148 *
149 * @maps ordinal
150 */
151 public function setOrdinal(?int $ordinal): void
152 {
153 $this->ordinal['value'] = $ordinal;
154 }
155
156 /**
157 * Unsets Ordinal.
158 * The order in which this Quick Amount should be displayed.
159 */
160 public function unsetOrdinal(): void
161 {
162 $this->ordinal = [];
163 }
164
165 /**
166 * Encode this object to JSON
167 *
168 * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields
169 * are set. (default: false)
170 *
171 * @return array|stdClass
172 */
173 #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1)
174 public function jsonSerialize(bool $asArrayWhenEmpty = false)
175 {
176 $json = [];
177 $json['type'] = $this->type;
178 $json['amount'] = $this->amount;
179 if (!empty($this->score)) {
180 $json['score'] = $this->score['value'];
181 }
182 if (!empty($this->ordinal)) {
183 $json['ordinal'] = $this->ordinal['value'];
184 }
185 $json = array_filter($json, function ($val) {
186 return $val !== null;
187 });
188
189 return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json;
190 }
191 }
192