LoyaltyClientFirstCardOrCreateVirtualCard Method |
Searches for an existing Card that belongs to:
public ResultOfCardCredentials FirstCardOrCreateVirtualCard( ManagementGroupRequestOfFirstCardOrCreateVirtualCard request )
using (var svc = new LoyaltyService.LoyaltyClient()) { var request = new LoyaltyService.ManagementGroupRequestOfFirstCardOrCreateVirtualCard(); request.Token = "Token";//Required - Token returned from AccountService.ManagementGroupLogin request.ManagementGroup = "Management group";//Required - ManagementGroup supplied when calling AccountService.ManagementGroupLogin var firstCardOrCreateVirtualCard = new LoyaltyService.FirstCardOrCreateVirtualCard(); //Required //firstCardOrCreateVirtualCard.CardStatus ignored //firstCardOrCreateVirtualCard.CardType ignored //firstCardOrCreateVirtualCard.SendEmail ignored //Search criteria var memberSearchFilter = new LoyaltyService.MemberSearchFilter(); memberSearchFilter.PageNumber = 1;//Optional - defaults to 1 if not supplied memberSearchFilter.PageSize = 100;//Optional - default to 100 if not supplied memberSearchFilter.ProgramCode = "SRB"; //Optional - Required if card not found memberSearchFilter.EmailAddress = "demo@simplicitycrm.com"; //Optional memberSearchFilter.GivenName = "John"; //Optional memberSearchFilter.FamilyName = "Doe"; //Optional memberSearchFilter.CardOrVoucher = "21000005"; //Optional memberSearchFilter.PhoneLocal = "9265400"; //Optional memberSearchFilter.PostCode = "1234"; //Optional memberSearchFilter.ActiveMembership = false;//Optional - true: active only. false: inactive only. null: both active and inactive memberSearchFilter.CompanyName = "";//Optional memberSearchFilter.CustomerAccountID = "CA_123";//Optional //set firstCardOrCreateVirtualCard member search firstCardOrCreateVirtualCard.MemberSearch = memberSearchFilter; var programMembership = new LoyaltyService.ProgramMembership(); //programMembership.RSN ignored //programMembership.MemberRSN ignored //programMembership.DisplayValue ignored //programMembership.ProgramRSN ignored programMembership.OriginalStartDate = DateTime.Now; //Optional programMembership.StartDate = DateTime.Now; //Optional programMembership.EndDate = DateTime.Now.AddYears(1); //Optional - leave blank or set to DateTime.Min to have a program membership that does not expire programMembership.BranchName = "Albany Branch"; //Optional programMembership.JoiningKeyCode = "";//Optional programMembership.RedemptionOnHold = false;//Optional programMembership.PointsExpiredExemption = false;//Optional programMembership.HomeBranch_Organisation_RSN = new Guid("0cb45e95-d234-4057-86aa-c93fcec9fe2d");;//Optional - RSN of home branch (partner or outlet). May be required depending on Program configuration programMembership.PromotionalPointsConversionFactor = 0.0m;//Optional programMembership.PointsConversionFactor = 0.0m;//Optional var programMembershipCustomFields = new LoyaltyService.ProfileCustomFieldValues(); programMembershipCustomFields.CustomText_1 = string.Empty; //Optional CustomText_2 - CustomText_15 available programMembershipCustomFields.CustomBoolean_1 = false; //Optional CustomBoolean_2 - CustomBoolean_20 available programMembershipCustomFields.CustomDate_1 = DateTime.MinValue; //Optional CustomDate_2 - CustomDate_15 available programMembershipCustomFields.CustomDecimal_1 = 0.0M; //Optional CustomDecimal_2 - CustomDecimal_5 available programMembershipCustomFields.CustomInteger_1 = 0; //Optional CustomInteger_2 - CustomInteger_10 available //add custom fields to program membership programMembership.CustomFieldValues = programMembershipCustomFields;//Optional //set firstCardOrCreateVirtualCard program membership firstCardOrCreateVirtualCard.Membership = programMembership; //Optional - Required if card not found //add firstCardOrCreateVirtualCard to request request.Value = firstCardOrCreateVirtualCard; LoyaltyService.ResultOfCardCredentials result = svc.FirstCardOrCreateVirtualCard(request); if (result.FaultCode == 0) { //Request succeeded } else { //Request failed if (result.FaultCode == 020201) { //Request failed - Member Search found more than one member (Search criteria needs to be specific enough to find a single member). } else if (result.FaultCode == 020101) { //Request failed - Member search found no members meeting the supplied criteria. } else { //Request failed for some other reason. throw new Exception(result.FaultDescription); } } }