最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【记录】尝试使用eBay的示例项目代码ConsoleAddItem去使用真实数据发布产品并封装成函数

eBay crifan 3442浏览 0评论

【背景】

之前在:

【记录】eBay API的开发流程

中,已经:

【记录】尝试使用ebay的示例代码ConsoleAddItem去向sandbox中添加发布商品

现在去:

继续用ConsoleAddItem,但是改为真实的某个产品的数据。

然后确定也是可以发布的。

然后,再重新整理其代码,封装成函数,单独发布产品的函数,供后续使用。

【折腾过程】

1.已经写了点代码:

        struct AmazonProductInfo
        {
            public string url; //record who it is

            public string title;
            public string description;
            //5 bullet
            public string[] bulletArr; // total 5 (or more, but only record 5)
            //download 5 pics
            public string[] imgUrlArr; // total 5 (or more, but only record 5)
            //product keyword fileds, up to 3
            public string[] keywordFieldArr; //each field, less than 50 chars, seperated by ','
            //cheapest price of total (up to 8) sellers
            public float cheapestPrice;
            public bool isOneSellerIsAmazon;
            public int reviewNumber;
            public bool isBestSeller;
            public float weightInPound;
        };

        public AmazonProductInfo generateSingleAmazonProduct()
        {
            AmazonProductInfo productInfo = new AmazonProductInfo();
            productInfo.bulletArr = new string[5];
            crl.emptyStringArray(productInfo.bulletArr);
            productInfo.imgUrlArr = new string[5];
            crl.emptyStringArray(productInfo.imgUrlArr);
            productInfo.keywordFieldArr = new string[3];
            crl.emptyStringArray(productInfo.keywordFieldArr);

            
            productInfo.url = "http://www.amazon.com/gp/product/B00A8UT562";
            productInfo.title = "Dr. Who: The Eleventh Doctor's Sonic Screwdriver";
            productInfo.description = "The Doctors multipurpose tool is a Gallifreyan device, with numerous settings, easily controlled at the press of his thumb. The Doctor has had many sonic screwdrivers of different designs throughout his life, and this latest one was created from within the TARDIS console itself after the previous one was destroyed during a confrontation with Prisoner Zero in the village of Leadworth. This new sonic is larger, with a luminous green light but continues to be an essential part of the Doctors equipment as he explores the universe. This faithful copy of the Doctors trusty Sonic Device has spring loaded extending action. Pressing the button on the side of the handle activates the LED and Sound FX which operates in CLOSED mode. Flip open the cap at the end of the Screwdriver to reveal an additional button that activates the light and sound effects when it is in full extension OPEN mode. Requires 3 x L1154 batteries.";

            //tmp not set productInfo.bulletArr/productInfo.imgUrlArr/productInfo.keywordFieldArr

            productInfo.cheapestPrice = 23.62999916F;

            productInfo.isOneSellerIsAmazon = false;

            productInfo.reviewNumber = 555;
            productInfo.isBestSeller = true;
            productInfo.weightInPound = 0.51F;
            
            return productInfo; 
        }

        public struct ebayItemInfo
        {
            public string Title;
            public string Description;
            public ListingTypeCodeType ListingType;
            public CurrencyCodeType Currency;
            public AmountType StartPrice;
            public string ListingDuration;
            public string Location;
            public CountryCodeType Country;
            public CategoryType PrimaryCategory;
            public int Quantity;
            public int ConditionID;
            public NameValueListTypeCollection ItemSpecifics;

            //public SellerProfilesType sellerProfiles; //tmp not support SellerProfiles
            public BuyerPaymentMethodCodeTypeCollection PaymentMethods;
            public string PayPalEmailAddress;
            public int DispatchTimeMax;
            public ShippingDetailsType ShippingDetails;
            public ReturnPolicyType ReturnPolicy;
        };

        public ebayItemInfo generateeBayItemInfo(AmazonProductInfo singleAmazonProduct)
        {
            ebayItemInfo eBayItem = new ebayItemInfo();
            
            eBayItem.Title = singleAmazonProduct.title;

            eBayItem.Description = singleAmazonProduct.description;

            // listing type
            eBayItem.ListingType = ListingTypeCodeType.Chinese;
            // listing price
            eBayItem.Currency = CurrencyCodeType.USD;
            eBayItem.StartPrice = new AmountType();
            eBayItem.StartPrice.Value = singleAmazonProduct.cheapestPrice;
            eBayItem.StartPrice.currencyID = CurrencyCodeType.USD;

            // listing duration
            //http://developer.ebay.com/DevZone/xml/docs/Reference/ebay/types/ListingDurationCodeType.html
            //https://developer.ebay.com/DevZone/javasdk-jaxb/docs/LibRef/com/ebay/soap/eBLBaseComponents/ListingDurationCodeType.html
            eBayItem.ListingDuration = "Days_3";

            // item location and country
            eBayItem.Location = "San Jose";
            eBayItem.Country = CountryCodeType.US;

            // listing category, 
            CategoryType primaryCategory = new CategoryType();
            primaryCategory.CategoryID = "11104"; //CategoryID = 11104 (CookBooks) , Parent CategoryID=267(Books)
            eBayItem.PrimaryCategory = primaryCategory;
            

            return eBayItem; 
        }

2.抽空再继续。

 

【总结】

转载请注明:在路上 » 【记录】尝试使用eBay的示例项目代码ConsoleAddItem去使用真实数据发布产品并封装成函数

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (1)

  1. 你好,我都在分享eBay營運經驗,有空來坐一下=] http://igo2sell.blogspot.hk/ https://igo2sell.wordpress.com/ 希望你還會繼續更新,相信很多賣家都在關注
    Riva10年前 (2015-03-10)回复
88 queries in 0.174 seconds, using 22.03MB memory