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
  • 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 to HTTPS channel.
      Method type : POST Register data need to be sent as post body..
      Parameters:
      login - - login to be created
      password - - customer password
      firstName - - customer first name
      lastName - - customer last name
      titleCode - - customer's title
      Throws:
      DuplicateUidException - in case the requested login already exists
      RequestParameterException
    • 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:
      DuplicateUidException
      SessionAttributeException
    • 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:
      DuplicateUidException
      WebserviceValidationException
    • 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 password
      newPassword - - 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 to HTTPS channel.
      Method type : GET.
      Parameters:
      saved - - true to retrieve only saved payment infos. false by default
      Returns:
      List of CCPaymentInfoData as 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 to HTTPS channel.
      Method type : GET.
      Returns:
      CCPaymentInfoData as 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 to HTTPS channel.
      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 to HTTPS channel.
      Method type : POST. Address data need to be sent as post body.
      Method uses HttpRequestAddressDataPopulator to 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 to HTTPS channel.
      Method type : PUT. PaymentInfo data need to be sent in body.
      Method uses HttpRequestPaymentInfoPopulator to 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 to HTTPS channel.
      Method type : GET.
      Returns:
      UserGroupDataList as 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 to HTTPS channel.
      Method type : POST.
      Parameters:
      newLogin -
      password -
      Returns:
      LoginChangeResponse
      Throws:
      DuplicateUidException
      PasswordMismatchException
      RequestParameterException
    • 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 to HTTPS channel.
      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:
      true if address is valid; false otherwise
    • 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 -