@@ 23-79 (lines=57) @@ | ||
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 | public function __construct($tokenValue, Context $context = null) |
|
39 | { |
|
40 | parent::__construct(CustomersEndpoint::endpoint(), $context); |
|
41 | $this->tokenValue = $tokenValue; |
|
42 | } |
|
43 | ||
44 | /** |
|
45 | * @param string $tokenValue |
|
46 | * @param Context $context |
|
47 | * @return static |
|
48 | */ |
|
49 | public static function ofToken($tokenValue, Context $context = null) |
|
50 | { |
|
51 | return new static($tokenValue, $context); |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * @return string |
|
56 | * @internal |
|
57 | */ |
|
58 | protected function getPath() |
|
59 | { |
|
60 | return (string)$this->getEndpoint() . '/email/confirm' . $this->getParamString(); |
|
61 | } |
|
62 | ||
63 | /** |
|
64 | * @return JsonRequest |
|
65 | * @internal |
|
66 | */ |
|
67 | public function httpRequest() |
|
68 | { |
|
69 | $payload = [ |
|
70 | static::TOKEN_VALUE => $this->tokenValue, |
|
71 | ]; |
|
72 | return new JsonRequest(HttpMethod::POST, $this->getPath(), $payload); |
|
73 | } |
|
74 | ||
75 | public function buildResponse(ResponseInterface $response) |
|
76 | { |
|
77 | return new ResourceResponse($response, $this, $this->getContext()); |
|
78 | } |
|
79 | } |
|
80 |
@@ 23-86 (lines=64) @@ | ||
20 | * @link https://dev.commercetools.com/http-api-projects-customers.html#create-token-for-resetting-customers-password |
|
21 | * @method CustomerToken mapResponse(ApiResponseInterface $response) |
|
22 | */ |
|
23 | class CustomerPasswordTokenRequest extends AbstractApiRequest |
|
24 | { |
|
25 | const EMAIL = 'email'; |
|
26 | ||
27 | protected $resultClass = '\Commercetools\Core\Model\Customer\CustomerToken'; |
|
28 | ||
29 | /** |
|
30 | * @var string |
|
31 | */ |
|
32 | protected $email; |
|
33 | ||
34 | /** |
|
35 | * @param string $email |
|
36 | * @param Context $context |
|
37 | */ |
|
38 | public function __construct($email, Context $context = null) |
|
39 | { |
|
40 | parent::__construct(CustomersEndpoint::endpoint(), $context); |
|
41 | $this->email = $email; |
|
42 | } |
|
43 | ||
44 | /** |
|
45 | * @param string $email |
|
46 | * @param Context $context |
|
47 | * @return static |
|
48 | */ |
|
49 | public static function ofEmail( |
|
50 | $email, |
|
51 | Context $context = null |
|
52 | ) { |
|
53 | return new static($email, $context); |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * @return string |
|
58 | * @internal |
|
59 | */ |
|
60 | protected function getPath() |
|
61 | { |
|
62 | return (string)$this->getEndpoint() . '/password-token' . $this->getParamString(); |
|
63 | } |
|
64 | ||
65 | /** |
|
66 | * @return JsonRequest |
|
67 | * @internal |
|
68 | */ |
|
69 | public function httpRequest() |
|
70 | { |
|
71 | $payload = [ |
|
72 | static::EMAIL => $this->email |
|
73 | ]; |
|
74 | return new JsonRequest(HttpMethod::POST, $this->getPath(), $payload); |
|
75 | } |
|
76 | ||
77 | /** |
|
78 | * @param ResponseInterface $response |
|
79 | * @return ResourceResponse |
|
80 | * @internal |
|
81 | */ |
|
82 | public function buildResponse(ResponseInterface $response) |
|
83 | { |
|
84 | return new ResourceResponse($response, $this, $this->getContext()); |
|
85 | } |
|
86 | } |
|
87 |
@@ 22-78 (lines=57) @@ | ||
19 | * @link https://dev.commercetools.com/http-api-projects-me-profile.html#verify-customers-email |
|
20 | * @method Customer mapResponse(ApiResponseInterface $response) |
|
21 | */ |
|
22 | class MeEmailConfirmRequest extends AbstractApiRequest |
|
23 | { |
|
24 | protected $resultClass = '\Commercetools\Core\Model\Customer\Customer'; |
|
25 | ||
26 | const TOKEN_VALUE = 'tokenValue'; |
|
27 | ||
28 | /** |
|
29 | * @var string |
|
30 | */ |
|
31 | protected $tokenValue; |
|
32 | ||
33 | /** |
|
34 | * @param string $tokenValue |
|
35 | * @param Context $context |
|
36 | */ |
|
37 | public function __construct($tokenValue, Context $context = null) |
|
38 | { |
|
39 | parent::__construct(MeEndpoint::endpoint(), $context); |
|
40 | $this->tokenValue = $tokenValue; |
|
41 | } |
|
42 | ||
43 | /** |
|
44 | * @param string $tokenValue |
|
45 | * @param Context $context |
|
46 | * @return static |
|
47 | */ |
|
48 | public static function ofToken($tokenValue, Context $context = null) |
|
49 | { |
|
50 | return new static($tokenValue, $context); |
|
51 | } |
|
52 | ||
53 | /** |
|
54 | * @return string |
|
55 | * @internal |
|
56 | */ |
|
57 | protected function getPath() |
|
58 | { |
|
59 | return (string)$this->getEndpoint() . '/email/confirm' . $this->getParamString(); |
|
60 | } |
|
61 | ||
62 | /** |
|
63 | * @return JsonRequest |
|
64 | * @internal |
|
65 | */ |
|
66 | public function httpRequest() |
|
67 | { |
|
68 | $payload = [ |
|
69 | static::TOKEN_VALUE => $this->tokenValue, |
|
70 | ]; |
|
71 | return new JsonRequest(HttpMethod::POST, $this->getPath(), $payload); |
|
72 | } |
|
73 | ||
74 | public function buildResponse(ResponseInterface $response) |
|
75 | { |
|
76 | return new ResourceResponse($response, $this, $this->getContext()); |
|
77 | } |
|
78 | } |
|
79 |