Exemplo n.º 1
0
        /// <summary>
        /// Initialises a new instance of the request with the given description.
        /// </summary>
        ///
        /// <param name="desc">The description.</param>
        /// <param name="metricsAccessToken">MetricsAccessToken as returned from a call to SessionStart.</param>
        public AddIapEventRequest(AddIapEventRequestDesc desc, string metricsAccessToken)
        {
            ReleaseAssert.IsNotNull(desc, "A description object cannot be null.");

            ReleaseAssert.IsNotNull(desc.Item, "Item cannot be null.");
            ReleaseAssert.IsNotNull(desc.LocalCurrency, "LocalCurrency cannot be null.");

            ReleaseAssert.IsNotNull(metricsAccessToken, "Metrics Access Token cannot be null.");

            UserGrade          = desc.UserGrade;
            TestGroup          = desc.TestGroup;
            Offer              = desc.Offer;
            Item               = desc.Item;
            LocalCost          = desc.LocalCost;
            LocalCurrency      = desc.LocalCurrency;
            MetricsAccessToken = metricsAccessToken;
            Date               = DateTime.Now;

            Url = "https://metrics.chilliconnect.com/1.0/iaps/add";
            HttpRequestMethod = HttpRequestMethod.Post;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Records a successfully completed IAP transaction.
        /// </summary>
        ///
        /// <param name="desc">The request description.</param>
        /// <param name="successCallback">The delegate which is called if the request was successful.</param>
        /// <param name="errorCallback">The delegate which is called if the request was unsuccessful. Provides
        /// a container with information on what went wrong.</param>
        public void AddIapEvent(AddIapEventRequestDesc desc, Action <AddIapEventRequest> successCallback, Action <AddIapEventRequest, AddIapEventError> errorCallback)
        {
            m_logging.LogVerboseMessage("Sending Add Iap Event request.");

            var metricsAccessToken = m_dataStore.GetString("MetricsAccessToken");
            var request            = new AddIapEventRequest(desc, metricsAccessToken);

            m_serverRequestSystem.SendImmediateRequest(request, (IImmediateServerRequest sentRequest, ServerResponse serverResponse) =>
            {
                ReleaseAssert.IsTrue(request == sentRequest, "Received request is not the same as the one sent!");

                if (serverResponse.Result == HttpResult.Success && serverResponse.HttpResponseCode == SuccessHttpResponseCode)
                {
                    NotifyAddIapEventSuccess(serverResponse, request, successCallback);
                }
                else
                {
                    NotifyAddIapEventError(serverResponse, request, errorCallback);
                }
            });
        }