MeUpdateRequest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
eloc 7
dl 0
loc 40
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A ofVersion() 0 3 1
A __construct() 0 3 1
A httpRequest() 0 4 1
A getPath() 0 3 1
1
<?php
2
/**
3
 * @author @jenschude <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Request\Me;
7
8
use Commercetools\Core\Client\HttpMethod;
9
use Commercetools\Core\Client\HttpRequest;
10
use Commercetools\Core\Client\JsonRequest;
11
use Commercetools\Core\Model\Common\Context;
12
use Commercetools\Core\Model\Customer\Customer;
13
use Commercetools\Core\Request\AbstractUpdateRequest;
14
use Commercetools\Core\Response\ApiResponseInterface;
15
use Commercetools\Core\Model\MapperInterface;
16
17
/**
18
 * @package Commercetools\Core\Request\Me
19
 * @link https://docs.commercetools.com/http-api-projects-me-profile.html#update-customer
20
 * @method Customer mapResponse(ApiResponseInterface $response)
21
 * @method Customer mapFromResponse(ApiResponseInterface $response, MapperInterface $mapper = null)
22
 */
23
class MeUpdateRequest extends AbstractUpdateRequest
24
{
25
    protected $resultClass = Customer::class;
26
27
    /**
28
     * @param int $version
29
     * @param Context $context
30
     */
31
    public function __construct($version, Context $context = null)
32
    {
33
        parent::__construct(MeEndpoint::endpoint(), null, $version, [], $context);
34
    }
35
36
    /**
37
     * @param int $version
38
     * @param Context $context
39
     * @return static
40
     */
41
    public static function ofVersion($version, Context $context = null)
42
    {
43
        return new static($version, $context);
44
    }
45
46
    /**
47
     * @return string
48
     * @internal
49
     */
50
    protected function getPath()
51
    {
52
        return (string)$this->getEndpoint() . $this->getParamString();
53
    }
54
55
    /**
56
     * @return HttpRequest
57
     * @internal
58
     */
59
    public function httpRequest()
60
    {
61
        $payload = [static::VERSION => $this->getVersion(), static::ACTIONS => $this->getActions()];
62
        return new JsonRequest(HttpMethod::POST, $this->getPath(), $payload);
63
    }
64
}
65