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 BaseControllerMain 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 Constructor Description CustomersController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchangeCustomerPassword(java.lang.String customerId, java.lang.String newPassword)Client should pass old and new password in Body.LoginChangeResponsechangeLogin(java.lang.String newLogin, java.lang.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(java.lang.String old, java.lang.String newPassword)Client should pass old and new password in Body.voidconvertAnonymousUserToCustomer(java.lang.String password, javax.servlet.http.HttpSession httpSession)Converts currently logged guest user to full user.AddressDatacreateAddress(javax.servlet.http.HttpServletRequest request)Create new address for current customerprotected ErrorListWsDTOcreateResponseErrors(org.springframework.validation.Errors errors)voiddeleteAddress(java.lang.String id)Remove address from current customervoiddeletePaymentInfo(java.lang.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.AddressDataeditAddress(java.lang.String id, javax.servlet.http.HttpServletRequest request)Edit address from current customerAddressDataListgetAddresses()Get all customer's addressesUserGroupDataListgetAllCustomerGroupsForCurrentCustomer()UserGroupDataListgetAllCustomerGroupsForCustomer(java.lang.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.CustomerDatagetCurrentCustomer()Get customer dataCCPaymentInfoDatagetPaymentInfo(java.lang.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.CCPaymentInfoDatasgetPaymentInfos(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(java.lang.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 objectvoidregisterUser(java.lang.String login, java.lang.String password, java.lang.String titleCode, java.lang.String firstName, java.lang.String lastName)Client should pass customer's data as POST Body.PasswordRestoreResponserestorePassword(java.lang.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.voidupdateDefaultAddress(java.lang.String id)Update customer's default addressvoidupdatePaymentInfo(java.lang.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(java.lang.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.CustomerDataupdateProfile(javax.servlet.http.HttpServletRequest request)Update customer's profileprotected AddressValidationDataverifyAddresByService(AddressData addressData, org.springframework.validation.Errors errors, AddressValidationData validationData)Verifies address by commerce serviceAddressValidationDataverifyAddress(javax.servlet.http.HttpServletRequest request)Verifies address-
Methods inherited from class de.hybris.platform.ycommercewebservices.v1.controller.BaseController
handleErrorInternal, handleModelNotFoundException, sanitize
-
-
-
-
Method Detail
-
registerUser
@Secured({"ROLE_CLIENT","ROLE_TRUSTED_CLIENT"}) @RequestMapping(method=POST) @ResponseBody @ResponseStatus(CREATED) public void registerUser(@RequestParam java.lang.String login, @RequestParam java.lang.String password, @RequestParam(required=false) java.lang.String titleCode, @RequestParam java.lang.String firstName, @RequestParam java.lang.String lastName) throws DuplicateUidException, RequestParameterExceptionClient 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 java.lang.String email) throws DuplicateUidExceptionCreates 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 java.lang.String password, javax.servlet.http.HttpSession httpSession) throws DuplicateUidException, SessionAttributeExceptionConverts 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 java.lang.String id) throws DuplicateUidExceptionUpdate 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 DuplicateUidExceptionUpdate 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, WebserviceValidationExceptionCreate 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 java.lang.String id, javax.servlet.http.HttpServletRequest request) throws WebserviceValidationExceptionEdit 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 java.lang.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 java.lang.String old, @RequestParam("new") java.lang.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 java.lang.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 java.lang.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 java.lang.String paymentInfoId, javax.servlet.http.HttpServletRequest request) throws RequestParameterExceptionWeb 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 java.lang.String paymentInfoId, javax.servlet.http.HttpServletRequest request) throws RequestParameterExceptionWeb 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 java.lang.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 java.lang.String newLogin, @RequestParam java.lang.String password) throws DuplicateUidException, PasswordMismatchException, RequestParameterExceptionWeb 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 java.lang.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 java.lang.String customerId, @RequestParam("new") java.lang.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
protected ErrorListWsDTO createResponseErrors(org.springframework.validation.Errors errors)
-
populateErrors
protected void populateErrors(org.springframework.validation.Errors errors, AddressVerificationResult<AddressVerificationDecision> addressVerificationResult)Populates Errors object- Parameters:
errors-addressVerificationResult-
-
-