Class CustomersController
java.lang.Object
de.hybris.platform.ycommercewebservices.v1.controller.BaseController
de.hybris.platform.ycommercewebservices.v1.controller.CustomersController
@Controller("customersControllerV1")
@RequestMapping("/{baseSiteId}/customers")
public class CustomersController
extends BaseController
Main Controller for CustomerFacade WebServices
-
Field Summary
Fields inherited from class de.hybris.platform.ycommercewebservices.v1.controller.BaseController
DEFAULT_CURRENT_PAGE, DEFAULT_PAGE_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidchangeCustomerPassword(String customerId, String newPassword) Client should pass old and new password in Body.changeLogin(String newLogin, String password) Web service for changing customer login.
Sample call: https://localhost:9002/rest/v1/mysite/customers/current/login?newLogin=:newLogin&password=:password
Method requires customer authentication and is restricted toHTTPSchannel.
Method type :POST.voidchangePassword(String old, String newPassword) Client should pass old and new password in Body.voidconvertAnonymousUserToCustomer(String password, javax.servlet.http.HttpSession httpSession) Converts currently logged guest user to full user.createAddress(javax.servlet.http.HttpServletRequest request) Create new address for current customerprotected ErrorListWsDTOcreateResponseErrors(org.springframework.validation.Errors errors) voiddeleteAddress(String id) Remove address from current customervoidWeb service for deleting current user's credit card payment info by id.
Sample call: http://localhost:9001/rest/v1/mysite/customers/paymentinfos/123
Method requires authentication and is restricted toHTTPSchannel.
Method type :DELETE.editAddress(String id, javax.servlet.http.HttpServletRequest request) Edit address from current customerGet all customer's addressesWeb service for getting customer groups for current user.
Sample call: https://localhost:9002/rest/v1/mysite/customers/{uid}/customergroups
Method requires authentication and is restricted toHTTPSchannel.
Method type :GET.Get customer datagetPaymentInfo(String id) Web service for getting current user's credit card payment info by id.
Sample call: https://localhost:9002/rest/v1/mysite/customers/paymentinfos/123
Method requires authentication and is restricted toHTTPSchannel.
Method type :GET.getPaymentInfos(boolean saved) Web service for getting current user's credit card payment infos.
Sample call: http://localhost:9001/rest/v1/mysite/customers/paymentinfos?saved=true
Method requires authentication and is restricted toHTTPSchannel.
Method type :GET.voidguestLogin(String email) Creates the user dedicated to do a guest checkout.protected booleanisAddressValid(AddressData addressData, org.springframework.validation.Errors errors, AddressValidationData validationData) Checks if address is valid by a validatorsprotected voidpopulateErrors(org.springframework.validation.Errors errors, AddressVerificationResult<AddressVerificationDecision> addressVerificationResult) Populates Errors objectvoidClient should pass customer's data as POST Body.restorePassword(String login) Web service for restoring password of current customer.
Sample call: https://localhost:9002/rest/v1/mysite/customers/current/forgottenpassword?login=:login/
Method requires client or trusted_client authentication and is restricted toHTTPSchannel.
Method type :POST.voidUpdate customer's default addressvoidupdatePaymentInfo(String paymentInfoId, javax.servlet.http.HttpServletRequest request) Web service for modifying existing payment info.
Sample call: https://localhost:9002/rest/v1/mysite/paymentinfos/123
Method requires authentication and is restricted toHTTPSchannel.
Method type :PUT.voidupdatePaymentInfoAddress(String paymentInfoId, javax.servlet.http.HttpServletRequest request) Web service for modifying billing address data for the specific payment info.
Sample call: https://localhost:9002/rest/v1/mysite/paymentinfos/123/address
Method requires authentication and is restricted toHTTPSchannel.
Method type :POST.updateProfile(javax.servlet.http.HttpServletRequest request) Update customer's profileprotected AddressValidationDataverifyAddresByService(AddressData addressData, org.springframework.validation.Errors errors, AddressValidationData validationData) Verifies address by commerce serviceverifyAddress(javax.servlet.http.HttpServletRequest request) Verifies addressMethods inherited from class de.hybris.platform.ycommercewebservices.v1.controller.BaseController
handleErrorInternal, handleModelNotFoundException, sanitize
-
Constructor Details
-
CustomersController
public CustomersController()
-
-
Method Details
-
registerUser
@Secured({"ROLE_CLIENT","ROLE_TRUSTED_CLIENT"}) @RequestMapping(method=POST) @ResponseBody @ResponseStatus(CREATED) public void registerUser(@RequestParam String login, @RequestParam String password, @RequestParam(required=false) String titleCode, @RequestParam String firstName, @RequestParam String lastName) throws DuplicateUidException, RequestParameterException Client should pass customer's data as POST Body. Content-Type needs to be set to application/x-www-form-urlencoded; charset=UTF-8 and sample body (urlencoded) is: old=1234&new=1111
Sample call: https://localhost:9002/rest/v1/mysite/customers
Method requires authentication and is restricted toHTTPSchannel.
Method type :POSTRegister data need to be sent as post body..- Parameters:
login- - login to be createdpassword- - customer passwordfirstName- - customer first namelastName- - customer last nametitleCode- - customer's title- Throws:
DuplicateUidException- in case the requested login already existsRequestParameterException
-
guestLogin
@Secured({"ROLE_CLIENT","ROLE_TRUSTED_CLIENT"}) @RequestMapping(value="/current/guestlogin", method=POST) @ResponseBody @ResponseStatus(OK) public void guestLogin(@RequestParam String email) throws DuplicateUidException Creates the user dedicated to do a guest checkout. Newly created user will be available only by cartService and only during the current session.- Parameters:
email- - guest user's e-mail, it will be part of user id- Throws:
DuplicateUidException
-
convertAnonymousUserToCustomer
@Secured({"ROLE_CLIENT","ROLE_TRUSTED_CLIENT"}) @RequestMapping(value="/current/convert", method=POST) @ResponseBody @ResponseStatus(OK) public void convertAnonymousUserToCustomer(@RequestParam String password, javax.servlet.http.HttpSession httpSession) throws DuplicateUidException, SessionAttributeException Converts currently logged guest user to full user. It is possible to call it after guest user has placed order during the same session.- Parameters:
password-httpSession-- Throws:
DuplicateUidExceptionSessionAttributeException
-
updateDefaultAddress
@Secured("ROLE_CUSTOMERGROUP") @RequestMapping(value="/current/addresses/default/{id}", method=PUT) @ResponseBody @ResponseStatus(OK) public void updateDefaultAddress(@PathVariable String id) throws DuplicateUidException Update customer's default address- Parameters:
id- - Address id to be set as default address- Throws:
DuplicateUidException
-
updateProfile
@Secured("ROLE_CUSTOMERGROUP") @RequestMapping(value="/current/profile", method={PUT,POST}) @ResponseBody public CustomerData updateProfile(javax.servlet.http.HttpServletRequest request) throws DuplicateUidException Update customer's profile- Parameters:
request- - http request- Returns:
- updated profile
- Throws:
DuplicateUidException
-
getAddresses
@Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"}) @RequestMapping(value="/current/addresses", method=GET) @ResponseBody public AddressDataList getAddresses()Get all customer's addresses- Returns:
- List of customer addresses
-
createAddress
@Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"}) @RequestMapping(value="/current/addresses", method=POST) @ResponseBody public AddressData createAddress(javax.servlet.http.HttpServletRequest request) throws DuplicateUidException, WebserviceValidationException Create new address for current customer- Parameters:
request-- Returns:
- address created
- Throws:
DuplicateUidExceptionWebserviceValidationException
-
editAddress
@Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"}) @RequestMapping(value="/current/addresses/{id}", method=PUT) @ResponseBody public AddressData editAddress(@PathVariable String id, javax.servlet.http.HttpServletRequest request) throws WebserviceValidationException Edit address from current customer- Parameters:
id- - id of address to be edited- Returns:
- modified address
- Throws:
WebserviceValidationException
-
deleteAddress
@Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"}) @RequestMapping(value="/current/addresses/{id}", method=DELETE) @ResponseBody public void deleteAddress(@PathVariable String id) Remove address from current customer- Parameters:
id- - id of address to be removed
-
getCurrentCustomer
@Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"}) @RequestMapping(value="/current", method=GET) @ResponseBody public CustomerData getCurrentCustomer()Get customer data- Returns:
- CustomerData object containing customer information
-
changePassword
@Secured("ROLE_CUSTOMERGROUP") @RequestMapping(value="/current/password", method={PUT,POST}) @ResponseBody @ResponseStatus(ACCEPTED) public void changePassword(@RequestParam String old, @RequestParam("new") String newPassword) Client should pass old and new password in Body. Content-Type needs to be set to application/x-www-form-urlencoded; charset=UTF-8 and sample body (urlencoded) is: old=1234&new=1111- Parameters:
old- - old passwordnewPassword- - new password
-
getPaymentInfos
@Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"}) @RequestMapping(value="/current/paymentinfos", method=GET) @ResponseBody public CCPaymentInfoDatas getPaymentInfos(@RequestParam(required=false,defaultValue="false") boolean saved) Web service for getting current user's credit card payment infos.
Sample call: http://localhost:9001/rest/v1/mysite/customers/paymentinfos?saved=true
Method requires authentication and is restricted toHTTPSchannel.
Method type :GET.- Parameters:
saved- -trueto retrieve only saved payment infos.falseby default- Returns:
- List of
CCPaymentInfoDataas response body
-
getPaymentInfo
@Secured("ROLE_CUSTOMERGROUP") @RequestMapping(value="/current/paymentinfos/{id}", method=GET) @ResponseBody public CCPaymentInfoData getPaymentInfo(@PathVariable String id) Web service for getting current user's credit card payment info by id.
Sample call: https://localhost:9002/rest/v1/mysite/customers/paymentinfos/123
Method requires authentication and is restricted toHTTPSchannel.
Method type :GET.- Returns:
CCPaymentInfoDataas response body
-
deletePaymentInfo
@Secured("ROLE_CUSTOMERGROUP") @RequestMapping(value="/current/paymentinfos/{id}", method=DELETE) @ResponseBody public void deletePaymentInfo(@PathVariable String id) Web service for deleting current user's credit card payment info by id.
Sample call: http://localhost:9001/rest/v1/mysite/customers/paymentinfos/123
Method requires authentication and is restricted toHTTPSchannel.
Method type :DELETE. -
updatePaymentInfoAddress
@RequestMapping(value="/current/paymentinfos/{paymentInfoId}/address", method=POST) @ResponseBody @Secured("ROLE_CUSTOMERGROUP") public void updatePaymentInfoAddress(@PathVariable String paymentInfoId, javax.servlet.http.HttpServletRequest request) throws RequestParameterException Web service for modifying billing address data for the specific payment info.
Sample call: https://localhost:9002/rest/v1/mysite/paymentinfos/123/address
Method requires authentication and is restricted toHTTPSchannel.
Method type :POST. Address data need to be sent as post body.
Method usesHttpRequestAddressDataPopulatorto populate address data from request parameters.- Parameters:
paymentInfoId-request-- Throws:
RequestParameterException
-
updatePaymentInfo
@RequestMapping(value="/current/paymentinfos/{paymentInfoId}", method=PUT) @ResponseBody @Secured("ROLE_CUSTOMERGROUP") public void updatePaymentInfo(@PathVariable String paymentInfoId, javax.servlet.http.HttpServletRequest request) throws RequestParameterException Web service for modifying existing payment info.
Sample call: https://localhost:9002/rest/v1/mysite/paymentinfos/123
Method requires authentication and is restricted toHTTPSchannel.
Method type :PUT. PaymentInfo data need to be sent in body.
Method usesHttpRequestPaymentInfoPopulatorto populate payment info data from request parameters.- Parameters:
paymentInfoId-request-- Throws:
RequestParameterException
-
getAllCustomerGroupsForCurrentCustomer
@Secured("ROLE_CUSTOMERGROUP") @RequestMapping(value="/current/customergroups", method=GET) @ResponseBody public UserGroupDataList getAllCustomerGroupsForCurrentCustomer() -
getAllCustomerGroupsForCustomer
@Secured("ROLE_CUSTOMERMANAGERGROUP") @RequestMapping(value="/{uid}/customergroups", method=GET) @ResponseBody public UserGroupDataList getAllCustomerGroupsForCustomer(@PathVariable String uid) Web service for getting customer groups for current user.
Sample call: https://localhost:9002/rest/v1/mysite/customers/{uid}/customergroups
Method requires authentication and is restricted toHTTPSchannel.
Method type :GET.- Returns:
UserGroupDataListas response body
-
changeLogin
@Secured("ROLE_CUSTOMERGROUP") @RequestMapping(value="/current/login", method={PUT,POST}) @ResponseBody public LoginChangeResponse changeLogin(@RequestParam String newLogin, @RequestParam String password) throws DuplicateUidException, PasswordMismatchException, RequestParameterException Web service for changing customer login.
Sample call: https://localhost:9002/rest/v1/mysite/customers/current/login?newLogin=:newLogin&password=:password
Method requires customer authentication and is restricted toHTTPSchannel.
Method type :POST.- Parameters:
newLogin-password-- Returns:
LoginChangeResponse- Throws:
DuplicateUidExceptionPasswordMismatchExceptionRequestParameterException
-
restorePassword
@Secured({"ROLE_CLIENT","ROLE_TRUSTED_CLIENT"}) @RequestMapping(value="/current/forgottenpassword", method=POST) @ResponseBody public PasswordRestoreResponse restorePassword(@RequestParam String login) Web service for restoring password of current customer.
Sample call: https://localhost:9002/rest/v1/mysite/customers/current/forgottenpassword?login=:login/
Method requires client or trusted_client authentication and is restricted toHTTPSchannel.
Method type :POST.- Parameters:
login-- Returns:
PasswordRestoreResponse
-
changeCustomerPassword
@Secured("ROLE_TRUSTED_CLIENT") @RequestMapping(value="/{customerId}/password", method={PUT,POST}) @ResponseBody @ResponseStatus(ACCEPTED) public void changeCustomerPassword(@PathVariable String customerId, @RequestParam("new") String newPassword) Client should pass old and new password in Body. Content-Type needs to be set to application/x-www-form-urlencoded; charset=UTF-8 and sample body (urlencoded) is: new=1111- Parameters:
newPassword- - new password
-
verifyAddress
@Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"}) @RequestMapping(value="/current/addresses/verify", method=POST) @ResponseBody public AddressValidationData verifyAddress(javax.servlet.http.HttpServletRequest request) Verifies address- Parameters:
request-- Returns:
- address created
-
isAddressValid
protected boolean isAddressValid(AddressData addressData, org.springframework.validation.Errors errors, AddressValidationData validationData) Checks if address is valid by a validators- Parameters:
addressData-errors-validationData-- Returns:
trueif address is valid;falseotherwise
-
verifyAddresByService
protected AddressValidationData verifyAddresByService(AddressData addressData, org.springframework.validation.Errors errors, AddressValidationData validationData) Verifies address by commerce service- Parameters:
addressData-errors-validationData-- Returns:
- verified address
-
createResponseErrors
-
populateErrors
protected void populateErrors(org.springframework.validation.Errors errors, AddressVerificationResult<AddressVerificationDecision> addressVerificationResult) Populates Errors object- Parameters:
errors-addressVerificationResult-
-