public void GetEtsyShopListingAll()
        {
            int shopId = testShops["C"];

            EtsyAPIProxy ec = this.etsyAPI;
            EtsyDataContainer <Listing> requestedShop = ec.GetActiveListingsByShop(shopId, limit: 6);

            Assert.Equal <int>(requestedShop.Count, requestedShop.Results.Count);
        }
        public void GetEtsyShopListing()
        {
            int shopId = testShops["A"];

            EtsyAPIProxy   ec            = this.etsyAPI;
            List <Listing> requestedShop = ec.GetActiveListingsByShop(shopId, 100, 0).Results;

            Assert.True(requestedShop.Count > 0);
        }
        public void GetInvalidShopID()
        {
            int invalidShopID = int.MaxValue;

            EtsyAPIProxy ec = this.etsyAPI;

            EtsyDataContainer <Listing> requestedShop = ec.GetActiveListingsByShop(invalidShopID, 100, 0);

            Assert.Null(requestedShop);
        }
Beispiel #4
0
        /// <summary>
        /// Determine the difference in listing from now to the last cached listing.
        /// </summary>
        /// <param name="shopID"></param>
        /// <returns></returns>
        public InventoryStatus GetInventoryStatus(int shopID)
        {
            Shop shop = getShopSmart(shopID);

            //Indicated that ShopId Invalud
            if (shop is null)
            {
                return(new InventoryStatus()
                {
                    Shop = new Shop()
                    {
                        Shop_id = shopID,
                        Shop_name = null
                    },
                    IsShopIdValid = false
                });
            }


            ShopInventory previousInventoryState         = syncDatabase.ReadShopInventory(shopID);
            EtsyDataContainer <Listing> listingsFromEtsy = estyAPI.GetActiveListingsByShop(shopID);

            syncDatabase.PersistShopInventory(shop, listingsFromEtsy.Results);

            //Indicates first time request for synchronization.
            if (previousInventoryState == null)
            {
                return(new InventoryStatus()
                {
                    Shop = shop,
                    AsOfDate = DateTime.Today,
                    Added = listingsFromEtsy.Results,
                    Removed = new List <Listing>()
                });
            }

            //Determine the changes between the two lists.
            Deltas <Listing> deltas = determineListingsDeltas(listingsFromEtsy, previousInventoryState.Listings);

            InventoryStatus invStat = new InventoryStatus()
            {
                Shop     = shop,
                AsOfDate = DateTime.Today,
                Added    = deltas.Adds,
                Removed  = deltas.Deletes
            };

            return(invStat);
        }
Beispiel #5
0
        public void PersistInventory()
        {
            int shopId = 19099945;

            EtsyAPIProxy ec = this.etsyAPI;

            List <Shop> requestedShops = ec.GetShops(new int[] { shopId }, 100, 0).Results;
            Shop        shop           = requestedShops[0];


            List <Listing> reqListing   = ec.GetActiveListingsByShop(shopId, 100, 0).Results;
            int            listingCount = reqListing.Count;

            this.syncDatabase.PersistShopInventory(shop, reqListing);


            List <ShopInventory> shopInventorys = this.syncDatabase.ReadShopInventory(new int[] { shopId });
            int persistedListingCount           = shopInventorys[0].Listings.Count;


            Assert.Equal(listingCount, persistedListingCount);
        }