public void MutateUserLists() { moq::Mock <UserListService.UserListServiceClient> mockGrpcClient = new moq::Mock <UserListService.UserListServiceClient>(moq::MockBehavior.Strict); MutateUserListsRequest request = new MutateUserListsRequest { CustomerId = "customer_id3b3724cb", Operations = { new UserListOperation(), }, }; MutateUserListsResponse expectedResponse = new MutateUserListsResponse { Results = { new MutateUserListResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateUserLists(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); UserListServiceClient client = new UserListServiceClientImpl(mockGrpcClient.Object, null); MutateUserListsResponse response = client.MutateUserLists(request.CustomerId, request.Operations); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task MutateUserListsAsync() { moq::Mock <UserListService.UserListServiceClient> mockGrpcClient = new moq::Mock <UserListService.UserListServiceClient>(moq::MockBehavior.Strict); MutateUserListsRequest request = new MutateUserListsRequest { CustomerId = "customer_id3b3724cb", Operations = { new UserListOperation(), }, }; MutateUserListsResponse expectedResponse = new MutateUserListsResponse { Results = { new MutateUserListResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.MutateUserListsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateUserListsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); UserListServiceClient client = new UserListServiceClientImpl(mockGrpcClient.Object, null); MutateUserListsResponse responseCallSettings = await client.MutateUserListsAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); MutateUserListsResponse responseCancellationToken = await client.MutateUserListsAsync(request.CustomerId, request.Operations, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The client customer ID.</param> /// <param name="conversionActionIds">The IDs of the conversion actions for the basic user /// list.</param> public void Run(GoogleAdsClient client, long customerId, long[] conversionActionIds) { // Creates the service client. UserListServiceClient userListServiceClient = client.GetService(Services.V4.UserListService); List <UserListActionInfo> userListActionInfoList = new List <UserListActionInfo>(); foreach (long conversionActionId in conversionActionIds) { // Creates the UserListActionInfo object for a given conversion action. This // specifies the conversion action that, when triggered, will cause a user to be // added to a UserList. userListActionInfoList.Add(new UserListActionInfo { ConversionAction = ResourceNames.ConversionAction(customerId, conversionActionId) }); } // Creates a basic user list info object with all of the conversion actions. BasicUserListInfo basicUserListInfo = new BasicUserListInfo(); basicUserListInfo.Actions.Add(userListActionInfoList); // Creates the basic user list. UserList basicUserList = new UserList { Name = $"Example BasicUserList #{ExampleUtilities.GetShortRandomString()}", Description = "A list of people who have triggered one or more conversion actions", MembershipLifeSpan = 365L, BasicUserList = basicUserListInfo, MembershipStatus = UserListMembershipStatus.Open }; // Creates the operation. UserListOperation operation = new UserListOperation { Create = basicUserList }; try { // Adds the new user list. MutateUserListsResponse response = userListServiceClient.MutateUserLists (customerId.ToString(), new[] { operation }); // Prints the result. Console.WriteLine("Created basic user list with resource name: " + $"{response.Results.First().ResourceName}"); } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
/// <summary> /// Creates the customer match user list. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID for which the user list is added. /// </param> /// <returns>The resource name of the newly created user list</returns> private string CreateCustomerMatchUserList(GoogleAdsClient client, long customerId) { // Get the UserListService. UserListServiceClient service = client.GetService(Services.V4.UserListService); // Creates the user list. UserList userList = new UserList() { Name = $"Customer Match list# {ExampleUtilities.GetShortRandomString()}", Description = "A list of customers that originated from email and physical" + " addresses", // Customer Match user lists can use a membership life span of 10000 to // indicate unlimited; otherwise normal values apply. // Sets the membership life span to 30 days. MembershipLifeSpan = 30, CrmBasedUserList = new CrmBasedUserListInfo() { UploadKeyType = CustomerMatchUploadKeyType.ContactInfo } }; // Creates the user list operation. UserListOperation operation = new UserListOperation() { Create = userList }; // Issues a mutate request to add the user list and prints some information. MutateUserListsResponse response = service.MutateUserLists( customerId.ToString(), new[] { operation }); string userListResourceName = response.Results[0].ResourceName; Console.WriteLine($"User list with resource name '{userListResourceName}' " + $"was created."); return(userListResourceName); }
/// <summary>Snippet for MutateUserLists</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateUserLists() { // Create client UserListServiceClient userListServiceClient = UserListServiceClient.Create(); // Initialize request argument(s) string customerId = ""; IEnumerable <UserListOperation> operations = new UserListOperation[] { new UserListOperation(), }; // Make the request MutateUserListsResponse response = userListServiceClient.MutateUserLists(customerId, operations); }
/// <summary>Snippet for MutateUserListsAsync</summary> public async Task MutateUserListsAsync() { // Snippet: MutateUserListsAsync(string, IEnumerable<UserListOperation>, CallSettings) // Additional: MutateUserListsAsync(string, IEnumerable<UserListOperation>, CancellationToken) // Create client UserListServiceClient userListServiceClient = await UserListServiceClient.CreateAsync(); // Initialize request argument(s) string customerId = ""; IEnumerable <UserListOperation> operations = new UserListOperation[] { new UserListOperation(), }; // Make the request MutateUserListsResponse response = await userListServiceClient.MutateUserListsAsync(customerId, operations); // End snippet }
/// <summary>Snippet for MutateUserLists</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateUserListsRequestObject() { // Create client UserListServiceClient userListServiceClient = UserListServiceClient.Create(); // Initialize request argument(s) MutateUserListsRequest request = new MutateUserListsRequest { CustomerId = "", Operations = { new UserListOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateUserListsResponse response = userListServiceClient.MutateUserLists(request); }
public async Task MutateUserListsAsync3() { Mock <UserListService.UserListServiceClient> mockGrpcClient = new Mock <UserListService.UserListServiceClient>(MockBehavior.Strict); MutateUserListsRequest request = new MutateUserListsRequest { CustomerId = "customerId-1772061412", Operations = { }, }; MutateUserListsResponse expectedResponse = new MutateUserListsResponse(); mockGrpcClient.Setup(x => x.MutateUserListsAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <MutateUserListsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); UserListServiceClient client = new UserListServiceClientImpl(mockGrpcClient.Object, null); MutateUserListsResponse response = await client.MutateUserListsAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void MutateUserLists3() { Mock <UserListService.UserListServiceClient> mockGrpcClient = new Mock <UserListService.UserListServiceClient>(MockBehavior.Strict); MutateUserListsRequest request = new MutateUserListsRequest { CustomerId = "customerId-1772061412", Operations = { }, }; MutateUserListsResponse expectedResponse = new MutateUserListsResponse(); mockGrpcClient.Setup(x => x.MutateUserLists(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); UserListServiceClient client = new UserListServiceClientImpl(mockGrpcClient.Object, null); MutateUserListsResponse response = client.MutateUserLists(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for MutateUserListsAsync</summary> public async Task MutateUserListsRequestObjectAsync() { // Snippet: MutateUserListsAsync(MutateUserListsRequest, CallSettings) // Additional: MutateUserListsAsync(MutateUserListsRequest, CancellationToken) // Create client UserListServiceClient userListServiceClient = await UserListServiceClient.CreateAsync(); // Initialize request argument(s) MutateUserListsRequest request = new MutateUserListsRequest { CustomerId = "", Operations = { new UserListOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateUserListsResponse response = await userListServiceClient.MutateUserListsAsync(request); // End snippet }
public async Task MutateUserListsAsync() { Mock <UserListService.UserListServiceClient> mockGrpcClient = new Mock <UserListService.UserListServiceClient>(MockBehavior.Strict); MutateUserListsRequest expectedRequest = new MutateUserListsRequest { CustomerId = "customerId-1772061412", Operations = { }, PartialFailure = true, ValidateOnly = false, }; MutateUserListsResponse expectedResponse = new MutateUserListsResponse(); mockGrpcClient.Setup(x => x.MutateUserListsAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <MutateUserListsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); UserListServiceClient client = new UserListServiceClientImpl(mockGrpcClient.Object, null); string customerId = "customerId-1772061412"; IEnumerable <UserListOperation> operations = new List <UserListOperation>(); bool partialFailure = true; bool validateOnly = false; MutateUserListsResponse response = await client.MutateUserListsAsync(customerId, operations, partialFailure, validateOnly); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID.</param> /// <param name="userListIds">The IDs of the lists to be used for the new combination user /// list.</param> public void Run(GoogleAdsClient client, long customerId, long[] userListIds) { // Gets the UserListService client. UserListServiceClient userListServiceClient = client.GetService(Services.V6.UserListService); // Adds each of the provided list IDs to a list of rule operands specifying which lists // the operator should target. List <LogicalUserListOperandInfo> logicalUserListOperandInfoList = userListIds.Select(userListId => new LogicalUserListOperandInfo { UserList = ResourceNames.UserList(customerId, userListId) }).ToList(); // Creates the UserListLogicalRuleInfo specifying that a user should be added to the new // list if they are present in any of the provided lists. UserListLogicalRuleInfo userListLogicalRuleInfo = new UserListLogicalRuleInfo { // Using ANY means that a user should be added to the combined list if they are // present on any of the lists targeted in the LogicalUserListOperandInfo. Use ALL // to add users present on all of the provided lists or NONE to add users that // aren't present on any of the targeted lists. Operator = UserListLogicalRuleOperatorEnum.Types.UserListLogicalRuleOperator.Any, }; userListLogicalRuleInfo.RuleOperands.Add(logicalUserListOperandInfoList); LogicalUserListInfo logicalUserListInfo = new LogicalUserListInfo(); logicalUserListInfo.Rules.Add(userListLogicalRuleInfo); // Creates the new combination user list. UserList userList = new UserList { Name = "My combination list of other user lists " + $"#{ExampleUtilities.GetRandomString()}", LogicalUserList = logicalUserListInfo }; // Creates the operation. UserListOperation operation = new UserListOperation { Create = userList }; try { // Sends the request to add the user list and prints the response. MutateUserListsResponse response = userListServiceClient.MutateUserLists (customerId.ToString(), new[] { operation }); Console.WriteLine("Created combination user list with resource name: " + $"{response.Results.First().ResourceName}"); } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
/// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID.</param> // [START add_combined_rule_user_list] public void Run(GoogleAdsClient client, long customerId) { // Get the UserListServiceClient. UserListServiceClient userListServiceClient = client.GetService(Services.V10.UserListService); // Creates a rule targeting any user that visited a url that equals // 'http://example.com/example1'. UserListRuleInfo userVisitedSite1RuleInfo = BuildVisitedSiteRuleInfo("http://example.com/example1"); // Creates a rule targeting any user that visited a url that equals // 'http://example.com/example2'. UserListRuleInfo userVisitedSite2RuleInfo = BuildVisitedSiteRuleInfo("http://example.com/example2"); // Creates the user list where "Visitors of a page who did visit another page". // To create a user list where "Visitors of a page who did not visit another page", // change the UserListCombinedRuleOperator from .And to .AndNot. CombinedRuleUserListInfo combinedRuleUserListInfo = new CombinedRuleUserListInfo() { LeftOperand = userVisitedSite1RuleInfo, RightOperand = userVisitedSite2RuleInfo, RuleOperator = UserListCombinedRuleOperator.And }; // Defines a representation of a user list that is generated by a rule. RuleBasedUserListInfo ruleBasedUserListInfo = new RuleBasedUserListInfo() { // Optional: To include past users in the user list, set the prepopulation_status to // REQUESTED. PrepopulationStatus = UserListPrepopulationStatus.Requested, CombinedRuleUserList = combinedRuleUserListInfo }; // Creates a user list. UserList userList = new UserList() { Name = "All visitors to http://example.com/example1 AND " + $"http://example.com/example2 #{ExampleUtilities.GetShortRandomString()}", Description = "Visitors of both http://example.com/example1 AND " + "http://example.com/example2", MembershipStatus = UserListMembershipStatus.Open, MembershipLifeSpan = 365L, RuleBasedUserList = ruleBasedUserListInfo }; // Creates the operation. UserListOperation operation = new UserListOperation() { Create = userList }; try { // Adds the new user list and prints the result. MutateUserListsResponse response = userListServiceClient.MutateUserLists (customerId.ToString(), new[] { operation }); Console.WriteLine("Created user list with resource name:" + $"{response.Results.First().ResourceName}"); } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
/// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID to which the new user list will be /// added.</param> public void Run(GoogleAdsClient client, long customerId) { // Gets the UserListService. UserListServiceClient userListServiceClient = client.GetService(Services.V4.UserListService); // Creates the user targeting rules for each URL. UserListRuleItemInfo rule1 = BuildVisitedSiteRuleInfo("example.com/section1"); UserListRuleItemInfo rule2 = BuildVisitedSiteRuleInfo("example.com/section2"); // Combine the two rule items into a UserListRuleItemGroupInfo object so Google Ads will // AND their rules together. To instead OR the rules together, each rule should be // placed in its own rule item group. UserListRuleItemGroupInfo userListRuleItemGroupInfo = new UserListRuleItemGroupInfo(); userListRuleItemGroupInfo.RuleItems.Add(rule1); userListRuleItemGroupInfo.RuleItems.Add(rule2); UserListRuleInfo userListRuleInfo = new UserListRuleInfo(); userListRuleInfo.RuleItemGroups.Add(userListRuleItemGroupInfo); // Creates an ExpressionRuleUserListInfo object, or a boolean rule that defines this // user list. The default rule_type for a UserListRuleInfo object is OR of ANDs // (disjunctive normal form). That is, rule items will be ANDed together within rule // item groups and the groups themselves will be ORed together. ExpressionRuleUserListInfo expressionRuleUserListInfo = new ExpressionRuleUserListInfo { Rule = userListRuleInfo }; // Defines a representation of a user list that is generated by a rule. RuleBasedUserListInfo ruleBasedUserListInfo = new RuleBasedUserListInfo { // Optional: To include past users in the user list, set the prepopulation_status to // REQUESTED. PrepopulationStatus = UserListPrepopulationStatus.Requested, ExpressionRuleUserList = expressionRuleUserListInfo }; // Creates a new user list. UserList userList = new UserList { Name = "All visitors to example.com/section1 AND example.com/section2 " + $"#{ExampleUtilities.GetRandomString()}", Description = "Visitors of both example.com/section1 AND example.com/section2", MembershipStatus = UserListMembershipStatus.Open, MembershipLifeSpan = 365L, RuleBasedUserList = ruleBasedUserListInfo }; // Creates the operation. UserListOperation operation = new UserListOperation() { Create = userList }; try { // Adds the user list. MutateUserListsResponse response = userListServiceClient.MutateUserLists (customerId.ToString(), new[] { operation }); // Displays the results. Console.WriteLine("Created new user list with resource name: " + $"'{response.Results.First().ResourceName}'."); } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
/// <summary> /// Creates a user list targeting users that have visited a given url. /// </summary> /// <param name="client">The Google Ads API client.</param> /// <param name="customerId">The Google Ads customer ID for which the call is made.</param> /// <returns>The resource name of the newly created user list.</returns> // [START setup_remarketing] private string CreateUserList(GoogleAdsClient client, long customerId) { // Get the UserListService client. UserListServiceClient userListServiceClient = client.GetService(Services.V10.UserListService); // Create a rule targeting any user that visited a url containing 'example.com'. UserListRuleItemInfo rule = new UserListRuleItemInfo { // Use a built-in parameter to create a domain URL rule. Name = "url__", StringRuleItem = new UserListStringRuleItemInfo { Operator = UserListStringRuleItemOperator.Contains, Value = "example.com" } }; // Specify that the user list targets visitors of a page based on the provided rule. ExpressionRuleUserListInfo expressionRuleUserListInfo = new ExpressionRuleUserListInfo { Rule = new UserListRuleInfo() }; UserListRuleItemGroupInfo userListRuleItemGroupInfo = new UserListRuleItemGroupInfo(); userListRuleItemGroupInfo.RuleItems.Add(rule); expressionRuleUserListInfo.Rule.RuleItemGroups.Add(userListRuleItemGroupInfo); // Define a representation of a user list that is generated by a rule. RuleBasedUserListInfo ruleBasedUserListInfo = new RuleBasedUserListInfo { // Optional: To include past users in the user list, set the prepopulation_status to // REQUESTED. PrepopulationStatus = UserListPrepopulationStatus.Requested, ExpressionRuleUserList = expressionRuleUserListInfo }; // Create the user list. UserList userList = new UserList { Name = $"All visitors to example.com #{ExampleUtilities.GetRandomString()}", Description = "Any visitor to any page of example.com", MembershipStatus = UserListMembershipStatus.Open, MembershipLifeSpan = 365L, RuleBasedUserList = ruleBasedUserListInfo }; // Create the operation. UserListOperation userListOperation = new UserListOperation { Create = userList }; // Add the user list, then print and return the new list's resource name. MutateUserListsResponse mutateUserListsResponse = userListServiceClient .MutateUserLists(customerId.ToString(), new[] { userListOperation }); string userListResourceName = mutateUserListsResponse.Results.First().ResourceName; Console.WriteLine($"Created user list with resource name '{userListResourceName}'."); return(userListResourceName); }
/// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID for the conversion action is /// added.</param> public void Run(GoogleAdsClient client, long customerId) { // Get the user list service client. UserListServiceClient userListServiceClient = client.GetService(Services.V6.UserListService); try { // Create a rule targeting any user that visited the checkout page. UserListRuleItemInfo checkoutRule = new UserListRuleItemInfo { // The rule variable name must match a corresponding key name fired from a pixel. // To learn more about setting up remarketing tags, visit // https://support.google.com/google-ads/answer/2476688. // To learn more about remarketing events and parameters, visit // https://support.google.com/google-ads/answer/7305793. Name = "ecomm_pagetype", StringRuleItem = new UserListStringRuleItemInfo { Operator = UserListStringRuleItemOperator.Equals, Value = "checkout" } }; // Create a rule targeting any user that had more than one item in their cart. UserListRuleItemInfo cartSizeRule = new UserListRuleItemInfo { // The rule variable name must match a corresponding key name fired from a pixel. Name = "cart_size", NumberRuleItem = new UserListNumberRuleItemInfo { Operator = UserListNumberRuleItemOperator.GreaterThan, Value = 1.0 } }; // Create a rule group that includes the checkout and cart size rules. Combining the // two rule items into a UserListRuleItemGroupInfo object causes Google Ads to AND // their rules together. To instead OR the rules together, each rule should be // placed in its own rule item group. UserListRuleItemGroupInfo checkoutAndCartSizeRuleGroup = new UserListRuleItemGroupInfo(); checkoutAndCartSizeRuleGroup.RuleItems.Add(checkoutRule); checkoutAndCartSizeRuleGroup.RuleItems.Add(cartSizeRule); // Create the RuleItem for checkout start date. // The tags and keys used below must have been in place in the past for the date // range specified in the rules. UserListRuleItemInfo startDateRule = new UserListRuleItemInfo { // The rule variable name must match a corresponding key name fired from a pixel. Name = "checkoutdate", DateRuleItem = new UserListDateRuleItemInfo { // Available UserListDateRuleItemOperators can be found at // https://developers.google.com/google-ads/api/reference/rpc/latest/UserListDateRuleItemOperatorEnum.UserListDateRuleItemOperator Operator = UserListDateRuleItemOperator.After, Value = "20191031" } }; // Create the RuleItem for checkout end date. UserListRuleItemInfo endDateRule = new UserListRuleItemInfo { // The rule variable name must match a corresponding key name fired from a pixel. Name = "checkoutdate", DateRuleItem = new UserListDateRuleItemInfo { Operator = UserListDateRuleItemOperator.Before, Value = "20200101" } }; // Create a rule group targeting users who checked out between November and December // by using the start and end date rules. Combining the two rule items into a // UserListRuleItemGroupInfo object causes Google Ads to AND their rules together. // To instead OR the rules together, each rule should be placed in its own rule item // group. UserListRuleItemGroupInfo checkoutDateRuleGroup = new UserListRuleItemGroupInfo(); checkoutDateRuleGroup.RuleItems.Add(startDateRule); checkoutDateRuleGroup.RuleItems.Add(endDateRule); // Create an ExpressionRuleUserListInfo object, or a boolean rule that defines this // user list. The default rule_type for a UserListRuleInfo object is OR of ANDs // (disjunctive normal form). That is, rule items will be ANDed together within rule // item groups and the groups themselves will be ORed together. ExpressionRuleUserListInfo expressionRuleUserListInfo = new ExpressionRuleUserListInfo { Rule = new UserListRuleInfo() }; expressionRuleUserListInfo.Rule.RuleItemGroups.Add(checkoutAndCartSizeRuleGroup); expressionRuleUserListInfo.Rule.RuleItemGroups.Add(checkoutDateRuleGroup); // Defines a representation of a user list that is generated by a rule. RuleBasedUserListInfo ruleBasedUserListInfo = new RuleBasedUserListInfo { // Optional: To include past users in the user list, set the // prepopulation status to REQUESTED. PrepopulationStatus = UserListPrepopulationStatus.Requested, ExpressionRuleUserList = expressionRuleUserListInfo }; // Create a user list. UserList userList = new UserList { Name = $"My expression rule user list #{ExampleUtilities.GetRandomString()}", Description = "Users who checked out in November or December OR visited the checkout " + "page with more than one item in their cart", MembershipLifeSpan = 90L, MembershipStatus = UserListMembershipStatus.Open, RuleBasedUserList = ruleBasedUserListInfo }; // Create the operation. UserListOperation userListOperation = new UserListOperation { Create = userList }; // Add the user list and print the results. MutateUserListsResponse response = userListServiceClient.MutateUserLists(customerId.ToString(), new[] { userListOperation }); string userListResourceName = response.Results.First().ResourceName; Console.WriteLine( $"Created user list with resource name '{userListResourceName}'."); } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }