# Public Methods

ReferralHero provides a very simple and efficient approach for an application to communicate with our SDK.

A whole set of public methods exists within the SDK using which you can easily access most of the data, execute various SDK tasks, invoke from a large set of APIs, etc.

RH is the main object through which you can access all the APIs and get its response in the delegate methods.assign delegate of Viewcontroller class like below.

Use the following code to instantiate the RH class:

```swift
override func viewDidLoad() {
        super.viewDidLoad()
        RH.delegate = self
    }
`
```

Here are the delegate methods by which Response will be received:

{% code overflow="wrap" %}

```swift
extension CreateAccount: RHDelegate{
    func didReceiveAPIResponse(_ response: [String : Any], _ endPoint:                          String) {
        print("\(endPoint) \n + \(response)")
    }
    	
    func didFailWithError(_ error: Error, _ endPoint: String) {
        print("\(endPoint) \n + \(error)")
    }
}
```

{% endcode %}

### **1. Add Subscriber**

This method is most commonly used to add an organic subscriber or create a referral (if identified) after a user successfully signs up or logs in to your app.

When using this method please take note of your Campaign Goal as our tracking logic will depend on if you are tracking a single or multi-step conversion event.

{% hint style="info" %}
**GOAL: One Conversion Event**\
If you have your Campaign Goal set up to track one conversion event, the following tracking logic will take place:

* If a referral, a referral will be automatically created and set to Confirmed in the correct campaign.
* If not a referral, an organic subscriber will be created in the campaign UUID specified.
* If the subscriber exists in our database, the subscriber will be 'identified'. Data is not overwritten. Additional data will be created.
  {% endhint %}

{% hint style="info" %}
**GOAL: Two or Three Conversion Events**\
If you have your Campaign Goal set up to track two or three conversion events, the following tracking logic will take place:

* If a referral, a referral will be created and set to Pending in the correct campaign.
* If not a referral, an organic subscriber will be created in the campaign UUID specified.
* If the subscriber exists in our database, the subscriber will be 'identified'. Data is not overwritten.
  {% endhint %}

**Step 1. Input Parameters**

**Parameters**

<table data-header-hidden><thead><tr><th width="382"></th><th></th></tr></thead><tbody><tr><td><p><strong>referralParams</strong></p><p>RHSubscriber</p></td><td><p>You can access the subscriber model to pass the input parameters.</p><p>Required Parameters : email, domain, name</p></td></tr><tr><td><p><strong>Response</strong></p><p>didReceiveAPIResponse</p><p>didFailWithError</p></td><td>In RHDelegate methods you will get the response model</td></tr></tbody></table>

Here are more input parameters.

This class provides various methods to set several user referral details like name, email, device, etc. This class is used mainly to pass referral details data to the SDK while accessing its public method or while updating user information.

\
**Step 2. ReferRHSubscriber Model**

<table><thead><tr><th width="345"></th><th></th></tr></thead><tbody><tr><td><strong>Method</strong></td><td><strong>Description</strong></td></tr><tr><td>transaction_id (String)</td><td>The unique ID of the transaction. Useful for tracking referrals for purchases.</td></tr><tr><td>conversion_category (String)</td><td>The type of referral. Useful for creating reports.</td></tr><tr><td>conversion_value (String)</td><td>The monetary value of the referral.</td></tr><tr><td>device (String value)</td><td>The device used by the subscriber to sign up. Used for analytics.</td></tr><tr><td>email (String value)</td><td>The email of the subscriber.</td></tr><tr><td>domain (String)</td><td>The URL for the referral link.</td></tr><tr><td>name (String)</td><td>The name of the subscriber.</td></tr><tr><td>referrer (String)</td><td>We will get it from the universal link.</td></tr><tr><td>visitorId (String)</td><td>We will get it from the universal link.</td></tr><tr><td>source (String)</td><td>The source of the subscriber. Used for analytics.</td></tr><tr><td>crypto_wallet_address (String)</td><td>The crypto wallet address</td></tr><tr><td>extra_field (String)</td><td>The extra field of the subscriber.</td></tr><tr><td>extra_field2 (String)</td><td>The extra field 2 of the subscriber.</td></tr><tr><td>points (String)</td><td>The number of points for the subscriber. Only applicable for "contest" campaigns.</td></tr><tr><td>phone_number (String)</td><td>The Phone Number of subscriber</td></tr><tr><td>double_optin (string value)</td><td>If set to false, the subscriber will not receive a confirmation email.</td></tr><tr><td>status (String)</td><td>Use 'custom_event_pending' to set the referral status to pending</td></tr></tbody></table>

**Step 3. Implementation**

**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.

{% tabs %}
{% tab title="Input" %}
{% code overflow="wrap" %}

```swift
func formSubmit()
    {
        RH.formSubmit(param: RHSubscriber(
        email: "xyz@gmail.com", //Required value, capture this from user
        domain: "www.abc.com", //Required value, should match the default referral link set within your RH account
        name: “ABC", //Optional but recommended, capture this from user
        referrer: "53f8acf7", // Optional value, Get from the universal link.
        visitorId: sub_********, // Optional value, Get this from the universal link params.
        device: "iPhone", //Required value, see below
        os_type:"iOS", //Required value, see below
        status: "custom_event_pending" //Use 'custom_event_pending' to set the referral status to pending
        ))
    }
```

{% endcode %}
{% endtab %}

{% tab title="Output" %}

```swift
 {
    "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/MFxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "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
}
```

{% endtab %}
{% endtabs %}

The minimum values you should send for the endpoint to work are the following:

```java
param: RHSubscriber(
        email: "xyz@gmail.com", 
        domain: "www.abc.com")
```

### **2. Add Pending Referral**

This method is most commonly used to create a referral entering the 1st step of your multi-step conversion event funnel (i.e. after a referred user successfully signs up for your app). If you want us to automatically add every user to your campaign and determine if the user is a referral or not, use the Add Subscriber method instead. This logic only checks for referrals:

{% hint style="info" %}
**Tracking Logic**

**GOAL: Two or Three Conversion Events**

Your campaign Goal must be set up to track two or three conversion events, and then the following tracking logic will take place:

* If a referral, a referral will be automatically created and set to Pending in the correct campaign.
* If not a referral, no subscriber will be created.
  {% endhint %}

**Step 1. Input Parameters**

**Parameters**

| <p><strong>referralParams</strong></p><p>RHReferral</p>                             | Carrying the referral data.                           |
| ----------------------------------------------------------------------------------- | ----------------------------------------------------- |
| <p><strong>Response</strong></p><p>didReceiveAPIResponse</p><p>didFailWithError</p> | In RHDelegate methods you will get the response model |

**Step 2. Implementation**

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.

{% tabs %}
{% tab title="Input" %}
{% code overflow="wrap" %}

```swift
RH.CreatePendingReferral(param: RHReferral(
        email: "xyz@gmail.com", //Capture this from user
        domain: "www.abc.com", 
        name: “ABC", //Capture this from user
        referrer: "53f8acf7", // Optional value, Get from the universal link.
        visitorId: sub_********, // Get this from the universal link params.
        device: "iPhone", //Required value, see below
        os_type:"iOS", //Required value, see below
        status: "custom_event_pending" //Use 'custom_event_pending' to set the referral status to pending
        )))
```

{% endcode %}
{% endtab %}

{% tab title="Output" %}

```
{
  "status": "ok",
  "data": {
    "id": "sub_1bb1e02b90cb",
    "name": "Pending Referral",
    "email": "testpending1@email.com",
    "phone_number": "",
    "crypto_wallet_address": "",
    "crypto_wallet_provider": "",
    "extra_field": "",
    "extra_field_2": "",
    "option_field": "",
    "conversion_amount": 0,
    "code": "1b155f4e",
    "position": 3,
    "referred": true,
    "referred_by": {
      "id": "sub_7b9be1ed8ccb",
      "name": "Test User 10",
      "email": "test15@gmail.com",
      "code": "2c2dbefb",
      "people_referred": 0,
      "points": 0
    },
    "people_referred": 0,
    "promoted": false,
    "promoted_at": null,
    "verified": true,
    "verified_at": 1685018482,
    "points": 0,
    "risk_level": 0,
    "host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxx/analytics/traffic",
    "source": null,
    "device": "IOS",
    "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic?mwr=1b155f4e",
    "created_at": 1685018482,
    "last_updated_at": 1685018482,
    "os_type": "IOS",
    "screen_size": "64*32",
    "ip_address": "123.456.789.0123",
    "response": "subscriber_created"
  },
  "calls_left": null,
  "timestamp": 1685018482
}
```

{% endtab %}
{% endtabs %}

The minimum values you should send for the endpoint to work are the following:

```java
param: RHReferral(
        email: "xyz@gmail.com", 
        referrer: "M12345fc2")
```

### **3. Track Referral**

This method is used for tracking a referral conversion event (i.e. a purchase, but can be any conversion event).

{% hint style="info" %}
**Tracking Logic**:

* If a referral and pre-existing in the campaign as Pending

**OR**

* If a referral and setReferrer or mobile pramas are provided, a referral is automatically created in the correct campaign and

**The Referral Is Set To:**

* Confirmed (if tracking two conversion events)
* Unconfirmed (if tracking three conversion events)
  {% endhint %}

Note:

1. Your campaign must be set up as a custom event or a multi-step event otherwise, an error will return.
2. If the referral is present in ReferralHero with pending status, a successful response `custom_event_completed` will return.
3. 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.
4. If a referral exists but the referral status is not pending, the error `custom event is already completed` will return.
5. 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.
6. If the referral status is unconfirmed or confirmed, the error `custom event is already completed` will return.

{% hint style="info" %}

* 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
  {% endhint %}

**Step 1. Input Parameters**

**Parameters**

| <p><strong>referralParams</strong></p><p>RHTrackReferral</p>                        | You can pass email and name.                          |
| ----------------------------------------------------------------------------------- | ----------------------------------------------------- |
| <p><strong>Response</strong></p><p>didReceiveAPIResponse</p><p>didFailWithError</p> | In RHDelegate methods you will get the response model |

**Step 2. Implementation**

Call `RH.trackReferral`(**RHTrackReferral** *referralparams* ). Use the following code to Track Referral:

{% tabs %}
{% tab title="Input" %}
{% code overflow="wrap" %}

```swift
RH.trackReferral(param: RHTrackReferral(
email: "xyz@gmail.com", //Required value, capture this from user
name: “ABC", //Optional value, capture this from user
referrer:"52f7acf8", // Optional value, Get from the universal link.
visitorId: sub_********, // Get this from the universal link params.
device: "iPhone",//Optional value, only required if the user does not exist in the campaign
os_type:"iOS"//Optional value, only required if the user does not exist in the campaign
))
```

{% endcode %}
{% endtab %}

{% tab title="Output" %}

```swift
{
  "status": "error",
  "message": "Custom Event is already completed.",
  "code": "custom_event_already_completed"
}
```

{% endtab %}
{% endtabs %}

**If the referral is pre-existing in the campaign**, the minimum value for this endpoint to work:

```java
param: RHTrackReferral(
email: "xyz@gmail.com",
)
```

{% hint style="info" %}
**If the referral is NOT pre-existing in the campaign** (and you want to identify and create a referral), you must send either the setReferrer OR the required Visitor Id is provided in the correct format so that our matching algorithm can automatically identify a referral. See the Getting Started section here.
{% endhint %}

### **4. Confirm Referral**

Use this method when your Campaign Goal is set to track three conversion events and you want to confirm a referral when your third conversion event occurs (complete profile, upgrade to a paid plan, end of the trial, etc).

{% hint style="info" %}
**Tracking Logic**:

* If a referral and pre-existing in the campaign as Unconfirmed

**The Referral Is Set To:**

* Confirmed (if tracking three conversion events)
  {% endhint %}

{% hint style="warning" %}
Only verified referrals can be confirmed. Trying to confirm a non-verified referral will return a `subscriber_not_found` error.
{% endhint %}

**Step 1. Input Parameter**

**Parameters**

| <p><strong>Response</strong></p><p>didReceiveAPIResponse</p><p>didFailWithError</p> | In RHDelegate methods you will get the response model |
| ----------------------------------------------------------------------------------- | ----------------------------------------------------- |

**Step 2. Implementation**

Call the `RH.ConfrimReferral` method of the RH class.

{% tabs %}
{% tab title="Input" %}

```swift
RH.ConfirmReferral()
```

{% endtab %}

{% tab title="Output" %}

```swift
{
  "status": "error",
  "message": "Subscriber is already confirmed",
  "code": "subscriber_already_confirmed"
}
```

{% endtab %}
{% endtabs %}

### **5. Organic Track Referral**

If you would like to add an organic subscriber or a track referral on the conversion page to your referral campaign, you can use the following method. This method would most commonly be used if the **user has not been previously added to your campaign** and instead directly passes through a post-checkout/subscribe event.

{% hint style="info" %}
**Tracking Logic**:

* If a referral and pre-existing in the campaign as Pending

**OR**

* If a referral and setReferrer or Visitor Id is provided, a referral is automatically created in the correct campaign and

**The Referral Is Set To:**

* Confirmed (if tracking two conversion events)
* Unconfirmed (if tracking three conversion events)

**OR**

* If not a referral, an organic subscriber is created in the campaign UUID specified.
  {% endhint %}

**Step 1. Input Parameters**

**Parameters**

| <p><strong>referralParams</strong></p><p>RHOrganicReferral</p><p><br></p>           | <p>Add all the Input parameters as string.</p><p>email</p><p>name</p><p>referrer</p><p>hosting\_url</p> |
| ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| <p><strong>Response</strong></p><p>didReceiveAPIResponse</p><p>didFailWithError</p> | In RHDelegate methods you will get the response model                                                   |

**Step 2. Implementation**

Create a RHOrganicReferral model and set the various user details to recognize the user matching your back-end system.

{% tabs %}
{% tab title="Input" %}
{% code overflow="wrap" %}

```swift
RH.OrganicTrackReferral(param: RHOrganicReferral(email: "abc@gmail.com", name: "ABC"))
```

{% endcode %}
{% endtab %}

{% tab title="Output" %}

```json
{
  "status": "ok",
  "data": {
    "id": "sub_41adff0cfc8e",
    "name": "Test organic User1",
    "email": "testorganic1@gmail.com",
    "phone_number": "",
    "crypto_wallet_address": "",
    "crypto_wallet_provider": "",
    "extra_field": "",
    "extra_field_2": "",
    "option_field": "",
    "conversion_amount": 0,
    "code": "23e0fb1c",
    "position": 5,
    "referred": true,
    "referred_by": {
      "id": "sub_7b9be1ed8ccb",
      "name": "Test User 10",
      "email": "test15@gmail.com",
      "code": "2c2dbefb",
      "people_referred": 0,
      "points": 0
    },
    "people_referred": 0,
    "promoted": false,
    "promoted_at": null,
    "verified": true,
    "verified_at": 1685020506,
    "points": 0,
    "risk_level": 0,
    "host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic",
    "source": null,
    "device": null,
    "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxx/analytics/traffic?mwr=23e0fb1c",
    "created_at": 1685020506,
    "last_updated_at": 1685020506,
    "os_type": null,
    "screen_size": null,
    "ip_address": null,
    "response": "subscriber_created"
  },
  "calls_left": null,
  "timestamp": 1685020506
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
**If the referral is NOT pre-existing in the campaign** (and you want to identify and create a referral), you must send either the setReferrer OR the required Visitor Id is provided in the correct format so that our matching algorithm can automatically identify a referral. See the Getting Started section here.
{% endhint %}

### **6. Update Subscriber Details**

This method is used to update various subscriber related data.

First, create a RHSubscriber model and set the user data you want to update.

**Parameters**

| <p><strong>referralParams</strong></p><p>RHSubscriber</p>                           | Carrying the user data to be updated.                 |
| ----------------------------------------------------------------------------------- | ----------------------------------------------------- |
| <p><strong>Response</strong></p><p>didReceiveAPIResponse</p><p>didFailWithError</p> | In RHDelegate methods you will get the response model |

**Step 1. Input Parameters**

**Step 2. ReferRHSubscriber Model**

**Step 3. Implementation**

To update the subscriber simply call ReferralHero's `RH.UpdateSubscriber()` function and send the `RHSubscriber` information such as email address and name.

{% tabs %}
{% tab title="Input" %}
{% code overflow="wrap" %}

```swift
  RH.UpdateSubscriber(param: RHSubscriber(email:"abc@gmail.com", domain: "www.xyz.com", name: "abc"))

```

{% endcode %}
{% endtab %}

{% tab title="Output" %}

```json
{
  "status": "ok",
  "data": {
    "response": "subscribers_retrieved",
    "subscribers": [
      {
        "id": "sub_fa49ba0d30e9",
        "name": "Test User 10",
        "email": "test125@gmail.com",
        "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": "test26@gmail.com",
          "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/MFxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxx/analytics/traffic?mwr=dededb46",
        "created_at": 1684985427,
        "last_updated_at": 1684985427
      }
    ],
    "pagination": {
      "total_pages": 1,
      "current_page": 1,
      "per_page": 50,
      "total_objects": 1
    }
```

{% endtab %}
{% endtabs %}

### **7. Get Subscriber Details**

This method is used to retrieve Subscriber details. RH.getSubscriberDetail()

**Step 1. Input Parameters**

**Parameters**

| <p><strong>Response</strong></p><p>didReceiveAPIResponse</p><p>didFailWithError</p> | In RHDelegate methods you will get the response model |
| ----------------------------------------------------------------------------------- | ----------------------------------------------------- |

**Step 2. Implementation**

To get the subscriber details simply call ReferralHero's `RH.getSubscriberDetail()` function.

{% tabs %}
{% tab title="Input" %}

```swift
  RH.getSubscriberDetail()
```

{% endtab %}

{% tab title="Output" %}

```json
{
    "status": "ok",
    "data": {
        "id": "sub_ee32baa54196",
        "name": "Test User 10",
        "email": "test15@gmail.com",
        "phone_number": "",
        "crypto_wallet_address": "",
        "crypto_wallet_provider": "",
        "extra_field": "",
        "extra_field_2": "",
        "option_field": "",
        "conversion_amount": 0,
        "code": "e7ceeff6",
        "position": 1,
        "referred": false,
        "referred_by": {},
        "people_referred": 0,
        "promoted": false,
        "promoted_at": null,
        "verified": true,
        "verified_at": 1684408479,
        "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/MFxxxxxxxxxx/analytics/traffic?mwr=e7ceeff6",
        "created_at": 1684408479,
        "last_updated_at": 1684408479,
        "response": "subscriber_retrieved"
    },
    "calls_left": null,
    "timestamp": 1684414915
}


```

{% endtab %}
{% endtabs %}

### **8. Delete Subscriber**

This method is used to Delete a newly Created Subscriber.

**Step 1. Input Parameters**

**Parameters**

| <p><strong>Response</strong></p><p>didReceiveAPIResponse</p><p>didFailWithError</p> | In RHDelegate methods you will get the response model |
| ----------------------------------------------------------------------------------- | ----------------------------------------------------- |

**Step 2. Implementation**

To delete the subscriber simply call ReferralHero's `RH.DeleteSubscriber()`.

{% tabs %}
{% tab title="Input" %}

```
  RH.DeleteSubscriber()
```

{% endtab %}

{% tab title="Output" %}

```
{
    "status": "ok",
    "data": {
        "id": "sub_0d7cfab3a25f",
        "name": "Test User 10",
        "email": "android3@test",
        "phone_number": "",
        "crypto_wallet_address": "",
        "crypto_wallet_provider": "",
        "extra_field": "",
        "extra_field_2": "",
        "option_field": "",
        "conversion_amount": 0,
        "code": "41eace36",
        "position": 8,
        "referred": false,
        "referred_by": {},
        "people_referred": 0,
        "promoted": false,
        "promoted_at": null,
        "verified": true,
        "verified_at": 1684831504,
        "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/MFxxxxxxxxx/analytics/traffic?mwr=41eace36",
        "created_at": 1684831504,
        "last_updated_at": 1684831504,
        "response": "subscriber_deleted"
    },
    "calls_left": null,
    "timestamp": 1685012056
}
```

{% endtab %}
{% endtabs %}

### **9. 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.

**Step 2. Input Parameters**

**Parameters**

| <p><strong>referralParams</strong></p><p>social</p>                                 | Add the Input para as string.                         |
| ----------------------------------------------------------------------------------- | ----------------------------------------------------- |
| <p><strong>Response</strong></p><p>didReceiveAPIResponse</p><p>didFailWithError</p> | In RHDelegate methods you will get the response model |

**Step 3. Implementation**

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:

{% tabs %}
{% tab title="Input" %}

```swift
RH.clickCapture(social: "facebook")
```

{% endtab %}

{% tab title="Output" %}

```
{
  "status": "ok",
  "data": {
    "id": "sub_0d7cfab3a25f",
    "name": "Test User 10",
    "email": "android3@test",
    "phone_number": "",
    "crypto_wallet_address": "",
    "crypto_wallet_provider": "",
    "extra_field": "",
    "extra_field_2": "",
    "option_field": "",
    "conversion_amount": 0,
    "code": "41eace36",
    "position": 8,
    "referred": false,
    "referred_by": {},
    "people_referred": 0,
    "promoted": false,
    "promoted_at": null,
    "verified": true,
    "verified_at": 1684831504,
    "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/MFxxxxxxxxxx/analytics/traffic?mwr=41eace36",
    "created_at": 1684831504,
    "last_updated_at": 1684831504,
    "response": "click captured"
  },
  "calls_left": null,
  "timestamp": 1685006602
}
```

{% endtab %}
{% endtabs %}

### **10. Get My Referrals**

This method is used for retrieving all referrals of the specific subscriber.

**Step 1. Input Parameters**

**Parameters**

| <p><strong>Response</strong></p><p>didReceiveAPIResponse</p><p>didFailWithError</p> | In RHDelegate methods you will get the response model |
| ----------------------------------------------------------------------------------- | ----------------------------------------------------- |

**Step 2. Implementation.**

Call `RH.getMyReferrals()` method of the RH class

Use the following code to Get My Referrals:

{% tabs %}
{% tab title="Input" %}

```swift
RH.getMyReferrals()
```

{% endtab %}

{% tab title="Output" %}

```json
{
  "status": "ok",
  "data": {
    "response": "subscribers_retrieved",
    "subscribers": [
      {
        "id": "sub_fa49ba0d30e9",
        "name": "Test User 10",
        "email": "test125@gmail.com",
        "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": "test26@gmail.com",
          "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/MFxxxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/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
}
```

{% endtab %}
{% endtabs %}

### **11. Get Leaderboard**

This method is used for retrieving the campaign leaderboard. It will get the leaderboard from the Campaign specified in the Appdelegate.swift file.

**Step 1. Input Parameters**

**Parameters**

| <p><strong>Response</strong></p><p>didReceiveAPIResponse</p><p>didFailWithError</p> | In RHDelegate methods you will get the response model |
| ----------------------------------------------------------------------------------- | ----------------------------------------------------- |

**Step 2. Implementation**

Call the `RH.getLeaderboard()` method of the RH class to get the Subscriber Leaderboard.

{% tabs %}
{% tab title="Input" %}

```swift
RH.getLeaderboard()
```

{% endtab %}

{% tab title="Output" %}

```json
{
  "status": "ok",
  "data": {
    "ranking": [
      {
        "id": "sub_7b9be1ed8ccb",
        "name": "Test User 10",
        "email": "test15@gmail.com",
        "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,
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxx/analytics/traffic?mwr=2c2dbefb",
        "created_at": 1685018462,
        "last_updated_at": 1685020506
      },
      {
        "id": "sub_06e2af5a2236",
        "name": "Test User multi1",
        "email": "testorganic3@gmail.com",
        "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/MFxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic?mwr=afd54225",
        "created_at": 1685018562,
        "last_updated_at": 1685018562
      }
    ],
    "count": 2
  },
  "calls_left": null,
  "timestamp": 1685020750
}
```

{% endtab %}
{% endtabs %}

### **12. Get Referrer**

**Step 1. Input Parameter**

**Parameters**

| <p>Response</p><p>didReceiveAPIResponse</p><p>didFailWithError</p> | In RHDelegate methods you will get the response model |
| ------------------------------------------------------------------ | ----------------------------------------------------- |

**Step 2. Implementation**

Call the RH.GetReferrer() method of the RH class. Use the following code to get the referrer:

{% tabs %}
{% tab title="Input" %}

```
RH.GetReferrer()
```

{% endtab %}

{% tab title="Output" %}

```json
{
  "status": "ok",
  "data": {
    "id": "sub_68c9ed9e2712",
    "name": "test one",
    "email": "test1@gmail.com",
    "phone_number": "",
    "crypto_wallet_address": "",
    "crypto_wallet_provider": "",
    "extra_field": "",
    "extra_field_2": "",
    "option_field": "",
    "conversion_amount": 0,
    "code": "00598133",
    "position": 3,
    "referred": false,
    "referred_by": {},
    "people_referred": 1,
    "promoted": false,
    "promoted_at": null,
    "verified": true,
    "verified_at": 1686310876,
    "points": 0,
    "risk_level": 0,
    "host": "https://app.referralhero.com",
    "source": null,
    "device": null,
    "referral_link": "https://app.referralhero.com?mwr=00598133",
    "created_at": 1686310876,
    "last_updated_at": 1686311874,
    "response": "subscriber_retrieved"
  },
  "calls_left": null,
  "timestamp": 1686554060
}
```

{% endtab %}
{% endtabs %}

### **13. Get Rewards**

Call the RH.RewardsList method of the RH class. Use the following code to get the rewards:

{% tabs %}
{% tab title="Input" %}

```swift
RH.RewardsList()
```

{% endtab %}

{% tab title="Output" %}

```swift
{
  "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
      }
    ],
    "pagination": {
      "total_pages": 1,
      "current_page": 1,
      "per_page": 10,
      "total_objects": 1
    }
  },
  "calls_left": null,
  "timestamp": 1686561327
}
```

{% endtab %}
{% endtabs %}
