Owns the referral and invitation domain: referral programs, invitations sent to prospective members, and the acceptance of those invitations into a group or organisation. Reached from server-side JS as the registered service "referralManager". Invitations and acceptances are built with the fluent ReferralBuilder and AcceptReferralBuilder returned by newReferralBuilder and newAcceptReferralBuilder, and this class also listens for SubscriptionEvent to convert a referral automatically when the referred person signs up.

Group: Managers


Properties

PropertyReturnsDescription
allReferralProgramsList<ReferralProgram>All referral programs configured for the current tenant organisation.
generateEmailbooleanWhether an invitation email is sent automatically when a referral is created. If false, the account must set up a journey or automation to respond to referral events and send the email itself.

Methods

deleteProgram(ReferralProgram p) · getAllReferralPrograms() · findProgramsByPromotion(Reward promo) · findProgramById(long id) · findProgramByName(String name) · findByToken(String referralToken) · findByProgramAndToken(ReferralProgram program, String referralToken) · findById(Long id) · findAcceptanceById(Long id) · findAcceptancesByReferral(Referral r) · newAcceptReferralBuilder() · accept(AcceptReferralBuilder b) · canConvert(Referral r, Profile acceptor) · canConvert(Referral r) · invite(ReferralBuilder b) · newReferralBuilder() · isGenerateEmail() · findMatchingProfiles(Referral referral)

deleteProgram(ReferralProgram p)

Returns: void

Permanently deletes a referral program and its configuration.

ParameterDescription
pthe referral program to delete

getAllReferralPrograms()

Returns: List<ReferralProgram>

All referral programs configured for the current tenant organisation.

findProgramsByPromotion(Reward promo)

Returns: List<ReferralProgram>

Finds the referral programs, for the current tenant organisation, that award the given reward as a promotion.

ParameterDescription
promothe reward to search for

findProgramById(long id)

Returns: ReferralProgram

Looks up a referral program, scoped to the current tenant organisation, by its database id.

ParameterDescription
idthe referral program's id

findProgramByName(String name)

Returns: ReferralProgram

Looks up a referral program, scoped to the current tenant organisation, by its unique name.

ParameterDescription
namethe referral program's name

findByToken(String referralToken)

Returns: Referral

Looks up a referral, scoped to the current tenant organisation, by the unique token issued when it was created.

ParameterDescription
referralTokenthe referral's token, as sent in the invitation link

findByProgramAndToken(ReferralProgram program, String referralToken)

Returns: Referral

Looks up a referral by its token, within a specific referral program.

ParameterDescription
programthe referral program the referral must belong to
referralTokenthe referral's token, as sent in the invitation link

findById(Long id)

Returns: Referral

Looks up a referral, scoped to the current tenant organisation, by its database id.

ParameterDescription
idthe referral's id

findAcceptanceById(Long id)

Returns: ReferralAcceptance

Looks up a referral acceptance, scoped to the current tenant organisation, by its database id.

ParameterDescription
idthe referral acceptance's id

findAcceptancesByReferral(Referral r)

Returns: List<ReferralAcceptance>

All acceptances recorded against a referral. Returns null if the referral does not belong to the current tenant organisation.

ParameterDescription
rthe referral whose acceptances are read

newAcceptReferralBuilder()

Returns: AcceptReferralBuilder

Creates a new AcceptReferralBuilder for accepting a referral. Set the properties you need on the builder and then call its build method, or pass it to accept, to process the acceptance.

accept(AcceptReferralBuilder b)

Returns: ReferralAcceptance

Processes the acceptance of a referral described by an AcceptReferralBuilder: resolves or creates the accepting profile, checks its password where required, adds it to the group or organisation the referral invited it to, and records a ReferralAcceptance. Throws a RuntimeException if the referral has expired, has already been accepted, or the accepting profile cannot be resolved or authenticated.

ParameterDescription
bthe builder describing which referral is being accepted and by whom

canConvert(Referral r, Profile acceptor)

Returns: boolean

Whether the given profile is allowed to accept (convert) this referral: the referral itself must still be acceptable, and if it belongs to a referral program the profile must not have already accepted a referral in that same program.

ParameterDescription
rthe referral to check
acceptorthe profile that would be accepting the referral

canConvert(Referral r)

Returns: boolean

Whether it is still possible to convert (accept) this referral: a single-accept referral can only be converted if it has not already been responded to, a multi-accept referral can always be converted.

ParameterDescription
rthe referral to check

invite(ReferralBuilder b)

Returns: Referral

Creates and sends a referral invitation described by a ReferralBuilder: saves the referral, creates a recipient profile if none exists, adds the recipient to the program's contacts group, and, unless the caller disabled it and email generation is enabled, generates and queues an invitation email. Call this after creating a ReferralBuilder with newReferralBuilder and setting the properties you want, or via the builder's build method.

ParameterDescription
bthe builder describing the invitation to send

newReferralBuilder()

Returns: ReferralBuilder

Creates a new ReferralBuilder for sending an invitation. Set the properties you need on the builder and then call its build method, or pass it to invite, to send the invitation.

isGenerateEmail()

Returns: boolean

Whether an invitation email is sent automatically when a referral is created. If false, the account must set up a journey or automation to respond to referral events and send the email itself.

findMatchingProfiles(Referral referral)

Returns: List<ReferralProfile>

Finds enabled profiles, in the current tenant organisation, whose email address matches a referral's recipient email. Used to detect an existing account before creating a new one to accept the referral.

ParameterDescription
referralthe referral whose recipient email is matched, may be null
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.