public final class GravityClient
extends java.lang.Object
Example usage:
public com.gravityrd.recengclient.webshop.GravityClient createGravityClient() { com.gravityrd.recengclient.webshop.GravityClient client = new com.gravityrd.recengclient.webshop.GravityClient(); client.setRemoteUrl("https://- .gravityrd-services.com/grrec- -war/WebshopServlet"); client.setUserName("sampleUser"); client.setPassword("samplePasswd"); return client; } com.gravityrd.recengclient.webshop.GravityClient client = createGravityClient(); GravityRecommendationContext context = new GravityRecommendationContext(); context.numberLimit = 1; context.scenarioId = "ITEM_PAGE"; client.getItemRecommendation("user1", context);
Modifier and Type | Field and Description |
---|---|
protected static com.fasterxml.jackson.databind.ObjectMapper |
mapper |
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.GravityEvent[] |
getEventsByCookieId(java.lang.String cookieId,
int limit)
Retrieves full event history associated with the cookieId from the recommendation engine.
|
com.gravityrd.receng.web.webshop.jsondto.GravityEvent[] |
getEventsByUserId(java.lang.String userId,
int limit)
Retrieves full event history associated with the userId from 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() |
com.gravityrd.receng.web.webshop.jsondto.GravityScenario[] |
getScenarioInformation()
Query the list of available recommendation scenarios for the backend
|
com.gravityrd.receng.web.webshop.jsondto.GravityUser |
getUserByCookieId(java.lang.String cookieId)
Retrieves user metadata from the recommendation engine if a user can be recognized from the specified cookieId.
|
com.gravityrd.receng.web.webshop.jsondto.GravityUser |
getUserByUserId(java.lang.String userId)
Retrieves user metadata from the recommendation engine.
|
java.lang.String |
getUserName() |
void |
optOutCookie(java.lang.String cookieId)
Deletes full event history assigned with the given cookieId from the recommendation engine.
|
void |
optOutUser(java.lang.String userId)
Deletes full event history and metadata assigned with the given userId from the recommendation engine.
|
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 com.gravityrd.receng.web.webshop.jsondto.GravityScenario[] getScenarioInformation() throws com.gravityrd.receng.web.webshop.jsondto.GravityRecEngException, java.io.IOException
com.gravityrd.receng.web.webshop.jsondto.GravityRecEngException
- cannot process answerjava.io.IOException
- cannot connect to serverpublic 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 com.gravityrd.receng.web.webshop.jsondto.GravityUser getUserByUserId(java.lang.String userId) throws com.gravityrd.receng.web.webshop.jsondto.GravityRecEngException, java.io.IOException
userId
- GravityUser.userId
java.io.IOException
- if cannot connectcom.gravityrd.receng.web.webshop.jsondto.GravityRecEngException
- if cannot process the answer filespublic com.gravityrd.receng.web.webshop.jsondto.GravityUser getUserByCookieId(java.lang.String cookieId) throws com.gravityrd.receng.web.webshop.jsondto.GravityRecEngException, java.io.IOException
cookieId
- GravityEvent.cookieId
java.io.IOException
- if cannot connectcom.gravityrd.receng.web.webshop.jsondto.GravityRecEngException
- if cannot process the answer filespublic com.gravityrd.receng.web.webshop.jsondto.GravityEvent[] getEventsByUserId(java.lang.String userId, int limit) throws com.gravityrd.receng.web.webshop.jsondto.GravityRecEngException, java.io.IOException
userId
- GravityEvent.userId
limit
- upper limit for returned events. If 0 or negative a default limit will be usedjava.io.IOException
- if cannot connectcom.gravityrd.receng.web.webshop.jsondto.GravityRecEngException
- if cannot process the answer filespublic com.gravityrd.receng.web.webshop.jsondto.GravityEvent[] getEventsByCookieId(java.lang.String cookieId, int limit) throws com.gravityrd.receng.web.webshop.jsondto.GravityRecEngException, java.io.IOException
cookieId
- GravityEvent.cookieId
limit
- upper limit for returned events. If 0 or negative a default limit will be usedjava.io.IOException
- if cannot connectcom.gravityrd.receng.web.webshop.jsondto.GravityRecEngException
- if cannot process the answer filespublic void optOutUser(java.lang.String userId) throws com.gravityrd.receng.web.webshop.jsondto.GravityRecEngException, java.io.IOException
userId
- GravityEvent.userId
java.io.IOException
- if cannot connectcom.gravityrd.receng.web.webshop.jsondto.GravityRecEngException
- if the userId is invalidpublic void optOutCookie(java.lang.String cookieId) throws com.gravityrd.receng.web.webshop.jsondto.GravityRecEngException, java.io.IOException
cookieId
- GravityEvent.cookieId
java.io.IOException
- if cannot connectcom.gravityrd.receng.web.webshop.jsondto.GravityRecEngException
- if the cookieId is invalidpublic 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