public override void LogCommerceEvent(CommerceEvent commerceEvent) { var bindingCommerceEvent = new iOSBinding.MPCommerceEvent(); if (commerceEvent.TransactionAttributes != null) { bindingCommerceEvent.TransactionAttributes = Utils.ConvertToMpTransactionAttributes(commerceEvent.TransactionAttributes); } bindingCommerceEvent.ScreenName = commerceEvent.ScreenName; bindingCommerceEvent.Currency = commerceEvent.Currency; bindingCommerceEvent.SetCustomAttributes(ConvertToNSDictionary <NSString, NSString>(commerceEvent.CustomAttributes)); bindingCommerceEvent.CheckoutOptions = commerceEvent.CheckoutOptions; if (commerceEvent.Products != null) { bindingCommerceEvent.Action = ConvertToMpProductAction(commerceEvent.ProductAction); foreach (var product in commerceEvent.Products) { bindingCommerceEvent.AddProduct(Utils.ConvertToMpProduct(product)); } } if (commerceEvent.CheckoutStep != null) { bindingCommerceEvent.CheckoutStep = commerceEvent.CheckoutStep.Value; } if (commerceEvent.NonInteractive.HasValue) { bindingCommerceEvent.NonInteractive = commerceEvent.NonInteractive.Value; } if (commerceEvent.Promotions != null) { bindingCommerceEvent.PromotionContainer = new MPPromotionContainer(ConvertToMpPromotionAction(commerceEvent.PromotionAction), null); foreach (var promotion in commerceEvent.Promotions) { bindingCommerceEvent.PromotionContainer.AddPromotion(ConvertToMpPromotion(promotion)); } } if (commerceEvent.Impressions != null) { foreach (var impression in commerceEvent.Impressions) { foreach (var product in impression.Products) { bindingCommerceEvent.AddImpression(Utils.ConvertToMpProduct(product), impression.ImpressionListName); } } } iOSBinding.MParticle.SharedInstance.LogCommerceEvent(bindingCommerceEvent); }
/// <summary> /// Logs the commerce event. /// </summary> /// <param name="commerceEvent">Commerce event.</param> public abstract void LogCommerceEvent(CommerceEvent commerceEvent);
public override void LogCommerceEvent(CommerceEvent commerceEvent) { Android.CommerceBinding.CommerceEvent.Builder bindingCommerceEventBuilder = null; if (commerceEvent.ProductAction > 0 && commerceEvent.Products != null && commerceEvent.Products.Length > 0) { bindingCommerceEventBuilder = new Android.CommerceBinding.CommerceEvent.Builder(Utils.ConvertToMpProductAction(commerceEvent.ProductAction), Utils.ConvertToMpProduct(commerceEvent.Products[0])); var temp = new List <Product>(commerceEvent.Products); temp.RemoveAt(0); commerceEvent.Products = temp.ToArray(); } else if (commerceEvent.Promotions != null && commerceEvent.Promotions.Length > 0) { bindingCommerceEventBuilder = new Android.CommerceBinding.CommerceEvent.Builder(Utils.ConvertToMpPromotionAction(commerceEvent.PromotionAction), Utils.ConvertToMpPromotion(commerceEvent.Promotions[0])); var temp = new List <Promotion>(commerceEvent.Promotions); temp.RemoveAt(0); commerceEvent.Promotions = temp.ToArray(); } else { bindingCommerceEventBuilder = new Android.CommerceBinding.CommerceEvent.Builder(Utils.ConvertToMpImpression(commerceEvent.Impressions[0])); var temp = new List <Impression>(commerceEvent.Impressions); temp.RemoveAt(0); commerceEvent.Impressions = temp.ToArray(); } if (bindingCommerceEventBuilder == null) { return; } if (commerceEvent.TransactionAttributes != null) { bindingCommerceEventBuilder.TransactionAttributes(Utils.ConvertToMpTransactionAttributes(commerceEvent.TransactionAttributes)); } bindingCommerceEventBuilder.Screen(commerceEvent.ScreenName); bindingCommerceEventBuilder.Currency(commerceEvent.Currency); bindingCommerceEventBuilder.CustomAttributes(commerceEvent.CustomAttributes); bindingCommerceEventBuilder.CheckoutOptions(commerceEvent.CheckoutOptions); if (commerceEvent.Products != null) { foreach (var product in commerceEvent.Products) { bindingCommerceEventBuilder.AddProduct(Utils.ConvertToMpProduct(product)); } } if (commerceEvent.CheckoutStep != null) { bindingCommerceEventBuilder.CheckoutStep(new Java.Lang.Integer(commerceEvent.CheckoutStep.Value)); } if (commerceEvent.NonInteractive.HasValue) { bindingCommerceEventBuilder.NonInteraction(commerceEvent.NonInteractive.Value); } if (commerceEvent.Promotions != null) { foreach (var promotion in commerceEvent.Promotions) { bindingCommerceEventBuilder.AddPromotion(Utils.ConvertToMpPromotion(promotion)); } } if (commerceEvent.Impressions != null) { foreach (var impression in commerceEvent.Impressions) { bindingCommerceEventBuilder.AddImpression(Utils.ConvertToMpImpression(impression)); } } AndroidBinding.MParticle.Instance.LogEvent(bindingCommerceEventBuilder.Build()); }