com.amazonaws.mobileconnectors.amazonmobileanalytics.monetization
Class AmazonMonetizationEventBuilder

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

public class AmazonMonetizationEventBuilder
extends MonetizationEventBuilder

Builds monetization events representing an Amazon purchase. This Builder automatically sets the store attribute to "Amazon". This Builder will return null if the ProductId, Formatted Localized Price, or Quantity are not set.

Example:
    // get the event client from your MobileAnalyticsManager instance
    EventClient eventClient = mobileAnalyticsManager.getEventClient();
    
    // create a builder that can record purchase events for Amazon IAP
    AmazonMonetizationEventBuilder builder = AmazonMonetizationEventBuilder.create(eventClient);
    
    // build the monetization event with the product id, formatted item price, and quantity
    // product id and formatted item price are obtained from the Item object
    // Amazon IAP currently only supports a quantity of 1
    Event purchaseEvent = builder.withProductId(purchasedItem.getSku()).withFormattedItemPrice(purchasedItem.getPrice()).withQuantity(1).build();
    
    // record the monetization event
    eventClient.recordEvent(purchaseEvent);
 


Method Summary
static AmazonMonetizationEventBuilder create(EventClient eventClient)
          Create a AmazonMonetizationEventBuilder with the specified Event client
 AmazonMonetizationEventBuilder withFormattedItemPrice(java.lang.String formattedItemPrice)
          Sets the formatted localized price of the item being purchased (accessed from the getPrice() method of the Item class).
 AmazonMonetizationEventBuilder withProductId(java.lang.String productId)
          Sets the product identifier field of the item being purchased
 AmazonMonetizationEventBuilder withQuantity(java.lang.Double quantity)
          Sets the quantity of the item being purchased.
 
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 AmazonMonetizationEventBuilder create(EventClient eventClient)
Create a AmazonMonetizationEventBuilder with the specified Event client

Parameters:
eventClient - The event client to use when creating monetization events
Returns:
a AmazonMonetizationEventBuilder to build monetization events from the Amazon IAP API

withProductId

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

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

withFormattedItemPrice

public AmazonMonetizationEventBuilder withFormattedItemPrice(java.lang.String formattedItemPrice)
Sets the formatted localized price of the item being purchased (accessed from the getPrice() method of the Item class).

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

withQuantity

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

Parameters:
quantity - Currently, Amazon IAP only supports purchasing 1 item at a time.
Returns:
this for chaining


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