public class APIContext
extends java.lang.Object
APIContext wraps wire-level parameters for the API call.
AccessToken, which is essentially an OAuth token, is treated as a mandatory
parameter for (PayPal REST APIs). RequestId is generated if not supplied for
marking Idempotency of the API call. OAuth token can be generated using
OAuthTokenCredential. The Application Header property may be used by
clients to access application level headers. The clients are responsible to
cast the Application Header property to appropriate type.| Constructor and Description |
|---|
APIContext()
Deprecated.
Please use
APIContext(String, String, String) instead.
APIContext ideally needs more information than just accessToken to operate correctly. Now, you do not need
to fetch accessToken from OAuthTokenCredential separately. Instead, just initialize APIContext with
clientId, clientSecret and mode, with optional configurations, as shown below, and pass the context to paypal API methods:
|
APIContext(java.lang.String accessToken)
Deprecated.
Please use
APIContext(String, String, String) instead.
APIContext ideally needs more information than just accessToken to operate correctly. Now, you do not need
to fetch accessToken from OAuthTokenCredential separately. Instead, just initialize APIContext with
clientId, clientSecret and mode, with optional configurations, as shown below, and pass the context to paypal API methods:
|
APIContext(java.lang.String accessToken,
java.lang.String requestId)
Deprecated.
Please use
APIContext(String, String, String) instead.
APIContext ideally needs more information than just accessToken to operate correctly. Now, you do not need
to fetch accessToken from OAuthTokenCredential separately. Instead, just initialize APIContext with
clientId, clientSecret and mode, with optional configurations, as shown below, and pass the context to paypal API methods:
|
APIContext(java.lang.String clientID,
java.lang.String clientSecret,
java.lang.String mode)
Pass the clientID, secret and mode.
|
APIContext(java.lang.String clientID,
java.lang.String clientSecret,
java.lang.String mode,
java.util.Map<java.lang.String,java.lang.String> configurations)
Pass the clientID, secret and mode along with additional configurations.
|
| Modifier and Type | Method and Description |
|---|---|
APIContext |
addConfiguration(java.lang.String key,
java.lang.String value)
Adds configuration
|
APIContext |
addConfigurations(java.util.Map<java.lang.String,java.lang.String> configurations)
Adds configurations
|
APIContext |
addHTTPHeader(java.lang.String key,
java.lang.String value)
Adds HTTP Header to existing list
|
APIContext |
addHTTPHeaders(java.util.Map<java.lang.String,java.lang.String> httpHeaders)
Adds HTTP Headers to existing list
|
java.lang.String |
fetchAccessToken()
Returns the access Token.
|
java.lang.String |
getAccessToken()
Deprecated.
Please use
fetchAccessToken() instead.
Previously, this was a dumb getter method. However, we enabled the feature to re-generate the access Token if null, or expired.
This required us to throw proper PayPalRESTException, with error information on failure. |
java.lang.String |
getClientID() |
java.lang.String |
getClientSecret() |
java.lang.String |
getConfiguration(java.lang.String key)
Returns string value of specific configuration.
|
java.util.Map<java.lang.String,java.lang.String> |
getConfigurationMap()
Returns Configuration Map
|
java.util.Map<java.lang.String,java.lang.String> |
getHeadersMap()
Deprecated.
Use getHTTPHeaders() instead
|
java.lang.String |
getHTTPHeader(java.lang.String key) |
java.util.Map<java.lang.String,java.lang.String> |
getHTTPHeaders()
Returns HTTP Headers.
|
java.lang.String |
getRequestId()
Returns the unique requestId set during creation, if not available and if
maskRequestId is set to false returns a generated one, else returns null.
|
SDKVersion |
getSdkVersion() |
APIContext |
setConfigurationMap(java.util.Map<java.lang.String,java.lang.String> configurationMap)
Replaces the existing configurations with provided one
|
void |
setHeadersMap(java.util.Map<java.lang.String,java.lang.String> headersMap)
Deprecated.
Please use
setHTTPHeaders(Map) or addHTTPHeaders(Map) instead. |
APIContext |
setHTTPHeaders(java.util.Map<java.lang.String,java.lang.String> httpHeaders)
Replaces existing headers with provided one.
|
void |
setMaskRequestId(boolean maskRequestId) |
APIContext |
setMode(java.lang.String mode)
Sets mode to either `live` or `sandbox`.
|
APIContext |
setRefreshToken(java.lang.String refreshToken)
Sets refresh token to be used for third party OAuth operations.
|
APIContext |
setRequestId(java.lang.String requestId)
Sets the requestId to be sent on each request.
|
void |
setSdkVersion(SDKVersion sdkVersion) |
APIContext |
usingGoogleAppEngine(boolean usingGoogleAppEngine)
Enables settings for Google App Engine.
|
public APIContext()
APIContext(String, String, String) instead.
APIContext ideally needs more information than just accessToken to operate correctly. Now, you do not need
to fetch accessToken from OAuthTokenCredential separately. Instead, just initialize APIContext with
clientId, clientSecret and mode, with optional configurations, as shown below, and pass the context to paypal API methods:
APIContext context = new APIContext(clientId, clientSecret, "sandbox");
public APIContext(java.lang.String clientID,
java.lang.String clientSecret,
java.lang.String mode)
clientID - clientSecret - mode - public APIContext(java.lang.String clientID,
java.lang.String clientSecret,
java.lang.String mode,
java.util.Map<java.lang.String,java.lang.String> configurations)
clientID - clientSecret - mode - configurations - public APIContext(java.lang.String accessToken)
APIContext(String, String, String) instead.
APIContext ideally needs more information than just accessToken to operate correctly. Now, you do not need
to fetch accessToken from OAuthTokenCredential separately. Instead, just initialize APIContext with
clientId, clientSecret and mode, with optional configurations, as shown below, and pass the context to paypal API methods:
APIContext context = new APIContext(clientId, clientSecret, "sandbox");
accessToken - OAuthToken required for the call. OAuth token used by the REST
API service. The token should be of the form 'Bearer xxxx..'.
See OAuthTokenCredential to generate OAuthTokenpublic APIContext(java.lang.String accessToken,
java.lang.String requestId)
APIContext(String, String, String) instead.
APIContext ideally needs more information than just accessToken to operate correctly. Now, you do not need
to fetch accessToken from OAuthTokenCredential separately. Instead, just initialize APIContext with
clientId, clientSecret and mode, with optional configurations, as shown below, and pass the context to paypal API methods:
APIContext context = new APIContext(clientId, clientSecret, "sandbox");
accessToken - OAuthToken required for the call. OAuth token used by the REST
API service. The token should be of the form 'Bearer xxxx..'.
See OAuthTokenCredential to generate OAuthTokenrequestId - Unique requestId required for the call. Idempotency id,
Calling setMaskRequestId(true) will override the requestId
getter to return null, which can be used by the client (null
check) to forcibly not sent requestId in the API call.public APIContext setRefreshToken(java.lang.String refreshToken)
refreshToken - APIContextpublic APIContext setMode(java.lang.String mode)
mode - APIContextpublic APIContext usingGoogleAppEngine(boolean usingGoogleAppEngine)
usingGoogleAppEngine - APIContextpublic java.util.Map<java.lang.String,java.lang.String> getHTTPHeaders()
public java.lang.String getHTTPHeader(java.lang.String key)
public APIContext setHTTPHeaders(java.util.Map<java.lang.String,java.lang.String> httpHeaders)
httpHeaders - the httpHeaders to setpublic APIContext addHTTPHeaders(java.util.Map<java.lang.String,java.lang.String> httpHeaders)
httpHeaders - the httpHeaders to setpublic APIContext addHTTPHeader(java.lang.String key, java.lang.String value)
key - value - public java.util.Map<java.lang.String,java.lang.String> getConfigurationMap()
Map of configurationspublic APIContext setConfigurationMap(java.util.Map<java.lang.String,java.lang.String> configurationMap)
configurationMap - the configurationMap to setAPIContextpublic APIContext addConfigurations(java.util.Map<java.lang.String,java.lang.String> configurations)
configurations - Map of configurations.APIContextpublic APIContext addConfiguration(java.lang.String key, java.lang.String value)
key - keyvalue - valueAPIContextpublic java.lang.String getConfiguration(java.lang.String key)
key - keyString value of specific configuration.public java.lang.String getAccessToken()
fetchAccessToken() instead.
Previously, this was a dumb getter method. However, we enabled the feature to re-generate the access Token if null, or expired.
This required us to throw proper PayPalRESTException, with error information on failure.public java.lang.String fetchAccessToken()
throws PayPalRESTException
String of AccessTokenPayPalRESTExceptionpublic java.lang.String getRequestId()
public APIContext setRequestId(java.lang.String requestId)
requestId - request Idpublic void setMaskRequestId(boolean maskRequestId)
maskRequestId - the maskRequestId to setpublic SDKVersion getSdkVersion()
public void setSdkVersion(SDKVersion sdkVersion)
sdkVersion - the sdkVersion to setpublic java.util.Map<java.lang.String,java.lang.String> getHeadersMap()
public void setHeadersMap(java.util.Map<java.lang.String,java.lang.String> headersMap)
setHTTPHeaders(Map) or addHTTPHeaders(Map) instead.headersMap - the headersMap to setpublic java.lang.String getClientID()
public java.lang.String getClientSecret()