Example #1
0
        /// <summary>
        /// <see ref="Fulfillment" /> Accepts deserialized json data.
        /// <see ref="Fulfillment" /> Will further parse passed in data.
        /// </summary>
        /// <param name="dataJSON">Deserialized JSON data for Fulfillment</param>
        public Fulfillment(Dictionary <string, object> dataJSON)
        {
            DataJSON = dataJSON;
            Data     = new Dictionary <string, object>();

            foreach (string key in dataJSON.Keys)
            {
                string fieldName  = key;
                Regex  regexAlias = new Regex("^(.+)___.+$");
                Match  match      = regexAlias.Match(key);

                if (match.Success)
                {
                    fieldName = match.Groups[1].Value;
                }

                switch (fieldName)
                {
                case "fulfillmentLineItems":

                    Data.Add(
                        key,

                        new FulfillmentLineItemConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "trackingCompany":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "trackingInfo":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <FulfillmentTrackingInfo> >((IList)dataJSON[key])
                        );

                    break;
                }
            }
        }
Example #2
0
        /// <summary>
        /// <see ref="CheckoutLineItemsAddPayload" /> Accepts deserialized json data.
        /// <see ref="CheckoutLineItemsAddPayload" /> Will further parse passed in data.
        /// </summary>
        /// <param name="dataJSON">Deserialized JSON data for CheckoutLineItemsAddPayload</param>
        public CheckoutLineItemsAddPayload(Dictionary <string, object> dataJSON)
        {
            DataJSON = dataJSON;
            Data     = new Dictionary <string, object>();

            foreach (string key in dataJSON.Keys)
            {
                string fieldName  = key;
                Regex  regexAlias = new Regex("^(.+)___.+$");
                Match  match      = regexAlias.Match(key);

                if (match.Success)
                {
                    fieldName = match.Groups[1].Value;
                }

                switch (fieldName)
                {
                case "checkout":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new Checkout((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "checkoutUserErrors":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <CheckoutUserError> >((IList)dataJSON[key])
                        );

                    break;

                case "userErrors":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <UserError> >((IList)dataJSON[key])
                        );

                    break;
                }
            }
        }
Example #3
0
        public void TestCastStringListWithNull()
        {
            List <object> list = new List <object> {
                "Mikko", null, "Teppo"
            };

            List <string> castList = CastUtils.CastList <List <string> >(list);

            CollectionAssert.AreEqual(list, castList);
        }
Example #4
0
        public void TestCastClassList()
        {
            List <object> list = new List <object> {
                1, 2, 3
            };

            List <TestClass> castList = CastUtils.CastList <List <TestClass> >(list);

            Assert.AreEqual(1, castList[0].Value);
            Assert.AreEqual(2, castList[1].Value);
            Assert.AreEqual(3, castList[2].Value);
            Assert.AreEqual(3, castList.Count);
        }
Example #5
0
        public void TestCastStringList2D()
        {
            List <List <object> > list = new List <List <object> > {
                new List <object>()
                {
                    "Toronto", "Seinäjoki", "Vancouver"
                }
            };

            List <List <string> > castList = CastUtils.CastList <List <List <string> > >(list);

            CollectionAssert.AreEqual(list, castList);
        }
Example #6
0
        /// <summary>
        /// <see ref="ProductOption" /> Accepts deserialized json data.
        /// <see ref="ProductOption" /> Will further parse passed in data.
        /// </summary>
        /// <param name="dataJSON">Deserialized JSON data for ProductOption</param>
        public ProductOption(Dictionary <string, object> dataJSON)
        {
            DataJSON = dataJSON;
            Data     = new Dictionary <string, object>();

            foreach (string key in dataJSON.Keys)
            {
                string fieldName  = key;
                Regex  regexAlias = new Regex("^(.+)___.+$");
                Match  match      = regexAlias.Match(key);

                if (match.Success)
                {
                    fieldName = match.Groups[1].Value;
                }

                switch (fieldName)
                {
                case "id":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "name":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "values":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <string> >((IList)dataJSON[key])
                        );

                    break;
                }
            }
        }
Example #7
0
        public void TestCastEnumList()
        {
            List <object> list = new List <object> {
                "MIKKO", "IDONTEXIST", "TEPPO"
            };

            List <TestEnum> castList = CastUtils.CastList <List <TestEnum> >(list);

            CollectionAssert.AreEqual(new List <TestEnum>()
            {
                TestEnum.MIKKO,
                TestEnum.UNKNOWN,
                TestEnum.TEPPO
            }, castList);
        }
        /// <summary>
        /// <see ref="UnknownDisplayableError" /> Accepts deserialized json data.
        /// <see ref="UnknownDisplayableError" /> Will further parse passed in data.
        /// </summary>
        /// <param name="dataJSON">Deserialized JSON data for DisplayableError</param>
        public UnknownDisplayableError(Dictionary <string, object> dataJSON)
        {
            DataJSON = dataJSON;
            Data     = new Dictionary <string, object>();

            foreach (string key in dataJSON.Keys)
            {
                string fieldName  = key;
                Regex  regexAlias = new Regex("^(.+)___.+$");
                Match  match      = regexAlias.Match(key);

                if (match.Success)
                {
                    fieldName = match.Groups[1].Value;
                }

                switch (fieldName)
                {
                case "field":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            CastUtils.CastList <List <string> >((IList)dataJSON[key])
                            );
                    }

                    break;

                case "message":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;
                }
            }
        }
Example #9
0
        /// <summary>
        /// <see ref="AvailableShippingRates" /> Accepts deserialized json data.
        /// <see ref="AvailableShippingRates" /> Will further parse passed in data.
        /// </summary>
        /// <param name="dataJSON">Deserialized JSON data for AvailableShippingRates</param>
        public AvailableShippingRates(Dictionary <string, object> dataJSON)
        {
            DataJSON = dataJSON;
            Data     = new Dictionary <string, object>();

            foreach (string key in dataJSON.Keys)
            {
                string fieldName  = key;
                Regex  regexAlias = new Regex("^(.+)___.+$");
                Match  match      = regexAlias.Match(key);

                if (match.Success)
                {
                    fieldName = match.Groups[1].Value;
                }

                switch (fieldName)
                {
                case "ready":

                    Data.Add(
                        key,

                        (bool)dataJSON[key]
                        );

                    break;

                case "shippingRates":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            CastUtils.CastList <List <ShippingRate> >((IList)dataJSON[key])
                            );
                    }

                    break;
                }
            }
        }
Example #10
0
        /// <summary>
        /// <see ref="CustomerRecoverPayload" /> Accepts deserialized json data.
        /// <see ref="CustomerRecoverPayload" /> Will further parse passed in data.
        /// </summary>
        /// <param name="dataJSON">Deserialized JSON data for CustomerRecoverPayload</param>
        public CustomerRecoverPayload(Dictionary <string, object> dataJSON)
        {
            DataJSON = dataJSON;
            Data     = new Dictionary <string, object>();

            foreach (string key in dataJSON.Keys)
            {
                string fieldName  = key;
                Regex  regexAlias = new Regex("^(.+)___.+$");
                Match  match      = regexAlias.Match(key);

                if (match.Success)
                {
                    fieldName = match.Groups[1].Value;
                }

                switch (fieldName)
                {
                case "customerUserErrors":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <CustomerUserError> >((IList)dataJSON[key])
                        );

                    break;

                case "userErrors":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <UserError> >((IList)dataJSON[key])
                        );

                    break;
                }
            }
        }
Example #11
0
        /// <summary>
        /// <see ref="MetafieldConnection" /> Accepts deserialized json data.
        /// <see ref="MetafieldConnection" /> Will further parse passed in data.
        /// </summary>
        /// <param name="dataJSON">Deserialized JSON data for MetafieldConnection</param>
        public MetafieldConnection(Dictionary <string, object> dataJSON)
        {
            DataJSON = dataJSON;
            Data     = new Dictionary <string, object>();

            foreach (string key in dataJSON.Keys)
            {
                string fieldName  = key;
                Regex  regexAlias = new Regex("^(.+)___.+$");
                Match  match      = regexAlias.Match(key);

                if (match.Success)
                {
                    fieldName = match.Groups[1].Value;
                }

                switch (fieldName)
                {
                case "edges":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <MetafieldEdge> >((IList)dataJSON[key])
                        );

                    break;

                case "pageInfo":

                    Data.Add(
                        key,

                        new PageInfo((Dictionary <string, object>)dataJSON[key])
                        );

                    break;
                }
            }
        }
Example #12
0
        /// <summary>
        /// <see ref="PaymentSettings" /> Accepts deserialized json data.
        /// <see ref="PaymentSettings" /> Will further parse passed in data.
        /// </summary>
        /// <param name="dataJSON">Deserialized JSON data for PaymentSettings</param>
        public PaymentSettings(Dictionary <string, object> dataJSON)
        {
            DataJSON = dataJSON;
            Data     = new Dictionary <string, object>();

            foreach (string key in dataJSON.Keys)
            {
                string fieldName  = key;
                Regex  regexAlias = new Regex("^(.+)___.+$");
                Match  match      = regexAlias.Match(key);

                if (match.Success)
                {
                    fieldName = match.Groups[1].Value;
                }

                switch (fieldName)
                {
                case "acceptedCardBrands":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <CardBrand> >((IList)dataJSON[key])
                        );

                    break;

                case "cardVaultUrl":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "countryCode":

                    Data.Add(
                        key,

                        CastUtils.GetEnumValue <CountryCode>(dataJSON[key])
                        );

                    break;

                case "currencyCode":

                    Data.Add(
                        key,

                        CastUtils.GetEnumValue <CurrencyCode>(dataJSON[key])
                        );

                    break;

                case "enabledPresentmentCurrencies":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <CurrencyCode> >((IList)dataJSON[key])
                        );

                    break;

                case "shopifyPaymentsAccountId":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "supportedDigitalWallets":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <DigitalWallet> >((IList)dataJSON[key])
                        );

                    break;
                }
            }
        }
Example #13
0
        /// <summary>
        /// <see ref="MailingAddress" /> Accepts deserialized json data.
        /// <see ref="MailingAddress" /> Will further parse passed in data.
        /// </summary>
        /// <param name="dataJSON">Deserialized JSON data for MailingAddress</param>
        public MailingAddress(Dictionary <string, object> dataJSON)
        {
            DataJSON = dataJSON;
            Data     = new Dictionary <string, object>();

            foreach (string key in dataJSON.Keys)
            {
                string fieldName  = key;
                Regex  regexAlias = new Regex("^(.+)___.+$");
                Match  match      = regexAlias.Match(key);

                if (match.Success)
                {
                    fieldName = match.Groups[1].Value;
                }

                switch (fieldName)
                {
                case "address1":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "address2":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "city":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "company":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "country":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "countryCode":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "countryCodeV2":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            CastUtils.GetEnumValue <CountryCode>(dataJSON[key])
                            );
                    }

                    break;

                case "firstName":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "formatted":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <string> >((IList)dataJSON[key])
                        );

                    break;

                case "formattedArea":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "id":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "lastName":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "latitude":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (double)dataJSON[key]
                            );
                    }

                    break;

                case "longitude":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (double)dataJSON[key]
                            );
                    }

                    break;

                case "name":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "phone":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "province":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "provinceCode":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "zip":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;
                }
            }
        }
Example #14
0
        /// <summary>
        /// <see ref="Customer" /> Accepts deserialized json data.
        /// <see ref="Customer" /> Will further parse passed in data.
        /// </summary>
        /// <param name="dataJSON">Deserialized JSON data for Customer</param>
        public Customer(Dictionary <string, object> dataJSON)
        {
            DataJSON = dataJSON;
            Data     = new Dictionary <string, object>();

            foreach (string key in dataJSON.Keys)
            {
                string fieldName  = key;
                Regex  regexAlias = new Regex("^(.+)___.+$");
                Match  match      = regexAlias.Match(key);

                if (match.Success)
                {
                    fieldName = match.Groups[1].Value;
                }

                switch (fieldName)
                {
                case "acceptsMarketing":

                    Data.Add(
                        key,

                        (bool)dataJSON[key]
                        );

                    break;

                case "addresses":

                    Data.Add(
                        key,

                        new MailingAddressConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "createdAt":

                    Data.Add(
                        key,

                        Convert.ToDateTime(dataJSON[key])
                        );

                    break;

                case "defaultAddress":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new MailingAddress((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "displayName":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "email":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "firstName":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "id":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "lastIncompleteCheckout":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new Checkout((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "lastName":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "orders":

                    Data.Add(
                        key,

                        new OrderConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "phone":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "tags":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <string> >((IList)dataJSON[key])
                        );

                    break;

                case "updatedAt":

                    Data.Add(
                        key,

                        Convert.ToDateTime(dataJSON[key])
                        );

                    break;
                }
            }
        }
        /// <summary>
        /// <see ref="Shop" /> Accepts deserialized json data.
        /// <see ref="Shop" /> Will further parse passed in data.
        /// </summary>
        /// <param name="dataJSON">Deserialized JSON data for Shop</param>
        public Shop(Dictionary <string, object> dataJSON)
        {
            DataJSON = dataJSON;
            Data     = new Dictionary <string, object>();

            foreach (string key in dataJSON.Keys)
            {
                string fieldName  = key;
                Regex  regexAlias = new Regex("^(.+)___.+$");
                Match  match      = regexAlias.Match(key);

                if (match.Success)
                {
                    fieldName = match.Groups[1].Value;
                }

                switch (fieldName)
                {
                case "articles":

                    Data.Add(
                        key,

                        new ArticleConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "blogs":

                    Data.Add(
                        key,

                        new BlogConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "collectionByHandle":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new Collection((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "collections":

                    Data.Add(
                        key,

                        new CollectionConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "currencyCode":

                    Data.Add(
                        key,

                        CastUtils.GetEnumValue <CurrencyCode>(dataJSON[key])
                        );

                    break;

                case "description":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "moneyFormat":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "name":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "paymentSettings":

                    Data.Add(
                        key,

                        new PaymentSettings((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "primaryDomain":

                    Data.Add(
                        key,

                        new Domain((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "privacyPolicy":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new ShopPolicy((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "productByHandle":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new Product((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "productTags":

                    Data.Add(
                        key,

                        new StringConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "productTypes":

                    Data.Add(
                        key,

                        new StringConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "products":

                    Data.Add(
                        key,

                        new ProductConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "refundPolicy":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new ShopPolicy((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "shipsToCountries":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <CountryCode> >((IList)dataJSON[key])
                        );

                    break;

                case "shopifyPaymentsAccountId":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "termsOfService":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new ShopPolicy((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;
                }
            }
        }
Example #16
0
        /// <summary>
        /// <see ref="Blog" /> Accepts deserialized json data.
        /// <see ref="Blog" /> Will further parse passed in data.
        /// </summary>
        /// <param name="dataJSON">Deserialized JSON data for Blog</param>
        public Blog(Dictionary <string, object> dataJSON)
        {
            DataJSON = dataJSON;
            Data     = new Dictionary <string, object>();

            foreach (string key in dataJSON.Keys)
            {
                string fieldName  = key;
                Regex  regexAlias = new Regex("^(.+)___.+$");
                Match  match      = regexAlias.Match(key);

                if (match.Success)
                {
                    fieldName = match.Groups[1].Value;
                }

                switch (fieldName)
                {
                case "articleByHandle":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new Article((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "articles":

                    Data.Add(
                        key,

                        new ArticleConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "authors":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <ArticleAuthor> >((IList)dataJSON[key])
                        );

                    break;

                case "handle":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "id":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "title":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "url":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;
                }
            }
        }
Example #17
0
        /// <summary>
        /// <see ref="Order" /> Accepts deserialized json data.
        /// <see ref="Order" /> Will further parse passed in data.
        /// </summary>
        /// <param name="dataJSON">Deserialized JSON data for Order</param>
        public Order(Dictionary <string, object> dataJSON)
        {
            DataJSON = dataJSON;
            Data     = new Dictionary <string, object>();

            foreach (string key in dataJSON.Keys)
            {
                string fieldName  = key;
                Regex  regexAlias = new Regex("^(.+)___.+$");
                Match  match      = regexAlias.Match(key);

                if (match.Success)
                {
                    fieldName = match.Groups[1].Value;
                }

                switch (fieldName)
                {
                case "currencyCode":

                    Data.Add(
                        key,

                        CastUtils.GetEnumValue <CurrencyCode>(dataJSON[key])
                        );

                    break;

                case "customerLocale":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "customerUrl":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "discountApplications":

                    Data.Add(
                        key,

                        new DiscountApplicationConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "email":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "id":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "lineItems":

                    Data.Add(
                        key,

                        new OrderLineItemConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "name":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "orderNumber":

                    Data.Add(
                        key,

                        (long)dataJSON[key]
                        );

                    break;

                case "phone":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "processedAt":

                    Data.Add(
                        key,

                        Convert.ToDateTime(dataJSON[key])
                        );

                    break;

                case "shippingAddress":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new MailingAddress((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "shippingDiscountAllocations":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <DiscountAllocation> >((IList)dataJSON[key])
                        );

                    break;

                case "statusUrl":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "subtotalPrice":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            Convert.ToDecimal(dataJSON[key])
                            );
                    }

                    break;

                case "subtotalPriceV2":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new MoneyV2((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "successfulFulfillments":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            CastUtils.CastList <List <Fulfillment> >((IList)dataJSON[key])
                            );
                    }

                    break;

                case "totalPrice":

                    Data.Add(
                        key,

                        Convert.ToDecimal(dataJSON[key])
                        );

                    break;

                case "totalPriceV2":

                    Data.Add(
                        key,

                        new MoneyV2((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "totalRefunded":

                    Data.Add(
                        key,

                        Convert.ToDecimal(dataJSON[key])
                        );

                    break;

                case "totalRefundedV2":

                    Data.Add(
                        key,

                        new MoneyV2((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "totalShippingPrice":

                    Data.Add(
                        key,

                        Convert.ToDecimal(dataJSON[key])
                        );

                    break;

                case "totalShippingPriceV2":

                    Data.Add(
                        key,

                        new MoneyV2((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "totalTax":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            Convert.ToDecimal(dataJSON[key])
                            );
                    }

                    break;

                case "totalTaxV2":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new MoneyV2((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;
                }
            }
        }
Example #18
0
        /// <summary>
        /// <see ref="Article" /> Accepts deserialized json data.
        /// <see ref="Article" /> Will further parse passed in data.
        /// </summary>
        /// <param name="dataJSON">Deserialized JSON data for Article</param>
        public Article(Dictionary <string, object> dataJSON)
        {
            DataJSON = dataJSON;
            Data     = new Dictionary <string, object>();

            foreach (string key in dataJSON.Keys)
            {
                string fieldName  = key;
                Regex  regexAlias = new Regex("^(.+)___.+$");
                Match  match      = regexAlias.Match(key);

                if (match.Success)
                {
                    fieldName = match.Groups[1].Value;
                }

                switch (fieldName)
                {
                case "author":

                    Data.Add(
                        key,

                        new ArticleAuthor((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "authorV2":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new ArticleAuthor((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "blog":

                    Data.Add(
                        key,

                        new Blog((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "comments":

                    Data.Add(
                        key,

                        new CommentConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "content":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "contentHtml":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "excerpt":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "excerptHtml":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "handle":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "id":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "image":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new Image((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "publishedAt":

                    Data.Add(
                        key,

                        Convert.ToDateTime(dataJSON[key])
                        );

                    break;

                case "seo":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new Seo((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "tags":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <string> >((IList)dataJSON[key])
                        );

                    break;

                case "title":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "url":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;
                }
            }
        }
Example #19
0
        /// <summary>
        /// <see ref="CheckoutLineItem" /> Accepts deserialized json data.
        /// <see ref="CheckoutLineItem" /> Will further parse passed in data.
        /// </summary>
        /// <param name="dataJSON">Deserialized JSON data for CheckoutLineItem</param>
        public CheckoutLineItem(Dictionary <string, object> dataJSON)
        {
            DataJSON = dataJSON;
            Data     = new Dictionary <string, object>();

            foreach (string key in dataJSON.Keys)
            {
                string fieldName  = key;
                Regex  regexAlias = new Regex("^(.+)___.+$");
                Match  match      = regexAlias.Match(key);

                if (match.Success)
                {
                    fieldName = match.Groups[1].Value;
                }

                switch (fieldName)
                {
                case "customAttributes":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <Attribute> >((IList)dataJSON[key])
                        );

                    break;

                case "discountAllocations":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <DiscountAllocation> >((IList)dataJSON[key])
                        );

                    break;

                case "id":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "quantity":

                    Data.Add(
                        key,

                        (long)dataJSON[key]
                        );

                    break;

                case "title":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "variant":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new ProductVariant((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;
                }
            }
        }
        /// <summary>
        /// <see ref="Product" /> Accepts deserialized json data.
        /// <see ref="Product" /> Will further parse passed in data.
        /// </summary>
        /// <param name="dataJSON">Deserialized JSON data for Product</param>
        public Product(Dictionary <string, object> dataJSON)
        {
            DataJSON = dataJSON;
            Data     = new Dictionary <string, object>();

            foreach (string key in dataJSON.Keys)
            {
                string fieldName  = key;
                Regex  regexAlias = new Regex("^(.+)___.+$");
                Match  match      = regexAlias.Match(key);

                if (match.Success)
                {
                    fieldName = match.Groups[1].Value;
                }

                switch (fieldName)
                {
                case "availableForSale":

                    Data.Add(
                        key,

                        (bool)dataJSON[key]
                        );

                    break;

                case "collections":

                    Data.Add(
                        key,

                        new CollectionConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "createdAt":

                    Data.Add(
                        key,

                        Convert.ToDateTime(dataJSON[key])
                        );

                    break;

                case "description":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "descriptionHtml":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "handle":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "id":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "images":

                    Data.Add(
                        key,

                        new ImageConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "metafield":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new Metafield((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "metafields":

                    Data.Add(
                        key,

                        new MetafieldConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "onlineStoreUrl":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "options":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <ProductOption> >((IList)dataJSON[key])
                        );

                    break;

                case "priceRange":

                    Data.Add(
                        key,

                        new ProductPriceRange((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "productType":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "publishedAt":

                    Data.Add(
                        key,

                        Convert.ToDateTime(dataJSON[key])
                        );

                    break;

                case "tags":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <string> >((IList)dataJSON[key])
                        );

                    break;

                case "title":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "updatedAt":

                    Data.Add(
                        key,

                        Convert.ToDateTime(dataJSON[key])
                        );

                    break;

                case "variantBySelectedOptions":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new ProductVariant((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "variants":

                    Data.Add(
                        key,

                        new ProductVariantConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "vendor":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;
                }
            }
        }
Example #21
0
        /// <summary>
        /// <see ref="Checkout" /> Accepts deserialized json data.
        /// <see ref="Checkout" /> Will further parse passed in data.
        /// </summary>
        /// <param name="dataJSON">Deserialized JSON data for Checkout</param>
        public Checkout(Dictionary <string, object> dataJSON)
        {
            DataJSON = dataJSON;
            Data     = new Dictionary <string, object>();

            foreach (string key in dataJSON.Keys)
            {
                string fieldName  = key;
                Regex  regexAlias = new Regex("^(.+)___.+$");
                Match  match      = regexAlias.Match(key);

                if (match.Success)
                {
                    fieldName = match.Groups[1].Value;
                }

                switch (fieldName)
                {
                case "appliedGiftCards":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <AppliedGiftCard> >((IList)dataJSON[key])
                        );

                    break;

                case "availableShippingRates":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new AvailableShippingRates((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "completedAt":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            Convert.ToDateTime(dataJSON[key])
                            );
                    }

                    break;

                case "createdAt":

                    Data.Add(
                        key,

                        Convert.ToDateTime(dataJSON[key])
                        );

                    break;

                case "currencyCode":

                    Data.Add(
                        key,

                        CastUtils.GetEnumValue <CurrencyCode>(dataJSON[key])
                        );

                    break;

                case "customAttributes":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <Attribute> >((IList)dataJSON[key])
                        );

                    break;

                case "customer":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new Customer((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "discountApplications":

                    Data.Add(
                        key,

                        new DiscountApplicationConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "email":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "id":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "lineItems":

                    Data.Add(
                        key,

                        new CheckoutLineItemConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "lineItemsSubtotalPrice":

                    Data.Add(
                        key,

                        new MoneyV2((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "note":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "order":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new Order((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "orderStatusUrl":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "paymentDue":

                    Data.Add(
                        key,

                        Convert.ToDecimal(dataJSON[key])
                        );

                    break;

                case "paymentDueV2":

                    Data.Add(
                        key,

                        new MoneyV2((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "ready":

                    Data.Add(
                        key,

                        (bool)dataJSON[key]
                        );

                    break;

                case "requiresShipping":

                    Data.Add(
                        key,

                        (bool)dataJSON[key]
                        );

                    break;

                case "shippingAddress":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new MailingAddress((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "shippingDiscountAllocations":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <DiscountAllocation> >((IList)dataJSON[key])
                        );

                    break;

                case "shippingLine":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new ShippingRate((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "subtotalPrice":

                    Data.Add(
                        key,

                        Convert.ToDecimal(dataJSON[key])
                        );

                    break;

                case "subtotalPriceV2":

                    Data.Add(
                        key,

                        new MoneyV2((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "taxExempt":

                    Data.Add(
                        key,

                        (bool)dataJSON[key]
                        );

                    break;

                case "taxesIncluded":

                    Data.Add(
                        key,

                        (bool)dataJSON[key]
                        );

                    break;

                case "totalPrice":

                    Data.Add(
                        key,

                        Convert.ToDecimal(dataJSON[key])
                        );

                    break;

                case "totalPriceV2":

                    Data.Add(
                        key,

                        new MoneyV2((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "totalTax":

                    Data.Add(
                        key,

                        Convert.ToDecimal(dataJSON[key])
                        );

                    break;

                case "totalTaxV2":

                    Data.Add(
                        key,

                        new MoneyV2((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "updatedAt":

                    Data.Add(
                        key,

                        Convert.ToDateTime(dataJSON[key])
                        );

                    break;

                case "webUrl":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;
                }
            }
        }
Example #22
0
        /// <summary>
        /// <see ref="ProductVariant" /> Accepts deserialized json data.
        /// <see ref="ProductVariant" /> Will further parse passed in data.
        /// </summary>
        /// <param name="dataJSON">Deserialized JSON data for ProductVariant</param>
        public ProductVariant(Dictionary <string, object> dataJSON)
        {
            DataJSON = dataJSON;
            Data     = new Dictionary <string, object>();

            foreach (string key in dataJSON.Keys)
            {
                string fieldName  = key;
                Regex  regexAlias = new Regex("^(.+)___.+$");
                Match  match      = regexAlias.Match(key);

                if (match.Success)
                {
                    fieldName = match.Groups[1].Value;
                }

                switch (fieldName)
                {
                case "available":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (bool)dataJSON[key]
                            );
                    }

                    break;

                case "availableForSale":

                    Data.Add(
                        key,

                        (bool)dataJSON[key]
                        );

                    break;

                case "compareAtPrice":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            Convert.ToDecimal(dataJSON[key])
                            );
                    }

                    break;

                case "compareAtPriceV2":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new MoneyV2((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "id":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "image":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new Image((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "metafield":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            new Metafield((Dictionary <string, object>)dataJSON[key])
                            );
                    }

                    break;

                case "metafields":

                    Data.Add(
                        key,

                        new MetafieldConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "presentmentPrices":

                    Data.Add(
                        key,

                        new ProductVariantPricePairConnection((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "price":

                    Data.Add(
                        key,

                        Convert.ToDecimal(dataJSON[key])
                        );

                    break;

                case "priceV2":

                    Data.Add(
                        key,

                        new MoneyV2((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "product":

                    Data.Add(
                        key,

                        new Product((Dictionary <string, object>)dataJSON[key])
                        );

                    break;

                case "selectedOptions":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <SelectedOption> >((IList)dataJSON[key])
                        );

                    break;

                case "sku":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "title":

                    Data.Add(
                        key,

                        (string)dataJSON[key]
                        );

                    break;

                case "weight":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (double)dataJSON[key]
                            );
                    }

                    break;

                case "weightUnit":

                    Data.Add(
                        key,

                        CastUtils.GetEnumValue <WeightUnit>(dataJSON[key])
                        );

                    break;
                }
            }
        }
Example #23
0
        /// <summary>
        /// <see ref="CustomerAccessTokenDeletePayload" /> Accepts deserialized json data.
        /// <see ref="CustomerAccessTokenDeletePayload" /> Will further parse passed in data.
        /// </summary>
        /// <param name="dataJSON">Deserialized JSON data for CustomerAccessTokenDeletePayload</param>
        public CustomerAccessTokenDeletePayload(Dictionary <string, object> dataJSON)
        {
            DataJSON = dataJSON;
            Data     = new Dictionary <string, object>();

            foreach (string key in dataJSON.Keys)
            {
                string fieldName  = key;
                Regex  regexAlias = new Regex("^(.+)___.+$");
                Match  match      = regexAlias.Match(key);

                if (match.Success)
                {
                    fieldName = match.Groups[1].Value;
                }

                switch (fieldName)
                {
                case "deletedAccessToken":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "deletedCustomerAccessTokenId":

                    if (dataJSON[key] == null)
                    {
                        Data.Add(key, null);
                    }
                    else
                    {
                        Data.Add(
                            key,

                            (string)dataJSON[key]
                            );
                    }

                    break;

                case "userErrors":

                    Data.Add(
                        key,

                        CastUtils.CastList <List <UserError> >((IList)dataJSON[key])
                        );

                    break;
                }
            }
        }