public void GetItem()
		{
			bool includeCrossPromotion=true;
			bool includeItemSpecifics=true;
			bool includeTaxTable=false;
			bool includeWatchCount=true;
			ItemType item = null;

			Assert.IsNotNull(TestData.NewItem2, "Failed because no item available -- requires successful AddItem test");
			
			GetItemCall api=new GetItemCall(this.apiContext);
			
			api.IncludeCrossPromotion = includeCrossPromotion;
			api.IncludeItemSpecifics = includeItemSpecifics;
			api.IncludeTaxTable = includeTaxTable;
			api.IncludeWatchCount = includeWatchCount;
			api.ItemID = TestData.NewItem2.ItemID;
			api.Execute();

			//check whether the call is success.
			Assert.IsTrue(api.ApiResponse.Ack==AckCodeType.Success || api.ApiResponse.Ack==AckCodeType.Warning,"do not success!");
			Assert.IsNotNull(api.ApiResponse.Item);
			item = api.ApiResponse.Item;
			Assert.IsTrue(item.ItemSpecifics.Count>0,"this is no item spcifics");
			Assert.IsTrue(item.WatchCount>=0);
		}
示例#2
0
        public void GetListingInfo(bool live, string id, out ListingInfo info)
        {
            ApiContext apiContext = GetApiContext(live);

            var getItem = new GetItemCall(apiContext);
            getItem.ItemID = id;
            try
            {
                getItem.Execute();
            }
            catch (Exception ex)
            {
                info = new ListingInfo();
                info.CurrentStatus = EbayStatus.Unlisted;
                return;
            }
            info = new ListingInfo();

            info.ViewUrl = getItem.ApiResponse.Item.ListingDetails.ViewItemURL;
            switch (getItem.ApiResponse.Item.SellingStatus.ListingStatus)
            {
                case ListingStatusCodeType.Active:
                    info.CurrentStatus = EbayStatus.InProgressBuyItNow;
                    break;
                case ListingStatusCodeType.Ended:
                    info.CurrentStatus = EbayStatus.Unsold;
                    break;
                case ListingStatusCodeType.Completed:
                    if (getItem.ApiResponse.Item.SellingStatus.QuantitySold > 0)
                    {
                        info.CurrentStatus = EbayStatus.Sold;
                        info.SoldPrice = getItem.ApiResponse.Item.SellingStatus.CurrentPrice.Value;
                    }
                    else
                    {
                        info.CurrentStatus = EbayStatus.Unsold;
                    }
                    break;
            }
        }
        private StoreProductSearchModel ConvertSearchItemToSearchItemModel(SearchItem searchItem)
        {
            StoreProductSearchModel searchProductModel = new StoreProductSearchModel();

            searchProductModel.StoreProductId = searchItem.itemId;
            searchProductModel.ProductTitle = searchItem.title;
            searchProductModel.StoreProductVariantSearchModels = new List<StoreProductVariantSearchModel>();

            searchProductModel.ImageUrl = searchItem.galleryURL;

            if (searchItem.productId != null)
            {
                searchProductModel.StoreProductId1 = searchItem.productId.Value;
            }

            //searchProductModel.unitPrice = searchItem.unitPrice.quantity,

            GetItemCall itemCall = new GetItemCall(eBayContext);

            itemCall.ItemID = searchItem.itemId;

            itemCall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);

            itemCall.Execute();

            if (itemCall.ApiResponse.Ack != AckCodeType.Failure)
            {

                ItemType item = itemCall.Item;

                if (item != null)
                {
                    if (item.Variations != null && item.Variations.Variation != null && item.Variations.Variation.Count > 0)
                    {
                        VariationsType variation = item.Variations;

                        VariationTypeCollection variationCollection = variation.Variation;

                        string pictureAttributeName = variation.Pictures[0].VariationSpecificName;

                        Dictionary<string, string> imageCollection = GetAllImages(variation);

                        foreach (VariationType vitem in variationCollection)
                        {
                            StoreProductVariantSearchModel searchVariant = new StoreProductVariantSearchModel()
                            {
                                ProductVariantTitle = vitem.VariationTitle,
                                SellerVariantSKU = vitem.SKU,
                                Price = (decimal)vitem.StartPrice.Value,
                            };

                            searchVariant.ProductVariantAttributes = new Dictionary<string, string>();

                            if (vitem.VariationSpecifics != null && vitem.VariationSpecifics.Count > 0)
                            {
                                NameValueListTypeCollection variationSpecifics = vitem.VariationSpecifics;

                                foreach (NameValueListType spec in variationSpecifics)
                                {
                                    if(spec.Name == pictureAttributeName)
                                    {
                                        if(imageCollection.ContainsKey(spec.Value[0]))
                                        {
                                            searchVariant.productVariantImageUrl = imageCollection[spec.Value[0]];
                                        }
                                    }

                                    searchVariant.ProductVariantAttributes.Add(spec.Name, string.Join(";", spec.Value.ToArray()));

                                }

                            }

                            searchProductModel.StoreProductVariantSearchModels.Add(searchVariant);
                        }
                    }
                }

            }

            return searchProductModel;
        }