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 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 / InventoryCount.php

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

317 lines 9.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 * Represents Square-estimated quantity of items in a particular state at a
11 * particular seller location based on the known history of physical counts and
12 * inventory adjustments.
13 */
14 class InventoryCount implements \JsonSerializable
15 {
16 /**
17 * @var array
18 */
19 private $catalogObjectId = [];
20
21 /**
22 * @var array
23 */
24 private $catalogObjectType = [];
25
26 /**
27 * @var string|null
28 */
29 private $state;
30
31 /**
32 * @var array
33 */
34 private $locationId = [];
35
36 /**
37 * @var array
38 */
39 private $quantity = [];
40
41 /**
42 * @var string|null
43 */
44 private $calculatedAt;
45
46 /**
47 * @var bool|null
48 */
49 private $isEstimated;
50
51 /**
52 * Returns Catalog Object Id.
53 * The Square-generated ID of the
54 * [CatalogObject](entity:CatalogObject) being tracked.
55 */
56 public function getCatalogObjectId(): ?string
57 {
58 if (count($this->catalogObjectId) == 0) {
59 return null;
60 }
61 return $this->catalogObjectId['value'];
62 }
63
64 /**
65 * Sets Catalog Object Id.
66 * The Square-generated ID of the
67 * [CatalogObject](entity:CatalogObject) being tracked.
68 *
69 * @maps catalog_object_id
70 */
71 public function setCatalogObjectId(?string $catalogObjectId): void
72 {
73 $this->catalogObjectId['value'] = $catalogObjectId;
74 }
75
76 /**
77 * Unsets Catalog Object Id.
78 * The Square-generated ID of the
79 * [CatalogObject](entity:CatalogObject) being tracked.
80 */
81 public function unsetCatalogObjectId(): void
82 {
83 $this->catalogObjectId = [];
84 }
85
86 /**
87 * Returns Catalog Object Type.
88 * The [type](entity:CatalogObjectType) of the [CatalogObject](entity:CatalogObject) being tracked.
89 *
90 * The Inventory API supports setting and reading the `"catalog_object_type": "ITEM_VARIATION"` field
91 * value.
92 * In addition, it can also read the `"catalog_object_type": "ITEM"` field value that is set by the
93 * Square Restaurants app.
94 */
95 public function getCatalogObjectType(): ?string
96 {
97 if (count($this->catalogObjectType) == 0) {
98 return null;
99 }
100 return $this->catalogObjectType['value'];
101 }
102
103 /**
104 * Sets Catalog Object Type.
105 * The [type](entity:CatalogObjectType) of the [CatalogObject](entity:CatalogObject) being tracked.
106 *
107 * The Inventory API supports setting and reading the `"catalog_object_type": "ITEM_VARIATION"` field
108 * value.
109 * In addition, it can also read the `"catalog_object_type": "ITEM"` field value that is set by the
110 * Square Restaurants app.
111 *
112 * @maps catalog_object_type
113 */
114 public function setCatalogObjectType(?string $catalogObjectType): void
115 {
116 $this->catalogObjectType['value'] = $catalogObjectType;
117 }
118
119 /**
120 * Unsets Catalog Object Type.
121 * The [type](entity:CatalogObjectType) of the [CatalogObject](entity:CatalogObject) being tracked.
122 *
123 * The Inventory API supports setting and reading the `"catalog_object_type": "ITEM_VARIATION"` field
124 * value.
125 * In addition, it can also read the `"catalog_object_type": "ITEM"` field value that is set by the
126 * Square Restaurants app.
127 */
128 public function unsetCatalogObjectType(): void
129 {
130 $this->catalogObjectType = [];
131 }
132
133 /**
134 * Returns State.
135 * Indicates the state of a tracked item quantity in the lifecycle of goods.
136 */
137 public function getState(): ?string
138 {
139 return $this->state;
140 }
141
142 /**
143 * Sets State.
144 * Indicates the state of a tracked item quantity in the lifecycle of goods.
145 *
146 * @maps state
147 */
148 public function setState(?string $state): void
149 {
150 $this->state = $state;
151 }
152
153 /**
154 * Returns Location Id.
155 * The Square-generated ID of the [Location](entity:Location) where the related
156 * quantity of items is being tracked.
157 */
158 public function getLocationId(): ?string
159 {
160 if (count($this->locationId) == 0) {
161 return null;
162 }
163 return $this->locationId['value'];
164 }
165
166 /**
167 * Sets Location Id.
168 * The Square-generated ID of the [Location](entity:Location) where the related
169 * quantity of items is being tracked.
170 *
171 * @maps location_id
172 */
173 public function setLocationId(?string $locationId): void
174 {
175 $this->locationId['value'] = $locationId;
176 }
177
178 /**
179 * Unsets Location Id.
180 * The Square-generated ID of the [Location](entity:Location) where the related
181 * quantity of items is being tracked.
182 */
183 public function unsetLocationId(): void
184 {
185 $this->locationId = [];
186 }
187
188 /**
189 * Returns Quantity.
190 * The number of items affected by the estimated count as a decimal string.
191 * Can support up to 5 digits after the decimal point.
192 */
193 public function getQuantity(): ?string
194 {
195 if (count($this->quantity) == 0) {
196 return null;
197 }
198 return $this->quantity['value'];
199 }
200
201 /**
202 * Sets Quantity.
203 * The number of items affected by the estimated count as a decimal string.
204 * Can support up to 5 digits after the decimal point.
205 *
206 * @maps quantity
207 */
208 public function setQuantity(?string $quantity): void
209 {
210 $this->quantity['value'] = $quantity;
211 }
212
213 /**
214 * Unsets Quantity.
215 * The number of items affected by the estimated count as a decimal string.
216 * Can support up to 5 digits after the decimal point.
217 */
218 public function unsetQuantity(): void
219 {
220 $this->quantity = [];
221 }
222
223 /**
224 * Returns Calculated At.
225 * An RFC 3339-formatted timestamp that indicates when the most recent physical count or adjustment
226 * affecting
227 * the estimated count is received.
228 */
229 public function getCalculatedAt(): ?string
230 {
231 return $this->calculatedAt;
232 }
233
234 /**
235 * Sets Calculated At.
236 * An RFC 3339-formatted timestamp that indicates when the most recent physical count or adjustment
237 * affecting
238 * the estimated count is received.
239 *
240 * @maps calculated_at
241 */
242 public function setCalculatedAt(?string $calculatedAt): void
243 {
244 $this->calculatedAt = $calculatedAt;
245 }
246
247 /**
248 * Returns Is Estimated.
249 * Whether the inventory count is for composed variation (TRUE) or not (FALSE). If true, the inventory
250 * count will not be present in the response of
251 * any of these endpoints: [BatchChangeInventory]($e/Inventory/BatchChangeInventory),
252 * [BatchRetrieveInventoryChanges]($e/Inventory/BatchRetrieveInventoryChanges),
253 * [BatchRetrieveInventoryCounts]($e/Inventory/BatchRetrieveInventoryCounts), and
254 * [RetrieveInventoryChanges]($e/Inventory/RetrieveInventoryChanges).
255 */
256 public function getIsEstimated(): ?bool
257 {
258 return $this->isEstimated;
259 }
260
261 /**
262 * Sets Is Estimated.
263 * Whether the inventory count is for composed variation (TRUE) or not (FALSE). If true, the inventory
264 * count will not be present in the response of
265 * any of these endpoints: [BatchChangeInventory]($e/Inventory/BatchChangeInventory),
266 * [BatchRetrieveInventoryChanges]($e/Inventory/BatchRetrieveInventoryChanges),
267 * [BatchRetrieveInventoryCounts]($e/Inventory/BatchRetrieveInventoryCounts), and
268 * [RetrieveInventoryChanges]($e/Inventory/RetrieveInventoryChanges).
269 *
270 * @maps is_estimated
271 */
272 public function setIsEstimated(?bool $isEstimated): void
273 {
274 $this->isEstimated = $isEstimated;
275 }
276
277 /**
278 * Encode this object to JSON
279 *
280 * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields
281 * are set. (default: false)
282 *
283 * @return array|stdClass
284 */
285 #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1)
286 public function jsonSerialize(bool $asArrayWhenEmpty = false)
287 {
288 $json = [];
289 if (!empty($this->catalogObjectId)) {
290 $json['catalog_object_id'] = $this->catalogObjectId['value'];
291 }
292 if (!empty($this->catalogObjectType)) {
293 $json['catalog_object_type'] = $this->catalogObjectType['value'];
294 }
295 if (isset($this->state)) {
296 $json['state'] = $this->state;
297 }
298 if (!empty($this->locationId)) {
299 $json['location_id'] = $this->locationId['value'];
300 }
301 if (!empty($this->quantity)) {
302 $json['quantity'] = $this->quantity['value'];
303 }
304 if (isset($this->calculatedAt)) {
305 $json['calculated_at'] = $this->calculatedAt;
306 }
307 if (isset($this->isEstimated)) {
308 $json['is_estimated'] = $this->isEstimated;
309 }
310 $json = array_filter($json, function ($val) {
311 return $val !== null;
312 });
313
314 return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json;
315 }
316 }
317