1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author @jayS-de <[email protected]> |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Request\Me; |
7
|
|
|
|
8
|
|
|
use Commercetools\Core\Client\HttpMethod; |
9
|
|
|
use Commercetools\Core\Client\JsonRequest; |
10
|
|
|
use Commercetools\Core\Model\Common\Context; |
11
|
|
|
use Commercetools\Core\Request\AbstractApiRequest; |
12
|
|
|
use Commercetools\Core\Response\ResourceResponse; |
13
|
|
|
use Psr\Http\Message\ResponseInterface; |
14
|
|
|
use Commercetools\Core\Model\Customer\Customer; |
15
|
|
|
use Commercetools\Core\Response\ApiResponseInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @package Commercetools\Core\Request\Me |
19
|
|
|
* @method Customer mapResponse(ApiResponseInterface $response) |
20
|
|
|
*/ |
21
|
|
|
class MePasswordChangeRequest extends AbstractApiRequest |
22
|
|
|
{ |
23
|
|
|
const ID = 'id'; |
24
|
|
|
const VERSION = 'version'; |
25
|
|
|
const CURRENT_PASSWORD = 'currentPassword'; |
26
|
|
|
const NEW_PASSWORD = 'newPassword'; |
27
|
|
|
|
28
|
|
|
protected $resultClass = '\Commercetools\Core\Model\Customer\Customer'; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var int |
32
|
|
|
*/ |
33
|
|
|
protected $version; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
protected $currentPassword; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
protected $newPassword; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param string $id |
|
|
|
|
47
|
|
|
* @param int $version |
48
|
|
|
* @param string $currentPassword |
49
|
|
|
* @param string $newPassword |
50
|
|
|
* @param Context $context |
51
|
|
|
*/ |
52
|
2 |
View Code Duplication |
public function __construct($version, $currentPassword, $newPassword, Context $context = null) |
|
|
|
|
53
|
|
|
{ |
54
|
2 |
|
parent::__construct(MeEndpoint::endpoint(), $context); |
55
|
2 |
|
$this->setVersion($version); |
56
|
2 |
|
$this->currentPassword = $currentPassword; |
57
|
2 |
|
$this->newPassword = $newPassword; |
58
|
2 |
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return int |
62
|
|
|
*/ |
63
|
2 |
|
public function getVersion() |
64
|
|
|
{ |
65
|
2 |
|
return $this->version; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param int $version |
70
|
|
|
* @return $this |
71
|
|
|
*/ |
72
|
2 |
|
public function setVersion($version) |
73
|
|
|
{ |
74
|
2 |
|
$this->version = $version; |
75
|
|
|
|
76
|
2 |
|
return $this; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param int $version |
81
|
|
|
* @param string $currentPassword |
82
|
|
|
* @param string $newPassword |
83
|
|
|
* @param Context $context |
84
|
|
|
* @return static |
85
|
|
|
*/ |
86
|
2 |
|
public static function ofVersionAndPasswords( |
87
|
|
|
$version, |
88
|
|
|
$currentPassword, |
89
|
|
|
$newPassword, |
90
|
|
|
Context $context = null |
91
|
|
|
) { |
92
|
2 |
|
return new static($version, $currentPassword, $newPassword, $context); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return string |
97
|
|
|
* @internal |
98
|
|
|
*/ |
99
|
2 |
|
protected function getPath() |
100
|
|
|
{ |
101
|
2 |
|
return (string)$this->getEndpoint() . '/password' . $this->getParamString(); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return JsonRequest |
106
|
|
|
* @internal |
107
|
|
|
*/ |
108
|
2 |
|
public function httpRequest() |
109
|
|
|
{ |
110
|
|
|
$payload = [ |
111
|
2 |
|
static::VERSION => $this->getVersion(), |
112
|
2 |
|
static::CURRENT_PASSWORD => $this->currentPassword, |
113
|
2 |
|
static::NEW_PASSWORD => $this->newPassword |
114
|
|
|
]; |
115
|
2 |
|
return new JsonRequest(HttpMethod::POST, $this->getPath(), $payload); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @param ResponseInterface $response |
120
|
|
|
* @return ResourceResponse |
121
|
|
|
* @internal |
122
|
|
|
*/ |
123
|
2 |
|
public function buildResponse(ResponseInterface $response) |
124
|
|
|
{ |
125
|
2 |
|
return new ResourceResponse($response, $this, $this->getContext()); |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.