1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author @jayS-de <[email protected]> |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Request\Orders; |
7
|
|
|
|
8
|
|
|
use Commercetools\Core\Model\Common\Context; |
9
|
|
|
use Commercetools\Core\Request\AbstractDeleteRequest; |
10
|
|
|
use Commercetools\Core\Response\ApiResponseInterface; |
11
|
|
|
use Commercetools\Core\Model\Order\Order; |
12
|
|
|
use Commercetools\Core\Model\MapperInterface; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @package Commercetools\Core\Request\Orders |
16
|
|
|
* @link https://dev.commercetools.com/http-api-projects-orders.html#delete-order-by-ordernumber |
17
|
|
|
* @method Order mapResponse(ApiResponseInterface $response) |
18
|
|
|
* @method Order mapFromResponse(ApiResponseInterface $response, MapperInterface $mapper = null) |
19
|
|
|
*/ |
20
|
|
View Code Duplication |
class OrderDeleteByOrderNumberRequest extends AbstractDeleteRequest |
|
|
|
|
21
|
|
|
{ |
22
|
|
|
protected $resultClass = Order::class; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @param string $id |
26
|
|
|
* @param int $version |
27
|
|
|
* @param Context $context |
28
|
|
|
*/ |
29
|
1 |
|
public function __construct($id, $version, Context $context = null) |
30
|
|
|
{ |
31
|
1 |
|
parent::__construct(OrdersEndpoint::endpoint(), $id, $version, $context); |
32
|
1 |
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param string $orderNumber |
36
|
|
|
* @param int $version |
37
|
|
|
* @param Context $context |
38
|
|
|
* @return static |
39
|
|
|
*/ |
40
|
1 |
|
public static function ofOrderNumberAndVersion($orderNumber, $version, Context $context = null) |
41
|
|
|
{ |
42
|
1 |
|
return new static($orderNumber, $version, $context); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return string |
47
|
|
|
*/ |
48
|
|
|
public function getOrderNumber() |
49
|
|
|
{ |
50
|
|
|
return $this->getId(); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param string $orderNumber |
55
|
|
|
* @return $this |
56
|
|
|
*/ |
57
|
|
|
public function setOrderNumber($orderNumber) |
58
|
|
|
{ |
59
|
|
|
return $this->setId($orderNumber); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return string |
64
|
|
|
* @internal |
65
|
|
|
*/ |
66
|
1 |
|
protected function getPath() |
67
|
|
|
{ |
68
|
1 |
|
return (string)$this->getEndpoint() . '/order-number=' . urlencode($this->getId()) . $this->getParamString(); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.