public async Task UpdateDiscountCodeSetCustomField() { var fields = CreateNewFields(); var newValue = TestingUtility.RandomString(10); await WithType(client, async type => { await WithUpdateableDiscountCodeWithCustomType(client, type, fields, async discountCode => { var updateActions = new List <UpdateAction <DiscountCode> >(); var setCustomFieldUpdateAction = new SetCustomFieldUpdateAction() { Name = "string-field", Value = newValue }; updateActions.Add(setCustomFieldUpdateAction); var updatedCartDiscount = await client.ExecuteAsync(new UpdateByIdCommand <DiscountCode>(discountCode, updateActions)); Assert.Equal(newValue, updatedCartDiscount.Custom.Fields["string-field"]); return(updatedCartDiscount); }); }); }
public async void UpdateInventoryEntrySetCustomField() { var fields = CreateNewFields(); var newValue = TestingUtility.RandomString(10); await WithType(client, async type => { await WithUpdateableInventoryEntry(client, inventoryEntryDraft => DefaultInventoryEntryDraftWithCustomType(inventoryEntryDraft, type, fields), async inventoryEntry => { Assert.NotNull(inventoryEntry.Custom); var action = new SetCustomFieldUpdateAction() { Name = "string-field", Value = newValue }; var updatedInventoryEntry = await client .ExecuteAsync(inventoryEntry.UpdateById(actions => actions.AddUpdate(action))); Assert.NotNull(updatedInventoryEntry.Custom); Assert.Equal(newValue, updatedInventoryEntry.Custom.Fields["string-field"]); return(updatedInventoryEntry); }); }); }
public async Task UpdateShoppingListSetCustomField() { var fields = CreateNewFields(); var newValue = TestingUtility.RandomString(); await WithType(client, async type => { await WithUpdateableShoppingList(client, shoppingListDraft => DefaultShoppingListDraftWithCustomType(shoppingListDraft, type, fields), async shoppingList => { var updateActions = new List <UpdateAction <ShoppingList> >(); var action = new SetCustomFieldUpdateAction() { Name = "string-field", Value = newValue }; updateActions.Add(action); var updatedShoppingList = await client.ExecuteAsync(new UpdateByIdCommand <ShoppingList>(shoppingList, updateActions)); Assert.Equal(newValue, updatedShoppingList.Custom.Fields["string-field"]); return(updatedShoppingList); }); }); }
public async Task UpdateReviewSetCustomField() { var fields = CreateNewFields(); var newValue = TestingUtility.RandomString(10); await WithType(client, async type => { await WithUpdateableReview(client, reviewDraft => DefaultReviewDraftWithCustomType(reviewDraft, type, fields), async review => { Assert.Equal(type.Id, review.Custom.Type.Id); var updateActions = new List <UpdateAction <Review> >(); var setCustomFieldUpdateAction = new SetCustomFieldUpdateAction() { Name = "string-field", Value = newValue }; updateActions.Add(setCustomFieldUpdateAction); var updatedReview = await client.ExecuteAsync(new UpdateByIdCommand <Review>(review, updateActions)); Assert.Equal(newValue, updatedReview.Custom.Fields["string-field"]); return(updatedReview); }); }); }
public async Task UpdateChannelSetCustomField() { var fields = CreateNewFields(); var newValue = TestingUtility.RandomString(10); await WithType(client, async type => { await WithUpdateableChannel(client, channelDraft => DefaultChannelDraftWithCustomType(channelDraft, type, fields), async channel => { var updateActions = new List <UpdateAction <Channel> >(); var action = new SetCustomFieldUpdateAction() { Name = "string-field", Value = newValue }; updateActions.Add(action); var updatedChannel = await client.ExecuteAsync(new UpdateByIdCommand <Channel>(channel, updateActions)); Assert.Equal(newValue, updatedChannel.Custom.Fields["string-field"]); return(updatedChannel); }); }); }
public void UpdateCustomerGroupByKeySetCustomField() { IClient commerceToolsClient = this.customerGroupFixture.GetService <IClient>(); CustomerGroup customerGroup = this.customerGroupFixture.CreateCustomerGroupWithCustomFields(); List <UpdateAction <CustomerGroup> > updateActions = new List <UpdateAction <CustomerGroup> >(); string newValue = TestingUtility.RandomString(10); SetCustomFieldUpdateAction setCustomFieldUpdateAction = new SetCustomFieldUpdateAction() { Name = "string-field", Value = newValue }; updateActions.Add(setCustomFieldUpdateAction); CustomerGroup retrievedCustomerGroup = commerceToolsClient .ExecuteAsync(new UpdateByKeyCommand <CustomerGroup>(customerGroup.Key, customerGroup.Version, updateActions)).Result; this.customerGroupFixture.CustomerGroupsToDelete.Add(retrievedCustomerGroup); Assert.Equal(newValue, retrievedCustomerGroup.Custom.Fields["string-field"]); }
public void UpdatePaymentByIdSetCustomField() { IClient commerceToolsClient = this.paymentsFixture.GetService <IClient>(); Payment payment = this.paymentsFixture.CreatePaymentWithCustomFields(); var updateActions = new List <UpdateAction <Payment> >(); string newValue = TestingUtility.RandomString(10); SetCustomFieldUpdateAction setCustomFieldUpdateAction = new SetCustomFieldUpdateAction() { Name = "string-field", Value = newValue }; updateActions.Add(setCustomFieldUpdateAction); var retrievedPayment = commerceToolsClient .ExecuteAsync(new UpdateByIdCommand <Payment>(payment.Id, payment.Version, updateActions)).Result; this.paymentsFixture.PaymentsToDelete.Add(retrievedPayment); Assert.Equal(payment.Id, retrievedPayment.Id); Assert.Equal(newValue, retrievedPayment.Custom.Fields["string-field"]); }
public async Task UpdateCustomerGroupSetCustomField() { var fields = CreateNewFields(); var newValue = TestingUtility.RandomString(10); await WithType(client, async type => { await WithUpdateableCustomerGroup(client, customerGroupDraft => DefaultCustomerGroupDraftWithCustomType(customerGroupDraft, type, fields), async customerGroup => { var action = new SetCustomFieldUpdateAction() { Name = "string-field", Value = newValue }; var updatedCustomerGroup = await client .ExecuteAsync(customerGroup.UpdateByKey(actions => actions.AddUpdate(action))); Assert.Equal(newValue, updatedCustomerGroup.Custom.Fields["string-field"]); return(updatedCustomerGroup); }); }); }