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)
static PlacementContext forEndLocation(String locationName, Location location)
Creates a new PlacementContext object with an end location, this can be used for transportation promotions to indicate the drop off location.
static PlacementContext forStartLocation(String locationName, Location location)
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.
String toString()
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.
PlacementContext withEndLocation(LatLngPair coordinate)
Add an end location to this context, this is useful for e.g.
PlacementContext withEndLocation(Location location)
Adds an end location to this promotion context.
PlacementContext withEndLocation(String locationName, LatLngPair coordinate)
Add an end location to this context, this is useful for e.g.
PlacementContext withEndLocation(String name, Location location)
Adds a named end location to this promotion context.
synchronized PlacementContext withEndTime(Date endTime)
PlacementContext withStartLocation(String name, Location location)
Adds a start location to context.
PlacementContext withStartLocation(String locationName, double latitude, double longitude)
Creates a context with a freeform combination of location name and latitude/longitude pair as start location for a transportation pickup.
PlacementContext withStartLocation(LatLngPair coordinate)
Creates a context with coordinate as start location for a transportation pickup.
synchronized PlacementContext withStartLocation(String locationName, LatLngPair coordinate)
Creates a context with a freeform combination of location name and latitude/longitude pair as start location for a transportation pickup.
synchronized PlacementContext withStartTime(Date startTime)
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)

Returns
  • the new context instance, for nested calls.

public static PlacementContext forEndLocation (String locationName, Location location)

Creates a new PlacementContext object with an end location, this can be used for transportation promotions to indicate the drop off location. Usually paired with a call to withStartLocation(String, android.location.Location). Equivalent to new PlacementContext().withEndLocation(...);.

Returns
  • the new context instance, for nested calls.

public static PlacementContext forStartLocation (String locationName, Location location)

Creates a new PlacementContext object with a location, this can be used for transportation promotions to indicate the pick up location. Usually paired with a call to withEndLocation(String, android.location.Location) Equivalent to new PlacementContext().withStartLocation(...);.

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 String toString ()

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 PlacementContext withEndLocation (LatLngPair coordinate)

Add an end location to this context, this is useful for e.g. getting transportation to location, same as new PlacementContext().withEndLocation(...);.

Parameters
coordinate LatLngPair object holding the latitude/longitude information.
Returns
  • same object, for nested calls.

public PlacementContext withEndLocation (Location location)

Adds an end location to this promotion context.

Returns
  • same object, for nested calls.

public PlacementContext withEndLocation (String locationName, LatLngPair coordinate)

Add an end location to this context, this is useful for e.g. getting transportation to location, same as new PlacementContext().withEndLocation(...);.

Parameters
coordinate LatLngPair object holding the latitude/longitude information.
Returns
  • same object, for nested calls.

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)

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 PlacementContext withStartLocation (String locationName, double latitude, double longitude)

Creates a context with a freeform combination of location name and latitude/longitude pair as start location for a transportation pickup.

Returns
  • same object, for nested calls.

public PlacementContext withStartLocation (LatLngPair coordinate)

Creates a context with coordinate as start location for a transportation pickup.

Returns
  • same object, for nested calls.

public synchronized PlacementContext withStartLocation (String locationName, LatLngPair coordinate)

Creates a context with a freeform combination of location name and latitude/longitude pair as start location for a transportation pickup.

Returns
  • same object, for nested calls.

public synchronized PlacementContext withStartTime (Date startTime)

public void writeToParcel (Parcel dest, int flags)