Listeners & Interfaces
ReferralHero Kotlin / Java SDK
ReferralHero provides various interfaces with its SDK that can be used to receive a callback upon successful execution, or in case of some error while executing the API.
You can use these callbacks to:
Track the execution of the API
Check if the API call is successful or not
Receive API response data or some other data depending on the API
Get error message in case the API call fails
RHReferralCallBackListener
Callback interface for when the AddSubscriber, UpdateSubscriber, and also use in other API finishes execution.
This interface is used to receive a callback while updating Subscriber detail and status.
There are 2 methods in this Listener like success and failure methods
fun onSuccessCallback(response: String?)
fun onFailureCallback(response: String?)
onSuccessCallback method call, when the API finishes execution With success if api execution finishes with exception it will call onFailureCallback.
Parameters
response – String check below response for reference
Subscriber Data Class Sample Response
{
"status": "ok",
"data": {
"id": "sub_8645f85ac894",
"name": "Test User 10",
"email": "[email protected]",
"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/MFxxxxxxxxxx/analytics/traffic",
"source": null,
"device": null,
"status":"",
"referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxx/analytics/traffic?mwr=3ab0f674",
"created_at": 1684403108,
"last_updated_at": 1684403108,
"response": "subscriber_created"
},
"calls_left": null,
"timestamp": 1684403108
}
RHMyReferralCallBackListener
Callback interface for when the Get My Referral API finishes execution.
This interface is used to receive a callback while retrieving my Referral details.
There are 2 methods in this Listener like success and failure methods
fun onMyReferralSuccessCallback(response: String?)
fun onMyReferralFailureCallback(response: String?)
onMyReferralSuccessCallback method call, when the API finishes execution With success if api execution finishes with exception it will call onMyReferralFailureCallback.
Parameters
response– ApiResponse<ListSubscriberData> check below response for reference
Get My Referral Sample Response
{
"status": "ok",
"data": {
"response": "subscribers_retrieved",
"subscribers": [
{
"id": "sub_fa49ba0d30e9",
"name": "Test User 10",
"email": "[email protected]",
"phone_number": "",
"crypto_wallet_address": "",
"crypto_wallet_provider": "",
"extra_field": "",
"extra_field_2": "",
"option_field": "",
"conversion_amount": 0,
"code": "dededb46",
"position": 20,
"referred": true,
"referred_by": {
"id": "sub_d0cc231dce89",
"name": "Test name",
"email": "[email protected]",
"code": "0879561f",
"people_referred": 1,
"points": 0
},
"people_referred": 0,
"promoted": false,
"promoted_at": null,
"verified": true,
"verified_at": 1684985427,
"points": 0,
"risk_level": 0,
"host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxx/analytics/traffic",
"source": null,
"device": null,
"referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxxx/analytics/traffic?mwr=dededb46",
"created_at": 1684985427,
"last_updated_at": 1684985427
}
],
"pagination": {
"total_pages": 1,
"current_page": 1,
"per_page": 50,
"total_objects": 1
}
},
"calls_left": null,
"timestamp": 1685012334
}
RHLeaderboardReferralCallBackListener
Callback interface for when the Get My Referral API finishes execution.
This interface is used to receive a callback while retrieving my Referral details.
There are 2 methods in this Listener like success and failure methods
fun onLeaderboardReferralSuccessCallback(response: String?)
fun onLeaderboardReferralFailureCallback(response: String?)
onLeaderboardReferralSuccessCallback method call, when the API finishes execution With success if api execution finishes with exception it will call onLeaderboard ReferralFailureCallback.
Parameters
response– ApiResponse<RankingDataContent> check below response for reference
Get Leaderboard Sample Response
{
"status": "ok",
"data": {
"ranking": [
{
"id": "sub_7b9be1ed8ccb",
"name": "Test User 10",
"email": "[email protected]",
"phone_number": "",
"crypto_wallet_address": "",
"crypto_wallet_provider": "",
"extra_field": "",
"extra_field_2": "",
"option_field": "",
"conversion_amount": 0,
"code": "2c2dbefb",
"position": 1,
"referred": false,
"referred_by": {
},
"people_referred": 0,
"promoted": false,
"promoted_at": null,
"verified": true,
"verified_at": 1685018462,
"points": 0,
"risk_level": 0,
"host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxx/analytics/traffic",
"source": null,
"device": null,
"status":"",
"referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic?mwr=2c2dbefb",
"created_at": 1685018462,
"last_updated_at": 1685020506
},
{
"id": "sub_06e2af5a2236",
"name": "Test User multi1",
"email": "[email protected]",
"phone_number": "",
"crypto_wallet_address": "",
"crypto_wallet_provider": "",
"extra_field": "",
"extra_field_2": "",
"option_field": "",
"conversion_amount": 0,
"code": "afd54225",
"position": 2,
"referred": false,
"referred_by": {
},
"people_referred": 0,
"promoted": false,
"promoted_at": null,
"verified": true,
"verified_at": 1685018562,
"points": 0,
"risk_level": 0,
"host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxx/analytics/traffic",
"source": null,
"device": null,
"status":"",
"referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxx/analytics/traffic?mwr=afd54225",
"created_at": 1685018562,
"last_updated_at": 1685018562
}
],
"count": 2
},
"calls_left": null,
"timestamp": 1685020750
}
RHRewardsCallBackListener
Callback interface for when the Get Rewards API finishes execution.
This interface is used to receive a callback while retrieving my Referral details.
There are 2 methods in this Listener like success and failure methods
fun onRewardsSuccessCallback(response: String?)
fun onRewardsFailureCallback(response: String?)
onRewardsSuccessCallback method call, when the API finishes execution With success if api execution finishes with exception it will call onRewardsFailureCallback.
Parameters
response– ApiResponse<ListSubscriberData> check this response for reference
Get Rewards Sample Response
{
"status": "ok",
"data": {
"response": "rewards_retrieved",
"rewards": [
{
"id": 1795,
"name": "A free Premium account for 1 year",
"status": "confirmed",
"referrals": null,
"created_at": 1686397951,
"signup_type": "organic subscriber",
"referrals_type": null,
"recurring_count": null,
"image_url": null
}
],
"pagination": {
"total_pages": 1,
"current_page": 1,
"per_page": 10,
"total_objects": 1
}
},
"calls_left": null,
"timestamp": 1687759997
}
Last updated
Was this helpful?