com.amazonaws.mobileconnectors.amazonmobileanalytics.monetization
Class CustomMonetizationEventBuilder

java.lang.Object
  extended by com.amazonaws.mobileconnectors.amazonmobileanalytics.monetization.MonetizationEventBuilder
      extended by com.amazonaws.mobileconnectors.amazonmobileanalytics.monetization.CustomMonetizationEventBuilder

public class CustomMonetizationEventBuilder
extends MonetizationEventBuilder

Builds monetization events representing a purchase from an IAP framework not defined by a specific builder. The store attribute must be set by the user. This Builder will return null if the Store, ProductId, Quantity, and either the Formatted Localized Price or Price and Currency are not set.

The example below demonstrates how to create a monetization event after you receive a purchase confirmation from the IAP framework you are using. You are responsible for storing and making sure that the bare minimum attributes required to build a Custom Purchase Event are available for use at this time. Note that the builder will maintain the values of its internal variables between builds.

Example:
    // get the event client from your MobileAnalyticsManager instance
    EventClient eventClient = mobileAnalyticsManager.getEventClient();
    
    // create a builder that can record purchase events for the IAP Framework you are using
    CustomMonetizationEventBuilder builder = CustomMonetizationEventBuilder.create(eventClient);
    
    // build the monetization event with at minimum the store, product id, quantity, and price information
    // The price information can be supplied in either of the following ways:
    // - The price as a double (i.e. 1.99) and the currency as a currency code (i.e. "USD"). This method is preferred as it provides more accuracy in the monetization reports
    // - The formatted localized price of the item as a string (i.e. "$1.99")
    // You may also build with any additional available attributes that the IAP Framework provides such as Transaction ID
    
    // Price and currency
    Event purchaseEvent = builder.withStore("Custom Store").withProductId("com.yourgame.sword").withItemPrice(1.99).withCurrency("USD").withQuantity(1).build();
    
    // Formatted Price
    purchaseEvent = builder.withStore("Custom Store").withProductId("com.yourgame.sword").withFormattedItemPrice("$1.99").withQuantity(1).build();
    
    // record the monetization event
    eventClient.recordEvent(purchaseEvent);
 


Method Summary
static CustomMonetizationEventBuilder create(EventClient eventClient)
          Create a CustomMonetizationEventBuilder with the specified Event client
 CustomMonetizationEventBuilder withCurrency(java.lang.String currency)
          Sets the currency of the item being purchased (Required if formatted localized price is not specified)
 CustomMonetizationEventBuilder withFormattedItemPrice(java.lang.String formattedItemPrice)
          Sets the formatted localized price of the item being purchased (Required if numerical price and currency are not specified)
 CustomMonetizationEventBuilder withItemPrice(double itemPrice)
          Sets the numerical price of the item being purchased (Required if formatted localized price is not specified)
 CustomMonetizationEventBuilder withProductId(java.lang.String productId)
          Sets the product identifier field of the item being purchased (Required)
 CustomMonetizationEventBuilder withQuantity(java.lang.Double quantity)
          Sets the quantity of the item being purchased (Required)
 CustomMonetizationEventBuilder withStore(java.lang.String store)
          Sets the store in which the transaction is taking place (Required)
 CustomMonetizationEventBuilder withTransactionId(java.lang.String transactionId)
          The transaction identifier of the purchase (Optional)
 
Methods inherited from class com.amazonaws.mobileconnectors.amazonmobileanalytics.monetization.MonetizationEventBuilder
build
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static CustomMonetizationEventBuilder create(EventClient eventClient)
Create a CustomMonetizationEventBuilder with the specified Event client

Parameters:
eventClient - The event client to use when creating monetization events
Returns:
a CustomMonetizationEventBuilder to build monetization events from a Non-Specific IAP Framework

withStore

public CustomMonetizationEventBuilder withStore(java.lang.String store)
Sets the store in which the transaction is taking place (Required)

Parameters:
store - The store in which the transaction is taking place
Returns:
this for chaining

withProductId

public CustomMonetizationEventBuilder withProductId(java.lang.String productId)
Sets the product identifier field of the item being purchased (Required)

Parameters:
productId - The product id representing the item being purchased
Returns:
this for chaining

withQuantity

public CustomMonetizationEventBuilder withQuantity(java.lang.Double quantity)
Sets the quantity of the item being purchased (Required)

Parameters:
quantity - The quantity of the item being purchased
Returns:
this for chaining

withFormattedItemPrice

public CustomMonetizationEventBuilder withFormattedItemPrice(java.lang.String formattedItemPrice)
Sets the formatted localized price of the item being purchased (Required if numerical price and currency are not specified)

Parameters:
formattedItemPrice - The formatted localized price of the item
Returns:
this for chaining

withItemPrice

public CustomMonetizationEventBuilder withItemPrice(double itemPrice)
Sets the numerical price of the item being purchased (Required if formatted localized price is not specified)

Parameters:
itemPrice - The numerical price of the item
Returns:
this for chaining

withCurrency

public CustomMonetizationEventBuilder withCurrency(java.lang.String currency)
Sets the currency of the item being purchased (Required if formatted localized price is not specified)

Parameters:
currency - The currency code of the currency used to purchase this item (i.e. "USD")
Returns:
this for chaining

withTransactionId

public CustomMonetizationEventBuilder withTransactionId(java.lang.String transactionId)
The transaction identifier of the purchase (Optional)

Parameters:
transactionId - The transaction id of the purchase
Returns:
this for chaining


Copyright © 2010 Amazon Web Services, Inc. All Rights Reserved.