|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author @jenschude <[email protected]> |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Model\Order; |
|
7
|
|
|
|
|
8
|
|
|
use Commercetools\Core\Model\Cart\ItemShippingDetailsDraft; |
|
9
|
|
|
use Commercetools\Core\Model\Common\AddressCollection; |
|
10
|
|
|
use Commercetools\Core\Model\Common\Context; |
|
11
|
|
|
use Commercetools\Core\Model\Common\JsonObject; |
|
12
|
|
|
use Commercetools\Core\Model\Common\LocalizedString; |
|
13
|
|
|
use Commercetools\Core\Model\Common\Price; |
|
14
|
|
|
use Commercetools\Core\Model\Channel\ChannelReference; |
|
15
|
|
|
use Commercetools\Core\Model\TaxCategory\TaxRate; |
|
16
|
|
|
use Commercetools\Core\Model\CustomField\CustomFieldObjectDraft; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @package Commercetools\Core\Model\Order |
|
20
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders-import.html#lineitemimportdraft |
|
21
|
|
|
* @method string getProductId() |
|
22
|
|
|
* @method LineItemImportDraft setProductId(string $productId = null) |
|
23
|
|
|
* @method LocalizedString getName() |
|
24
|
|
|
* @method LineItemImportDraft setName(LocalizedString $name = null) |
|
25
|
|
|
* @method ProductVariantImportDraft getVariant() |
|
26
|
|
|
* @method LineItemImportDraft setVariant(ProductVariantImportDraft $variant = null) |
|
27
|
|
|
* @method Price getPrice() |
|
28
|
|
|
* @method LineItemImportDraft setPrice(Price $price = null) |
|
29
|
|
|
* @method int getQuantity() |
|
30
|
|
|
* @method LineItemImportDraft setQuantity(int $quantity = null) |
|
31
|
|
|
* @method ItemStateCollection getState() |
|
32
|
|
|
* @method LineItemImportDraft setState(ItemStateCollection $state = null) |
|
33
|
|
|
* @method ChannelReference getSupplyChannel() |
|
34
|
|
|
* @method LineItemImportDraft setSupplyChannel(ChannelReference $supplyChannel = null) |
|
35
|
|
|
* @method TaxRate getTaxRate() |
|
36
|
|
|
* @method LineItemImportDraft setTaxRate(TaxRate $taxRate = null) |
|
37
|
|
|
* @method CustomFieldObjectDraft getCustom() |
|
38
|
|
|
* @method LineItemImportDraft setCustom(CustomFieldObjectDraft $custom = null) |
|
39
|
|
|
* @method AddressCollection getItemShippingAddresses() |
|
40
|
|
|
* @method LineItemImportDraft setItemShippingAddresses(AddressCollection $itemShippingAddresses = null) |
|
41
|
|
|
* @method ItemShippingDetailsDraft getShippingDetails() |
|
42
|
|
|
* @method LineItemImportDraft setShippingDetails(ItemShippingDetailsDraft $shippingDetails = null) |
|
43
|
|
|
* @method ChannelReference getDistributionChannel() |
|
44
|
|
|
* @method LineItemImportDraft setDistributionChannel(ChannelReference $distributionChannel = null) |
|
45
|
|
|
*/ |
|
46
|
|
|
class LineItemImportDraft extends JsonObject |
|
47
|
|
|
{ |
|
48
|
10 |
|
public function fieldDefinitions() |
|
49
|
|
|
{ |
|
50
|
|
|
return [ |
|
51
|
10 |
|
'productId' => [static::TYPE => 'string'], |
|
52
|
10 |
|
'name' => [static::TYPE => LocalizedString::class], |
|
53
|
10 |
|
'variant' => [static::TYPE => ProductVariantImportDraft::class], |
|
54
|
10 |
|
'price' => [static::TYPE => Price::class], |
|
55
|
10 |
|
'quantity' => [static::TYPE => 'int'], |
|
56
|
10 |
|
'state' => [static::TYPE => ItemStateCollection::class], |
|
57
|
10 |
|
'supplyChannel' => [static::TYPE => ChannelReference::class], |
|
58
|
10 |
|
'distributionChannel' => [static::TYPE => ChannelReference::class], |
|
59
|
10 |
|
'taxRate' => [static::TYPE => TaxRate::class], |
|
60
|
10 |
|
'custom' => [static::TYPE => CustomFieldObjectDraft::class], |
|
61
|
10 |
|
'shippingDetails' => [static::TYPE => ItemShippingDetailsDraft::class], |
|
62
|
|
|
]; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @param LocalizedString $name |
|
67
|
|
|
* @param Price $price |
|
68
|
|
|
* @param int $quantity |
|
69
|
|
|
* @param Context|callable $context |
|
70
|
|
|
* @return LineItemImportDraft |
|
71
|
|
|
*/ |
|
72
|
|
|
public static function ofNamePriceAndQuantity(LocalizedString $name, Price $price, $quantity, $context = null) |
|
73
|
|
|
{ |
|
74
|
|
|
return static::of($context)->setName($name)->setPrice($price)->setQuantity($quantity); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @param LocalizedString $name |
|
79
|
|
|
* @param Price $price |
|
80
|
|
|
* @param ProductVariantImportDraft $variant |
|
81
|
|
|
* @param int $quantity |
|
82
|
|
|
* @param Context|callable $context |
|
83
|
|
|
* @return LineItemImportDraft |
|
84
|
|
|
*/ |
|
85
|
8 |
|
public static function ofNamePriceVariantAndQuantity( |
|
86
|
|
|
LocalizedString $name, |
|
87
|
|
|
Price $price, |
|
88
|
|
|
ProductVariantImportDraft $variant, |
|
89
|
|
|
$quantity, |
|
90
|
|
|
$context = null |
|
91
|
|
|
) { |
|
92
|
8 |
|
return static::of($context) |
|
93
|
8 |
|
->setName($name) |
|
94
|
8 |
|
->setPrice($price) |
|
95
|
8 |
|
->setVariant($variant) |
|
96
|
8 |
|
->setQuantity($quantity); |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|