1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author @jayS-de <[email protected]> |
4
|
|
|
* @created: 12.02.15, 10:42 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace Commercetools\Core\Request\Customers; |
8
|
|
|
|
9
|
|
|
use Commercetools\Core\Client\HttpMethod; |
10
|
|
|
use Commercetools\Core\Client\JsonRequest; |
11
|
|
|
use Commercetools\Core\Model\Common\Context; |
12
|
|
|
use Commercetools\Core\Request\AbstractApiRequest; |
13
|
|
|
use Commercetools\Core\Model\Customer\Customer; |
14
|
|
|
use Commercetools\Core\Response\ApiResponseInterface; |
15
|
|
|
use Commercetools\Core\Response\ResourceResponse; |
16
|
|
|
use Psr\Http\Message\ResponseInterface; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @package Commercetools\Core\Request\Customers |
20
|
|
|
* @link https://dev.commercetools.com/http-api-projects-customers.html#reset-customers-password |
21
|
|
|
* @method Customer mapResponse(ApiResponseInterface $response) |
22
|
|
|
*/ |
23
|
|
|
class CustomerPasswordResetRequest extends AbstractApiRequest |
24
|
|
|
{ |
25
|
|
|
const TOKEN_VALUE = 'tokenValue'; |
26
|
|
|
const NEW_PASSWORD = 'newPassword'; |
27
|
|
|
|
28
|
|
|
protected $resultClass = '\Commercetools\Core\Model\Customer\Customer'; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
protected $tokenValue; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
protected $newPassword; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param string $id |
|
|
|
|
42
|
|
|
* @param int $version |
|
|
|
|
43
|
|
|
* @param string $tokenValue |
44
|
|
|
* @param string $newPassword |
45
|
|
|
* @param Context $context |
46
|
|
|
*/ |
47
|
4 |
|
public function __construct($tokenValue, $newPassword, Context $context = null) |
48
|
|
|
{ |
49
|
4 |
|
parent::__construct(CustomersEndpoint::endpoint(), $context); |
50
|
4 |
|
$this->tokenValue = $tokenValue; |
51
|
4 |
|
$this->newPassword = $newPassword; |
52
|
4 |
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param string $tokenValue |
56
|
|
|
* @param string $newPassword |
57
|
|
|
* @param Context $context |
58
|
|
|
* @return static |
59
|
|
|
*/ |
60
|
4 |
|
public static function ofTokenAndPassword( |
61
|
|
|
$tokenValue, |
62
|
|
|
$newPassword, |
63
|
|
|
Context $context = null |
64
|
|
|
) { |
65
|
4 |
|
return new static($tokenValue, $newPassword, $context); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return string |
70
|
|
|
* @internal |
71
|
|
|
*/ |
72
|
4 |
|
protected function getPath() |
73
|
|
|
{ |
74
|
4 |
|
return (string)$this->getEndpoint() . '/password/reset'; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return JsonRequest |
79
|
|
|
* @internal |
80
|
|
|
*/ |
81
|
4 |
|
public function httpRequest() |
82
|
|
|
{ |
83
|
|
|
$payload = [ |
84
|
4 |
|
static::TOKEN_VALUE => $this->tokenValue, |
85
|
4 |
|
static::NEW_PASSWORD => $this->newPassword |
86
|
|
|
]; |
87
|
4 |
|
return new JsonRequest(HttpMethod::POST, $this->getPath(), $payload); |
88
|
|
|
} |
89
|
|
|
|
90
|
1 |
|
public function buildResponse(ResponseInterface $response) |
91
|
|
|
{ |
92
|
1 |
|
return new ResourceResponse($response, $this, $this->getContext()); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
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.