Skip to content

Instantly share code, notes, and snippets.

@Mozu-CS
Created February 15, 2016 17:08
Show Gist options
  • Save Mozu-CS/b37568cc9a358a01f9b2 to your computer and use it in GitHub Desktop.
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
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