1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author @jenschude <[email protected]> |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Request\Orders; |
7
|
|
|
|
8
|
|
|
use Commercetools\Core\Model\Common\Context; |
9
|
|
|
use Commercetools\Core\Request\AbstractByIdGetRequest; |
10
|
|
|
use Commercetools\Core\Request\InStores\InStoreRequestDecorator; |
11
|
|
|
use Commercetools\Core\Request\InStores\InStoreTrait; |
12
|
|
|
use Commercetools\Core\Response\ApiResponseInterface; |
13
|
|
|
use Commercetools\Core\Model\Order\Order; |
14
|
|
|
use Commercetools\Core\Model\MapperInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @package Commercetools\Core\Request\Orders |
18
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#get-order-by-ordernumber |
19
|
|
|
* @method Order mapResponse(ApiResponseInterface $response) |
20
|
|
|
* @method Order mapFromResponse(ApiResponseInterface $response, MapperInterface $mapper = null) |
21
|
|
|
* @method OrderByOrderNumberGetRequest|InStoreRequestDecorator inStore($storeKey) |
22
|
|
|
*/ |
23
|
|
|
class OrderByOrderNumberGetRequest extends AbstractByIdGetRequest |
24
|
|
|
{ |
25
|
|
|
use InStoreTrait; |
26
|
|
|
|
27
|
|
|
protected $resultClass = Order::class; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param string $orderNumber |
31
|
|
|
* @param Context $context |
32
|
|
|
*/ |
33
|
|
|
public function __construct($orderNumber, Context $context = null) |
34
|
|
|
{ |
35
|
|
|
parent::__construct(OrdersEndpoint::endpoint(), $orderNumber, $context); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param string $orderNumber |
40
|
|
|
* @param Context $context |
41
|
|
|
* @return static |
42
|
|
|
*/ |
43
|
|
|
public static function ofOrderNumber($orderNumber, Context $context = null) |
44
|
|
|
{ |
45
|
|
|
return new static($orderNumber, $context); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return string |
50
|
|
|
*/ |
51
|
|
|
public function getOrderNumber() |
52
|
|
|
{ |
53
|
|
|
return $this->getId(); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param string $orderNumber |
58
|
|
|
* @return $this |
59
|
|
|
*/ |
60
|
|
|
public function setOrderNumber($orderNumber) |
61
|
|
|
{ |
62
|
|
|
return $this->setId($orderNumber); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return string |
67
|
|
|
* @internal |
68
|
|
|
*/ |
69
|
|
|
protected function getPath() |
70
|
|
|
{ |
71
|
|
|
return (string)$this->getEndpoint() . '/order-number=' . urlencode($this->getId()) . $this->getParamString(); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|