com.paypal.base.rest
Class PayPalResource

java.lang.Object
  extended by com.paypal.base.rest.PayPalResource

public abstract class PayPalResource
extends Object

PayPalResource acts as a base class for REST enabled resources.


Constructor Summary
PayPalResource()
           
 
Method Summary
static
<T> T
configureAndExecute(APIContext apiContext, HttpMethod httpMethod, String resourcePath, Map<String,String> headersMap, String payLoad, Class<T> clazz)
          Deprecated.  
static
<T> T
configureAndExecute(APIContext apiContext, HttpMethod httpMethod, String resourcePath, String payLoad, Class<T> clazz)
          Configures and executes REST call: Supports JSON
static
<T> T
configureAndExecute(String accessToken, HttpMethod httpMethod, String resourcePath, String payLoad, Class<T> clazz)
          Deprecated.  
static APICallPreHandler createAPICallPreHandler(Map<String,String> configurationMap, String payLoad, String resourcePath, Map<String,String> headersMap, String accessToken, String requestId, SDKVersion sdkVersion)
          Returns a implementation of APICallPreHandler for the underlying layer.
static String getClientID()
          Return Client ID from configuration Map
static String getClientSecret()
          Returns Client Secret from configuration Map
static String getLastRequest()
          Returns the last request sent to the Service
static String getLastResponse()
          Returns the last response returned by the Service
static OAuthTokenCredential getOAuthTokenCredential()
          Returns OAuthTokenCredential instance using client ID and client secret loaded from configuration.
static OAuthTokenCredential initConfig(File file)
          Initialize the system using a File(Properties file).
static OAuthTokenCredential initConfig(InputStream inputStream)
          Initialize using InputStream(of a Properties file)..
static OAuthTokenCredential initConfig(Properties properties)
          Initialize using Properties.
static void initializeToDefault()
          Initialize to default properties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PayPalResource

public PayPalResource()
Method Detail

initConfig

public static OAuthTokenCredential initConfig(File file)
                                       throws PayPalRESTException
Initialize the system using a File(Properties file). The system is initialized using the given file and if the initialization succeeds the default 'sdk_config.properties' can only be loaded by calling the method initializeToDefault()

Parameters:
file - File object of a properties entity
Returns:
OAuthTokenCredential instance with client ID and client secret stored in configuration file.
Throws:
PayPalRESTException

initConfig

public static OAuthTokenCredential initConfig(Properties properties)
Initialize using Properties. The system is initialized using the given properties object and if the initialization succeeds the default 'sdk_config.properties' can only be loaded by calling the method initializeToDefault()

Parameters:
properties - Properties object
Returns:
OAuthTokenCredential instance with client ID and client secret in given properties.

initConfig

public static OAuthTokenCredential initConfig(InputStream inputStream)
                                       throws PayPalRESTException
Initialize using InputStream(of a Properties file).. The system is initialized using the given InputStream and if the initialization succeeds the default 'sdk_config.properties' can only be loaded by calling the method initializeToDefault(). The system is initialized with the information after loading defaults for the parameters that are not passed as part of the configuration. For defaults see ConfigManager

Parameters:
inputStream - InputStream
Returns:
OAuthTokenCredential instance with client ID and client secret stored in given inputStream.
Throws:
PayPalRESTException

getClientID

public static String getClientID()
Return Client ID from configuration Map


getClientSecret

public static String getClientSecret()
Returns Client Secret from configuration Map


getOAuthTokenCredential

public static OAuthTokenCredential getOAuthTokenCredential()
Returns OAuthTokenCredential instance using client ID and client secret loaded from configuration.

Returns:
OAuthTokenCredential instance.

initializeToDefault

public static void initializeToDefault()
                                throws PayPalRESTException
Initialize to default properties

Throws:
PayPalRESTException

getLastRequest

public static String getLastRequest()
Returns the last request sent to the Service

Returns:
Last request sent to the server

getLastResponse

public static String getLastResponse()
Returns the last response returned by the Service

Returns:
Last response got from the Service

configureAndExecute

public static <T> T configureAndExecute(String accessToken,
                                        HttpMethod httpMethod,
                                        String resourcePath,
                                        String payLoad,
                                        Class<T> clazz)
                             throws PayPalRESTException
Deprecated. 

Configures and executes REST call: Supports JSON

Type Parameters:
T - Response Type for de-serialization
Parameters:
accessToken - OAuth AccessToken to be used for the call.
httpMethod - Http Method verb
resourcePath - Resource URI path
payLoad - Payload to Service
clazz - Class object used in De-serialization
Returns:
T
Throws:
PayPalRESTException

configureAndExecute

public static <T> T configureAndExecute(APIContext apiContext,
                                        HttpMethod httpMethod,
                                        String resourcePath,
                                        String payLoad,
                                        Class<T> clazz)
                             throws PayPalRESTException
Configures and executes REST call: Supports JSON

Type Parameters:
T - Response Type for de-serialization
Parameters:
apiContext - APIContext to be used for the call.
httpMethod - Http Method verb
resource - Resource URI path
payLoad - Payload to Service
clazz - Class object used in De-serialization
Returns:
T
Throws:
PayPalRESTException

configureAndExecute

public static <T> T configureAndExecute(APIContext apiContext,
                                        HttpMethod httpMethod,
                                        String resourcePath,
                                        Map<String,String> headersMap,
                                        String payLoad,
                                        Class<T> clazz)
                             throws PayPalRESTException
Deprecated. 

Configures and executes REST call: Supports JSON

Type Parameters:
T -
Parameters:
apiContext - APIContext to be used for the call.
httpMethod - Http Method verb
resourcePath - Resource URI path
headersMap - Optional headers Map
payLoad - Payload to Service
clazz - Class object used in De-serialization
Returns:
T
Throws:
PayPalRESTException

createAPICallPreHandler

public static APICallPreHandler createAPICallPreHandler(Map<String,String> configurationMap,
                                                        String payLoad,
                                                        String resourcePath,
                                                        Map<String,String> headersMap,
                                                        String accessToken,
                                                        String requestId,
                                                        SDKVersion sdkVersion)
Returns a implementation of APICallPreHandler for the underlying layer.

Parameters:
configurationMap - configuration Map
payLoad - Raw payload
resourcePath - URI part of the resource operated on
headersMap - Custom HTTP headers map
accessToken - OAuth Token
requestId - PayPal Request Id
sdkVersion - SDKVersion instance
Returns:


Copyright © 2015. All Rights Reserved.