|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
*/ |
|
4
|
|
|
|
|
5
|
|
|
namespace Commercetools\Core\Request\OrderEdits; |
|
6
|
|
|
|
|
7
|
|
|
use Commercetools\Core\Client\HttpMethod; |
|
8
|
|
|
use Commercetools\Core\Client\JsonRequest; |
|
9
|
|
|
use Commercetools\Core\Model\Common\Context; |
|
10
|
|
|
use Commercetools\Core\Model\OrderEdit\OrderEdit; |
|
11
|
|
|
use Commercetools\Core\Request\AbstractUpdateByKeyRequest; |
|
12
|
|
|
use Commercetools\Core\Response\ApiResponseInterface; |
|
13
|
|
|
use Commercetools\Core\Model\MapperInterface; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @package Commercetools\Core\Request\OrderEdits |
|
17
|
|
|
* |
|
18
|
|
|
* @method OrderEdit mapResponse(ApiResponseInterface $response) |
|
19
|
|
|
* @method OrderEdit mapFromResponse(ApiResponseInterface $response, MapperInterface $mapper = null) |
|
20
|
|
|
*/ |
|
21
|
|
|
class OrderEditUpdateByKeyRequest extends AbstractUpdateByKeyRequest |
|
22
|
|
|
{ |
|
23
|
|
|
const DRY_RUN = 'dryRun'; |
|
24
|
|
|
|
|
25
|
|
|
protected $resultClass = OrderEdit::class; |
|
26
|
|
|
|
|
27
|
|
|
protected $dryRun = false; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @param bool $dryRun |
|
31
|
|
|
* @return OrderEditUpdateByKeyRequest |
|
32
|
|
|
*/ |
|
33
|
1 |
|
public function setDryRun($dryRun) |
|
34
|
|
|
{ |
|
35
|
1 |
|
$this->dryRun = $dryRun; |
|
36
|
|
|
|
|
37
|
1 |
|
return $this; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @param string $key |
|
42
|
|
|
* @param int $version |
|
43
|
|
|
* @param array $actions |
|
44
|
|
|
* @param Context $context |
|
45
|
|
|
*/ |
|
46
|
4 |
|
public function __construct($key, $version, array $actions = [], Context $context = null) |
|
47
|
|
|
{ |
|
48
|
4 |
|
parent::__construct(OrderEditsEndpoint::endpoint(), $key, $version, $actions, $context); |
|
49
|
4 |
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @param string $key |
|
53
|
|
|
* @param int $version |
|
54
|
|
|
* @param Context $context |
|
55
|
|
|
* @return static |
|
56
|
|
|
*/ |
|
57
|
4 |
|
public static function ofKeyAndVersion($key, $version, Context $context = null) |
|
58
|
|
|
{ |
|
59
|
4 |
|
return new static($key, $version, [], $context); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @return JsonRequest |
|
64
|
|
|
* @internal |
|
65
|
|
|
*/ |
|
66
|
1 |
|
public function httpRequest() |
|
67
|
|
|
{ |
|
68
|
|
|
$payload = [ |
|
69
|
1 |
|
static::VERSION => $this->getVersion(), |
|
70
|
1 |
|
static::ACTIONS => $this->getActions(), |
|
71
|
1 |
|
static::DRY_RUN => $this->dryRun |
|
72
|
|
|
]; |
|
73
|
1 |
|
return new JsonRequest(HttpMethod::POST, $this->getPath(), $payload); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|