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 instance 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 a 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(merchant_customer_identification: "email/phone", merchant_customer_verification: "verification_from_your_api") 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 call Preferabli.main.logout(onCompletion:onFailure:).
All of our functions are thread safe and return results through a completion block. The type of data returned depends on the call made. If the call fails, the failure block will be initiated instead of the completion block. One of the two will always be executed, but never both. Here is an example of how to complete a standard product search using an onCompletion block and an onFailure block:
Preferabli.main.searchProducts(query: "wine") { products in
// Do what you want with the products returned.
} onFailure: { error in
// Call failed.
}Updated about 1 year ago
