Created
February 15, 2016 17:08
-
-
Save Mozu-CS/b37568cc9a358a01f9b2 to your computer and use it in GitHub Desktop.
An example on how to add a customer to a customer segment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var customerSegmentResouce = new Mozu.Api.Resources.Commerce.Customer.CustomerSegmentResource(_apiContext); | |
var customerAccountResource = new Mozu.Api.Resources.Commerce.Customer.CustomerAccountResource(_apiContext); | |
var customerSegment = (customerSegmentResouce.GetSegmentsAsync(filter:"Name eq 'High Volume Customer'").Result).Items[0]; | |
var customerAccountIds = new List<int>(); | |
var customerAccount = (customerAccountResource.GetAccountsAsync(filter:"FirstName eq 'Malcolm'").Result).Items[0]; | |
customerAccountIds.Add(customerAccount.Id); | |
if(!(customerAccount.Segments.Exists(x => x.Id == customerSegment.Id))) | |
{ | |
customerSegmentResouce.AddSegmentAccountsAsync(customerAccountIds, customerSegment.Id).Wait(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment