· 6 years ago · Oct 09, 2019, 01:54 PM
1<?php
2/**
3 *
4 * Copyright © Magento, Inc. All rights reserved.
5 * See COPYING.txt for license details.
6 */
7
8namespace Magento\Customer\Api;
9
10use Magento\Framework\Exception\InputException;
11
12/**
13 * Interface for managing customers accounts.
14 * @api
15 * @since 100.0.2
16 */
17interface AccountManagementInterface
18{
19 /**#@+
20 * Constant for confirmation status
21 */
22 const ACCOUNT_CONFIRMED = 'account_confirmed';
23 const ACCOUNT_CONFIRMATION_REQUIRED = 'account_confirmation_required';
24 const ACCOUNT_CONFIRMATION_NOT_REQUIRED = 'account_confirmation_not_required';
25 const MAX_PASSWORD_LENGTH = 256;
26 /**#@-*/
27
28 /**
29 * Create customer account. Perform necessary business operations like sending email.
30 *
31 * @param \Magento\Customer\Api\Data\CustomerInterface $customer
32 * @param string $password
33 * @param string $redirectUrl
34 * @return \Magento\Customer\Api\Data\CustomerInterface
35 * @throws \Magento\Framework\Exception\LocalizedException
36 */
37 public function createAccount(
38 \Magento\Customer\Api\Data\CustomerInterface $customer,
39 $password = null,
40 $redirectUrl = ''
41 );
42
43 /**
44 * Create customer account using provided hashed password. Should not be exposed as a webapi.
45 *
46 * @api
47 * @param \Magento\Customer\Api\Data\CustomerInterface $customer
48 * @param string $hash Password hash that we can save directly
49 * @param string $redirectUrl URL fed to welcome email templates. Can be used by templates to, for example, direct
50 * the customer to a product they were looking at after pressing confirmation link.
51 * @return \Magento\Customer\Api\Data\CustomerInterface
52 * @throws \Magento\Framework\Exception\InputException If bad input is provided
53 * @throws \Magento\Framework\Exception\State\InputMismatchException If the provided email is already used
54 * @throws \Magento\Framework\Exception\LocalizedException
55 */
56 public function createAccountWithPasswordHash(
57 \Magento\Customer\Api\Data\CustomerInterface $customer,
58 $hash,
59 $redirectUrl = ''
60 );
61
62 /**
63 * Validate customer data.
64 *
65 * @param \Magento\Customer\Api\Data\CustomerInterface $customer
66 * @return \Magento\Customer\Api\Data\ValidationResultsInterface
67 * @throws \Magento\Framework\Exception\LocalizedException
68 */
69 public function validate(\Magento\Customer\Api\Data\CustomerInterface $customer);
70
71 /**
72 * Check if customer can be deleted.
73 *
74 * @api
75 * @param int $customerId
76 * @return bool
77 * @throws \Magento\Framework\Exception\NoSuchEntityException If group is not found
78 * @throws \Magento\Framework\Exception\LocalizedException
79 */
80 public function isReadonly($customerId);
81
82 /**
83 * Activate a customer account using a key that was sent in a confirmation email.
84 *
85 * @param string $email
86 * @param string $confirmationKey
87 * @return \Magento\Customer\Api\Data\CustomerInterface
88 * @throws \Magento\Framework\Exception\LocalizedException
89 */
90 public function activate($email, $confirmationKey);
91
92 /**
93 * Activate a customer account using a key that was sent in a confirmation email.
94 *
95 * @api
96 * @param int $customerId
97 * @param string $confirmationKey
98 * @return \Magento\Customer\Api\Data\CustomerInterface
99 * @throws \Magento\Framework\Exception\LocalizedException
100 */
101 public function activateById($customerId, $confirmationKey);
102
103 /**
104 * Authenticate a customer by username and password
105 *
106 * @param string $email
107 * @param string $password
108 * @return \Magento\Customer\Api\Data\CustomerInterface
109 * @throws \Magento\Framework\Exception\LocalizedException
110 */
111 public function authenticate($email, $password);
112
113 /**
114 * Change customer password.
115 *
116 * @param string $email
117 * @param string $currentPassword
118 * @param string $newPassword
119 * @return bool true on success
120 * @throws \Magento\Framework\Exception\LocalizedException
121 */
122 public function changePassword($email, $currentPassword, $newPassword);
123
124 /**
125 * Change customer password.
126 *
127 * @param int $customerId
128 * @param string $currentPassword
129 * @param string $newPassword
130 * @return bool true on success
131 * @throws \Magento\Framework\Exception\LocalizedException
132 */
133 public function changePasswordById($customerId, $currentPassword, $newPassword);
134
135 /**
136 * Send an email to the customer with a password reset link.
137 *
138 * @param string $email
139 * @param string $template
140 * @param int $websiteId
141 * @return bool true on success
142 * @throws \Magento\Framework\Exception\LocalizedException
143 */
144 public function initiatePasswordReset($email, $template, $websiteId = null);
145
146 /**
147 * Reset customer password.
148 *
149 * @param string $email If empty value given then the customer
150 * will be matched by the RP token.
151 * @param string $resetToken
152 * @param string $newPassword
153 *
154 * @return bool true on success
155 * @throws \Magento\Framework\Exception\LocalizedException
156 * @throws InputException
157 */
158 public function resetPassword($email, $resetToken, $newPassword);
159
160 /**
161 * Check if password reset token is valid.
162 *
163 * @param int $customerId If null is given then a customer
164 * will be matched by the RP token.
165 * @param string $resetPasswordLinkToken
166 *
167 * @return bool True if the token is valid
168 * @throws \Magento\Framework\Exception\State\InputMismatchException If token is mismatched
169 * @throws \Magento\Framework\Exception\State\ExpiredException If token is expired
170 * @throws \Magento\Framework\Exception\InputException If token or customer id is invalid
171 * @throws \Magento\Framework\Exception\NoSuchEntityException If customer doesn't exist
172 * @throws \Magento\Framework\Exception\LocalizedException
173 */
174 public function validateResetPasswordLinkToken($customerId, $resetPasswordLinkToken);
175
176 /**
177 * Gets the account confirmation status.
178 *
179 * @param int $customerId
180 * @return string
181 * @throws \Magento\Framework\Exception\LocalizedException
182 */
183 public function getConfirmationStatus($customerId);
184
185 /**
186 * Resend confirmation email.
187 *
188 * @param string $email
189 * @param int $websiteId
190 * @param string $redirectUrl
191 * @return bool true on success
192 * @throws \Magento\Framework\Exception\LocalizedException
193 */
194 public function resendConfirmation($email, $websiteId, $redirectUrl = '');
195
196 /**
197 * Check if given email is associated with a customer account in given website.
198 *
199 * @param string $customerEmail
200 * @param int $websiteId If not set, will use the current websiteId
201 * @return bool
202 * @throws \Magento\Framework\Exception\LocalizedException
203 */
204 public function isEmailAvailable($customerEmail, $websiteId = null);
205
206 /**
207 * Check store availability for customer given the customerId.
208 *
209 * @param int $customerWebsiteId
210 * @param int $storeId
211 * @return bool
212 * @throws \Magento\Framework\Exception\LocalizedException
213 */
214 public function isCustomerInStore($customerWebsiteId, $storeId);
215
216 /**
217 * Retrieve default billing address for the given customerId.
218 *
219 * @param int $customerId
220 * @return \Magento\Customer\Api\Data\AddressInterface
221 * @throws \Magento\Framework\Exception\NoSuchEntityException If the customer Id is invalid
222 * @throws \Magento\Framework\Exception\LocalizedException
223 */
224 public function getDefaultBillingAddress($customerId);
225
226 /**
227 * Retrieve default shipping address for the given customerId.
228 *
229 * @param int $customerId
230 * @return \Magento\Customer\Api\Data\AddressInterface
231 * @throws \Magento\Framework\Exception\NoSuchEntityException If the customer Id is invalid
232 * @throws \Magento\Framework\Exception\LocalizedException
233 */
234 public function getDefaultShippingAddress($customerId);
235
236 /**
237 * Return hashed password, which can be directly saved to database.
238 *
239 * @param string $password
240 * @return string
241 */
242 public function getPasswordHash($password);
243}