Exemplo n.º 1
0
    public static Hashtable ToHashtable(this YandexAppMetricaRevenue self)
    {
        var data = new Hashtable {
            { "Price", self.Price },
            { "Currency", self.Currency }
        };

        if (self.Quantity.HasValue)
        {
            data ["Quantity"] = self.Quantity.Value;
        }
        if (self.ProductID != null)
        {
            data["ProductID"] = self.ProductID;
        }
        if (self.Payload != null)
        {
            data["Payload"] = self.Payload;
        }
        if (self.Receipt.HasValue)
        {
            data["Receipt"] = self.Receipt.Value.ToHashtable();
        }
        return(data);
    }
Exemplo n.º 2
0
    public static AndroidJavaObject ToAndroidRevenue(this YandexAppMetricaRevenue self)
    {
        AndroidJavaObject androidJavaObject = null;

        using (AndroidJavaClass androidJavaClass = new AndroidJavaClass("com.yandex.metrica.Revenue"))
        {
            AndroidJavaObject androidJavaObject2 = androidJavaClass.CallStatic <AndroidJavaObject>("newBuilder", new object[2]
            {
                self.Price,
                self.Currency.ToAndroidCurrency()
            });
            androidJavaObject2.Call <AndroidJavaObject>("withQuantity", new object[1]
            {
                self.Quantity.ToAndroidInteger()
            });
            androidJavaObject2.Call <AndroidJavaObject>("withProductID", new object[1]
            {
                self.ProductID
            });
            androidJavaObject2.Call <AndroidJavaObject>("withPayload", new object[1]
            {
                self.Payload
            });
            androidJavaObject2.Call <AndroidJavaObject>("withReceipt", new object[1]
            {
                self.Receipt.ToAndroidReceipt()
            });
            return(androidJavaObject2.Call <AndroidJavaObject>("build", new object[0]));
        }
    }
Exemplo n.º 3
0
    public static AndroidJavaObject ToAndroidRevenue(this YandexAppMetricaRevenue self)
    {
        AndroidJavaObject revenue;

        using (AndroidJavaClass revenueClass = new AndroidJavaClass("com.yandex.metrica.Revenue"))
        {
            AndroidJavaObject builder;
            if (self.PriceDecimal.HasValue)
            {
                long priceMicros = decimal.ToInt64(self.PriceDecimal.Value * 1000000m);
                builder = revenueClass.CallStatic <AndroidJavaObject>("newBuilderWithMicros", priceMicros,
                                                                      self.Currency.ToAndroidCurrency());
            }
            else
            {
                builder = revenueClass.CallStatic <AndroidJavaObject>("newBuilder", self.Price,
                                                                      self.Currency.ToAndroidCurrency());
            }

            builder.Call <AndroidJavaObject>("withQuantity", self.Quantity.ToAndroidInteger());
            builder.Call <AndroidJavaObject>("withProductID", self.ProductID);
            builder.Call <AndroidJavaObject>("withPayload", self.Payload);
            builder.Call <AndroidJavaObject>("withReceipt", self.Receipt.ToAndroidReceipt());
            revenue = builder.Call <AndroidJavaObject>("build");
        }

        return(revenue);
    }
Exemplo n.º 4
0
    public static Hashtable ToHashtable(this YandexAppMetricaRevenue self)
    {
        var data = new Hashtable {
            { "Currency", self.Currency }
        };

        if (self.Price.HasValue)
        {
            data["Price"] = self.Price.Value;
        }
        if (self.PriceDecimal.HasValue)
        {
            data["PriceDecimal"] = self.PriceDecimal.Value.ToString(CultureInfo.CreateSpecificCulture("en-US"));
        }
        if (self.Quantity.HasValue)
        {
            data["Quantity"] = self.Quantity.Value;
        }
        if (self.ProductID != null)
        {
            data["ProductID"] = self.ProductID;
        }
        if (self.Payload != null)
        {
            data["Payload"] = self.Payload;
        }
        if (self.Receipt.HasValue)
        {
            data["Receipt"] = self.Receipt.Value.ToHashtable();
        }
        return(data);
    }
Exemplo n.º 5
0
        public static YMMRevenueInfo ToIOSAppMetricaRevenue(this YandexAppMetricaRevenue self)
        {
            var price        = self.Price;
            var currency     = self.Currency;
            var quantity     = (nuint)(self.Quantity ?? 1);
            var productID    = self.ProductID;
            var trasactionID = self.Receipt.HasValue ? self.Receipt.Value.TransactionID : null;
            var data         = self.Receipt.HasValue ? new NSData(self.Receipt.Value.Data, 0) : null;
            var payload      = self.Payload.ToIOSDictionary();

            return(new YMMRevenueInfo(price, currency, quantity, productID, trasactionID, data, payload));
        }
Exemplo n.º 6
0
    public static AndroidJavaObject ToAndroidRevenue(this YandexAppMetricaRevenue self)
    {
        AndroidJavaObject revenue = null;

        using (var revenueClass = new AndroidJavaClass("com.yandex.metrica.Revenue")) {
            var builder = revenueClass.CallStatic <AndroidJavaObject> ("newBuilder", self.Price, self.Currency.ToAndroidCurrency());
            builder.Call <AndroidJavaObject> ("withQuantity", self.Quantity.ToAndroidInteger());
            builder.Call <AndroidJavaObject> ("withProductID", self.ProductID);
            builder.Call <AndroidJavaObject> ("withPayload", self.Payload);
            builder.Call <AndroidJavaObject> ("withReceipt", self.Receipt.ToAndroidReceipt());
            revenue = builder.Call <AndroidJavaObject> ("build");
        }
        return(revenue);
    }
Exemplo n.º 7
0
        public static Com.Yandex.Metrica.Revenue ToAndroidRevenue(this YandexAppMetricaRevenue self)
        {
            var builder = Com.Yandex.Metrica.Revenue.NewBuilder(self.Price, self.Currency.ToAndroidCurrency());

            if (self.Quantity.HasValue)
            {
                builder.WithQuantity(new Java.Lang.Integer(self.Quantity.Value));
            }
            if (self.ProductID != null)
            {
                builder.WithProductID(self.ProductID);
            }
            if (self.Payload != null)
            {
                builder.WithPayload(self.Payload.ToJsonString());
            }
            if (self.Receipt.HasValue)
            {
                builder.WithReceipt(self.Receipt.Value.ToAndroidReceipt());
            }

            return(builder.Build());
        }
Exemplo n.º 8
0
 public override void ReportRevenue(YandexAppMetricaRevenue revenue)
 {
     ymm_reportRevenueJSON(JsonStringFromDictionary(revenue.ToHashtable()));
 }
Exemplo n.º 9
0
 public override void ReportRevenue(YandexAppMetricaRevenue revenue)
 {
     metricaClass.CallStatic("reportRevenue", revenue.ToAndroidRevenue());
 }
Exemplo n.º 10
0
 public override void ReportRevenue(YandexAppMetricaRevenue revenue)
 {
 }
Exemplo n.º 11
0
 public abstract void ReportRevenue(YandexAppMetricaRevenue revenue);
Exemplo n.º 12
0
 public override void ReportRevenue(YandexAppMetricaRevenue revenue)
 {
     YMMYandexMetrica.ReportRevenue(revenue.ToIOSAppMetricaRevenue(), null);
 }
Exemplo n.º 13
0
 public override void ReportRevenue(YandexAppMetricaRevenue revenue)
 {
     Com.Yandex.Metrica.YandexMetrica.ReportRevenue(revenue.ToAndroidRevenue());
 }
Exemplo n.º 14
0
        /// <summary>
        /// Покупка
        /// </summary>
        /// <param name="id"></param>
        /// <param name="complete">удачно или нет</param>
        public void Report_PurchaseComplete(string id, bool complete, double price = 0, string currency = "", string transactionId = "", string receipt = "", string errmes = "")
        {
            if (!use_anilytics)
            {
                return;
            }
            string report = e_Purchase;

            if (complete)
            {
                var par3 = new Dictionary <string, object>(5)
                {
                    { e_DevId, deviceId }, { e_Purchase_TransactionId, transactionId }, { e_Purchase_Price, price }, { e_Purchase_Currency, currency }, { e_Purchase_Error, "" }
                };
                var par2 = new Dictionary <string, object>(1)
                {
                    { id, par3 }
                };
                var par1 = new Dictionary <string, object>(1)
                {
                    { e_Purchase_Complete, par2 }
                };
                Instance.ReportEvent(report, par1);
            }
            else
            {
                var par3 = new Dictionary <string, object>(5)
                {
                    { e_DevId, deviceId }, { e_Purchase_TransactionId, transactionId }, { e_Purchase_Price, price }, { e_Purchase_Currency, currency }, { e_Purchase_Error, errmes }
                };
                var par2 = new Dictionary <string, object>(1)
                {
                    { id, par3 }
                };
                var par1 = new Dictionary <string, object>(1)
                {
                    { e_Purchase_Failed, par2 }
                };
                Instance.ReportEvent(report, par1);
            }

            //string report = e_PurchaseComplete + "_" + id;
            //var parameters = new Dictionary<string, object>(4) { { "devId", deviceId }, { "completed", complete.ToString() }, { "price", price }, { "currency", currency } };

            if (complete)
            {
                var revenue = new YandexAppMetricaRevenue(price, currency);
                revenue.ProductID = id;

                if (!string.IsNullOrEmpty(receipt))
                {
                    YandexAppMetricaReceipt yaReceipt = new YandexAppMetricaReceipt();
                    Receipt r_receipt = JsonUtility.FromJson <Receipt>(receipt);
                    r_receipt.TransactionID = transactionId;
#if UNITY_ANDROID
                    PayloadAndroid payloadAndroid = JsonUtility.FromJson <PayloadAndroid>(r_receipt.Payload);
                    yaReceipt.Signature = payloadAndroid.Signature;
                    yaReceipt.Data      = payloadAndroid.Json;

                    yaReceipt.TransactionID = transactionId;
#elif UNITY_IPHONE
                    yaReceipt.TransactionID = receipt.TransactionID;
                    yaReceipt.Data          = receipt.Payload;
#endif
                    revenue.Receipt = yaReceipt;
                }

                Instance.ReportRevenue(revenue);
            }
            Instance.SendEventsBuffer();
        }