Create an Instance of LoyaltyAPIManager Class

Create an instance of LoyaltyAPIManager class and interact with the Loyalty Management APIs.
  1. Create an instance of LoyaltyAPIManager by using this signature.
    1let loyaltyAPIManager = LoyaltyAPIManager(auth: forceAuthenticator, loyaltyProgramName: "YourLoyaltyProgramName", instanceURL: "YourInstanceURL", forceClient: forceClient)
  2. Call the appropriate methods to interact with the Loyalty Management API by using this signature.
    1import LoyaltyMobileSDK
    2
    3let instanceURL = URL(string: "https://your_salesforce_instance_url")!
    4let loyaltyProgramName = "YourLoyaltyProgramName"
    5let forceClient = ForceClient(clientId: "your_client_id", clientSecret: "your_client_secret", redirectURI: "your_redirect_uri")
    6
    7let loyaltyAPIManager = LoyaltyAPIManager(instanceURL: instanceURL, loyaltyProgramName: loyaltyProgramName, forceClient: forceClient)
  3. To enroll an individual member, use this signature.
    1let enrollmentOutput = try await loyaltyAPIManager.postEnrollment(
    2    membershipNumber: membershipNumber,
    3    firstName: firstName,
    4    lastName: lastName,
    5    email: email,
    6    phone: phone,
    7    emailNotification: emailNotification
    For example:
    1let membershipNumber = "1234567890"
    2let firstName = "John"
    3let lastName = "Doe"
    4let email = "john.doe@example.com"
    5let phone = "4157891234"
    6let emailNotification = true
  4. To retrieve the member benefits, use this signature.
    1let benefits = try await loyaltyAPIManager.getMemberBenefits(for: "memberId")
  5. To retrieve the member profile, use this signature.
    1let profile = try await loyaltyAPIManager.getMemberProfile(for: "memberId")
  6. To retrieve the Experience Cloud user profile, use this signature.
    1let communityProfile = try await loyaltyAPIManager.getCommunityMemberProfile()
  7. To opt a member in to a promotion, use this signature.
    1try await loyaltyAPIManager.enrollIn(promotion: "PromotionName", for: "1234567890")
  8. To opt out a member from a promotion using promotion ID or promotion name, use this signature.
    1try await loyaltyAPIManager.unenroll(promotionId: "promotionId", for: "1234567890")
    2try await loyaltyAPIManager.unenroll(promotionName: "PromotionName", for: "1234567890")
  9. To retrieve loyalty member transactions, use this signature.
    1let transactions = try await loyaltyAPIManager.getTransactions(for: "1234567890")
  10. To retrieve promotions for a loyalty member, use this signature.
    1let promotions = try await loyaltyAPIManager.getPromotions(membershipNumber: "1234567890")
  11. To retrieve vouchers for a loyalty member, use this signature.
    1let vouchers = try await loyaltyAPIManager.getVouchers(membershipNumber: "1234567890")