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

            foreach (KeyValuePair <string, object> entry in jsonDictionary)
            {
                // Rewards
                if (entry.Key == "Rewards")
                {
                    ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type.");
                    Rewards = new MessageRewardRedeemed((IDictionary <string, object>)entry.Value);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Initialises the response with the given json dictionary.
        /// </summary>
        ///
        /// <param name="jsonDictionary">The dictionary containing the JSON data.</param>
        public RedeemMessageRewardsResponse(IDictionary <string, object> jsonDictionary)
        {
            ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null.");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Rewards"), "Json is missing required field 'Rewards'");

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

                // An error has occurred.
                else
                {
#if DEBUG
                    throw new ArgumentException("Input Json contains an invalid field.");
#endif
                }
            }
        }