public class

PlacementContext

extends Object
implements Parcelable
java.lang.Object
   ↳ com.usebutton.sdk.PlacementContext

Class Overview

Convenience class on top of JSONObject. Mutable key-value pairs with promotion relevant information. See ButtonDropin for a full example of a location aware context. Context parameters provided to promotions.

Summary

[Expand]
Inherited Constants
From interface android.os.Parcelable
Public Constructors
PlacementContext()
Public Methods
int describeContents()
static PlacementContext forEndLocation(String locationName, double latitude, double longitude)
Creates a new PlacementContext object with a location, this can be used for transportation promotions to indicate the drop off location.
static PlacementContext forStartLocation(String locationName, double latitude, double longitude)
Creates a new PlacementContext object with a location, this can be used for transportation promotions to indicate the pick up location.
synchronized PlacementContext putPrivate(String name, String value)
Reserved for future proofing the SDK so new top level keys can be used by partners without SDK changes.
synchronized PlacementContext with(String name, String value)
Add a String value to the context for key name, This will be added under the vendor top-level key.
synchronized PlacementContext with(String name, JSONObject value)
Add an arbitrary org.json.JSONObject value to the context for key name.
synchronized PlacementContext withEndLocation(String name, double latitude, double longitude)
PlacementContext withEndLocation(String name, Location location)
Adds a named end location to this promotion context.
synchronized PlacementContext withEndTime(Date endTime)
Add a start time to the context, for example the end of a trip.
PlacementContext withStartLocation(String name, Location location)
Adds a start location to context.
synchronized PlacementContext withStartLocation(String name, double latitude, double longitude)
Adds a start location to context.
synchronized PlacementContext withStartTime(Date startTime)
Add a start time to the context, for example the start of a trip.
synchronized PlacementContext withSubjectLocation(double latitude, double longitude)
Add a location representing the object the user is looking at, for a restaurant listing, it would be the location of the restaurant.
PlacementContext withUserLocation(double latitude, double longitude)
Add the user's location to the context, for example for interesting venues around the user.
void writeToParcel(Parcel dest, int flags)
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Public Constructors

public PlacementContext ()

Public Methods

public int describeContents ()

public static PlacementContext forEndLocation (String locationName, double latitude, double longitude)

Creates a new PlacementContext object with a location, this can be used for transportation promotions to indicate the drop off location. Equivalent to new PlacementContext().withEndLocation(...);.

Parameters
locationName for example "Pizza Restaurant"
Returns
  • the new context instance, for nested calls.

public static PlacementContext forStartLocation (String locationName, double latitude, double longitude)

Creates a new PlacementContext object with a location, this can be used for transportation promotions to indicate the pick up location. Equivalent to new PlacementContext().withStartLocation(...);.

Parameters
locationName for example "Work"
Returns
  • the new context instance, for nested calls.

public synchronized PlacementContext putPrivate (String name, String value)

Reserved for future proofing the SDK so new top level keys can be used by partners without SDK changes. You are probably looking for #putVendorValue(String, Object).

Returns
  • same object, for nesting.

public synchronized PlacementContext with (String name, String value)

Add a String value to the context for key name, This will be added under the vendor top-level key. {"vendor": {:name: :value}

public synchronized PlacementContext with (String name, JSONObject value)

Add an arbitrary org.json.JSONObject value to the context for key name. This will be added under the vendor top-level key. {"vendor": {:name: :value}

public synchronized PlacementContext withEndLocation (String name, double latitude, double longitude)

public PlacementContext withEndLocation (String name, Location location)

Adds a named end location to this promotion context.

Returns
  • same object, for nested calls.

public synchronized PlacementContext withEndTime (Date endTime)

Add a start time to the context, for example the end of a trip.

Returns
  • same object, for nested calls.

public PlacementContext withStartLocation (String name, Location location)

Adds a start location to context.

Parameters
name of start location, for example "Office"
Returns
  • same object, for nested calls.

public synchronized PlacementContext withStartLocation (String name, double latitude, double longitude)

Adds a start location to context.

Returns
  • same object, for nested calls.

public synchronized PlacementContext withStartTime (Date startTime)

Add a start time to the context, for example the start of a trip.

Returns
  • same object, for nested calls.

public synchronized PlacementContext withSubjectLocation (double latitude, double longitude)

Add a location representing the object the user is looking at, for a restaurant listing, it would be the location of the restaurant. For a travel app, it would be the location of the destination.

Returns
  • same object, for nested calls.

public PlacementContext withUserLocation (double latitude, double longitude)

Add the user's location to the context, for example for interesting venues around the user.

Returns
  • same object, for nested calls

public void writeToParcel (Parcel dest, int flags)