public async Task ApiV3WCObject_GetVariationsToUpdate() { var skusQuantities = new Dictionary <string, int> { { Testsku, 21 }, { "testsku2", 23 } }; const int productIdNew = 2; const int productIdExisting = 1; var variationsToUpdate = new Dictionary <ProductId, IEnumerable <QuantityUpdate> > { { new ProductId(productIdExisting), new List <QuantityUpdate>() } }; const string nonManagedSku = "testsku2"; ApiV3WCObject.GetVariationsToUpdate(skusQuantities, await CollectVariationsByProductFromAllPagesAsync(nonManagedSku, 11), productIdNew, variationsToUpdate); Assert.AreEqual(productIdExisting, variationsToUpdate.First().Key.Id); var secondProduct = variationsToUpdate.Skip(1).First(); Assert.AreEqual(1, secondProduct.Value.Count()); var newVariation = secondProduct.Value.First(); Assert.AreEqual(skusQuantities.First().Key, newVariation.Sku); Assert.AreEqual(skusQuantities.First().Value, newVariation.Quantity); }
public async Task ApiV3WCObject_GetProductsAndVariationsToUpdateAsync() { var testsku2 = "testsku2"; var skusQuantities = new Dictionary <string, int> { { Testsku, 21 }, { testsku2, 23 } }; const int pageSize = 10; var productsToUpdate = new List <QuantityUpdate>(); await ApiV3WCObject.GetProductsAndVariationsToUpdateAsync(async filter => await GetNextProductPageAsync(filter, testsku2), async productId => await Task.FromResult(new List <WooCommerceVariation>()), skusQuantities, pageSize, productsToUpdate, new Dictionary <ProductId, IEnumerable <QuantityUpdate> >()); Assert.AreEqual(1, productsToUpdate.Count); var product = productsToUpdate.First(); Assert.AreEqual(skusQuantities[Testsku], product.Quantity); }
public void Initialize() { this._apiV3WcObject = new ApiV3WCObject(new RestAPI(base.Config.ShopUrl + "wp-json/wc/v3/", base.Config.ConsumerKey, base.Config.ConsumerSecret)); }