Ejemplo n.º 1
0
        /// <summary>
        /// Handles the <c>onMarketItemsRefreshFinished</c> event, which is fired when items associated with market are
        /// refreshed (prices, titles ...).
        /// </summary>
        /// <param name="message">Message that contains information about the process that is occurring.</param>
        public void onMarketItemsRefreshFinished(string message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onMarketItemsRefreshFinished: " + message);

            var eventJSON = new JSONObject(message);

            List <VirtualItem> virtualItems = new List <VirtualItem>();
            List <MarketItem>  marketItems  = new List <MarketItem>();

            foreach (var micJSON in eventJSON.list)
            {
                string productId          = micJSON[StoreJSONConsts.MARKETITEM_PRODUCT_ID].str;
                string marketPrice        = micJSON[StoreJSONConsts.MARKETITEM_MARKETPRICE].str;
                string marketTitle        = micJSON[StoreJSONConsts.MARKETITEM_MARKETTITLE].str;
                string marketDescription  = micJSON[StoreJSONConsts.MARKETITEM_MARKETDESC].str;
                string marketCurrencyCode = micJSON[StoreJSONConsts.MARKETITEM_MARKETCURRENCYCODE].str;
                long   marketPriceMicros  = System.Convert.ToInt64(micJSON[StoreJSONConsts.MARKETITEM_MARKETPRICEMICROS].n);
                try {
                    PurchasableVirtualItem pvi = StoreInfo.GetPurchasableItemWithProductId(productId);
                    MarketItem             mi  = ((PurchaseWithMarket)pvi.PurchaseType).MarketItem;
                    mi.MarketPriceAndCurrency = marketPrice;
                    mi.MarketTitle            = marketTitle;
                    mi.MarketDescription      = marketDescription;
                    mi.MarketCurrencyCode     = marketCurrencyCode;
                    mi.MarketPriceMicros      = marketPriceMicros;

                    marketItems.Add(mi);
                    virtualItems.Add(pvi);
                } catch (VirtualItemNotFoundException ex) {
                    SoomlaUtils.LogDebug(TAG, ex.Message);
                }
            }

            if (virtualItems.Count > 0)
            {
                // no need to save to DB since it's already saved in native
                // before this event is received
                StoreInfo.Save(virtualItems, false);
            }

            StoreEvents.OnMarketItemsRefreshFinished(marketItems);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Save this instance with changes that were made to it.
 /// The saving is done in the metadata in StoreInfo and being persisted to the local DB
 /// (if requested).
 /// </summary>
 /// <param name="saveToDB">Should the changes be persisted to local DB</param>
 public void Save(bool saveToDB = true)
 {
     StoreInfo.Save(this, saveToDB);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Save this instance with changes that were made to it.
 /// The saving is done in the metadata in StoreInfo and being persisted to the local DB.
 /// </summary>
 public void Save()
 {
     StoreInfo.Save(this);
 }