Esempio n. 1
0
        /// <summary>
        /// Call to shopify to get the list of products, available in shopify website.
        /// </summary>
        /// <param name="apiKey">pass apiKey used login in Shopify main portal</param>
        /// <param name="password">password used login in Shopify main portal</param>
        /// <param name="storeUrl">pass storeUrl created for the store Shopify main portal</param>
        /// <returns>Return list of products</returns>
        public static List <TrekWoAProductsPortal.Model.product> GetAllProducts(string apiKey, string password, string storeUrl)
        {
            List <TrekWoAProductsPortal.Model.product> products = null;

            try
            {
                dynamic shopify     = new Shopify.Api(apiKey, password, storeUrl);
                var     selectQuery = shopify.Products();
                products = new List <Model.product>();
                if (selectQuery != null)
                {
                    products = new List <Model.product>();
                    foreach (var item in selectQuery.products)
                    {
                        TrekWoAProductsPortal.Model.product product = new TrekWoAProductsPortal.Model.product();
                        product.id    = Convert.ToString(item.id);
                        product.title = item.title;
                        products.Add(product);
                    }
                }
            }
            catch (Exception x)
            {
                MessageBox.Show(x.Message);
            }

            return(products);
        }
Esempio n. 2
0
        /// <summary>
        /// Return count of products uploaded into the shopify webisite.
        /// </summary>
        /// <param name="apiKey">pass apiKey used login in Shopify main portal</param>
        /// <param name="password">password used login in Shopify main portal</param>
        /// <param name="storeUrl">pass storeUrl created for the store Shopify main portal</param>
        /// <returns>Return number of products available on Shopify</returns>
        public static int GetProductCount(string apiKey, string password, string storeUrl, string fullUrl)
        {
            int count = 0;

            try
            {
                dynamic shopifyCount = new Shopify.Api(apiKey, password, storeUrl, fullUrl);
                var     CountQuery   = shopifyCount.Products();
                if (CountQuery != null)
                {
                    count = CountQuery.count;
                }
            }
            catch (Exception x)
            { }
            return(count);
        }
Esempio n. 3
0
 /// <summary>
 /// Call to Shopify api for get one product details based on product id.
 /// </summary>
 /// <param name="apiKey">pass apiKey used login in Shopify main portal</param>
 /// <param name="password">password used login in Shopify main portal</param>
 /// <param name="storeUrl">pass storeUrl created for the store Shopify main portal</param>
 /// <returns>Return a product based on product id, available on Shopify</returns>
 public static TrekWoAProductsPortal.Model.product GetProduct(string apiKey, string password, string storeUrl, string fullUrl = null)
 {
     TrekWoAProductsPortal.Model.product product = null;
     try
     {
         dynamic shopifyProductSelected = new Shopify.Api(apiKey, password, storeUrl, fullUrl);
         var     IsProductSelected      = shopifyProductSelected.Products();
         if (IsProductSelected != null)
         {
             product = new Model.product()
             {
                 id    = Convert.ToString(IsProductSelected.product.id),
                 title = IsProductSelected.product.title
             };
         }
     }
     catch (Exception ex)
     { }
     return(product);
 }
Esempio n. 4
0
        static void Main(string[] args)
        {
            //GET /admin/products.json
            dynamic shopify     = new Shopify.Api("67b9a85c8758934ab576f76e0daec9cf", "a5c2e67de6376e3cc76f54191155f93a", "trek-bikes.myshopify.com");
            var     selectQuery = shopify.Products();

            foreach (var prod in selectQuery.products)
            {
                Console.WriteLine(prod.title);
                Console.WriteLine(prod.id);
            }
            Console.ReadLine();



            //GET / admin / products/count.json
            //dynamic shopifyCount = new Shopify.Api("67b9a85c8758934ab576f76e0daec9cf", "a5c2e67de6376e3cc76f54191155f93a", "trek-bikes.myshopify.com", "https://trek-bikes.myshopify.com/admin/products/count.json");
            //var CountQuery = shopifyCount.Products();
            //Console.WriteLine(CountQuery.count);
            //Console.ReadLine();



            // GET / admin / products /#{product_id}.json
            //dynamic shopifyId = new Shopify.Api("67b9a85c8758934ab576f76e0daec9cf", "a5c2e67de6376e3cc76f54191155f93a", "trek-bikes.myshopify.com", "https://trek-bikes.myshopify.com/admin/products/1362489245814.json");
            //var selectIdQuery = shopifyId.Products();
            //Console.WriteLine(selectIdQuery.product.title);
            //Console.ReadLine();



            //POST / admin / products.json
            //var p = new Products()
            //{
            //    product = new product()
            //    {
            //        title = "watch",
            //        price="50"
            //    }
            //};


            //dynamic shopifySave = new Shopify.Api("67b9a85c8758934ab576f76e0daec9cf", "a5c2e67de6376e3cc76f54191155f93a", "trek-bikes.myshopify.com");
            //shopifySave.Products.Save(p);



            //PUT /admin/products/632910392.json
            //var pupdate = new Shopify.Products()
            //{
            //    product = new product()
            //    {
            //        title = "fitbit",
            //        id= "1370435747958",
            //        price = "100"

            //    }
            //};


            //dynamic shopifyUpdate = new Shopify.Api("67b9a85c8758934ab576f76e0daec9cf", "a5c2e67de6376e3cc76f54191155f93a", "trek-bikes.myshopify.com");
            //shopifyUpdate.Products.Save(pupdate);


            //DELETE /admin/products/#{product_id}.json
            //var pdelete = new Shopify.Products()
            //{
            //    product = new product()
            //    {

            //        id = "1370435747958",


            //    }
            //};


            //dynamic shopifyDelete = new Shopify.Api("67b9a85c8758934ab576f76e0daec9cf", "a5c2e67de6376e3cc76f54191155f93a", "trek-bikes.myshopify.com");
            //shopifyDelete.Products.Delete(pdelete);
        }