public static ShoppingListDraft DefaultShoppingListDraftWithTextLineItems(ShoppingListDraft draft) { var shoppingListDraft = DefaultShoppingListDraft(draft); var textLineItemDraft1 = new TextLineItemDraft { Name = new LocalizedString { { "en", $"TextLineItem1" } }, Quantity = 1 }; var textLineItemDraft2 = new TextLineItemDraft { Name = new LocalizedString { { "en", $"TextLineItem2" } }, Quantity = 2 }; var textLineItemDraft3 = new TextLineItemDraft { Name = new LocalizedString { { "en", $"TextLineItem3" } }, Quantity = 3 }; shoppingListDraft.TextLineItems = new List <TextLineItemDraft> { textLineItemDraft1, textLineItemDraft2, textLineItemDraft3 }; return(shoppingListDraft); }
public static async Task WithUpdateableShoppingListWithTextLineItemWithCustomFields(IClient client, long quantity, Func <ShoppingList, Task <ShoppingList> > func) { await WithType(client, async type => { var fields = CreateNewFields(); var customFieldsDraft = new CustomFieldsDraft { Type = type.ToKeyResourceIdentifier(), Fields = fields }; var textLineItemDraft = new TextLineItemDraft { Quantity = quantity, Name = new LocalizedString { { "en", TestingUtility.RandomString() } }, Custom = customFieldsDraft }; var shoppingListDraft = new ShoppingListDraft(); shoppingListDraft.TextLineItems = new List <TextLineItemDraft> { textLineItemDraft }; await WithUpdateableAsync(client, shoppingListDraft, DefaultShoppingListDraft, func); }); }
public static ShoppingListDraft DefaultShoppingListDraftWithKey(ShoppingListDraft draft, string key) { var shoppingListDraft = DefaultShoppingListDraft(draft); shoppingListDraft.Key = key; return(shoppingListDraft); }
public ShoppingList CreateShoppingList(ShoppingListDraft shoppingListDraft) { IClient commerceToolsClient = this.GetService <IClient>(); ShoppingList shoppingList = commerceToolsClient.ExecuteAsync(new CreateCommand <ShoppingList>(shoppingListDraft)).Result; return(shoppingList); }
public static async Task WithUpdateableShoppingListWithLineItemWithCustomFields(IClient client, long quantity, Func <ShoppingList, Task <ShoppingList> > func) { await WithType(client, async type => { await WithProduct(client, async product => { var fields = CreateNewFields(); var customFieldsDraft = new CustomFieldsDraft { Type = type.ToKeyResourceIdentifier(), Fields = fields }; var lineItemDraft = new LineItemDraft { Quantity = quantity, ProductId = product.Id, Custom = customFieldsDraft }; var shoppingListDraft = new ShoppingListDraft(); shoppingListDraft.LineItems = new List <LineItemDraft> { lineItemDraft }; await WithUpdateableAsync(client, shoppingListDraft, DefaultShoppingListDraft, func); }); }); }
public void CreateShoppingList() { IClient commerceToolsClient = this.shoppingListFixture.GetService <IClient>(); ShoppingListDraft shoppingListDraft = this.shoppingListFixture.GetShoppingListDraft(withLineItem: true); ShoppingList shoppingList = commerceToolsClient .ExecuteAsync(new CreateCommand <ShoppingList>(shoppingListDraft)).Result; this.shoppingListFixture.ShoppingListToDelete.Add(shoppingList); Assert.Equal(shoppingListDraft.Key, shoppingList.Key); }
public static ShoppingListDraft DefaultShoppingListDraft(ShoppingListDraft shoppingListDraft) { var random = TestingUtility.RandomInt(); shoppingListDraft.Key = $"Key_{random}"; shoppingListDraft.Name = new LocalizedString() { { "en", $"ShoppingList_{random}" } }; return(shoppingListDraft); }
public static ShoppingListDraft DefaultShoppingListDraftWithSingleLineItem(ShoppingListDraft draft, Product product) { var shoppingListDraft = DefaultShoppingListDraft(draft); var lineItemDraft1 = new LineItemDraft { ProductId = product.Id, Quantity = 1 }; shoppingListDraft.LineItems = new List <LineItemDraft> { lineItemDraft1 }; return(shoppingListDraft); }
public static ShoppingListDraft DefaultShoppingListDraftWithCustomType(ShoppingListDraft draft, Type type, Fields fields) { var customFieldsDraft = new CustomFieldsDraft { Type = type.ToKeyResourceIdentifier(), Fields = fields }; var shoppingListDraft = DefaultShoppingListDraft(draft); shoppingListDraft.Custom = customFieldsDraft; return(shoppingListDraft); }
public static async Task WithUpdateableShoppingListWithTextLineItem(IClient client, long quantity, Func <ShoppingList, Task <ShoppingList> > func) { var textLineItemDraft = new TextLineItemDraft { Quantity = quantity, Name = new LocalizedString { { "en", TestingUtility.RandomString() } } }; var shoppingListDraft = new ShoppingListDraft(); shoppingListDraft.TextLineItems = new List <TextLineItemDraft> { textLineItemDraft }; await WithUpdateableAsync(client, shoppingListDraft, DefaultShoppingListDraft, func); }
public static async Task WithUpdateableShoppingListWithLineItem(IClient client, long quantity, Func <ShoppingList, Task <ShoppingList> > func) { await WithProduct(client, async product => { var lineItemDraft = new LineItemDraft { Quantity = quantity, ProductId = product.Id }; var shoppingListDraft = new ShoppingListDraft(); shoppingListDraft.LineItems = new List <LineItemDraft> { lineItemDraft }; await WithUpdateableAsync(client, shoppingListDraft, DefaultShoppingListDraft, func); }); }
/// <summary> /// Get ShoppingList Draft /// </summary> /// <returns></returns> public ShoppingListDraft GetShoppingListDraft(bool withCustomer = true, bool withLineItem = false) { string name = $"ShoppingList_{TestingUtility.RandomInt()}"; ShoppingListDraft shoppingListDraft = new ShoppingListDraft { Key = TestingUtility.RandomString(10), Slug = new LocalizedString() { { "en", name } }, Name = new LocalizedString() { { "en", name } }, DeleteDaysAfterLastModification = 30 }; if (withCustomer) { Customer customer = this.customerFixture.CreateCustomer(); this.customerFixture.CustomersToDelete.Add(customer); shoppingListDraft.Customer = new ResourceIdentifier <Customer> { Id = customer.Id }; } if (withLineItem) { Product product = this.CreateProduct(); LineItemDraft lineItemDraft = this.GetLineItemDraftBySku(product.MasterData.Current.MasterVariant.Sku, 2); shoppingListDraft.LineItems = new List <LineItemDraft>() { lineItemDraft }; } return(shoppingListDraft); }
public static ShoppingListDraft DefaultShoppingListDraftInStore(ShoppingListDraft draft, IReferenceable <Store> store) { draft.Store = store; return(draft); }