Skip to main content

Reference

Beyable Singleton

Singleton class containing the communication logic between the SDK and the client app.

The class is instantiated at app startup with the API key provided by BEYABLE and the method Beyable.initInstance(Context context, String apiKey).

note

The Context provided at initialization is an ApplicationContext retrieved with getApplicationContext() from an Activity

For all subsequent calls, simply retrieve the instance with Beyable.getSharedInstance().

BYPage

BYAttributes

Superclass to represent attributes to be sent to the API.

Abstract class with toJSONObject() method to be overloaded. The method is called to set the data to what the API expects.

Child Classes:


BYHomeAttributes

Attributes for a page of type BYPage.BYPageType.HOME

public class BYHomeAttributes extends BYAttributes

The class BYHomeAttributes extends BYAttributes

public BYHomeAttributes()
public BYHomeAttributes( @NonNull String[] tags)
  • Parameters:
    • tags — the tags. It is NonNull
  • Returns: public
public JSONObject toJSONObject() throws JSONException

Converts object To JSON

  • Returns: JSONObject
  • Exceptions: JSONException
public JSONArray getTags()

Gets the tags

  • Returns: the tags
public void setTags(@NonNull String[] tags)

Sets the tags

  • Parameters: tags — the tags. It is NonNull

BYCategoryAttributes

Attributes for a page of type BYPage.BYPageType.CATEGORY

public class BYCategoryAttributes extends BYAttributes

The class BYCategoryAttributes extends BYAttributes

public BYCategoryAttributes()
public BYCategoryAttributes( @NonNull String id, @NonNull String name, @NonNull String[] tags)
  • Parameters:
    • id — the category ID. It is NonNull
    • name — the category name. It is NonNull
    • tags — the tags. It is NonNull
  • Returns: public
public JSONObject toJSONObject() throws JSONException

Converts object To JSON

  • Returns: JSONObject
  • Exceptions: JSONException
public String getId()

Gets the category ID

  • Returns: the id
public void setId(@NonNull String id)

Sets the category ID

  • Parameters: id — the id. It is NonNull
public String getName()

Gets the category name

  • Returns: the category name
public void setName(@NonNull String name)

Sets the category name

  • Parameters: name — the category name. It is NonNull
public JSONArray getTags()

Gets the tags

  • Returns: the tags
public void setTags(@NonNull String[] tags)

Sets the tags

  • Parameters: tags — the tags. It is NonNull

BYProductAttributes

Attributes for a page of type BYPage.BYPageType.PRODUCT

public class BYProductAttributes extends BYAttributes

The class BYProductAttributes extends BYAttributes

public BYProductAttributes()
public BYProductAttributes( @NonNull String reference, @NonNull String name, @NonNull String url, double priceBeforeDiscount, double sellingPrice, @NonNull String thumbnailUrl, double stock, @NonNull String[] tags)
  • Parameters:
    • reference — the reference. It is NonNull
    • name — the name. It is NonNull
    • url — the url. It is NonNull
    • priceBeforeDiscount — the price before discount.
    • sellingPrice — the selling price.
    • thumbnailUrl — the thumbnail url. It is NonNull
    • stock — the stock.
    • tags — the tags. It is NonNull
  • Returns: public
public JSONObject toJSONObject() throws JSONException

Converts object To JSON

  • Returns: JSONObject
  • Exceptions: JSONException
public String getReference()

Gets the product reference (ID)

  • Returns: the reference
public void setReference(@NonNull String reference)

Sets the product reference (ID)

  • Parameters: reference — the reference. It is NonNull
public String getName()

Gets the name

  • Returns: the name
public void setName(@NonNull String name)

Sets the name

  • Parameters: name — the name. It is NonNull
public String getUrl()

Gets the url

  • Returns: the url
public void setUrl(@NonNull String url)

Sets the url

  • Parameters: url — the url. It is NonNull
public double getPriceBeforeDiscount()

Gets the price before discount

  • Returns: the price before discount
public void setPriceBeforeDiscount(double priceBeforeDiscount)

Sets the price before discount

  • Parameters: priceBeforeDiscount — the price before discount.
public double getSellingPrice()

Gets the selling price

  • Returns: the selling price
public void setSellingPrice(double sellingPrice)

Sets the selling price

  • Parameters: sellingPrice — the selling price.
public String getThumbnailUrl()

Gets the thumbnail url

  • Returns: the thumbnail url
public void setThumbnailUrl(@NonNull String thumbnailUrl)

Sets the thumbnail url

  • Parameters: thumbnailUrl — the thumbnail url. It is NonNull
public double getStock()

Gets the stock

  • Returns: the stock
public void setStock(double stock)

Sets the stock

  • Parameters: stock — the stock.
public JSONArray getTags()

Gets the tags

  • Returns: the tags
public void setTags(@NonNull String[] tags)

Sets the tags

  • Parameters: tags — the tags. It is NonNull

BYTransactionAttributes

Attributes for a page of type BYPage.BYPageType.TRANSACTION

public class BYTransactionAttributes extends BYAttributes

The class BYTransactionAttributes extends BYAttributes

public BYTransactionAttributes()
public BYTransactionAttributes( @NonNull String[] tags)
  • Parameters:
    • tags — the tags. It is NonNull
  • Returns: public
public JSONObject toJSONObject() throws JSONException

Converts object To JSON

  • Returns: JSONObject
  • Exceptions: JSONException
public JSONArray getTags()

Gets the tags

  • Returns: the tags
public void setTags(@NonNull String[] tags)

Sets the tags

  • Parameters: tags — the tags. It is NonNull

BYCartAttributes

Attributes for a page of type BYPage.BYPageType.CART

public class BYCartAttributes extends BYAttributes

The class BYCartAttributes extends BYAttributes

public BYCartAttributes()
public BYCartAttributes( @NonNull String[] tags)
  • Parameters:
    • tags — the tags. It is NonNull
  • Returns: public
public JSONObject toJSONObject() throws JSONException

Converts object To JSON

  • Returns: JSONObject
  • Exceptions: JSONException
public JSONArray getTags()

Gets the tags

  • Returns: the tags
public void setTags(@NonNull String[] tags)

Sets the tags

  • Parameters: tags — the tags. It is NonNull

BYGenericAttributes

Attributes for a page of type BYPage.BYPageType.GENERAL

public class BYGenericAttributes extends BYAttributes

The class BYGenericAttributes extends BYAttributes

public BYGenericAttributes()

BY generic attributes

  • Returns: public
public JSONObject toJSONObject() throws JSONException

Converts object To JSON

  • Returns: JSONObject
  • Exceptions: JSONException
public String getId()

Gets the identifier

  • Returns: the identifier
public void setId(@NonNull String id)

Sets the identifier

  • Parameters: id — the id. It is NonNull
public String getCustomValue1()

Gets the custom value1

  • Returns: the custom value1
public void setCustomValue1(@NonNull String customValue1)

Sets the custom value1

  • Parameters: customValue1 — the custom value1. It is NonNull
public String getCustomValue2()

Gets the custom value2

  • Returns: the custom value2
public void setCustomValue2(@NonNull String customValue2)

Sets the custom value2

  • Parameters: customValue2 — the custom value2. It is NonNull
public String getCustomValue3()

Gets the custom value3

  • Returns: the custom value3
public void setCustomValue3(@NonNull String customValue3)

Sets the custom value3

  • Parameters: customValue3 — the custom value3. It is NonNull
public String getCustomValue4()

Gets the custom value4

  • Returns: the custom value4
public void setCustomValue4(@NonNull String customValue4)

Sets the custom value4

  • Parameters: customValue4 — the custom value4. It is NonNull
public String getCustomValue5()

Gets the custom value5

  • Returns: the custom value5
public void setCustomValue5(@NonNull String customValue5)

Sets the custom value5

  • Parameters: customValue5 — the custom value5. It is NonNull
public double getStock()

Gets the stock

  • Returns: the stock
public void setStock(double stock)

Sets the stock

  • Parameters: stock — the stock.
public JSONArray getTags()

Gets the tags

  • Returns: the tags
public void setTags(@NonNull String[] tags)

Sets the tags

  • Parameters: tags — the tags. It is NonNull

BYCampaign

Object to represent a BEYABLE campaign. The object is built using JSON data from the server.

Display type (DisplayType)

- DisplayType.MODAL: Modal popup display on screen
- DisplayType.STICKY_BANNER: Display of a sticky banner on the top of the screen (below the AppBar)
- DisplayType.STICKY_BOTTOM: Display of a sticky banner at the bottom of the screen
- DisplayType.IN_PAGE: Display the campaign at a referenced location
- DisplayType.HEADER_BANNER: Display of a dynamic header banner

CampaignView

Superclass for representing a campaign view.

It is responsible for parsing the HTML, CSS and Javascript content of the campaign with the method initWebView(WebView webview).

OverlayView

Subclass of CampaignView. Displays campaigns of the Modal type - BYCampaign.DisplayType.MODAL.

No conditions are required to display this view, because it uses an AlertDialog from the Android framework.

StickyHeaderView

Subclass of CampaignView. Displays campaigns of the Sticky Banner type - BYCampaign.DisplayType.STICKY_BANNER.

No special requirements for display.

note

The banner will always be placed below a Toolbar if one exists.

StickyFooterView

Subclass of CampaignView. Displays Sticky Bottom camapigns - BYCamapign.DisplayType.STICKY_BOTTOM.

InPageCampaignView

Subclass of CamapignView. Displays camapigns of the In Page type - BYCampaign.DisplayType.IN_PAGE.

For placement to take place correctly, the XML layout's Views must be correctly identified with the android:id="+@id/layout_id" tag.

The parent View of the selected view must be an instance of a ViewGroup (LinearLayout, RelativeLayout, etc.) to enable positioning rules.

CampaignDisplayer

Object responsible for displaying campaigns. It manages the logic and conditions for launching the display of a given campaign.