1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author @jayS-de <[email protected]> |
4
|
|
|
* @created: 12.02.15, 14:18 |
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\Response\ApiResponseInterface; |
14
|
|
|
use Commercetools\Core\Model\Customer\Customer; |
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#verify-customers-email |
21
|
|
|
* @method Customer mapResponse(ApiResponseInterface $response) |
22
|
|
|
*/ |
23
|
|
|
class CustomerEmailConfirmRequest extends AbstractApiRequest |
24
|
|
|
{ |
25
|
|
|
protected $resultClass = '\Commercetools\Core\Model\Customer\Customer'; |
26
|
|
|
|
27
|
|
|
const TOKEN_VALUE = 'tokenValue'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
protected $tokenValue; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param string $tokenValue |
36
|
|
|
* @param Context $context |
37
|
|
|
*/ |
38
|
4 |
|
public function __construct($tokenValue, Context $context = null) |
39
|
|
|
{ |
40
|
4 |
|
parent::__construct(CustomersEndpoint::endpoint(), $context); |
41
|
4 |
|
$this->tokenValue = $tokenValue; |
42
|
4 |
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param string $tokenValue |
46
|
|
|
* @param Context $context |
47
|
|
|
* @return static |
48
|
|
|
*/ |
49
|
4 |
|
public static function ofToken($tokenValue, Context $context = null) |
50
|
|
|
{ |
51
|
4 |
|
return new static($tokenValue, $context); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return string |
56
|
|
|
* @internal |
57
|
|
|
*/ |
58
|
4 |
|
protected function getPath() |
59
|
|
|
{ |
60
|
4 |
|
return (string)$this->getEndpoint() . '/email/confirm'; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return JsonRequest |
65
|
|
|
* @internal |
66
|
|
|
*/ |
67
|
4 |
|
public function httpRequest() |
68
|
|
|
{ |
69
|
|
|
$payload = [ |
70
|
4 |
|
static::TOKEN_VALUE => $this->tokenValue, |
71
|
|
|
]; |
72
|
4 |
|
return new JsonRequest(HttpMethod::POST, $this->getPath(), $payload); |
73
|
|
|
} |
74
|
|
|
|
75
|
1 |
|
public function buildResponse(ResponseInterface $response) |
76
|
|
|
{ |
77
|
1 |
|
return new ResourceResponse($response, $this, $this->getContext()); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|