Passed
Push — develop ( 92e1e8...d25e3e )
by Jens
12:17
created

OrderEditUpdateRequest::ofIdAndVersion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 3
crap 1
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\AbstractUpdateRequest;
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 OrderEditUpdateRequest extends AbstractUpdateRequest
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 OrderEditUpdateRequest
32
     */
33 2
    public function setDryRun($dryRun)
34
    {
35 2
        $this->dryRun = $dryRun;
36
37 2
        return $this;
38
    }
39
40
    /**
41
     * @param string $id
42
     * @param int $version
43
     * @param array $actions
44
     * @param Context $context
45
     */
46 55
    public function __construct($id, $version, array $actions = [], Context $context = null)
47
    {
48 55
        parent::__construct(OrderEditsEndpoint::endpoint(), $id, $version, $actions, $context);
49 55
    }
50
51
    /**
52
     * @param string $id
53
     * @param int $version
54
     * @param Context $context
55
     * @return static
56
     */
57 55
    public static function ofIdAndVersion($id, $version, Context $context = null)
58
    {
59 55
        return new static($id, $version, [], $context);
60
    }
61
62
    /**
63
     * @return JsonRequest
64
     * @internal
65
     */
66 51
    public function httpRequest()
67
    {
68
        $payload = [
69 51
            static::VERSION => $this->getVersion(),
70 51
            static::ACTIONS => $this->getActions(),
71 51
            static::DRY_RUN => $this->dryRun
72
        ];
73 51
        return new JsonRequest(HttpMethod::POST, $this->getPath(), $payload);
74
    }
75
}
76