예제 #1
0
        public Products GetHardGoods(string args, bool bTerse, int ipage, string postalcode, string radius)
        {
            // Note: Filter out accessories in favor of actual hard goods (ie: ipod, not ipod earbuds)??

            args = args.Replace(" ", "%20");
            string search = "type='HardGood'"
                            + "&name='" + args + "*'";
            string sort  = "&sort=regularPrice.desc";
            string show  = "";
            string spage = "";
            string area  = "";

            if (bTerse)
            {
                show = "&show=sku,productId,name,type,regularPrice,salePrice,url,inStoreAvailability,onlineAvailability,thumbnailImage";
            }
            if (postalcode != null && radius != null)
            {
                area = "+stores(area(" + postalcode + "," + radius + "))";
                if (bTerse)
                {
                    show += ",stores";
                }
            }
            if (ipage > 0)
            {
                spage = "&page=" + ipage.ToString();
            }

            Products list = UTF8XmlSerializer.Deserialize <Products>(Get(PRODUCT + "(" + search + ")" + area + "?apiKey=" + APIKEY + sort + show + spage));

            /*
             * int totalpages = 0;
             * int next = 0;
             * try
             * {
             *  totalpages = Convert.ToInt32(list.TotalPages);
             *  next = Convert.ToInt32(list.CurrentPage) + 1;
             * }
             * catch (Exception ex) { }
             *
             * list.RemoveAll(delegate(Product p) { return !p.Type.Contains("HardGood"); });
             *
             * if (list.Count == 0 && totalpages > 0 && next <= totalpages)
             * {
             *  list.AddRange(this.GetHardGoods(args, bTerse, next));
             * }
             *
             * foreach (Product p in list) { p.generateImageUrl(); };
             */

            return(list);
        }
예제 #2
0
        public Products GetProduct(string skuid, bool bTerse, string postalcode, string radius)
        {
            string search = "sku='" + skuid + "'";
            string show   = "";
            string area   = "";

            if (bTerse)
            {
                show = "&show=sku,productId,name,type,regularPrice,salePrice,url,inStoreAvailability,onlineAvailability,thumbnailImage";
            }
            if (postalcode != null && radius != null)
            {
                area = "+stores(area(" + postalcode + "," + radius + "))";
                if (bTerse)
                {
                    show += ",stores";
                }
            }

            Products p = UTF8XmlSerializer.Deserialize <Products>(Get(PRODUCT + "(" + search + ")" + area + "?apiKey=" + APIKEY + show));

            return(p);
        }
예제 #3
0
 public String ToXml()
 {
     return(UTF8XmlSerializer.Serialize(this));
 }