Newer Version Available

This content describes an older version of this product. View Latest

Create an Instance of LoyaltyAPIManager Class for Android

Create an instance of the LoyaltyAPIManager class and interact with the Loyalty Management APIs.
  1. Create an instance of LoyaltyAPIManager by using this signature.
    1val loyaltyAPIManager = LoyaltyAPIManager(
    2            auth = forceAuthManager,
    3            instanceUrl = mInstanceUrl,
    4            loyaltyClient = LoyaltyClient(forceAuthManager, mInstanceUrl)
    5        )```
  2. To interact with the Loyalty Management API, call the appropriate methods by using this signature.
    1import LoyaltyMobileSDK
    2
    3val forceAuthManager = ForceAuthManager(applicationContext)
    4val mInstanceUrl =
    5            forceAuthManager.getInstanceUrl() ?: AppSettings.DEFAULT_FORCE_CONNECTED_APP.instanceUrl
    6val loyaltyAPIManager = LoyaltyAPIManager(
    7            auth = forceAuthManager,
    8            instanceUrl = mInstanceUrl,
    9            loyaltyClient = LoyaltyClient(forceAuthManager, mInstanceUrl)
    10        ) 
  3. To enroll an individual member, use this signature.
    1let membershipNumber = "1234567890"
    2let firstName = "John"
    3let lastName = "Doe"
    4let email = "john.doe@example.com"
    5let phone = "4157891234"
    6let emailNotification = true
    7
    8loyaltyAPIManager.postEnrollment(
    9                    firstName = firstName,
    10                    lastName = lastName,
    11                    email = email,
    12                    additionalContactAttributes = mapof("phone" to phone),
    13                    emailNotification = emailNotification,
    14                    memberStatus = MemberStatus.ACTIVE,
    15                    createTransactionJournals = true,
    16                    transactionJournalStatementFrequency = TransactionalJournalStatementFrequency.MONTHLY,
    17                    transcationJournalStatementMethod = TransactionalJournalStatementMethod.EMAIL,
    18                    enrollmentChannel = EnrollmentChannel.EMAIL,
    19                    canReceivePromotions = true,
    20                    canReceivePartnerPromotions = true
    21                )
  4. To retrieve the member benefits, use this signature.
    1loyaltyAPIManager.getMemberBenefits(memberId = null, membershipKey = "1234567890")
    2
  5. To retrieve the member profile, use this signature.
    1loyaltyAPIManager.getMemberProfile(memberId = null, membershipKey = "1234567890", programCurrencyName = null)
  6. To opt a member into a promotion, use this signature.
    1loyaltyAPIManager.enrollInPromotions(membershipNumber = "1234567890", promotionName = "PromotionName")
  7. To opt out a member from a promotion using promotion ID or promotion name, use this signature.
    1loyaltyAPIManager.unEnrollPromotion(membershipNumber = "1234567890", promotionName = "PromotionName")
  8. To retrieve loyalty member transactions, use this signature.
    1loyaltyAPIManager.getTransactions(membershipNumber = "1234567890", pageNumber = null, 
    2            journalTypeName = null, journalSubTypeName = null, periodStartDate = null, periodEndDate = null)
  9. To retrieve promotions for a loyalty member, use this signature.
    1loyaltyAPIManager.getEligiblePromotions(membershipKey = "1234567890", memberId = null)
  10. To retrieve vouchers for a loyalty member, use this signature.
    1loyaltyAPIManager.getVouchers(
    2                membershipKey = "1234567890", vouchreStatus = null, pageNumber = 1, productId = null,
    3                productCategoryId = null, productName = null, productCategoryName = null
    4            )