LoyaltyClientCreateMember Method |
Create Member using the submitted values.
public ResultOfguid CreateMember( ManagementGroupRequestOfCreateMember request )
using (var svc = new LoyaltyService.LoyaltyClient()) { var request = new LoyaltyService.ManagementGroupRequestOfCreateMember(); request.Token = "Token";//Required - Token returned from AccountService.ManagementGroupLogin request.ManagementGroup = "Management group";//Required - ManagementGroup supplied when calling AccountService.ManagementGroupLogin var newMemberData = new LoyaltyService.CreateMember(); var member = new LoyaltyService.Member(); member.Member_RSN = Guid.NewGuid(); // Required - will be generated if not supplied member.Member_Type = "Person"; //Optional - Valid values are : 'Person' or 'Organisation'. Defaults to 'Person' if not supplied var profile = new LoyaltyService.Profile(); //Required profile.Member_RSN = Guid.NewGuid();//Optional - will be generated if not supplied profile.Member_Type = "Person"; //Optional - Valid values are : 'Person' or 'Organisation'. Defaults to 'Person' if not supplied //Name info profile.Title = "Mr"; //Required - Valid values are : 'Dr', 'Sir', 'Lady', 'Mr', 'Miss', 'Ms' or 'Mrs' (case sensitive)"; profile.GivenName = "John"; // Required profile.MiddleName = "David"; // Optional profile.FamilyName = "Doe"; // Required if (string.IsNullOrEmpty(profile.MiddleName)) { profile.DisplayValue = string.Concat(profile.Title, " ", profile.GivenName, " ", profile.FamilyName).Trim(); //Optional (it is recommended to give this property a value). } else { profile.DisplayValue = string.Concat(profile.Title, " ", profile.GivenName, " ", profile.MiddleName, " ", profile.FamilyName).Trim(); //Optional (it is recommended to give this property a value). } profile.Gender = "MALE"; //Required - Valid values are : 'MALE', 'FEMALE' or 'DONOTKNOW' profile.DateOfBirth = new DateTime(1950, 12, 25); // Optional profile.CompanyName = "";//Optional - Required if Member_Type set to 'Organisation' profile.TradingAs = "";//Optional - only used if Member_Type set to 'Organisation' profile.BankAccountHolderName = "J Doe";//Optional profile.BankAccountNumberBank = "12";//Optional profile.BankAccountNumberBranch = "1234";//Optional profile.BankAccountNumberAccount = "1234567";//Optional profile.BankAccountNumberSuffix = "123";//Optional profile.DefaultPartnerOrganisation_RSN = Guid.Empty;//Optional //Contact Info //One or more ContactPoint must be provided (Postal Address, Home Phone or Email) var shippingContact = new LoyaltyService.ProfileContact(); //Postal Address var shippingAddress = new LoyaltyService.Postal(); shippingAddress.ContactType = "SHIPPING"; // Should always be 'SHIPPING' for AddressContact for this method shippingAddress.Line1 = "Level 1, Simplicity Building"; // Required shippingAddress.Line2 = "14-22 Triton Drive"; // Optional shippingAddress.Suburb = "Albany"; // Required shippingAddress.TownCityState = "Auckland"; // Required shippingAddress.PostCode = "0632"; // Required shippingAddress.Country = "New Zealand"; // Required shippingContact.AddressContact = new LoyaltyService.Address[1] { shippingAddress }; //Home phone var homePhone = new LoyaltyService.Phone(); homePhone.ContactType = "HOME"; // Should always be 'HOME' for PhoneContact for this method homePhone.IDD = "64"; //Optional - Country code (optional) homePhone.STD = "9"; //Optional - Entire phone number (excluding IDD) can be placed in Local parameter depending on setup homePhone.Local = "926 5400";//Required shippingContact.PhoneContact = new LoyaltyService.Phone[1] { homePhone }; //Home email var homeEmail = new LoyaltyService.Email(); homeEmail.ContactType = "HOME"; // Should always be 'HOME' for EmailContact for this method homeEmail.Address = "Email address"; //Required - Must be a valid email address shippingContact.EmailContact = new LoyaltyService.Email[1] { homeEmail }; //add shippingContact to profile profile.Contact = shippingContact; // Required //Opt Ins var emailOptIn = new LoyaltyService.ProfileOptIn(); emailOptIn.OptInType = "EMAIL"; //Required - Valid values are : 'EMAIL', 'MAIL' or 'SMS' emailOptIn.OptIn = true; //Required - True for Opt in, False for Opt out var mailOptIn = new LoyaltyService.ProfileOptIn(); mailOptIn.OptInType = "MAIL"; //Required - Valid values are : 'EMAIL', 'MAIL' or 'SMS' mailOptIn.OptIn = false; //Required - True for Opt in, False for Opt out var smsOptIn = new LoyaltyService.ProfileOptIn(); smsOptIn.OptInType = "SMS"; //Required - Valid values are : 'EMAIL', 'MAIL' or 'SMS' smsOptIn.OptIn = true; //Required - True for Opt in, False for Opt out //add optIns to profile profile.OptIn = new LoyaltyService.ProfileOptIn[3] { emailOptIn, mailOptIn, smsOptIn };//Optional var profileCustomFields = new LoyaltyService.ProfileCustomFieldValues(); profileCustomFields.CustomText_1 = string.Empty; //Optional CustomText_2 - CustomText_15 available profileCustomFields.CustomBoolean_1 = false; //Optional CustomBoolean_2 - CustomBoolean_20 available profileCustomFields.CustomDate_1 = DateTime.MinValue; //Optional CustomDate_2 - CustomDate_15 available profileCustomFields.CustomDecimal_1 = 0.0M; //Optional CustomDecimal_2 - CustomDecimal_5 available profileCustomFields.CustomInteger_1 = 0; //Optional CustomInteger_2 - CustomInteger_10 available //add custom fields to profile profile.CustomFieldValues = profileCustomFields;//Optional //set member profile member.Profile = profile; //Required //set newMemberData member newMemberData.MemberProfile = member; //Required var customerAccount = new LoyaltyService.CustomerAccount(); // Optional customerAccount.CustomerAccount_RSN = Guid.NewGuid(); // Required customerAccount.CustomerAccount_ID = "CA_123"; // Required customerAccount.Member_RSN = member.Member_RSN; // Required customerAccount.Partner_RSN = new Guid("22bfcd84-d236-4bcb-9f5c-66c48dfb56b8");; // Required - RSN of partner customerAccount.DisplayValue = "Simplicity Demo";//Optional - name of partner company customerAccount.Category = "Loyalty";//Optional customerAccount.SubCategory = "";//Optional newMemberData.CustomerAccounts = new LoyaltyService.CustomerAccount[] { customerAccount };//Optional //add newMemberData to request request.Value = newMemberData;//Required LoyaltyService.ResultOfguid result = svc.CreateMember(request); if (result.FaultCode == 0) { //Request succeeded } else { //Request failed throw new Exception(result.FaultDescription); } }