1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author @jenschude <[email protected]> |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Model\Cart; |
7
|
|
|
|
8
|
|
|
use Commercetools\Core\Model\Channel\ChannelReference; |
9
|
|
|
use Commercetools\Core\Model\Common\Context; |
10
|
|
|
use Commercetools\Core\Model\Common\JsonObject; |
11
|
|
|
use Commercetools\Core\Model\CustomField\CustomFieldObject; |
12
|
|
|
use DateTime; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @package Commercetools\Core\Model\Cart |
16
|
|
|
* @link https://docs.commercetools.com/http-api-projects-me-carts.html#mylineitemdraft |
17
|
|
|
* @method string getProductId() |
18
|
|
|
* @method MyLineItemDraft setProductId(string $productId = null) |
19
|
|
|
* @method int getVariantId() |
20
|
|
|
* @method MyLineItemDraft setVariantId(int $variantId = null) |
21
|
|
|
* @method int getQuantity() |
22
|
|
|
* @method MyLineItemDraft setQuantity(int $quantity = null) |
23
|
|
|
* @method ChannelReference getSupplyChannel() |
24
|
|
|
* @method MyLineItemDraft setSupplyChannel(ChannelReference $supplyChannel = null) |
25
|
|
|
* @method ChannelReference getDistributionChannel() |
26
|
|
|
* @method MyLineItemDraft setDistributionChannel(ChannelReference $distributionChannel = null) |
27
|
|
|
* @method CustomFieldObject getCustom() |
28
|
|
|
* @method MyLineItemDraft setCustom(CustomFieldObject $custom = null) |
29
|
|
|
* @method ItemShippingDetailsDraft getShippingDetails() |
30
|
|
|
* @method MyLineItemDraft setShippingDetails(ItemShippingDetailsDraft $shippingDetails = null) |
31
|
|
|
* @method string getSku() |
32
|
|
|
* @method MyLineItemDraft setSku(string $sku = null) |
33
|
|
|
* @method DateTime getAddedAt() |
34
|
|
|
* @method MyLineItemDraft setAddedAt(DateTime $addedAt = null) |
35
|
|
|
*/ |
36
|
|
|
class MyLineItemDraft extends JsonObject |
37
|
|
|
{ |
38
|
2 |
|
public function fieldDefinitions() |
39
|
|
|
{ |
40
|
|
|
return [ |
41
|
2 |
|
'productId' => [static::TYPE => 'string'], |
42
|
2 |
|
'variantId' => [static::TYPE => 'int'], |
43
|
2 |
|
'quantity' => [static::TYPE => 'int'], |
44
|
2 |
|
'supplyChannel' => [static::TYPE => ChannelReference::class], |
45
|
2 |
|
'distributionChannel' => [static::TYPE => ChannelReference::class], |
46
|
2 |
|
'custom' => [static::TYPE => CustomFieldObject::class], |
47
|
2 |
|
'shippingDetails' => [static::TYPE => ItemShippingDetailsDraft::class], |
48
|
2 |
|
'sku' => [static::TYPE => 'string'], |
49
|
2 |
|
'addedAt' => [static::TYPE => DateTime::class], |
50
|
|
|
]; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param string $productId |
55
|
|
|
* @param Context|callable $context |
56
|
|
|
* @return MyLineItemDraft |
57
|
|
|
*/ |
58
|
|
|
public static function ofProductId($productId, $context = null) |
59
|
|
|
{ |
60
|
|
|
return static::of($context)->setProductId($productId); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param string $sku |
65
|
|
|
* @param Context|callable $context |
66
|
|
|
* @return MyLineItemDraft |
67
|
|
|
*/ |
68
|
|
|
public static function ofSku($sku, $context = null) |
69
|
|
|
{ |
70
|
|
|
return static::of($context)->setSku($sku); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @param string $productId |
75
|
|
|
* @param int $variantId |
76
|
|
|
* @param int $quantity |
77
|
|
|
* @param Context|callable $context |
78
|
|
|
* @return MyLineItemDraft |
79
|
|
|
*/ |
80
|
|
|
public static function ofProductIdVariantIdAndQuantity($productId, $variantId, $quantity, $context = null) |
81
|
|
|
{ |
82
|
|
|
return static::of($context)->setProductId($productId)->setVariantId($variantId)->setQuantity($quantity); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|