Skip to content
Home  »  Documentation  »  API Documentation  »  Customizing the API

Customizing the API

As with everything else in SoftSlate Commerce, with the source code you can extend and customize the API to suit whatever specific needs you have. What follows is a review of the key aspects in the source that process API requests. These should point you in the right direction when it comes time to customize.

com.softslate.commerce.customer.core.APIFilter

  • Intercepts the request before it hits the Struts action.
  • Translates API URLs under /api to the corresponding Struts URLs.
  • Sets the request attribute "isApiRequest" to true, and sets other key variables for the request.
  • Calls com.softslate.commerce.customer.core.APIRequestWrapper which converts incoming Json parameters to regular request parameters, for Struts' benefit.

 

com.softslate.commerce.administrator.core.AdministratorRequestProcessor.authenticateApiRequest(HttpServletRequest)

  • For API requests requiring Administrator authentication (not Public Operations), intercepts the request before it hits the Struts action.
  • If the request has an apiLoginID and apiAuthenticationToken parameter or http header, it tries to authenticate the API user.
  • API users are just Administrators but with the new isApiUser flag set to true. You can assign them specific roles just like other Administrators.

 

com.softslate.commerce.customer.core.BaseRequestProcessor: processForwardConfig and internalModuleRelativeForward methods

  • Intercepts responses before they are forwarded to the view layer.
  • If the request is an API request, forwards the response to /WEB-INF/templates/administrator/default/json/apiResponse.jsp.

 

/WEB-INF/templates/administrator/default/json/apiResponse.jsp

  • Dispatches API responses to the appropriate JSP page for producing the Json output.
  • The JSP pages are easily customized, by copying the core JSP into the corresponding directory under the "custom" folder.
  • The JSP pages allow for complete control over the Json output of each API request.