public void GetProductSearchResults()
        {
            this.apiContext.Timeout = 360000;
            GetProductSearchResultsCall api = new GetProductSearchResultsCall(this.apiContext);
            ProductSearchType ps = new ProductSearchType();
            //ps.AttributeSetID = 1785;// Cell phones
            ps.MaxChildrenPerFamily = 20; ps.MaxChildrenPerFamilySpecified = true;
            ps.AvailableItemsOnly = false; ps.AvailableItemsOnlySpecified = true;
            ps.QueryKeywords = "Nokia";
            StringCollection ids = new StringCollection();
            ids.Add("1785");
            ps.CharacteristicSetIDs = ids;
            // Pagination
            PaginationType pt = new PaginationType();
            pt.EntriesPerPage = 50; pt.EntriesPerPageSpecified = true;
            pt.PageNumber = 1; pt.PageNumberSpecified = true;
            ps.Pagination = pt;

            ProductSearchTypeCollection pstc = new ProductSearchTypeCollection();
            pstc.Add(ps);
            // Make API call.
            ProductSearchResultTypeCollection results = api.GetProductSearchResults(pstc);
            Assert.IsNotNull(results);
            Assert.IsTrue(results.Count > 0);
            TestData.ProductSearchResults = results;
            Assert.IsNotNull(TestData.ProductSearchResults);
            Assert.IsTrue(TestData.ProductSearchResults.Count > 0);
        }
示例#2
0
        public void GetProducts()
        {
            GetProductsCall api = new GetProductsCall(this.apiContext);
            //
            ProductSearchType prodSearchType = new ProductSearchType();
            prodSearchType.ProductID = "556677";
            prodSearchType.AttributeSetID = 123;
            prodSearchType.ProductReferenceID = "44462740";
            //
            ProductSortCodeType productSortCodeType = ProductSortCodeType.PopularityAsc;
            //
            AffiliateTrackingDetailsType affTrackingDetailsType = new AffiliateTrackingDetailsType();
            affTrackingDetailsType.TrackingID = "trackId";
            affTrackingDetailsType.AffiliateUserID = "UserId";
            affTrackingDetailsType.TrackingPartnerCode = "PartnerCode";
            //
            api.Site = SiteCodeType.US;

            try
            {
                CharacteristicsSetProductHistogramType products =
                    api.GetProducts(prodSearchType, productSortCodeType, true, false, true, false, affTrackingDetailsType,true);
            }
            catch(ApiException apie)
            {
                Console.WriteLine("ApiException: " + apie.Message);
            }
            catch(SdkException sdke)
            {
                Assert.Fail("SdkException: " + sdke.Message);
            }
        }
 public void GetProductFamilyMembers()
 {
     Assert.IsNotNull(TestData.ProductSearchResults);
     GetProductFamilyMembersCall api = new GetProductFamilyMembersCall(this.apiContext);
     ProductFamilyTypeCollection fm = TestData.ProductSearchResults[0].AttributeSet[0].ProductFamilies;
     ProductType parent = fm[0].ParentProduct;
     ProductSearchType ps = new ProductSearchType();
     ps.AttributeSetID = parent.CharacteristicsSet.AttributeSetID;
     ps.ProductID = parent.productID;
     api.ProductSearchList = new ProductSearchTypeCollection();
     api.ProductSearchList.Add(ps);
     // Make API call.
     api.Execute();
     ProductSearchResultTypeCollection results = api.ApiResponse.ProductSearchResult;
     Assert.IsNotNull(results);
     Assert.IsTrue(results.Count > 0);
 }
        public IQueryable<Product> GetProductsByCriteria(ProductSearchType searchType, string category, string productName)
        {
            IQueryable<Product> products = null;

            switch (searchType)
            {
                case ProductSearchType.None:
                    products = rep.GetAll();
                    break;
                case ProductSearchType.ByCategory:
                    products = rep.GetAll().Where(cu => cu.Category == category);
                    break;
                case ProductSearchType.ByName:
                    products = rep.GetAll().Where(cu => cu.Name == productName);
                    break;
            }

            return products;
        }
示例#5
0
        public void AddItemFull3()
        {
            bool isSucess,isProductSearchPageAvailable;
            bool existing=false,isbnExisting=false;
            string message;
            Int32Collection attributes=new Int32Collection();
            CategoryTypeCollection categories=null;
            CharacteristicsSetTypeCollection characteristics=null;

            ItemType item= ItemHelper.BuildItem();
            //check whether the category is catalog enabled.
            isSucess=CategoryHelper.IsCatagoryEnabled(this.apiContext,PSPACATEGORYID.ToString(),CategoryEnableCodeType.ProductSearchPageAvailable,out isProductSearchPageAvailable,out message);
            Assert.IsTrue(isSucess,message);
            Assert.IsTrue(isProductSearchPageAvailable,message);
            isSucess=CategoryHelper.IsCatagoryEnabled(this.apiContext,PSPACATEGORYID.ToString(),CategoryEnableCodeType.CatalogEnabled,out isProductSearchPageAvailable,out message);
            Assert.IsTrue(isSucess,message);
            Assert.IsTrue(isProductSearchPageAvailable,message);
            //modify item information approporiately.
            item.PrimaryCategory.CategoryID=PSPACATEGORYID.ToString();
            item.Description = "check whether the item can be added by GetProductSearchPage method way,This is a test item created by eBay SDK SanityTest.";

            //get characters information using GetCategory2CSCall
            GetCategory2CSCall csCall=new GetCategory2CSCall(this.apiContext);

            DetailLevelCodeTypeCollection levels=new DetailLevelCodeTypeCollection();
            DetailLevelCodeType level=new DetailLevelCodeType();
            level=DetailLevelCodeType.ReturnAll;
            levels.Add(level);
            csCall.DetailLevelList=levels;
            csCall.CategoryID=PSPACATEGORYID.ToString();
            csCall.Execute();
            //check whether the call is success.
            Assert.IsTrue(csCall.AbstractResponse.Ack==AckCodeType.Success || csCall.AbstractResponse.Ack==AckCodeType.Warning,"do not success!");
            Assert.IsNotNull(csCall.ApiResponse.MappedCategoryArray);
            Assert.Greater(csCall.ApiResponse.MappedCategoryArray.Count,0);
            categories=csCall.ApiResponse.MappedCategoryArray;

            foreach(CategoryType category in categories)
            {
                if(string.Compare(category.CategoryID,PSPACATEGORYID)==0)
                {
                    characteristics=category.CharacteristicsSets;
                    existing= true;
                    break;
                }
            }

            //confirm that the category was in the mapping category.
            Assert.IsTrue(existing,PSPACATEGORYID+" do not exist in the mapping category");
            Assert.IsNotNull(characteristics);
            Assert.Greater(characteristics.Count,0);

            foreach(CharacteristicsSetType characteristic in characteristics)
            {
                attributes.Add(characteristic.AttributeSetID);
            }

            //confirm that there is real attributeset in the mapping category.
            Assert.AreEqual(attributes.Count,1);//there is only one AttributeSetID in the category 279.

            GetProductSearchPageCall searchPageCall=new GetProductSearchPageCall(this.apiContext);
            searchPageCall.AttributeSetIDList=attributes;
            DetailLevelCodeTypeCollection levels2=new DetailLevelCodeTypeCollection();
            DetailLevelCodeType level2=new DetailLevelCodeType();
            level2=DetailLevelCodeType.ReturnAll;
            levels2.Add(level2);
            searchPageCall.DetailLevelList=levels2;
            searchPageCall.Execute();
            //check whether the call is success.
            Assert.IsTrue(searchPageCall.ApiResponse.Ack==AckCodeType.Success || searchPageCall.ApiResponse.Ack==AckCodeType.Warning,"do not success!");
            Assert.AreEqual(searchPageCall.ApiResponse.ProductSearchPage.Count,1);//for the input attributeset id is only one.
            Assert.IsNotNull(searchPageCall.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet);//for the input attributeset id is only one.
            Assert.IsNotNull(searchPageCall.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet.Characteristics);
            Assert.Greater(searchPageCall.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet.Characteristics.Count,0);

            //check the isbn-13 attribute id exists and its value has not been changed.
            CharacteristicTypeCollection chs = searchPageCall.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet.Characteristics;
            foreach(CharacteristicType charactersic in chs)
            {
                //check whether the isbn attribute can be used
                if(charactersic.AttributeID==ISBN13ATTRIBUTEID && (string.Compare(charactersic.Label.Name,"ISBN-13",true)==0))
                {
                    isbnExisting=true;
                    break;
                }
            }

            Assert.IsTrue(isbnExisting,"the isbn attribute id is not existing or has been changed!");
            //using GetProductSearchResults call to find products.
            ProductSearchType productSearch=new ProductSearchType();
            productSearch.AttributeSetID=attributes[0];
            SearchAttributesTypeCollection searchAttributes=new SearchAttributesTypeCollection();
            SearchAttributesType searchAttribute=new SearchAttributesType();
            searchAttribute.AttributeID=ISBN13ATTRIBUTEID;
            ValTypeCollection vals=new ValTypeCollection();
            ValType val=new ValType();
            val.ValueLiteral=ISBN;
            vals.Add(val);
            searchAttribute.ValueList=vals;
            searchAttributes.Add(searchAttribute);
            productSearch.SearchAttributes=searchAttributes;
            GetProductSearchResultsCall searchResultsCall=new GetProductSearchResultsCall(this.apiContext);
            searchResultsCall.ProductSearchList=new ProductSearchTypeCollection(new ProductSearchType[]{productSearch});
            searchResultsCall.Execute();
            //check whether the call is success.
            Assert.IsTrue(searchResultsCall.ApiResponse.Ack==AckCodeType.Success || searchResultsCall.ApiResponse.Ack==AckCodeType.Warning,"do not success!");
            Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult.Count,0);
            Assert.AreEqual(int.Parse(searchResultsCall.ApiResponse.ProductSearchResult[0].NumProducts),1);
            Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet.Count,0);
            Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies.Count,0);
            Assert.IsFalse(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies[0].hasMoreChildren);
            Assert.IsNotNull(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies[0].ParentProduct.productID);

            string productID=searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies[0].ParentProduct.productID;
            ProductListingDetailsType plist=new ProductListingDetailsType();
            plist.ProductID=productID;
            plist.IncludePrefilledItemInformation=true;
            plist.IncludeStockPhotoURL=true;
            item.ProductListingDetails=plist;

            FeeTypeCollection fees;

            VerifyAddItemCall vi = new VerifyAddItemCall(apiContext);
            fees = vi.VerifyAddItem(item);
            Assert.IsNotNull(fees);

            AddItemCall addItemCall = new AddItemCall(apiContext);;
            fees = addItemCall.AddItem(item);
            //check whether the call is success.
            Assert.IsTrue(addItemCall.AbstractResponse.Ack==AckCodeType.Success || addItemCall.AbstractResponse.Ack==AckCodeType.Warning,"do not success!");
            Assert.IsTrue(item.ItemID!=string.Empty);
            Assert.IsNotNull(fees);

            //caution check
            ItemType itemOut;
            isSucess=ItemHelper.GetItem(item,this.apiContext,out message, out itemOut);
            Assert.IsTrue(isSucess,message);
            Assert.IsNotNull(itemOut,"Item is null");
            Assert.Greater(itemOut.AttributeSetArray.Count,0);
            Assert.Greater(itemOut.AttributeSetArray[0].Attribute.Count,0);
            Assert.Greater(itemOut.AttributeSetArray[0].Attribute[0].Value.Count,0);
        }
示例#6
0
        /// <summary>
        /// Searches for stock information and reviews for certain kinds of products,
        /// such as a particular digital camera model.
        /// <p>
        /// GetProducts is designed to be useful to applications that support
        /// shopping comparison, product reviews, or basic supply and
        /// demand data.
        /// </p>
        /// <p>
        /// GetProducts also supports tracking so that members of the
        /// eBay Affiliates Program can get commissions for driving traffic to eBay.
        /// </p>
        /// <p class="tablenote"><b>Note:</b>
        /// For selling use cases, use GetProductSearchResults and
        /// GetProductSellingPages instead.
        /// </p>
        /// <p>
        /// To use this call, you typically pass in keywords, and GetProducts finds
        /// products with matching words in the product title, description, and/or
        /// Item Specifics.
        /// <p>
        /// For each product of interest, you call GetProducts again to retrieve
        /// additional details that would be useful to buyers:
        /// </p>
        /// <ul>
        /// <li>Top reviews of the product by eBay members,
        /// including part of the review text, plus links to the full text on the
        /// eBay Web site.</li>
        /// <li>Relevant buying guides (shopping advice) written by
        /// eBay members and by eBay staff, including part of the guide text,
        /// plus links to the full text
        /// on the eBay Web site.</li>
        /// <li>Up to 200 matching items on eBay (if any). (To find more matching
        /// items, use GetSearchResults.)</li>
        /// </ul>
        /// <p>
        /// <span class="tablenote"><b>Note:</b>
        /// As catalog queries can take longer than item queries,
        /// GetProducts can be slower than GetSearchResults.
        /// Also, due to the way product data is cached, you may get a faster response
        /// when you run the same query a second time.</span>
        /// </summary>
        /// 
        /// <param name="ProductSearch">
        /// Contains the fields that form the search query. You can query
        /// against keywords, an eBay product reference ID (not to be confused
        /// with an eBay product ID), or external product ID (like an ISBN).
        /// </param>
        ///
        /// <param name="ProductSort">
        /// Sorts the list of products returned. This is mostly only useful
        /// with QueryKeywords. (When you use ExternalProductID or
        /// ProductReferenceID, eBay usually only returns one product.)
        /// </param>
        ///
        /// <param name="IncludeItemArray">
        /// If true, the response includes items (if any) that match the
        /// product specified in ExternalProductID or ProductReferenceID.
        /// Not applicable with QueryKeywords.
        /// </param>
        ///
        /// <param name="IncludeReviewDetails">
        /// If true, the response includes up to 20 reviews (if any)
        /// for the product specified in ExternalProductID or
        /// ProductReferenceID.
        /// The reviews are sorted by most helpful (most votes) first.
        /// When you include review details, please note that
        /// response times may be longer than 60 seconds.
        /// Not applicable with QueryKeywords.
        /// </param>
        ///
        /// <param name="IncludeBuyingGuideDetails">
        /// If true, the response includes up to 5 buying guides (if any)
        /// for the product specified in ExternalProductID or
        /// ProductReferenceID.
        /// Not applicable with QueryKeywords.
        /// </param>
        ///
        /// <param name="IncludeHistogram">
        /// If true, the response includes a histogram that lists the
        /// number of matching products found and the domains in which
        /// they were found. (A domain is like a high-level category.)
        /// Including the histogram can affect the call's performance.
        /// You may see significantly slower response times when many
        /// matching products are found.
        /// </param>
        ///
        /// <param name="AffiliateTrackingDetails">
        /// See the
        /// <a href="https://www.ebaypartnernetwork.com/" target="_blank">eBay Partner Network</a>.
        /// eBay uses the values in AffiliateTrackingDetails to build a View Item URL
        /// string, in order to include that string in the response.
        /// When a user clicks through the URL to eBay,
        /// you may get a commission (see the URL above).
        /// Only applicable when IncludeItemArray is specified
        /// (because the View Item URL is only returned in item information,
        /// not in product information).
        /// </param>
        ///
        /// <param name="HideDuplicateItems">
        /// Specifies whether or not to remove duplicate items from search results.
        /// When set to true, and there are duplicate items for an item in the
        /// search results, the subsequent duplicates will not appear in the
        /// results.
        /// Item listings are considered duplicates in the following
        /// conditions: 
        /// <ul>
        /// <li>Items are listed by the same seller</li>
        /// <li>Items have exactly the same item title</li>
        /// <li>Items have similar listing formats</li>
        /// <ul>
        /// <li>Auctions: Auction Items, Auction BIN items, Multi-Quantity
        /// Auctions, and Multi-Quantity Auctions BIN items</li>
        /// <li>Fixed Price: Fixed Price, Multi-quantity Fixed Price, Fixed
        /// Price with Best Offer, and Store Inventory Format items</li>
        /// <li>Classified Ads</li>
        /// </ul>
        /// </ul>
        /// For Auctions, items must also have the same price and number of bids to
        /// be considered duplicates.
        /// 
        /// Filtering of duplicate item listings is not supported on all sites.
        /// For GetProducts, this filter only works when IncludeItemArray is set to
        /// true.
        /// </param>
        ///
        public CharacteristicsSetProductHistogramType GetProducts(ProductSearchType ProductSearch, ProductSortCodeType ProductSort, bool IncludeItemArray, bool IncludeReviewDetails, bool IncludeBuyingGuideDetails, bool IncludeHistogram, AffiliateTrackingDetailsType AffiliateTrackingDetails, bool HideDuplicateItems)
        {
            this.ProductSearch = ProductSearch;
            this.ProductSort = ProductSort;
            this.IncludeItemArray = IncludeItemArray;
            this.IncludeReviewDetails = IncludeReviewDetails;
            this.IncludeBuyingGuideDetails = IncludeBuyingGuideDetails;
            this.IncludeHistogram = IncludeHistogram;
            this.AffiliateTrackingDetails = AffiliateTrackingDetails;
            this.HideDuplicateItems = HideDuplicateItems;

            Execute();
            return ApiResponse.CharacteristicsSetProductHistogram;
        }
示例#7
0
 private IList<ProductDTO> getProducts(ProductSearchType searchType, string name, string category)
 {
     try
     {
         GetProductsRequest request = new GetProductsRequest();
         request.SearchType = searchType;
         request.ProductName = name;
         request.Category = category;
         GetProductsResponse response = Service.GetProductsByCriteria(request);
         return response.Products;
     }
     catch (Exception ex)
     {
         if (ExceptionPolicy.HandleException(ex, "PL Policy")) throw;
         return new List<ProductDTO>();
     }
 }
        public void GetProductSearchResultsFull()
        {
            bool isbnExisting=false;
            Int32Collection attributes=new Int32Collection();

            Assert.IsNotNull(TestData.ProductSearchPages2);
            Assert.Greater(TestData.ProductSearchPages2.Count,0);
            Assert.Greater(TestData.ProductSearchPages2[0].SearchCharacteristicsSet.Characteristics.Count,0);

            //check whether the call is success.
            Assert.AreEqual(string.Compare(TestData.Category2CS2.CategoryID,PSPACATEGORYID,true),0);
            CharacteristicsSetTypeCollection characteristics = TestData.Category2CS2.CharacteristicsSets;

            //confirm that the category was in the mapping category.
            Assert.IsNotNull(characteristics);
            Assert.Greater(characteristics.Count,0);

            foreach(CharacteristicsSetType characteristic in characteristics)
            {
                attributes.Add(characteristic.AttributeSetID);
            }

            //check the isbn-13 attribute id exists and its value has not been changed.
            CharacteristicTypeCollection chs = TestData.ProductSearchPages2[0].SearchCharacteristicsSet.Characteristics;
            foreach(CharacteristicType charactersic in chs)
            {
                //check whether the isbn attribute can be used
                if(charactersic.AttributeID==ISBN13ATTRIBUTEID && (string.Compare(charactersic.Label.Name,"ISBN-13",true)==0))
                {
                    isbnExisting=true;
                    break;
                }
            }

            Assert.IsTrue(isbnExisting,"the isbn attribute id is not existing or has been changed!");
            //using GetProductSearchResults call to find products.
            ProductSearchType productSearch=new ProductSearchType();
            productSearch.AttributeSetID=attributes[0];
            SearchAttributesTypeCollection searchAttributes=new SearchAttributesTypeCollection();
            SearchAttributesType searchAttribute=new SearchAttributesType();
            searchAttribute.AttributeID=ISBN13ATTRIBUTEID;
            ValTypeCollection vals=new ValTypeCollection();
            ValType val=new ValType();
            val.ValueLiteral=ISBN;
            vals.Add(val);
            searchAttribute.ValueList=vals;
            searchAttributes.Add(searchAttribute);
            productSearch.SearchAttributes=searchAttributes;
            GetProductSearchResultsCall searchResultsCall=new GetProductSearchResultsCall(this.apiContext);
            searchResultsCall.ProductSearchList=new ProductSearchTypeCollection(new ProductSearchType[]{productSearch});
            searchResultsCall.Execute();
            //check whether the call is success.
            Assert.IsTrue(searchResultsCall.ApiResponse.Ack==AckCodeType.Success || searchResultsCall.ApiResponse.Ack==AckCodeType.Warning,"do not success!");
            Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult.Count,0);
            Assert.AreEqual(int.Parse(searchResultsCall.ApiResponse.ProductSearchResult[0].NumProducts),1);
            Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet.Count,0);
            Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies.Count,0);
            Assert.IsFalse(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies[0].hasMoreChildren);
            Assert.IsNotNull(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies[0].ParentProduct.productID);
            TestData.ProductSearchResults2 = searchResultsCall.ApiResponse.ProductSearchResult;
        }