Inheritance: IShopifyProduct, IShopifyObject
Esempio n. 1
0
 public ShopifyLineItem(ShopifyProduct thisProduct, ShopifyVariant thisVariant)
 {
     Id = 0;
     FulfillmentService = thisVariant.FulfillmentService;
     FulfillmentStatus = null;
     Grams = thisVariant.Grams;
     Price = thisVariant.Price;
     ProductId = thisProduct.Id == null ? 0 : (int)thisProduct.Id;
     Quantity = thisVariant.InventoryQuantity == null ?  0 : (int) thisVariant.InventoryQuantity;
     RequiresShipping = thisVariant.RequiresShipping;
     Sku = thisVariant.Sku;
     Title = thisProduct.Title;
     VariantId = thisVariant.Id == null ? 0 : (int)thisVariant.Id;
     VariantTitle = thisVariant.Title;
     Vendor = thisProduct.Vendor;
     Name = thisVariant.Title;
 }
        internal bool UpdateShopifyProductTimeStamp(ShopifyProduct item, DateTime timestamp)
        {
            if (item == null)
            {
                throw new ArgumentException("Neither arguments can be null");
            }

            var query = String.Format(
                @" UPDATE ShopifyProduct SET versiondate = '{0:yyyy-MM-dd HH:mm:ss}' where id = {1} LIMIT 1;",
                timestamp, item.Id);

            var sqlCommand = new MySqlCommand(query, _dbConn);

            try
            {
                if (sqlCommand.ExecuteNonQuery() == 1)
                {
                    return true;
                }

                Logger.ErrorFormat(
                    "UpdateShopifyProductTimeStamp(): Couldnt update timestamp on ShopifyItem({0}).", item.Id);
                return false;
            }
            catch (Exception dbEx)
            {
                Logger.ErrorFormat(
                    "UpdateShopsterProductTimeStamp(): Database exception while attempting to update shopsterProduct({0}) with timestamp ({1}). " +
                    dbEx.Message, item.Id, timestamp);
                return false;
            }
        }
 public bool InsertProductForUser(ConnectsterUser user, InventoryItemType shopsterProduct,
                                  ShopifyProduct shopifyProduct)
 {
     //TODO: have this take a bool to decide if shopster is master, for now true
     //Todo: have actual dates from Shopster API, when available.
     return InsertProductForUser(user, Convert.ToInt32(shopsterProduct.ItemId), (DateTime.Now.ToUniversalTime()),
                                 (int) shopifyProduct.Id,
                                 ((DateTime) shopifyProduct.Variants[0].UpdatedAt).ToUniversalTime());
 }
        public ShopifyResponse<ShopifyProduct> UpdateProduct(ShopifyStoreAuth storeAuth, ShopifyProduct shopifyProduct)
        {
            if (shopifyProduct == null || shopifyProduct.Id == null)
            {
                throw new ArgumentNullException(
                    "shopifyProduct");
            }

            var xS = new XmlSerializer(typeof (ShopifyProduct));

            var memStream = new MemoryStream();
            var xDoc = new XmlDocument();

            xS.Serialize(memStream, shopifyProduct);
            memStream.Seek(0, SeekOrigin.Begin);
            xDoc.Load(memStream);
            memStream.Close();

            XmlDocument productResponse =
                ShopifyPutPost(
                    (_protocol + storeAuth.StoreSubDomain + _domain + "/admin/products/" + shopifyProduct.Id + ".xml"),
                    HashString(_appAuth.Secret + storeAuth.StoreAuthToken), xDoc, "PUT");

            return new ShopifyResponse<ShopifyProduct>(productResponse);
        }