LoyaltyClientCreateMemberForInStoreCard Method |
Assign an existing Physical Card to a New Member. The Card Status is set to "ACTIVE.
public ResultOfInstoreCard CreateMemberForInStoreCard( ManagementGroupRequestOfNewInstoreCardMember request )
using (var svc = new LoyaltyService.LoyaltyClient()) { var request = new LoyaltyService.ManagementGroupRequestOfNewInstoreCardMember(); request.Token = "Token";//Required - Token returned from AccountService.ManagementGroupLogin request.ManagementGroup = "Management group";//Required - ManagementGroup supplied when calling AccountService.ManagementGroupLogin var newInstoreCardMember = new LoyaltyService.NewInstoreCardMember(); newInstoreCardMember.CardNumber = "Card number";//Required newInstoreCardMember.AccessCode = "Access code"; //Required - May be optional depending on configuration newInstoreCardMember.SendEmail = true;//Optional - Sends welcome email to new member if true var profile = new LoyaltyService.Profile(); profile.Member_Password = "Password";//Required - Password must be between 8 and 20 characters long and include at least one letter and one number. 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 newInstoreCardMember profile newInstoreCardMember.Profile = profile; //Required var programMembership = new LoyaltyService.ProgramMembership(); //programMembership.CustomerAccountRSN ignored programMembership.StartDate = DateTime.Now; //Optional programMembership.EndDate = programMembership.StartDate.AddYears(1); //Optional - (leave blank or set to DateTime.Min to have a program membership that does not expire) programMembership.BranchName = "Branch"; //Optional //programMembership.DisplayValue should not be supplied //programMembership.RSN should not be supplied //programMembership.MemberRSN should not be supplied //programMembership.ProgramRSN should not be supplied //programMembership.PointsBalance should not be supplied //programMembership.Cards should not be supplied //programMembership.Vouchers should not be supplied //programMembership.CustomFieldValues should not be supplied //set newInstoreCardMember program membership newInstoreCardMember.ProgramMembership = programMembership;//Required var customerAccount = new LoyaltyService.CustomerAccount(); // Optional //customerAccount.Member_RSN ignored customerAccount.CustomerAccount_RSN = Guid.NewGuid(); // Required customerAccount.CustomerAccount_ID = "CA_123"; // Required customerAccount.Partner_RSN = new Guid("e35e8ef7-a1d6-4353-b7c6-a170ec52407a");; // Required - RSN of partner customerAccount.DisplayValue = "Simplicity Demo";//Optional - name of partner company customerAccount.Category = "Loyalty";//Optional customerAccount.SubCategory = "";//Optional //set newInstoreCardMember customer accounts newInstoreCardMember.CustomerAccounts = new LoyaltyService.CustomerAccount[] { customerAccount };// Optional //add newInstoreCardMember to request request.Value = newInstoreCardMember; //Required LoyaltyService.ResultOfInstoreCard result = svc.CreateMemberForInStoreCard(request); if (result.FaultCode == 0) { //Request succeeded } else { //Request failed throw new Exception(result.FaultDescription); } }