1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author @jenschude <[email protected]> |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Request\Orders\Command; |
7
|
|
|
|
8
|
|
|
use Commercetools\Core\Model\Common\Address; |
9
|
|
|
use Commercetools\Core\Model\Common\Context; |
10
|
|
|
use Commercetools\Core\Model\Order\DeliveryItemCollection; |
11
|
|
|
use Commercetools\Core\Model\Order\ParcelCollection; |
12
|
|
|
use Commercetools\Core\Model\Order\ParcelMeasurements; |
13
|
|
|
use Commercetools\Core\Model\Order\TrackingData; |
14
|
|
|
use Commercetools\Core\Request\AbstractAction; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @package Commercetools\Core\Request\Orders\Command |
18
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#add-delivery |
19
|
|
|
* @method string getAction() |
20
|
|
|
* @method OrderAddDeliveryAction setAction(string $action = null) |
21
|
|
|
* @method DeliveryItemCollection getItems() |
22
|
|
|
* @method OrderAddDeliveryAction setItems(DeliveryItemCollection $items = null) |
23
|
|
|
* @method ParcelCollection getParcels() |
24
|
|
|
* @method OrderAddDeliveryAction setParcels(ParcelCollection $parcels = null) |
25
|
|
|
* @method Address getAddress() |
26
|
|
|
* @method OrderAddDeliveryAction setAddress(Address $address = null) |
27
|
|
|
*/ |
28
|
|
|
class OrderAddDeliveryAction extends AbstractAction |
29
|
|
|
{ |
30
|
8 |
|
public function fieldDefinitions() |
31
|
|
|
{ |
32
|
|
|
return [ |
33
|
8 |
|
'action' => [static::TYPE => 'string'], |
34
|
8 |
|
'items' => [static::TYPE => DeliveryItemCollection::class], |
35
|
8 |
|
'parcels' => [static::TYPE => ParcelCollection::class], |
36
|
8 |
|
'address' => [static::TYPE => Address::class], |
37
|
|
|
]; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param array $data |
42
|
|
|
* @param Context|callable $context |
43
|
|
|
*/ |
44
|
6 |
|
public function __construct(array $data = [], $context = null) |
45
|
|
|
{ |
46
|
6 |
|
parent::__construct($data, $context); |
47
|
6 |
|
$this->setAction('addDelivery'); |
48
|
6 |
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param DeliveryItemCollection $items |
52
|
|
|
* @param Context|callable $context |
53
|
|
|
* @return OrderAddDeliveryAction |
54
|
|
|
*/ |
55
|
3 |
|
public static function ofDeliveryItems(DeliveryItemCollection $items, $context = null) |
56
|
|
|
{ |
57
|
3 |
|
return static::of($context)->setItems($items); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @deprecated not supported by platform - will be removed in 3.0 |
62
|
|
|
* @return null |
63
|
|
|
*/ |
64
|
|
|
public function getMeasurements() |
65
|
|
|
{ |
66
|
|
|
return null; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @deprecated not supported by platform - will be removed in 3.0 |
71
|
|
|
* @param ParcelMeasurements $measurements |
72
|
|
|
* @return OrderAddDeliveryAction |
73
|
|
|
*/ |
74
|
|
|
public function setMeasurements(ParcelMeasurements $measurements = null) |
|
|
|
|
75
|
|
|
{ |
76
|
|
|
return $this; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @deprecated not supported by platform - will be removed in 3.0 |
81
|
|
|
* @return null |
82
|
|
|
*/ |
83
|
|
|
public function getTrackingData() |
84
|
|
|
{ |
85
|
|
|
return null; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @deprecated not supported by platform - will be removed in 3.0 |
90
|
|
|
* @param TrackingData $trackingData |
91
|
|
|
* @return OrderAddDeliveryAction |
92
|
|
|
*/ |
93
|
|
|
public function setTrackingData(TrackingData $trackingData = null) |
|
|
|
|
94
|
|
|
{ |
95
|
|
|
return $this; |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.