public class GSRequest
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
apiDomain |
protected java.lang.String |
apiMethod |
static boolean |
ENABLE_CONNECTION_POOLING |
protected java.lang.String |
format |
protected java.lang.String |
hostOverride |
protected static long |
timestampOffsetSec |
static java.lang.String |
VERSION |
| Constructor and Description |
|---|
GSRequest(java.lang.String accessToken,
java.lang.String apiMethod) |
GSRequest(java.lang.String accessToken,
java.lang.String apiMethod,
GSObject clientParams) |
GSRequest(java.lang.String apiKey,
java.lang.String secretKey,
java.lang.String apiMethod) |
GSRequest(java.lang.String apiKey,
java.lang.String secretKey,
java.lang.String apiMethod,
boolean useHTTPS) |
GSRequest(java.lang.String apiKey,
java.lang.String secretKey,
java.lang.String apiMethod,
GSObject clientParams) |
GSRequest(java.lang.String apiKey,
java.lang.String secretKey,
java.lang.String apiMethod,
GSObject clientParams,
boolean useHTTPS) |
GSRequest(java.lang.String apiKey,
java.lang.String secretKey,
java.lang.String apiMethod,
GSObject clientParams,
boolean useHTTPS,
java.lang.String userKey) |
GSRequest(java.lang.String apiKey,
java.lang.String secretKey,
java.lang.String accessToken,
java.lang.String apiMethod,
GSObject clientParams,
boolean useHTTPS) |
GSRequest(java.lang.String apiKey,
java.lang.String secretKey,
java.lang.String accessToken,
java.lang.String apiMethod,
GSObject clientParams,
boolean useHTTPS,
java.lang.String userKey)
Constructs a request using an apiKey and a secretKey.
|
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
buildQS(GSObject params)
Converts a GSObject to a query string.
|
void |
clearParams()
Clear request parameters
|
GSLogger |
getLogger()
Retrieves the logger object
|
java.lang.String |
getMethod() |
GSObject |
getParams()
Returns a GSObject object containing the parameters of this request.
|
GSResponse |
send()
Sends the request synchronously.
|
void |
send(GSResponseListener listener)
Sends the request asynchronously.
|
void |
send(GSResponseListener listener,
java.lang.Object context)
Sends the request asynchronously.
|
GSResponse |
send(int timeoutMS)
Sends the request synchronously.
|
protected GSResponse |
sendRequest(java.lang.String httpMethod,
java.lang.String domain,
java.lang.String path,
GSObject params,
java.lang.String token,
java.lang.String secret,
boolean useHTTPS,
boolean isLoggedIn,
int timeoutMS)
Send the actual HTTP/S request
|
void |
setAPIDomain(java.lang.String apiDomain)
Sets the domain used for making API calls.
|
void |
setHostOverride(java.lang.String host) |
void |
setLogger(GSLogger logger)
Allows passing an existing GSLogger
|
void |
setMethod(java.lang.String apiMethod) |
void |
setParam(java.lang.String key,
boolean value)
Sets a request parameter with a value.
|
void |
setParam(java.lang.String key,
GSArray value)
Sets a request parameter with a value.
|
void |
setParam(java.lang.String key,
GSObject value)
Sets a request parameter with a value.
|
void |
setParam(java.lang.String key,
int value)
Sets a request parameter with a value.
|
void |
setParam(java.lang.String key,
long value)
Sets a request parameter with a value.
|
void |
setParam(java.lang.String key,
java.lang.String value)
Sets a request parameter with a value.
|
void |
setParams(GSObject clientParams)
Sets a GSObject object containing the parameters of this request.
|
void |
setProxy(java.net.Proxy p)
Sets a proxy.
|
void |
setUseHTTPS(boolean useHTTPS) |
static java.lang.String |
UrlEncode(java.lang.String value)
Applies URL encoding rules to the String value, and returns the outcome.
|
java.lang.String |
urlEncodedParam(java.lang.String key) |
public static final java.lang.String VERSION
public static boolean ENABLE_CONNECTION_POOLING
protected static long timestampOffsetSec
protected java.lang.String apiMethod
protected java.lang.String apiDomain
protected java.lang.String hostOverride
protected java.lang.String format
public GSRequest(java.lang.String accessToken,
java.lang.String apiMethod)
public GSRequest(java.lang.String accessToken,
java.lang.String apiMethod,
GSObject clientParams)
public GSRequest(java.lang.String apiKey,
java.lang.String secretKey,
java.lang.String apiMethod,
GSObject clientParams)
public GSRequest(java.lang.String apiKey,
java.lang.String secretKey,
java.lang.String apiMethod,
boolean useHTTPS)
public GSRequest(java.lang.String apiKey,
java.lang.String secretKey,
java.lang.String apiMethod)
public GSRequest(java.lang.String apiKey,
java.lang.String secretKey,
java.lang.String apiMethod,
GSObject clientParams,
boolean useHTTPS)
public GSRequest(java.lang.String apiKey,
java.lang.String secretKey,
java.lang.String accessToken,
java.lang.String apiMethod,
GSObject clientParams,
boolean useHTTPS)
public GSRequest(java.lang.String apiKey,
java.lang.String secretKey,
java.lang.String apiMethod,
GSObject clientParams,
boolean useHTTPS,
java.lang.String userKey)
public GSRequest(java.lang.String apiKey,
java.lang.String secretKey,
java.lang.String accessToken,
java.lang.String apiMethod,
GSObject clientParams,
boolean useHTTPS,
java.lang.String userKey)
apiKey - your Gigya API-Key which can be obtained from the Site Setup page on Gigya's website (Read more in the Site Setup guide).secretKey - your Gigya Secret-Key which can be obtained from the Site Setup page on Gigya's website.apiMethod - the Gigya API method to call, including namespace. For
example: "socialize.getUserInfo". Please refer to our REST API reference for the list of available methods.clientParams - a GSObject object that contains the parameters for the Gigya
API method to call. Please refer to our REST API reference and find in the specific method
reference the list of method parameters. Please provide a user
ID (UID) in the params object to specify the user.useHTTPS - this parameter determines whether the request to Gigya will be
sent over HTTP or HTTPS. To send of HTTPS, please set this
parameter to true. The library uses HTTP (the request is
signed with the session's secret key) and only uses HTTPS if
the secret is not present. but you can use this parameter to
override the decision.userKey - A key of an administrative user with extra permissions.
If this parameter is provided, then the secretKey parameter is assumed to be
the admin user's secret key and not the site's secret key.public void setLogger(GSLogger logger)
logger - public GSLogger getLogger()
public void setMethod(java.lang.String apiMethod)
public java.lang.String getMethod()
public void clearParams()
public void setParam(java.lang.String key,
java.lang.String value)
key - key with which the specified value is to be associatedvalue - a String value to be associated with the specified keypublic void setParam(java.lang.String key,
int value)
key - key with which the specified value is to be associatedvalue - a int value to be associated with the specified keypublic void setParam(java.lang.String key,
long value)
key - key with which the specified value is to be associatedvalue - a long value to be associated with the specified keypublic void setParam(java.lang.String key,
boolean value)
key - key with which the specified value is to be associatedvalue - a boolean value to be associated with the specified keypublic void setParam(java.lang.String key,
GSObject value)
key - key with which the specified value is to be associatedvalue - a GSObject value to be associated with the specified keypublic void setParam(java.lang.String key,
GSArray value)
key - key with which the specified value is to be associatedvalue - a GSArray value to be associated with the specified keypublic GSObject getParams()
public void setProxy(java.net.Proxy p)
p - a proxy settings objectpublic void setUseHTTPS(boolean useHTTPS)
public void setParams(GSObject clientParams)
public void setAPIDomain(java.lang.String apiDomain)
apiDomain - the domain of the data center to be used. For example: "eu1.gigya.com" for Europe data centerpublic void setHostOverride(java.lang.String host)
public GSResponse send()
public GSResponse send(int timeoutMS)
timeoutMS - using this parameter you may set a timeout to this request.
The timeout is the number of milliseconds till returning
timeout response. If the timeout expires, the server will
return a response with a "Request Timeout" error (error code
504002).public void send(GSResponseListener listener)
listener - an Object which implements the GSResponseListenerpublic void send(GSResponseListener listener, java.lang.Object context)
listener - an Object which implements the GSResponseListenercontext - this object will be passed untouched and received back in the
responsepublic static java.lang.String buildQS(GSObject params)
params - the GSObject to convertprotected GSResponse sendRequest(java.lang.String httpMethod, java.lang.String domain, java.lang.String path, GSObject params, java.lang.String token, java.lang.String secret, boolean useHTTPS, boolean isLoggedIn, int timeoutMS) throws java.lang.Exception
httpMethod - "POST" or "GET"domain - path - params - token - session tokensecret - session secretuseHTTPS - override HTTPS usagejava.lang.Exceptionpublic java.lang.String urlEncodedParam(java.lang.String key)
public static java.lang.String UrlEncode(java.lang.String value)
value - the string to encode