-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathCustomLineItemModel.php
More file actions
671 lines (590 loc) · 17.8 KB
/
Copy pathCustomLineItemModel.php
File metadata and controls
671 lines (590 loc) · 17.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
<?php
declare(strict_types=1);
/**
* This file has been auto generated
* Do not change it.
*/
namespace Commercetools\Api\Models\Cart;
use Commercetools\Api\Models\Common\CentPrecisionMoney;
use Commercetools\Api\Models\Common\CentPrecisionMoneyModel;
use Commercetools\Api\Models\Common\LocalizedString;
use Commercetools\Api\Models\Common\LocalizedStringModel;
use Commercetools\Api\Models\Common\TypedMoney;
use Commercetools\Api\Models\Common\TypedMoneyModel;
use Commercetools\Api\Models\Order\ItemStateCollection;
use Commercetools\Api\Models\TaxCategory\TaxCategoryReference;
use Commercetools\Api\Models\TaxCategory\TaxCategoryReferenceModel;
use Commercetools\Api\Models\TaxCategory\TaxRate;
use Commercetools\Api\Models\TaxCategory\TaxRateModel;
use Commercetools\Api\Models\Type\CustomFields;
use Commercetools\Api\Models\Type\CustomFieldsModel;
use Commercetools\Base\DateTimeImmutableCollection;
use Commercetools\Base\JsonObject;
use Commercetools\Base\JsonObjectModel;
use Commercetools\Base\MapperFactory;
use stdClass;
/**
* @internal
*/
final class CustomLineItemModel extends JsonObjectModel implements CustomLineItem
{
/**
*
* @var ?string
*/
protected $id;
/**
*
* @var ?string
*/
protected $key;
/**
*
* @var ?LocalizedString
*/
protected $name;
/**
*
* @var ?TypedMoney
*/
protected $money;
/**
*
* @var ?TaxedItemPrice
*/
protected $taxedPrice;
/**
*
* @var ?MethodTaxedPriceCollection
*/
protected $taxedPricePortions;
/**
*
* @var ?CentPrecisionMoney
*/
protected $totalPrice;
/**
*
* @var ?string
*/
protected $slug;
/**
*
* @var ?int
*/
protected $quantity;
/**
*
* @var ?ItemStateCollection
*/
protected $state;
/**
*
* @var ?TaxCategoryReference
*/
protected $taxCategory;
/**
*
* @var ?TaxRate
*/
protected $taxRate;
/**
*
* @var ?MethodTaxRateCollection
*/
protected $perMethodTaxRate;
/**
*
* @var ?DiscountedLineItemPriceForQuantityCollection
*/
protected $discountedPricePerQuantity;
/**
*
* @var ?CustomFields
*/
protected $custom;
/**
*
* @var ?ItemShippingDetails
*/
protected $shippingDetails;
/**
*
* @var ?string
*/
protected $priceMode;
/**
* @psalm-suppress MissingParamType
*/
public function __construct(
?string $id = null,
?string $key = null,
?LocalizedString $name = null,
?TypedMoney $money = null,
?TaxedItemPrice $taxedPrice = null,
?MethodTaxedPriceCollection $taxedPricePortions = null,
?CentPrecisionMoney $totalPrice = null,
?string $slug = null,
?int $quantity = null,
?ItemStateCollection $state = null,
?TaxCategoryReference $taxCategory = null,
?TaxRate $taxRate = null,
?MethodTaxRateCollection $perMethodTaxRate = null,
?DiscountedLineItemPriceForQuantityCollection $discountedPricePerQuantity = null,
?CustomFields $custom = null,
?ItemShippingDetails $shippingDetails = null,
?string $priceMode = null
) {
$this->id = $id;
$this->key = $key;
$this->name = $name;
$this->money = $money;
$this->taxedPrice = $taxedPrice;
$this->taxedPricePortions = $taxedPricePortions;
$this->totalPrice = $totalPrice;
$this->slug = $slug;
$this->quantity = $quantity;
$this->state = $state;
$this->taxCategory = $taxCategory;
$this->taxRate = $taxRate;
$this->perMethodTaxRate = $perMethodTaxRate;
$this->discountedPricePerQuantity = $discountedPricePerQuantity;
$this->custom = $custom;
$this->shippingDetails = $shippingDetails;
$this->priceMode = $priceMode;
}
/**
* <p>Unique identifier of the Custom Line Item.</p>
*
*
* @return null|string
*/
public function getId()
{
if (is_null($this->id)) {
/** @psalm-var ?string $data */
$data = $this->raw(self::FIELD_ID);
if (is_null($data)) {
return null;
}
$this->id = (string) $data;
}
return $this->id;
}
/**
* <p>User-defined unique identifier of the Custom Line Item.</p>
*
*
* @return null|string
*/
public function getKey()
{
if (is_null($this->key)) {
/** @psalm-var ?string $data */
$data = $this->raw(self::FIELD_KEY);
if (is_null($data)) {
return null;
}
$this->key = (string) $data;
}
return $this->key;
}
/**
* <p>Name of the Custom Line Item.</p>
*
*
* @return null|LocalizedString
*/
public function getName()
{
if (is_null($this->name)) {
/** @psalm-var stdClass|array<string, mixed>|null $data */
$data = $this->raw(self::FIELD_NAME);
if (is_null($data)) {
return null;
}
$this->name = LocalizedStringModel::of($data);
}
return $this->name;
}
/**
* <p>Money value of the Custom Line Item.</p>
*
*
* @return null|TypedMoney
*/
public function getMoney()
{
if (is_null($this->money)) {
/** @psalm-var stdClass|array<string, mixed>|null $data */
$data = $this->raw(self::FIELD_MONEY);
if (is_null($data)) {
return null;
}
$className = TypedMoneyModel::resolveDiscriminatorClass($data);
$this->money = $className::of($data);
}
return $this->money;
}
/**
* <p>Automatically set after the <code>taxRate</code> is set.</p>
*
*
* @return null|TaxedItemPrice
*/
public function getTaxedPrice()
{
if (is_null($this->taxedPrice)) {
/** @psalm-var stdClass|array<string, mixed>|null $data */
$data = $this->raw(self::FIELD_TAXED_PRICE);
if (is_null($data)) {
return null;
}
$this->taxedPrice = TaxedItemPriceModel::of($data);
}
return $this->taxedPrice;
}
/**
* <p>Total taxed prices based on the quantity of the Custom Line Item assigned to each <a href="ctp:api:type:ShippingMethod">Shipping Method</a>. Only applicable for Carts with <code>Multiple</code> <a href="ctp:api:type:ShippingMode">ShippingMode</a>.
* Automatically set after <code>perMethodTaxRate</code> is set.</p>
*
*
* @return null|MethodTaxedPriceCollection
*/
public function getTaxedPricePortions()
{
if (is_null($this->taxedPricePortions)) {
/** @psalm-var ?list<stdClass> $data */
$data = $this->raw(self::FIELD_TAXED_PRICE_PORTIONS);
if (is_null($data)) {
return null;
}
$this->taxedPricePortions = MethodTaxedPriceCollection::fromArray($data);
}
return $this->taxedPricePortions;
}
/**
* <p>Total price of the Custom Line Item (<code>money</code> multiplied by <code>quantity</code>).
* If the Custom Line Item is discounted, the total price is <code>discountedPricePerQuantity</code> multiplied by <code>quantity</code>.</p>
* <p>Includes taxes if the <a href="ctp:api:type:TaxRate">TaxRate</a> <code>includedInPrice</code> is <code>true</code>.</p>
*
*
* @return null|CentPrecisionMoney
*/
public function getTotalPrice()
{
if (is_null($this->totalPrice)) {
/** @psalm-var stdClass|array<string, mixed>|null $data */
$data = $this->raw(self::FIELD_TOTAL_PRICE);
if (is_null($data)) {
return null;
}
$this->totalPrice = CentPrecisionMoneyModel::of($data);
}
return $this->totalPrice;
}
/**
* <p>User-defined identifier used in a deep-link URL for the Custom Line Item.
* It matches the pattern <code>[a-zA-Z0-9_-]{2,256}</code>.</p>
*
*
* @return null|string
*/
public function getSlug()
{
if (is_null($this->slug)) {
/** @psalm-var ?string $data */
$data = $this->raw(self::FIELD_SLUG);
if (is_null($data)) {
return null;
}
$this->slug = (string) $data;
}
return $this->slug;
}
/**
* <p>Number of Custom Line Items in the <a href="ctp:api:type:Cart">Cart</a> or <a href="ctp:api:type:Order">Order</a>.</p>
*
*
* @return null|int
*/
public function getQuantity()
{
if (is_null($this->quantity)) {
/** @psalm-var ?int $data */
$data = $this->raw(self::FIELD_QUANTITY);
if (is_null($data)) {
return null;
}
$this->quantity = (int) $data;
}
return $this->quantity;
}
/**
* <p>Tracks specific quantities of the Custom Line Item within a given State. When a Custom Line Item is added to a Cart, its full quantity is set to the built-in "Initial" state. State transitions for Custom Line Items are managed on the <a href="ctp:api:type:Order">Order</a>.</p>
*
*
* @return null|ItemStateCollection
*/
public function getState()
{
if (is_null($this->state)) {
/** @psalm-var ?list<stdClass> $data */
$data = $this->raw(self::FIELD_STATE);
if (is_null($data)) {
return null;
}
$this->state = ItemStateCollection::fromArray($data);
}
return $this->state;
}
/**
* <p>Used to select a Tax Rate when a Cart has the <code>Platform</code> <a href="ctp:api:type:TaxMode">TaxMode</a>.</p>
*
*
* @return null|TaxCategoryReference
*/
public function getTaxCategory()
{
if (is_null($this->taxCategory)) {
/** @psalm-var stdClass|array<string, mixed>|null $data */
$data = $this->raw(self::FIELD_TAX_CATEGORY);
if (is_null($data)) {
return null;
}
$this->taxCategory = TaxCategoryReferenceModel::of($data);
}
return $this->taxCategory;
}
/**
* <ul>
* <li>For a Cart with <code>Platform</code> <a href="ctp:api:type:TaxMode">TaxMode</a>, the <code>taxRate</code> of Custom Line Items is set automatically once a shipping address is set. The rate is based on the <a href="ctp:api:type:TaxCategory">TaxCategory</a> that applies for the shipping address.</li>
* <li>For a Cart with <code>External</code> TaxMode, the <code>taxRate</code> of Custom Line Items can be set using <a href="ctp:api:type:ExternalTaxRateDraft">ExternalTaxRateDraft</a>.</li>
* </ul>
*
*
* @return null|TaxRate
*/
public function getTaxRate()
{
if (is_null($this->taxRate)) {
/** @psalm-var stdClass|array<string, mixed>|null $data */
$data = $this->raw(self::FIELD_TAX_RATE);
if (is_null($data)) {
return null;
}
$this->taxRate = TaxRateModel::of($data);
}
return $this->taxRate;
}
/**
* <p>Tax Rate per Shipping Method for a Cart with <code>Multiple</code> <a href="ctp:api:type:ShippingMode">ShippingMode</a>. For a Cart with <code>Platform</code> <a href="ctp:api:type:TaxMode">TaxMode</a> it is automatically set after the <a href="ctp:api:type:CartAddShippingMethodAction">Shipping Method is added</a>.
* For a Cart with <code>External</code> <a href="ctp:api:type:TaxMode">TaxMode</a>, the Tax Rate must be set with <a href="ctp:api:type:ExternalTaxRateDraft">ExternalTaxRateDraft</a>.</p>
*
*
* @return null|MethodTaxRateCollection
*/
public function getPerMethodTaxRate()
{
if (is_null($this->perMethodTaxRate)) {
/** @psalm-var ?list<stdClass> $data */
$data = $this->raw(self::FIELD_PER_METHOD_TAX_RATE);
if (is_null($data)) {
return null;
}
$this->perMethodTaxRate = MethodTaxRateCollection::fromArray($data);
}
return $this->perMethodTaxRate;
}
/**
* <p>Discounted price of a single quantity of the Custom Line Item.</p>
*
*
* @return null|DiscountedLineItemPriceForQuantityCollection
*/
public function getDiscountedPricePerQuantity()
{
if (is_null($this->discountedPricePerQuantity)) {
/** @psalm-var ?list<stdClass> $data */
$data = $this->raw(self::FIELD_DISCOUNTED_PRICE_PER_QUANTITY);
if (is_null($data)) {
return null;
}
$this->discountedPricePerQuantity = DiscountedLineItemPriceForQuantityCollection::fromArray($data);
}
return $this->discountedPricePerQuantity;
}
/**
* <p>Custom Fields of the Custom Line Item.</p>
*
*
* @return null|CustomFields
*/
public function getCustom()
{
if (is_null($this->custom)) {
/** @psalm-var stdClass|array<string, mixed>|null $data */
$data = $this->raw(self::FIELD_CUSTOM);
if (is_null($data)) {
return null;
}
$this->custom = CustomFieldsModel::of($data);
}
return $this->custom;
}
/**
* <p>Container for Custom Line Item-specific addresses.</p>
*
*
* @return null|ItemShippingDetails
*/
public function getShippingDetails()
{
if (is_null($this->shippingDetails)) {
/** @psalm-var stdClass|array<string, mixed>|null $data */
$data = $this->raw(self::FIELD_SHIPPING_DETAILS);
if (is_null($data)) {
return null;
}
$this->shippingDetails = ItemShippingDetailsModel::of($data);
}
return $this->shippingDetails;
}
/**
* <p>Indicates whether Cart Discounts with a matching <a href="ctp:api:type:CartDiscountCustomLineItemsTarget">CartDiscountCustomLineItemsTarget</a>, <a href="ctp:api:type:MultiBuyCustomLineItemsTarget">MultiBuyCustomLineItemsTarget</a>, or <a href="ctp:api:type:CartDiscountPatternTarget">CartDiscountPatternTarget</a> are applied to the Custom Line Item.</p>
*
*
* @return null|string
*/
public function getPriceMode()
{
if (is_null($this->priceMode)) {
/** @psalm-var ?string $data */
$data = $this->raw(self::FIELD_PRICE_MODE);
if (is_null($data)) {
return null;
}
$this->priceMode = (string) $data;
}
return $this->priceMode;
}
/**
* @param ?string $id
*/
public function setId(?string $id): void
{
$this->id = $id;
}
/**
* @param ?string $key
*/
public function setKey(?string $key): void
{
$this->key = $key;
}
/**
* @param ?LocalizedString $name
*/
public function setName(?LocalizedString $name): void
{
$this->name = $name;
}
/**
* @param ?TypedMoney $money
*/
public function setMoney(?TypedMoney $money): void
{
$this->money = $money;
}
/**
* @param ?TaxedItemPrice $taxedPrice
*/
public function setTaxedPrice(?TaxedItemPrice $taxedPrice): void
{
$this->taxedPrice = $taxedPrice;
}
/**
* @param ?MethodTaxedPriceCollection $taxedPricePortions
*/
public function setTaxedPricePortions(?MethodTaxedPriceCollection $taxedPricePortions): void
{
$this->taxedPricePortions = $taxedPricePortions;
}
/**
* @param ?CentPrecisionMoney $totalPrice
*/
public function setTotalPrice(?CentPrecisionMoney $totalPrice): void
{
$this->totalPrice = $totalPrice;
}
/**
* @param ?string $slug
*/
public function setSlug(?string $slug): void
{
$this->slug = $slug;
}
/**
* @param ?int $quantity
*/
public function setQuantity(?int $quantity): void
{
$this->quantity = $quantity;
}
/**
* @param ?ItemStateCollection $state
*/
public function setState(?ItemStateCollection $state): void
{
$this->state = $state;
}
/**
* @param ?TaxCategoryReference $taxCategory
*/
public function setTaxCategory(?TaxCategoryReference $taxCategory): void
{
$this->taxCategory = $taxCategory;
}
/**
* @param ?TaxRate $taxRate
*/
public function setTaxRate(?TaxRate $taxRate): void
{
$this->taxRate = $taxRate;
}
/**
* @param ?MethodTaxRateCollection $perMethodTaxRate
*/
public function setPerMethodTaxRate(?MethodTaxRateCollection $perMethodTaxRate): void
{
$this->perMethodTaxRate = $perMethodTaxRate;
}
/**
* @param ?DiscountedLineItemPriceForQuantityCollection $discountedPricePerQuantity
*/
public function setDiscountedPricePerQuantity(?DiscountedLineItemPriceForQuantityCollection $discountedPricePerQuantity): void
{
$this->discountedPricePerQuantity = $discountedPricePerQuantity;
}
/**
* @param ?CustomFields $custom
*/
public function setCustom(?CustomFields $custom): void
{
$this->custom = $custom;
}
/**
* @param ?ItemShippingDetails $shippingDetails
*/
public function setShippingDetails(?ItemShippingDetails $shippingDetails): void
{
$this->shippingDetails = $shippingDetails;
}
/**
* @param ?string $priceMode
*/
public function setPriceMode(?string $priceMode): void
{
$this->priceMode = $priceMode;
}
}