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