How to use
After installation, read the following to familiarize yourself with the framework.
Preferabli is the primary class you will utilize to access the Preferabli Data SDK.
Grab the main instance by calling Preferabli.main() to get started. This will unlock all of Preferabli's functionalities. For example:
Preferabli.main().logout()The Preferabli class also holds onto some important variables for you, including PRIMARY_INVENTORY_ID, CHANNEL_ID, and INTEGRATION_ID.
By default, when the SDK is initialized, an anonymous session is created. This anonymous session allows immediate access to any of the SDK's unauthenticated actions.
Unauthenticated ActionsThese functions do not return personalized results that are based on a customer's profile.
You do not need to authenticate an Object_Customer to use the SDK. However, once a customer is authenticated, you are able to unlock several user-centric functions.
To authenticate your customers, verify their credentials then pass us their identifier (usually email or phone) and the verification hash provided by your API:
Preferabli.main().loginCustomer("email/phone", "verification_from_your_api", null) Once a user is authenticated, you can immediately start using any of our authenticated actions. These functions return personalized results for your customer.
Customer data persists across app sessions.Please note that once a user has been authenticated, that user's state persists across sessions until you logout.
All of our functions are thread safe and return results through an interface called API_ResultHandler. If the call was a success, the interface's onSuccess callback is initiated and can return different things depending on the call. If the call was a failure, the interface's onFailure callback is initiated instead. One of the two will always be executed, but never both. Here is an example of how to complete a standard product search using the result handler interface:
Preferabli.main().searchProducts("wine", null, null, null, null, new API_ResultHandler<ArrayList<Object_Product>>() {
@Override
public void onSuccess(ArrayList<Object_Product> data) {
// Do what you like with the products returned.
}
@Override
public void onFailure(API_PreferabliException e) {
// Call failed.
}
});Updated about 1 year ago
