Here is a description of Each Method of the class API_HELPER in order to get access to all information provided by the SDK.
A whole set of public methods exists within the SDK using which you can easily access most of the data.
formSubmit(param: RHSubscriber)
Submits a form to create a new subscriber.
getSubscriberDetail()`
Fetches details for a subscriber.
DeleteSubscriber()
Deletes a subscriber
UpdateSubscriber(param: RHSubscriber)
Updates subscriber details.
clickCapture(social: String)
Captures a click action for a specified social media
getMyReferrals()
Retrieves referral data for the subscriber
getLeaderboard()
Fetches the leaderboard data
trackReferral(param: RHTrackReferral)
Tracks a referral event
ConfirmReferral()
Confirms a referral
OrganicTrackReferral(param: RHOrganicReferral)
Tracks an organic referral event
CreatePendingReferral(param: RHReferral)
Creates a pending referral
RewardsList()
Retrieves a list of rewards
ReferrerList()
Fetches a list of referrers based on specific parameters
Logout()
Logs out the current user and clears stored data
1. Add Subscriber
Setting/Updating the ReferralParams details is an important step. This is how ReferralHero would be aware of the identity of a business user as classified by your app.
To add a subscriber (for example, post a successful signup or login) simply call ReferralHero's RH.formSubmit() function and send the RHSubscriber information such as email address and name.
{"status":"ok","data": {"id":"sub_8645f85ac894","name":"Test User 10","email":"test10@gmail.com","phone_number":"","crypto_wallet_address":"","crypto_wallet_provider":"","extra_field":"","extra_field_2":"","option_field":"","conversion_amount":0,"code":"3ab0f674","position":10,"referred":false,"referred_by": {},"people_referred":0,"promoted":false,"promoted_at": null,"verified":true,"verified_at":1684403108,"points":0,"risk_level":0,"host":"https://app.referralhero.com/dashboard/lists/MF83c9616aa3/analytics/traffic","source": null,"device": null,"referral_link":"https://app.referralhero.com/dashboard/lists/MF83c9616aa3/analytics/traffic?mwr=3ab0f674","created_at":1684403108,"last_updated_at":1684403108,"response":"subscriber_created" },"calls_left": null,"timestamp":1684403108}
NOTE:
The parameters need to be sent in the correct order for our system to automatically generate a referral.
2. Update Subscriber Details
This method is used to update various user related data.
First, create a RHSubscriber model and set the user data you want to update.
To update the subscriber simply call ReferralHero's RH.UpdateSubscriber() function and send the RHSubscriber information such as email address and name.
This method is used to track the referral conversion event. It means it is used to convert Referral status from pending to unconfirmed/confirmed.
If the referrer is present in the API request params, we will check the referral unique identifier in your campaign and, if found, the referral status will be updated and, if not found, we will create the referral and set the referral status.
If the referrer is not present in the API request params, we will check the referral unique identifier in your campaign and, if found, the referral status will be updated and, if not found, the referral will not be created.
Note:
Your campaign must be set up as a custom event or a multi-step event otherwise, an error will return.
If the referral is present in ReferralHero with pending status, a successful response custom_event_completed will return.
If the referral unique identifier is not present in the ReferralHero, but the referrer unique identifier is present, a successful response custom_event_completed with the data of the new confirmed referral will return.
If a referral exists but the referral status is not pending, the error custom event is already completed will return.
If the referral unique identifier is not present in ReferralHero and the referrer is also not provided in the API, the error referer is invalid or not present will return.
If the referral status is unconfirmed or confirmed, the error custom event is already completed will return.
uniqueIdentifier is a placeholder.
When tracking referrals on your App you should ALWAYS send the ACTUAL unique identifier (email, phone number, crypto wallet address, or other ID) of the user in RHSubscriber class Object
Call RH.trackReferral(RHTrackReferralreferralparams ). Use the following code to Track referral:
{"status":"error","message":"Custom Event is already completed.","code":"custom_event_already_completed"}
6. Capture Share
Step 1. Method Usage
This method is used to send the Share event to the RH. It means if a user called this method with any params like Facebook, messenger, etc. We capture this as a share in our system.
Call the RH.clickCapture method of the RH class and pass “social” as an input parameter. Use the following code to Capture Share for a user:
This method is used for creating a Referral with the Pending Status.
Create a ReferralParams class object and set the various user details to recognize the user matching your back-end system. To add a pending referral, simply call ReferralHero's RH.CreatePendingReferral() function and send the ReferralParams information such as email address and name.
If you would like to track referrals or add organic subscribers on the conversion page to your referral campaign, you can use this method.
If the Referrer code and uniqueidentifier are present, a Referral is created with the status unconfirmed/confirmed referral on the basis of the ‘Review Referral’ feature enabled/disabled.
If the Referrer code is not present but uniqueidentifier is present, an Organic Subscriber is created.
If the Referrer code is not present but a uniqueidentifier is present and a Referral already exists with the same uniqueidentifier in the campaign with pending status, the Referral Status will convert from pending to unconfirmed/confirmed on the basis of the ‘Review Referral’ feature enabled/disabled.
Create a RHOrganicReferral model and set the various user details to recognize the user matching your back-end system.
Confirm a referral. Useful when your campaign Goal is set to a "3-step conversion event" option and you want to confirm referrals when they complete your 3rd conversion event.
Only verified referrals can be confirmed. Trying to confirm a non-verified referral will return a subscriber_not_found error.
Call the RH.ConfrimReferral method of the RH class.
RH.ConfirmReferral()
{"status":"error","message":"Subscriber is already confirmed","code":"subscriber_already_confirmed"}
12. Get Referrer
Call the RH.ReferrerList method of the RH class. Use the following code to get the referrer: