public class GravityClient
extends java.lang.Object
Example usage:
public GravityClient createGravityClient() {
GravityClient client = new GravityClient();
client.setRemoteUrl("https://saas.gravityrd.com/grrec-CustomerID-war/WebshopServlet");
client.setUserName("sampleUser");
client.setPassword("samplePasswd");
return client;
}
GravityClient client = createGravityClient();
GravityRecommendationContext context = new GravityRecommendationContext();
context.numberLimit = 1;
context.scenarioId = "ITEM_PAGE";
client.getItemRecommendation("user1", context);
| Constructor and Description |
|---|
GravityClient() |
| Modifier and Type | Method and Description |
|---|---|
void |
addEvents(com.gravityrd.receng.web.webshop.jsondto.GravityEvent[] events,
boolean async)
Adds events to the recommendation engine.
|
void |
addItems(com.gravityrd.receng.web.webshop.jsondto.GravityItem[] items,
boolean async)
Adds items to the recommendation engine.
|
void |
addUsers(com.gravityrd.receng.web.webshop.jsondto.GravityUser[] users,
boolean async)
Adds users to the recommendation engine.
|
com.gravityrd.receng.web.webshop.jsondto.GravityItemRecommendation |
getItemRecommendation(java.lang.String userId,
java.lang.String cookieId,
com.gravityrd.receng.web.webshop.jsondto.GravityRecommendationContext context)
Returns a list of recommended items, based on the given context parameters.
|
com.gravityrd.receng.web.webshop.jsondto.GravityItemRecommendation[] |
getItemRecommendationBulk(java.lang.String userId,
java.lang.String cookieId,
com.gravityrd.receng.web.webshop.jsondto.GravityRecommendationContext[] context)
Given the userId and the cookieId, we can request recommendations for multiple scenarios (described by the context).
|
java.lang.String |
getPassword() |
int |
getReadTimeout() |
java.lang.String |
getRemoteUrl() |
java.lang.String |
getUserName() |
void |
setPassword(java.lang.String password)
Set the password for the http authenticated connection.
|
void |
setReadTimeout(int readTimeout)
Set the timeout for the operations in millisecs.
|
void |
setRemoteUrl(java.lang.String remoteUrl)
Set the URL of the server side interface.
|
void |
setUserName(java.lang.String userName)
Set the user name for the http authenticated connection.
|
java.lang.String |
test(java.lang.String name)
Simple test function to test without side effects whether the service is alive.
|
void |
testException()
Simple test function to test throwing an exception.
|
public java.lang.String getRemoteUrl()
public void setRemoteUrl(java.lang.String remoteUrl)
remoteUrl - the server url provided by Gravity integration teampublic java.lang.String getUserName()
public void setUserName(java.lang.String userName)
userName - user authentication name provided by Gravitypublic java.lang.String getPassword()
public void setPassword(java.lang.String password)
password - user authentication password provided by Gravitypublic int getReadTimeout()
public void setReadTimeout(int readTimeout)
readTimeout - wait up to this millisecond for the request answerspublic void addEvents(com.gravityrd.receng.web.webshop.jsondto.GravityEvent[] events,
boolean async)
throws com.gravityrd.receng.web.webshop.jsondto.GravityRecEngException,
java.io.IOException
events - The events to add.async - true if the call is asynchronous. An asynchronous call
returns immediately after an input data checking,
a synchronous call returns only after the data is saved to database.java.io.IOException - if cannot connectcom.gravityrd.receng.web.webshop.jsondto.GravityRecEngException - if cannot process the answer filespublic void addUsers(com.gravityrd.receng.web.webshop.jsondto.GravityUser[] users,
boolean async)
throws com.gravityrd.receng.web.webshop.jsondto.GravityRecEngException,
java.io.IOException
users - The user to add.async - true if the call is asynchronous. An asynchronous call
returns immediately after an input data checking,
a synchronous call returns only after the data is saved to database.java.io.IOException - if cannot connectcom.gravityrd.receng.web.webshop.jsondto.GravityRecEngException - if cannot process the answer filespublic void addItems(com.gravityrd.receng.web.webshop.jsondto.GravityItem[] items,
boolean async)
throws com.gravityrd.receng.web.webshop.jsondto.GravityRecEngException,
java.io.IOException
items - The items to addasync - true if the call is asynchronous. An asynchronous call
returns immediately after an input data checking,
a synchronous call returns only after the data is saved tojava.io.IOException - if cannot connectcom.gravityrd.receng.web.webshop.jsondto.GravityRecEngException - if cannot process the answer filesdatabase.public com.gravityrd.receng.web.webshop.jsondto.GravityItemRecommendation getItemRecommendation(java.lang.String userId,
java.lang.String cookieId,
com.gravityrd.receng.web.webshop.jsondto.GravityRecommendationContext context)
throws com.gravityrd.receng.web.webshop.jsondto.GravityRecEngException,
java.io.IOException
userId - The identifier of the logged in user. If no user is logged in, null should be specified.cookieId - It should be a permanent identifier for the end users computer, preserving its value across browser sessions.
It should be always specified.context - Additional information which describes the actual scenario.java.io.IOException - if cannot connectcom.gravityrd.receng.web.webshop.jsondto.GravityRecEngException - if cannot process the answer filespublic com.gravityrd.receng.web.webshop.jsondto.GravityItemRecommendation[] getItemRecommendationBulk(java.lang.String userId,
java.lang.String cookieId,
com.gravityrd.receng.web.webshop.jsondto.GravityRecommendationContext[] context)
throws com.gravityrd.receng.web.webshop.jsondto.GravityRecEngException,
java.io.IOException
userId - The identifier of the logged in user. If no user is logged in, null should be specified.cookieId - It should be a permanent identifier for the end users computer, preserving its value across browser sessions.
It should be always specified.context - Additional Array of information which describes the actual scenarios.java.io.IOException - if cannot connectcom.gravityrd.receng.web.webshop.jsondto.GravityRecEngException - if cannot process the answer filespublic java.lang.String test(java.lang.String name)
throws com.gravityrd.receng.web.webshop.jsondto.GravityRecEngException,
java.io.IOException
name - a test stringname* @throws IOException if cannot connectjava.io.IOException - if cannot connectcom.gravityrd.receng.web.webshop.jsondto.GravityRecEngException - if cannot process the answer filespublic void testException()
throws com.gravityrd.receng.web.webshop.jsondto.GravityRecEngException,
java.io.IOException
java.io.IOException - if cannot connectcom.gravityrd.receng.web.webshop.jsondto.GravityRecEngException - if cannot process the answer files