public class Ranker
extends com.jetlore.sdk.common.JetloreCommon
Ranker needs permission to access the Internet. Add the following to AndroidManifest.xml (inside <manifest>
element):
<uses-permission android:name="android.permission.INTERNET"/>
To initialize ActionTracker you need to provide a Client Hash and Jetlore API URL in AndroidManifest.xml:
<string name="jetlore_api_url">https://api.jetlore.com</string>
to strings.xml<meta-data android:name="com.jetlore.sdk.API_URL" android:value="@string/jetlore_api_url"/>
to AndroidManifest.xml (inside <application>
element)<string name="jetlore_client_hash">YOUR_JETLORE_CLIENT_HASH</string>
to strings.xml<meta-data android:name="com.jetlore.sdk.ClientHash" android:value="@string/jetlore_client_hash"/>
to AndroidManifest.xml (inside <application>
element)configure(String, String, String)
configure(userId, apiUrl, accessToken, String clientHash)
You can create an ActionTracker instance in your Application onCreate method like this:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
actionTracker = new ActionTracker(this);
}
Modifier and Type | Field and Description |
---|---|
static RankContext |
EMPTY_CONTEXT
Empty ranking context
|
Constructor and Description |
---|
Ranker(android.content.Context context)
Creates a new Ranker
|
Modifier and Type | Method and Description |
---|---|
void |
configure(java.lang.String userId,
java.lang.String apiUrl,
java.lang.String clientHash)
Re-Initialize Ranker with userId, apiUrl and clientHash
Please use
JetloreCommon.configure(String) to change or initialize userId |
void |
getLayout(java.lang.String layoutName,
ActionContext context,
com.jetlore.sdk.ranking.callback.GetLayoutCallback callback)
An asynchronous method to obtain
Layout . |
void |
getProducts(java.lang.Integer tileId,
int limit,
RankContext context,
com.jetlore.sdk.ranking.callback.GetProductsCallback callback)
An asynchronous method to obtain ranked products for current user from Jetlore API
|
void |
getProducts(java.lang.Integer tileId,
java.lang.String filter,
int limit,
RankContext context,
com.jetlore.sdk.ranking.callback.GetProductsCallback callback)
An asynchronous method to obtain ranked products for current user from Jetlore API
|
void |
getProducts(int limit,
RankContext context,
com.jetlore.sdk.ranking.callback.GetProductsCallback callback)
An asynchronous method to obtain ranked products for current user from Jetlore API
|
void |
getProducts(java.lang.String filter,
int limit,
RankContext context,
com.jetlore.sdk.ranking.callback.GetProductsCallback callback)
An asynchronous method to obtain ranked products for current user from Jetlore API
|
void |
getPromos(java.lang.String collection,
java.lang.String tile,
int limit,
ActionContext context,
com.jetlore.sdk.ranking.callback.GetPromotionsCallback callback)
An asynchronous method to obtain personalized promotions for current user from Jetlore API.
|
protected void |
readAdditionalParameters(android.os.Bundle bundle) |
void |
sortProductsByRelevance(SortProductsContext context,
com.jetlore.sdk.ranking.callback.SortProductsCallback callback)
An asynchronous method to obtain products sorted by relevance from Jetlore API
|
public static final RankContext EMPTY_CONTEXT
public Ranker(android.content.Context context)
Uses provided Context
to get Jetlore API access key
from AndroidManifest.xml and to get SharedPreferences
to persist cookies
context
- ranking contextprotected void readAdditionalParameters(android.os.Bundle bundle)
readAdditionalParameters
in class com.jetlore.sdk.common.JetloreCommon
public void configure(java.lang.String userId, java.lang.String apiUrl, java.lang.String clientHash)
JetloreCommon.configure(String)
to change or initialize userId
Use JetloreCommon.NO_USER
as userId if user id is unknown at the moment.
Make sure to call configure(java.lang.String, java.lang.String, java.lang.String)
again once user id is known.
userId
- tracking user idapiUrl
- Jetlore API endpoint URLclientHash
- client hashcom.jetlore.sdk.common.InvalidUseException
- if userId is null or empty
if apiUrl is null or empty
if clientHash is null or emptypublic void getProducts(java.lang.Integer tileId, java.lang.String filter, int limit, RankContext context, com.jetlore.sdk.ranking.callback.GetProductsCallback callback)
This method makes an asynchronous HTTP call to Jetlore API, does NOT block and is safe to use from the UI thread
tileId
- identification of Tile (product image representation)filter
- name of filter that will be used in ranking processlimit
- number of products in responsecontext
- RankContext
action context objectcallback
- GetProductsCallback
callback. Please be aware that callback will be triggered in different threadcom.jetlore.sdk.common.InvalidUseException
- if name of custom parameter ActionContext.addCustomParameter(String, String)
intersects with internally used
if limit is 0 or negative
if callback is nullpublic void getProducts(java.lang.String filter, int limit, RankContext context, com.jetlore.sdk.ranking.callback.GetProductsCallback callback)
This method makes an asynchronous HTTP call to Jetlore API, does NOT block and is safe to use from the UI thread
filter
- name of filter that will be used in ranking processlimit
- number of products in responsecontext
- RankContext
action context objectcallback
- GetProductsCallback
callback. Please be aware that callback will be triggered in different threadcom.jetlore.sdk.common.InvalidUseException
- if name of custom parameter ActionContext.addCustomParameter(String, String)
intersects with internally used
if limit is 0 or negative
if callback is nullpublic void getProducts(java.lang.Integer tileId, int limit, RankContext context, com.jetlore.sdk.ranking.callback.GetProductsCallback callback)
This method makes an asynchronous HTTP call to Jetlore API, does NOT block and is safe to use from the UI thread
tileId
- identification of Tilelimit
- number of products in responsecontext
- RankContext
action context objectcallback
- GetProductsCallback
callback. Please be aware that callback will be triggered in different threadcom.jetlore.sdk.common.InvalidUseException
- if name of custom parameter ActionContext.addCustomParameter(String, String)
intersects with internally used
if limit is 0 or negative
if callback is nullpublic void getProducts(int limit, RankContext context, com.jetlore.sdk.ranking.callback.GetProductsCallback callback)
This method makes an asynchronous HTTP call to Jetlore API, does NOT block and is safe to use from the UI thread
limit
- number of products in responsecontext
- RankContext
action context objectcallback
- GetProductsCallback
callback. Please be aware that callback will be triggered in different threadcom.jetlore.sdk.common.InvalidUseException
- if name of custom parameter ActionContext.addCustomParameter(String, String)
intersects with internally used
if limit is 0 or negative
if callback is nullpublic void sortProductsByRelevance(SortProductsContext context, com.jetlore.sdk.ranking.callback.SortProductsCallback callback)
This method makes an asynchronous HTTP call to Jetlore API, does NOT block and is safe to use from the UI thread
context
- SortProductsContext
action context objectcallback
- SortProductsCallback
callback. Please be aware that callback will be triggered in different threadcom.jetlore.sdk.common.InvalidUseException
- if callback is null
if SortProductsContext.filter
or SortProductsContext.productIds
both are nulls
if SortProductsContext.Pagination
itemsPerPage or page is 0 or negative
if SortProductsContext.Pagination.itemsPerPage
itemsPerPage is greater then SortProductsContext.Pagination.MAX_ITEMS_PER_PAGE
public void getLayout(java.lang.String layoutName, ActionContext context, com.jetlore.sdk.ranking.callback.GetLayoutCallback callback)
Layout
. Layout is combination of personalized products and promotions for current user from Jetlore API.layoutName
- name of layout (from Jetlore Dashboard)context
- ActionContext
action context objectcallback
- callback. Please be aware that callback will be triggered in different threadpublic void getPromos(java.lang.String collection, java.lang.String tile, int limit, ActionContext context, com.jetlore.sdk.ranking.callback.GetPromotionsCallback callback)
collection
- collection identifiertile
- tile identifierlimit
- limit number of promotions in responsecontext
- ActionContext
action context objectcallback
- callback. Please be aware that callback will be triggered in different thread