|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author @jenschude <[email protected]> |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Model\Cart; |
|
7
|
|
|
|
|
8
|
|
|
use Commercetools\Core\Model\Common\AddressCollection; |
|
9
|
|
|
use Commercetools\Core\Model\Common\Context; |
|
10
|
|
|
use Commercetools\Core\Model\Common\HighPrecisionMoney; |
|
11
|
|
|
use Commercetools\Core\Model\Common\JsonObject; |
|
12
|
|
|
use Commercetools\Core\Model\Common\LocalizedString; |
|
13
|
|
|
use Commercetools\Core\Model\Common\Money; |
|
14
|
|
|
use Commercetools\Core\Model\Common\ResourceIdentifier; |
|
15
|
|
|
use Commercetools\Core\Model\TaxCategory\TaxCategory; |
|
16
|
|
|
use Commercetools\Core\Model\TaxCategory\TaxCategoryReference; |
|
17
|
|
|
use Commercetools\Core\Model\CustomField\CustomFieldObject; |
|
18
|
|
|
use Commercetools\Core\Model\TaxCategory\ExternalTaxRateDraft; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @package Commercetools\Core\Model\Cart |
|
22
|
|
|
* @link https://docs.commercetools.com/http-api-projects-carts.html#customlineitemdraft |
|
23
|
|
|
* @method LocalizedString getName() |
|
24
|
|
|
* @method CustomLineItemDraft setName(LocalizedString $name = null) |
|
25
|
|
|
* @method Money getMoney() |
|
26
|
|
|
* @method CustomLineItemDraft setMoney(Money $money = null) |
|
27
|
|
|
* @method string getSlug() |
|
28
|
|
|
* @method CustomLineItemDraft setSlug(string $slug = null) |
|
29
|
|
|
* @method int getQuantity() |
|
30
|
|
|
* @method CustomLineItemDraft setQuantity(int $quantity = null) |
|
31
|
|
|
* @method TaxCategoryReference getTaxCategory() |
|
32
|
|
|
* @method CustomLineItemDraft setTaxCategory(TaxCategoryReference $taxCategory = null) |
|
33
|
|
|
* @method CustomFieldObject getCustom() |
|
34
|
|
|
* @method CustomLineItemDraft setCustom(CustomFieldObject $custom = null) |
|
35
|
|
|
* @method ExternalTaxRateDraft getExternalTaxRate() |
|
36
|
|
|
* @method CustomLineItemDraft setExternalTaxRate(ExternalTaxRateDraft $externalTaxRate = null) |
|
37
|
|
|
* @method AddressCollection getItemShippingAddresses() |
|
38
|
|
|
* @method CustomLineItemDraft setItemShippingAddresses(AddressCollection $itemShippingAddresses = null) |
|
39
|
|
|
* @method ItemShippingDetailsDraft getShippingDetails() |
|
40
|
|
|
* @method CustomLineItemDraft setShippingDetails(ItemShippingDetailsDraft $shippingDetails = null) |
|
41
|
|
|
*/ |
|
42
|
|
|
class CustomLineItemDraft extends JsonObject |
|
43
|
|
|
{ |
|
44
|
21 |
|
public function fieldDefinitions() |
|
45
|
|
|
{ |
|
46
|
|
|
return [ |
|
47
|
21 |
|
'name' => [static::TYPE => LocalizedString::class], |
|
48
|
21 |
|
'money' => [static::TYPE => Money::class], |
|
49
|
21 |
|
'slug' => [static::TYPE => 'string'], |
|
50
|
21 |
|
'quantity' => [static::TYPE => 'int'], |
|
51
|
21 |
|
'taxCategory' => [static::TYPE => TaxCategoryReference::class], |
|
52
|
21 |
|
'externalTaxRate' => [static::TYPE => ExternalTaxRateDraft::class], |
|
53
|
21 |
|
'custom' => [static::TYPE => CustomFieldObject::class], |
|
54
|
21 |
|
'shippingDetails' => [static::TYPE => ItemShippingDetailsDraft::class], |
|
55
|
|
|
]; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @param LocalizedString $name |
|
60
|
|
|
* @param Money|HighPrecisionMoney $money |
|
61
|
|
|
* @param string $slug |
|
62
|
|
|
* @param Context|callable $context |
|
63
|
|
|
* @return CustomLineItemDraft |
|
64
|
|
|
*/ |
|
65
|
|
|
public static function ofNameMoneyAndSlug(LocalizedString $name, Money $money, $slug, $context = null) |
|
66
|
|
|
{ |
|
67
|
|
|
return static::of($context)->setName($name) |
|
68
|
|
|
->setMoney($money) |
|
69
|
|
|
->setSlug($slug); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @param LocalizedString $name |
|
74
|
|
|
* @param Money|HighPrecisionMoney $money |
|
75
|
|
|
* @param string $slug |
|
76
|
|
|
* @param int $quantity |
|
77
|
|
|
* @param Context|callable $context |
|
78
|
|
|
* @return CustomLineItemDraft |
|
79
|
|
|
*/ |
|
80
|
2 |
|
public static function ofNameMoneySlugAndQuantity( |
|
81
|
|
|
LocalizedString $name, |
|
82
|
|
|
Money $money, |
|
83
|
|
|
$slug, |
|
84
|
|
|
$quantity, |
|
85
|
|
|
$context = null |
|
86
|
|
|
) { |
|
87
|
2 |
|
return static::of($context)->setName($name) |
|
88
|
2 |
|
->setMoney($money) |
|
89
|
2 |
|
->setSlug($slug) |
|
90
|
2 |
|
->setQuantity($quantity); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @param LocalizedString $name |
|
95
|
|
|
* @param Money|HighPrecisionMoney $money |
|
96
|
|
|
* @param string $slug |
|
97
|
|
|
* @param ResourceIdentifier|TaxCategoryReference $taxCategory |
|
98
|
|
|
* @param Context|callable $context |
|
99
|
|
|
* @return CustomLineItemDraft |
|
100
|
|
|
*/ |
|
101
|
|
|
public static function ofNameMoneySlugAndTaxCategory( |
|
102
|
|
|
LocalizedString $name, |
|
103
|
|
|
Money $money, |
|
104
|
|
|
$slug, |
|
105
|
|
|
ResourceIdentifier $taxCategory, |
|
106
|
|
|
$context = null |
|
107
|
|
|
) { |
|
108
|
|
|
return static::of($context) |
|
109
|
|
|
->setName($name) |
|
110
|
|
|
->setMoney($money) |
|
111
|
|
|
->setSlug($slug) |
|
112
|
|
|
->setTaxCategory($taxCategory); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @param LocalizedString $name |
|
117
|
|
|
* @param Money|HighPrecisionMoney $money |
|
118
|
|
|
* @param string $slug |
|
119
|
|
|
* @param ResourceIdentifier|TaxCategoryReference $taxCategory |
|
120
|
|
|
* @param int $quantity |
|
121
|
|
|
* @param Context|callable $context |
|
122
|
|
|
* @return CustomLineItemDraft |
|
123
|
|
|
*/ |
|
124
|
17 |
|
public static function ofNameMoneySlugTaxCategoryAndQuantity( |
|
125
|
|
|
LocalizedString $name, |
|
126
|
|
|
Money $money, |
|
127
|
|
|
$slug, |
|
128
|
|
|
ResourceIdentifier $taxCategory, |
|
129
|
|
|
$quantity, |
|
130
|
|
|
$context = null |
|
131
|
|
|
) { |
|
132
|
17 |
|
return static::of($context) |
|
133
|
17 |
|
->setName($name) |
|
134
|
17 |
|
->setMoney($money) |
|
135
|
17 |
|
->setSlug($slug) |
|
136
|
17 |
|
->setTaxCategory($taxCategory) |
|
137
|
17 |
|
->setQuantity($quantity); |
|
138
|
|
|
} |
|
139
|
|
|
} |
|
140
|
|
|
|