public void post_adds_inventory_item() { var warehouseCode = "default"; var entryCode = "SKU-35278811"; var model = new WarehouseInventory { AllowBackorder = true, AllowPreorder = true, BackorderAvailabilityDate = DateTime.UtcNow, BackorderQuantity = 2, CatalogEntryCode = entryCode, InStockQuantity = 23, InventoryStatus = "Enabled", PreorderAvailabilityDate = DateTime.UtcNow, PreorderQuantity = 3, ReorderMinQuantity = 1, ReservedQuantity = 1, WarehouseCode = warehouseCode }; GetCatalogs(); GetFirst10Entries(); GetEntry(entryCode); PostXml(model); Post(model); Get(model); Delete(model); }
private void Delete(WarehouseInventory model) { var response = Client.DeleteAsync($"/episerverapi/commerce/entries/{model.CatalogEntryCode}/inventories/{model.WarehouseCode}") .Result; if (!response.IsSuccessStatusCode) { throw new Exception($"Delete failed! Status: {response.StatusCode}"); } }
private void Post(WarehouseInventory model) { var json = JsonConvert.SerializeObject(model); var response = Client.PostAsync($"/episerverapi/commerce/entries/{model.CatalogEntryCode}/inventories", new StringContent(json, Encoding.UTF8, "application/json")) .Result; if (!response.IsSuccessStatusCode) { throw new Exception($"Post failed! Status: {response.StatusCode}"); } }
private void PostXml(WarehouseInventory model) { var xml = SerializeXml(model); AcceptXml(); var response = Client.PostAsync($"/episerverapi/commerce/entries/{model.CatalogEntryCode}/inventories", new StringContent(xml, Encoding.Unicode, "application/xml")) .Result; RemoveAcceptXml(); var message = response.Content.ReadAsStringAsync().Result; if (!response.IsSuccessStatusCode) { throw new Exception($"Post failed! Status: {response.StatusCode}. Message: {message}"); } }