Exemplo n.º 1
0
        /// <summary>
        /// Initialises the response with the given json dictionary.
        /// </summary>
        ///
        /// <param name="jsonDictionary">The dictionary containing the JSON data.</param>
        public MakeVirtualPurchaseResponse(IDictionary <string, object> jsonDictionary)
        {
            ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null.");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Costs"), "Json is missing required field 'Costs'");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Rewards"), "Json is missing required field 'Rewards'");

            foreach (KeyValuePair <string, object> entry in jsonDictionary)
            {
                // Costs
                if (entry.Key == "Costs")
                {
                    ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type.");
                    Costs = new PurchaseExchange((IDictionary <string, object>)entry.Value);
                }

                // Rewards
                else if (entry.Key == "Rewards")
                {
                    ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type.");
                    Rewards = new PurchaseExchange((IDictionary <string, object>)entry.Value);
                }

                // An error has occurred.
                else
                {
#if DEBUG
                    throw new ArgumentException("Input Json contains an invalid field.");
#endif
                }
            }
        }
        /// <summary>
        /// Initialises the response with the given json dictionary.
        /// </summary>
        ///
        /// <param name="jsonDictionary">The dictionary containing the JSON data.</param>
        public RedeemGoogleIapResponse(IDictionary <string, object> jsonDictionary)
        {
            ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null.");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Redeemed"), "Json is missing required field 'Redeemed'");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Status"), "Json is missing required field 'Status'");

            foreach (KeyValuePair <string, object> entry in jsonDictionary)
            {
                // Redeemed
                if (entry.Key == "Redeemed")
                {
                    ReleaseAssert.IsTrue(entry.Value is bool, "Invalid serialised type.");
                    Redeemed = (bool)entry.Value;
                }

                // Status
                else if (entry.Key == "Status")
                {
                    ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type.");
                    Status = (string)entry.Value;
                }

                // Rewards
                else if (entry.Key == "Rewards")
                {
                    if (entry.Value != null)
                    {
                        ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type.");
                        Rewards = new PurchaseExchange((IDictionary <string, object>)entry.Value);
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initialises the response with the given json dictionary.
        /// </summary>
        ///
        /// <param name="jsonDictionary">The dictionary containing the JSON data.</param>
        public RedeemAppleIapResponse(IDictionary <string, object> jsonDictionary)
        {
            ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null.");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Redeemed"), "Json is missing required field 'Redeemed'");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Status"), "Json is missing required field 'Status'");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("AppStore"), "Json is missing required field 'AppStore'");

            foreach (KeyValuePair <string, object> entry in jsonDictionary)
            {
                // Redeemed
                if (entry.Key == "Redeemed")
                {
                    ReleaseAssert.IsTrue(entry.Value is bool, "Invalid serialised type.");
                    Redeemed = (bool)entry.Value;
                }

                // Status
                else if (entry.Key == "Status")
                {
                    ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type.");
                    Status = (string)entry.Value;
                }

                // App Store
                else if (entry.Key == "AppStore")
                {
                    ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type.");
                    AppStore = new AppStore((IDictionary <string, object>)entry.Value);
                }

                // Rewards
                else if (entry.Key == "Rewards")
                {
                    if (entry.Value != null)
                    {
                        ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type.");
                        Rewards = new PurchaseExchange((IDictionary <string, object>)entry.Value);
                    }
                }

                // An error has occurred.
                else
                {
#if DEBUG
                    throw new ArgumentException("Input Json contains an invalid field.");
#endif
                }
            }
        }
        /// <summary>
        /// Initialises the response with the given json dictionary.
        /// </summary>
        ///
        /// <param name="jsonDictionary">The dictionary containing the JSON data.</param>
        public MakeVirtualPurchaseResponse(IDictionary <string, object> jsonDictionary)
        {
            ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null.");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Costs"), "Json is missing required field 'Costs'");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Rewards"), "Json is missing required field 'Rewards'");

            foreach (KeyValuePair <string, object> entry in jsonDictionary)
            {
                // Costs
                if (entry.Key == "Costs")
                {
                    ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type.");
                    Costs = new PurchaseExchange((IDictionary <string, object>)entry.Value);
                }

                // Rewards
                else if (entry.Key == "Rewards")
                {
                    ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type.");
                    Rewards = new PurchaseExchange((IDictionary <string, object>)entry.Value);
                }
            }
        }