Sneha S
Sneha S

Reputation: 288

Custom CustomerEndPoint Broadleaf

I am new to broadleaf. I want to create a custom customerEndPoint Class which will provide services like registering customer getting a customer details etc. I tried creating a CustomerEndpoint Class in com.mycompany.api.endpoint.customer package. Is there any other configurations to be done to access the customer urls??

Please help on this...

Upvotes: 1

Views: 445

Answers (2)

Sneha S
Sneha S

Reputation: 288

I solved this, Sharing it as it may be helpful for someone. I Configured the CustomerEndPoint bean in applicationContent-rest-api.xml and annotated CustomerEndpoint as controller and just extented the BaseEndPoint.

CustomerEndpoint.java

@Controller
@Scope("singleton")
@Path("/customer/")
@Produces(value = { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes(value = { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public class CustomerEndpoint extends BaseEndpoint {
@Resource(name = "blCustomerService")
protected CustomerService customerService;

public void setCustomerService(CustomerService customerService) {
    this.customerService = customerService;
}

@GET
public CustomerWrapper getCustomer(@Context HttpServletRequest request,
        @QueryParam("id") String emailId) {
    CustomerWrapper customerWrapper = new CustomerWrapper();
    if (emailId != null && emailId != "") {
        customerWrapper.wrapDetails(
                customerService.readCustomerByEmail(emailId), request);
    }
    return customerWrapper;
}

}

applicationContext-rest-api.xml

<bean id="customerEndpoint" class="com.mycompany.api.endpoint.customer.CustomerEndpoint"/>

Upvotes: 1

Pr0 TuX
Pr0 TuX

Reputation: 241

It depends of whatever version are you using. If you using for example : broadleaf-3.1.X see http://mvnrepository.com/artifact/org.broadleafcommerce/broadleaf-framework/3.1.5-GA

You could take as an example com.mycompany.api.endpoint.checkout.CheckoutEndpoint.

Into default platform there is org.broadleafcommerce.core.web.api.endpoint.customer.CustomerEndpoint but this implementation is empty.

You could extend that class and add annotation similar to com.mycompany.api.endpoint.checkout.CheckoutEndpoint also add business logic according to your needs.

There isn't some platform default implementation into platform as far as I can see int broadleaf-3.1.6-GA

Upvotes: 0

Related Questions