com.paypal.base.rest
Class RESTAPICallPreHandler

java.lang.Object
  extended by com.paypal.base.rest.RESTAPICallPreHandler
All Implemented Interfaces:
APICallPreHandler

public class RESTAPICallPreHandler
extends Object
implements APICallPreHandler

RESTApiCallPreHandler acts as a APICallPreHandler for REST API calls. The implementation is PayPal specific, To do custom implementation override the protected methods


Constructor Summary
RESTAPICallPreHandler(Map<String,String> configurationMap)
          Constructor using configurations dynamically
RESTAPICallPreHandler(Map<String,String> configurationMap, Map<String,String> headersMap)
          Constructor using a Map of headers for forming custom headers
 
Method Summary
protected  Map<String,String> formUserAgentHeader()
          Returns User-Agent header
 URL getBaseURL()
          Returns the base URL configured in application resources or Map passed for dynamic configuration
 ICredential getCredential()
          Returns ICredential configured for the api call
 String getEndPoint()
          Returns the endpoint for the API call.
 Map<String,String> getHeaderMap()
          Returns HTTP headers as a Map
 String getPayLoad()
          Returns the payload for the API call.
protected  String getProcessedEndPoint()
          Override this method to process EndPoint
protected  Map<String,String> getProcessedHeaderMap()
          Override this method to return a Map of HTTP headers
protected  String getProcessedPayLoad()
          Override this method to process payload for processing
 void setAuthorizationToken(String authorizationToken)
           
 void setPayLoad(String payLoad)
           
 void setRequestId(String requestId)
           
 void setResourcePath(String resourcePath)
           
 void setSdkVersion(SDKVersion sdkVersion)
           
 void setUrl(String urlString)
           
 void validate()
          Validates settings and integrity before call
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RESTAPICallPreHandler

public RESTAPICallPreHandler(Map<String,String> configurationMap)
Constructor using configurations dynamically

Parameters:
configurationMap - Map used for dynamic configuration

RESTAPICallPreHandler

public RESTAPICallPreHandler(Map<String,String> configurationMap,
                             Map<String,String> headersMap)
Constructor using a Map of headers for forming custom headers

Parameters:
configurationMap - Map used for dynamic configuration
headersMap - Headers Map
Method Detail

setAuthorizationToken

public void setAuthorizationToken(String authorizationToken)
Parameters:
authorizationToken - the authorizationToken to set

setResourcePath

public void setResourcePath(String resourcePath)
Parameters:
resourcePath - the resourcePath to set

setRequestId

public void setRequestId(String requestId)
Parameters:
requestId - the requestId to set

setPayLoad

public void setPayLoad(String payLoad)
Parameters:
payLoad - the payLoad to set

setSdkVersion

public void setSdkVersion(SDKVersion sdkVersion)
Parameters:
sdkVersion - the sdkVersion to set

getHeaderMap

public Map<String,String> getHeaderMap()
Returns HTTP headers as a Map

Specified by:
getHeaderMap in interface APICallPreHandler
Returns:
Map of Http headers

getPayLoad

public String getPayLoad()
Description copied from interface: APICallPreHandler
Returns the payload for the API call. The implementation should take care in formatting the payload appropriately

Specified by:
getPayLoad in interface APICallPreHandler
Returns:
Payload as String

getEndPoint

public String getEndPoint()
Description copied from interface: APICallPreHandler
Returns the endpoint for the API call. The implementation may calculate the endpoint depending on parameters set on it. If no endpoint is found in the passed configuration, then SANDBOX endpoints (hardcoded in Constants)are taken to be default for the API call.

Specified by:
getEndPoint in interface APICallPreHandler
Returns:
Endpoint String.

getCredential

public ICredential getCredential()
Description copied from interface: APICallPreHandler
Returns ICredential configured for the api call

Specified by:
getCredential in interface APICallPreHandler
Returns:
ICredential object

validate

public void validate()
              throws ClientActionRequiredException
Description copied from interface: APICallPreHandler
Validates settings and integrity before call

Specified by:
validate in interface APICallPreHandler
Throws:
ClientActionRequiredException

getBaseURL

public URL getBaseURL()
               throws MalformedURLException
Returns the base URL configured in application resources or Map passed for dynamic configuration

Returns:
BaseUrl ending with a '/' character URL
Throws:
MalformedURLException - if endpoint cannot be found or formed

setUrl

public void setUrl(String urlString)
            throws MalformedURLException
Parameters:
urlString - the url to set
Throws:
MalformedURLException

formUserAgentHeader

protected Map<String,String> formUserAgentHeader()
Returns User-Agent header

Returns:
Map storing the User-Agent header

getProcessedEndPoint

protected String getProcessedEndPoint()
Override this method to process EndPoint

Returns:
Endpoint as String

getProcessedHeaderMap

protected Map<String,String> getProcessedHeaderMap()
Override this method to return a Map of HTTP headers

Returns:
Map of HTTP headers

getProcessedPayLoad

protected String getProcessedPayLoad()
Override this method to process payload for processing

Returns:
PayLoad as String


Copyright © 2015. All Rights Reserved.