Package classes

Class Preferabli


  • public class Preferabli
    extends java.lang.Object
    This is the primary class you will utilize to access the Preferabli Data SDK.
    • Field Detail

      • PRIMARY_INVENTORY_ID

        public static long PRIMARY_INVENTORY_ID
        The primary inventory id of your integration.
      • CHANNEL_ID

        public static long CHANNEL_ID
        The channel id of your integration.
      • INTEGRATION_ID

        public static long INTEGRATION_ID
        The id of your integration.
    • Constructor Detail

      • Preferabli

        public Preferabli()
    • Method Detail

      • main

        public static Preferabli main()
        Get and use this instance to make Preferabli API calls.
        Returns:
        an instance of Preferabli
      • initialize

        public static void initialize​(android.app.Application application,
                                      java.lang.String client_interface,
                                      java.lang.Long integration_id)
        Call this in your Application onCreate with your supplied information. Contact us if you do not have your client_interface and/or integration_id.
        Parameters:
        application - pass an instance of your application context.
        client_interface - your unique identifier - provided by Preferabli.
        integration_id - your integration id - provided by Preferabli. You may have more than one integration for different segments of your business (depending on how your account is set up)
      • initialize

        public static void initialize​(android.app.Application application,
                                      java.lang.String client_interface,
                                      java.lang.Long integration_id,
                                      java.lang.Boolean logging_enabled)
        Call this in your Application onCreate with your supplied information. Contact us if you do not have your client_interface and/or integration_id.
        Parameters:
        application - pass an instance of your application context.
        client_interface - your unique identifier - provided by Preferabli.
        integration_id - your integration id - provided by Preferabli. You may have more than one integration for different segments of your business (depending on how your account is set up).
        logging_enabled - pass true for full logging. Defaults to false.
      • isPreferabliUserLoggedIn

        public static boolean isPreferabliUserLoggedIn()
        Will let you know if a user is logged in or not.
        Returns:
        bool.
      • isCustomerLoggedIn

        public static boolean isCustomerLoggedIn()
        Will let you know if a customer is logged in or not.
        Returns:
        bool.
      • loginPreferabliUser

        public void loginPreferabliUser​(java.lang.String email,
                                        java.lang.String password,
                                        API_ResultHandler<Object_PreferabliUser> handler)
        Login an existing Preferabli user. Most SDK installations will never use this.
        Parameters:
        email - user's email address.
        password - user's password.
        handler - returns Object_PreferabliUser if the call was successful. Returns API_PreferabliException if the call fails.
      • loginCustomer

        public void loginCustomer​(java.lang.String merchant_customer_identification,
                                  java.lang.String merchant_customer_verification,
                                  API_ResultHandler<Object_Customer> handler)
        Link an existing customer or create a new one if they are not in our system.
        Parameters:
        merchant_customer_identification - unique identifier for your customer. Usually an email address or a phone number.
        merchant_customer_verification - authentication key given to you by your API.
        handler - returns Object_Customer if the call was successful. Returns API_PreferabliException if the call fails.
      • logout

        public void logout​(API_ResultHandler<java.lang.Boolean> handler)
        Logout a customer.
        Parameters:
        handler - returns true if the call was successful. Returns API_PreferabliException if the call fails.
      • forgotPassword

        public void forgotPassword​(java.lang.String email,
                                   API_ResultHandler<java.lang.Boolean> handler)
        Resets the password of an existing Preferabli user. Most SDK installations will never use this.
        Parameters:
        email - user's email address.
        handler - returns true if the call was successful. Returns API_PreferabliException if the call fails.
      • labelRecognition

        public void labelRecognition​(java.io.File label_file,
                                     java.lang.Boolean include_merchant_links,
                                     API_ResultHandler<Object_LabelRecResults> handler)
        Performs label recognition on a supplied image. Returns any Object_Product matches.
        Parameters:
        label_file - label image you want to search for.
        include_merchant_links - pass true if you want the results to include an array of Object_MerchantProductLink embedded in Object_Variant. These connect Preferabli products to your own. Passing true requires additional resources and therefore will take longer. Defaults to true.
        handler - returns Object_LabelRecResults if the call was successful. Returns API_PreferabliException if the call fails.
      • getGuidedRecResults

        public void getGuidedRecResults​(long guided_rec_id,
                                        java.util.ArrayList<java.lang.Long> selected_choice_ids,
                                        java.lang.Integer price_min,
                                        java.lang.Integer price_max,
                                        java.lang.Long collection_id,
                                        java.lang.Boolean include_merchant_links,
                                        API_ResultHandler<java.util.ArrayList<Object_Product>> handler)
        Get Guided Rec results based on the selected Object_GuidedRec.Object_GuidedRecChoice.
        Parameters:
        guided_rec_id - id of the Guided Rec you wish to run.
        selected_choice_ids - an array of selected Object_GuidedRec.Object_GuidedRecChoice ids.
        price_min - pass if you want to lock results to a minimum price. Pass null to ignore.
        price_max - pass if you want to lock results to a maximum price. Pass null to ignore.
        collection_id - the id of a specific Object_Collection that you want to draw results from. Pass PRIMARY_INVENTORY_ID for results from your primary inventory. Pass null for results from anywhere.
        include_merchant_links - pass true if you want the results to include an array of Object_MerchantProductLink embedded in Object_Variant. These connect Preferabli products to your own. Passing true requires additional resources and therefore will take longer. Defaults to true.
        handler - returns an array of Object_Product if the call was successful. Returns API_PreferabliException if the call fails.
      • whereToBuy

        public void whereToBuy​(long product_id,
                               Other_FulfillSort fulfill_sort,
                               java.lang.Boolean append_nonconforming_results,
                               java.lang.Boolean lock_to_integration,
                               API_ResultHandler<Object_WhereToBuy> handler)
        Get help finding out where a Object_Product is in stock.
        Parameters:
        product_id - id of the starting Object_Product. Only pass a Preferabli product id. If necessary, call getPreferabliProductId(String, String, API_ResultHandler) to convert your product id into a Preferabli product id.
        fulfill_sort - pass Other_FulfillSort for sorting & filtering options. If sorting by distance, Object_Location MUST be present!
        append_nonconforming_results - pass true if you want results that DO NOT conform to all filtering & sorting parameters to be returned. Useful so that something is returned even if the user's filter parameters are too narrow. All results that do not conform contain nonconforming_result = true within. Defaults to true.
        lock_to_integration - pass true if you only want to draw results from your integration. Defaults to true.
        handler - returns Object_WhereToBuy if the call was successful. Returns API_PreferabliException if the call fails.
      • getProfile

        public void getProfile​(java.lang.Boolean force_refresh,
                               API_ResultHandler<Object_Profile> handler)
        Get the Preference Profile of the customer. Customer must be logged in to run this call.
        Parameters:
        force_refresh - pass true if you want to force a refresh from the API and wait for the results to return. Otherwise, the call will load locally if available and run a background refresh only if one has not been initiated in the past 5 minutes. Defaults to false.
        handler - returns Object_Profile if the call was successful. Returns API_PreferabliException if the call fails.
      • getRatedProducts

        public void getRatedProducts​(java.lang.Boolean force_refresh,
                                     java.lang.Boolean include_merchant_links,
                                     API_ResultHandler<java.util.ArrayList<Object_Product>> handler)
        Get rated products. Customer must be logged in to run this call.
        Parameters:
        force_refresh - pass true if you want to force a refresh from the API and wait for the results to return. Otherwise, the call will load locally if available and run a background refresh only if one has not been initiated in the past 5 minutes. Defaults to false.
        include_merchant_links - pass true if you want the results to include an array of Object_MerchantProductLink embedded in Object_Variant. These connect Preferabli products to your own. Passing true requires additional resources and therefore will take longer. Defaults to true.
        handler - returns an array of Object_Product if the call was successful. Returns API_PreferabliException if the call fails.
      • getWishlistedProducts

        public void getWishlistedProducts​(java.lang.Boolean force_refresh,
                                          java.lang.Boolean include_merchant_links,
                                          API_ResultHandler<java.util.ArrayList<Object_Product>> handler)
        Get wishlisted products. Customer / Preferabli user must be logged in to run this call.
        Parameters:
        force_refresh - pass true if you want to force a refresh from the API and wait for the results to return. Otherwise, the call will load locally if available and run a background refresh only if one has not been initiated in the past 5 minutes. Defaults to false.
        include_merchant_links - pass true if you want the results to include an array of Object_MerchantProductLink embedded in Object_Variant. These connect Preferabli products to your own. Passing true requires additional resources and therefore will take longer. Defaults to true.
        handler - returns an array of Object_Product if the call was successful. Returns API_PreferabliException if the call fails.
      • getPurchasedProducts

        public void getPurchasedProducts​(java.lang.Boolean force_refresh,
                                         java.lang.Boolean lock_to_integration,
                                         java.lang.Boolean include_merchant_links,
                                         API_ResultHandler<java.util.ArrayList<Object_Product>> handler)
        Get purchased products. Customer must be logged in to run this call.
        Parameters:
        force_refresh - pass true if you want to force a refresh from the API and wait for the results to return. Otherwise, the call will load locally if available and run a background refresh only if one has not been initiated in the past 5 minutes. Defaults to false.
        lock_to_integration - pass true if you only want to draw results from your integration. Defaults to true.
        include_merchant_links - pass true if you want the results to include an array of Object_MerchantProductLink embedded in Object_Variant. These connect Preferabli products to your own. Passing true requires additional resources and therefore will take longer. Defaults to true.
        handler - returns an array of Object_Product if the call was successful. Returns API_PreferabliException if the call fails.
      • getCustomer

        public void getCustomer​(java.lang.Boolean force_refresh,
                                API_ResultHandler<Object_Customer> handler)
        Get the current logged in Object_Customer.
        Parameters:
        force_refresh - pass true if you want to force a refresh from the API and wait for the results to return. Otherwise, the call will load locally if available and run a background refresh only if one has not been initiated in the past 5 minutes. Defaults to false.
        handler - returns Object_Customer if the call was successful. Returns API_PreferabliException if the call fails.
      • getPreferabliProductId

        public void getPreferabliProductId​(java.lang.String merchant_product_id,
                                           java.lang.String merchant_variant_id,
                                           API_ResultHandler<java.lang.Long> handler)
        Call this to convert your merchant product / variant id to the Preferabli product id for use with our functions.
        Parameters:
        merchant_product_id - the id of your product (as it appears in your system). Either this or merchant_variant_id is required.
        merchant_variant_id - the id of your product variant (as it appears in your system). Used only if you have a hierarchical database format for your products.
        handler - returns product id as a long if the call was successful. Returns API_PreferabliException if the call fails.
      • isLoggingEnabled

        public static boolean isLoggingEnabled()
        Is logging enabled for the SDK?
        Returns:
        true if logging is enabled.
      • getVersionCode

        public static int getVersionCode()
        Get the version code of the SDK.
        Returns:
        the version code as an int.