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
| Property | Returns | Description |
|---|---|---|
| allReferralPrograms | List<ReferralProgram> | All referral programs configured for the current tenant organisation. |
| generateEmail | 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. |
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.
| Parameter | Description |
|---|---|
p | the 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.
| Parameter | Description |
|---|---|
promo | the reward to search for |
findProgramById(long id)
Returns: ReferralProgram
Looks up a referral program, scoped to the current tenant organisation, by its database id.
| Parameter | Description |
|---|---|
id | the referral program's id |
findProgramByName(String name)
Returns: ReferralProgram
Looks up a referral program, scoped to the current tenant organisation, by its unique name.
| Parameter | Description |
|---|---|
name | the 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.
| Parameter | Description |
|---|---|
referralToken | the 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.
| Parameter | Description |
|---|---|
program | the referral program the referral must belong to |
referralToken | the 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.
| Parameter | Description |
|---|---|
id | the referral's id |
findAcceptanceById(Long id)
Returns: ReferralAcceptance
Looks up a referral acceptance, scoped to the current tenant organisation, by its database id.
| Parameter | Description |
|---|---|
id | the 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.
| Parameter | Description |
|---|---|
r | the 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.
| Parameter | Description |
|---|---|
b | the 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.
| Parameter | Description |
|---|---|
r | the referral to check |
acceptor | the 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.
| Parameter | Description |
|---|---|
r | the 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.
| Parameter | Description |
|---|---|
b | the 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.
| Parameter | Description |
|---|---|
referral | the referral whose recipient email is matched, may be null |