# Referral


## List

<small class="badge badge-darkred">requires authentication</small>

Use this end point to get the list of referrals

> Example request:

```bash
curl -X GET \
    -G "https://apiqa.bettorfantasy.com/referrals?per_page=16&search=velit&sort_field=non&sort_method=veritatis&page=17&user_id=11&referred_user_id=15&season=2&week=11" \
    -H "Authorization: Bearer {YOUR_AUTH_KEY}" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json"
```


> Example response (200):

```json
{
    "message": "Referrals",
    "data": {
        "referrals": {
            "current_page": 1,
            "data": [
                {
                    "id": 4,
                    "user_id": 5,
                    "referred_user_id": 10,
                    "has_onboarding_completed": 1,
                    "referral_code": "01b6ad83-62e1-4bbe-aaa6-869d7ceaccb7",
                    "created_at": "2021-07-19T06:14:51.000000Z",
                    "updated_at": "2021-07-19T06:15:16.000000Z",
                    "season": 2020,
                    "week": 1,
                    "referred_by": [
                        {
                            "id": 5,
                            "email": "tahasethwala@gmail.com",
                            "username": "tahagmail",
                            "is_adult": 1,
                            "phone": "12345",
                            "avatar": "http:\/\/127.0.0.1:8000\/images\/avatar-default.png",
                            "is_email_verified": 0,
                            "is_phone_verified": 0,
                            "email_verified_date_time": null,
                            "phone_verified_date_time": null,
                            "password_last_changed_date_time": null,
                            "created_at": "2021-07-15T11:05:02.000000Z",
                            "updated_at": "2021-07-19T06:15:19.000000Z",
                            "is_active": 1,
                            "bucks": 0,
                            "credits": 2250,
                            "available_bucks": 0,
                            "available_credits": 2250,
                            "open_bucks": 0,
                            "open_credits": 0,
                            "referral_code": "01b6ad83-62e1-4bbe-aaa6-869d7ceaccb7"
                        }
                    ],
                    "referred_to": [
                        {
                            "id": 10,
                            "email": "tahaabbas123@yopmail.com",
                            "username": "tahaabbas123",
                            "is_adult": 1,
                            "phone": "1231312312311",
                            "avatar": "http:\/\/127.0.0.1:8000\/images\/avatar-default.png",
                            "is_email_verified": 1,
                            "is_phone_verified": 0,
                            "email_verified_date_time": "2021-07-19 11:45:15",
                            "phone_verified_date_time": null,
                            "password_last_changed_date_time": null,
                            "created_at": "2021-07-19T06:14:50.000000Z",
                            "updated_at": "2021-07-19T06:15:15.000000Z",
                            "is_active": 1,
                            "bucks": 0,
                            "credits": 0,
                            "available_bucks": 0,
                            "available_credits": 0,
                            "open_bucks": 0,
                            "open_credits": 0,
                            "referral_code": "e43a0ed2-b298-422e-9c93-5a2a2adcc98a"
                        }
                    ]
                },
                {
                    "id": 3,
                    "user_id": 5,
                    "referred_user_id": 9,
                    "has_onboarding_completed": 1,
                    "referral_code": "01b6ad83-62e1-4bbe-aaa6-869d7ceaccb7",
                    "created_at": "2021-07-19T06:12:39.000000Z",
                    "updated_at": "2021-07-19T06:13:18.000000Z",
                    "season": 2020,
                    "week": 1,
                    "referred_by": [
                        {
                            "id": 5,
                            "email": "tahasethwala@gmail.com",
                            "username": "tahagmail",
                            "is_adult": 1,
                            "phone": "12345",
                            "avatar": "http:\/\/127.0.0.1:8000\/images\/avatar-default.png",
                            "is_email_verified": 0,
                            "is_phone_verified": 0,
                            "email_verified_date_time": null,
                            "phone_verified_date_time": null,
                            "password_last_changed_date_time": null,
                            "created_at": "2021-07-15T11:05:02.000000Z",
                            "updated_at": "2021-07-19T06:15:19.000000Z",
                            "is_active": 1,
                            "bucks": 0,
                            "credits": 2250,
                            "available_bucks": 0,
                            "available_credits": 2250,
                            "open_bucks": 0,
                            "open_credits": 0,
                            "referral_code": "01b6ad83-62e1-4bbe-aaa6-869d7ceaccb7"
                        }
                    ],
                    "referred_to": [
                        {
                            "id": 9,
                            "email": "tahaabbas@yopmail.com",
                            "username": "tahaabbas",
                            "is_adult": 1,
                            "phone": "12313123123",
                            "avatar": "http:\/\/127.0.0.1:8000\/images\/avatar-default.png",
                            "is_email_verified": 1,
                            "is_phone_verified": 0,
                            "email_verified_date_time": "2021-07-19 11:43:18",
                            "phone_verified_date_time": null,
                            "password_last_changed_date_time": null,
                            "created_at": "2021-07-19T06:12:38.000000Z",
                            "updated_at": "2021-07-19T06:13:18.000000Z",
                            "is_active": 1,
                            "bucks": 0,
                            "credits": 0,
                            "available_bucks": 0,
                            "available_credits": 0,
                            "open_bucks": 0,
                            "open_credits": 0,
                            "referral_code": "32b5135b-6ca4-41c8-90f7-1ae749911301"
                        }
                    ]
                }
            ],
            "first_page_url": "http:\/\/127.0.0.1:8000\/referrals?per_page=10&search=&sort_field=id&sort_method=desc&is_active=&is_used=&page=1",
            "from": 1,
            "last_page": 1,
            "last_page_url": "http:\/\/127.0.0.1:8000\/referrals?per_page=10&search=&sort_field=id&sort_method=desc&is_active=&is_used=&page=1",
            "links": [
                {
                    "url": null,
                    "label": "pagination.previous",
                    "active": false
                },
                {
                    "url": "http:\/\/127.0.0.1:8000\/referrals?per_page=10&search=&sort_field=id&sort_method=desc&is_active=&is_used=&page=1",
                    "label": "1",
                    "active": true
                },
                {
                    "url": null,
                    "label": "pagination.next",
                    "active": false
                }
            ],
            "next_page_url": null,
            "path": "http:\/\/127.0.0.1:8000\/referrals",
            "per_page": 10,
            "prev_page_url": null,
            "to": 4,
            "total": 4
        }
    }
}
```
> Example response (422):

```json
{
    "message": "Validation Failed!",
    "errors": {
        "per_page": [
            "The per page must be a number."
        ]
    }
}
```
<div id="execution-results-GETreferrals" hidden>
    <blockquote>Received response<span id="execution-response-status-GETreferrals"></span>:</blockquote>
    <pre class="json"><code id="execution-response-content-GETreferrals"></code></pre>
</div>
<div id="execution-error-GETreferrals" hidden>
    <blockquote>Request failed with error:</blockquote>
    <pre><code id="execution-error-message-GETreferrals"></code></pre>
</div>
<form id="form-GETreferrals" data-method="GET" data-path="referrals" data-authed="1" data-hasfiles="0" data-headers='{"Authorization":"Bearer {YOUR_AUTH_KEY}","Content-Type":"application\/json","Accept":"application\/json"}' onsubmit="event.preventDefault(); executeTryOut('GETreferrals', this);">
<h3>
    Request&nbsp;&nbsp;&nbsp;
        <button type="button" style="background-color: #8fbcd4; padding: 5px 10px; border-radius: 5px; border-width: thin;" id="btn-tryout-GETreferrals" onclick="tryItOut('GETreferrals');">Try it out ⚡</button>
    <button type="button" style="background-color: #c97a7e; padding: 5px 10px; border-radius: 5px; border-width: thin;" id="btn-canceltryout-GETreferrals" onclick="cancelTryOut('GETreferrals');" hidden>Cancel</button>&nbsp;&nbsp;
    <button type="submit" style="background-color: #6ac174; padding: 5px 10px; border-radius: 5px; border-width: thin;" id="btn-executetryout-GETreferrals" hidden>Send Request 💥</button>
    </h3>
<p>
<small class="badge badge-green">GET</small>
 <b><code>referrals</code></b>
</p>
<p>
<label id="auth-GETreferrals" hidden>Authorization header: <b><code>Bearer </code></b><input type="text" name="Authorization" data-prefix="Bearer " data-endpoint="GETreferrals" data-component="header"></label>
</p>
<h4 class="fancy-heading-panel"><b>Query Parameters</b></h4>
<p>
<b><code>per_page</code></b>&nbsp;&nbsp;<small>integer</small>     <i>optional</i> &nbsp;
<input type="number" name="per_page" data-endpoint="GETreferrals" data-component="query"  hidden>
<br>
Number of records per page. Send '-1' for all records. Default: 10. Ex: 15
</p>
<p>
<b><code>search</code></b>&nbsp;&nbsp;<small>string</small>     <i>optional</i> &nbsp;
<input type="text" name="search" data-endpoint="GETreferrals" data-component="query"  hidden>
<br>
Search string. Search will be performed in referred_by:username, email, phone, referred_to:username, email, phone, referral_code. Ex: tahasethwala
</p>
<p>
<b><code>sort_field</code></b>&nbsp;&nbsp;<small>string</small>     <i>optional</i> &nbsp;
<input type="text" name="sort_field" data-endpoint="GETreferrals" data-component="query"  hidden>
<br>
Sort by field. Possible values: id, season, week, user_id, referred_user_id, created_at. Ex: season
</p>
<p>
<b><code>sort_method</code></b>&nbsp;&nbsp;<small>string</small>     <i>optional</i> &nbsp;
<input type="text" name="sort_method" data-endpoint="GETreferrals" data-component="query"  hidden>
<br>
Sort by method. Possible values: asc, desc. Ex: desc
</p>
<p>
<b><code>page</code></b>&nbsp;&nbsp;<small>integer</small>     <i>optional</i> &nbsp;
<input type="number" name="page" data-endpoint="GETreferrals" data-component="query"  hidden>
<br>
Page number. Ex: 2
</p>
<p>
<b><code>user_id</code></b>&nbsp;&nbsp;<small>integer</small>     <i>optional</i> &nbsp;
<input type="number" name="user_id" data-endpoint="GETreferrals" data-component="query"  hidden>
<br>
Referred By User Id. Ex: 12
</p>
<p>
<b><code>referred_user_id</code></b>&nbsp;&nbsp;<small>integer</small>     <i>optional</i> &nbsp;
<input type="number" name="referred_user_id" data-endpoint="GETreferrals" data-component="query"  hidden>
<br>
Referred To User Id. Ex: 14
</p>
<p>
<b><code>season</code></b>&nbsp;&nbsp;<small>integer</small>     <i>optional</i> &nbsp;
<input type="number" name="season" data-endpoint="GETreferrals" data-component="query"  hidden>
<br>
Season. Ex: 2020
</p>
<p>
<b><code>week</code></b>&nbsp;&nbsp;<small>integer</small>     <i>optional</i> &nbsp;
<input type="number" name="week" data-endpoint="GETreferrals" data-component="query"  hidden>
<br>
Week. Ex: 1
</p>
</form>


## Landing Page

<small class="badge badge-darkred">requires authentication</small>

Use this end point to get the landing page

> Example request:

```bash
curl -X GET \
    -G "https://apiqa.bettorfantasy.com/referrals/landing-page" \
    -H "Authorization: Bearer {YOUR_AUTH_KEY}" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json"
```


> Example response (200):

```json
{
    "message": "Recruit Landing Page",
    "data": {
        "reward_value": 30,
        "token_reward_value": 30000,
        "referral_code": "6cf03fd4-7356-43ed-94d1-68801486f1b5",
        "cta": "Share Your Referral Link",
        "is_referral_history": 0,
        "count": 0,
        "tier_info": {
            "tier_bonus_total": 300,
            "current_referrals": 0,
            "lifetime_bonus_text": "Lifetime Bonus: Every referral above 20 = $35* each",
            "lifetime_bonus_amount": "35",
            "tiers": [
                {
                    "referral_count": 5,
                    "referral_bonus": 100,
                    "referral_bonus_extra": 20,
                    "referral_bonus_total": 120,
                    "is_complete": 0
                },
                {
                    "referral_count": 10,
                    "referral_bonus": 220,
                    "referral_bonus_extra": 70,
                    "referral_bonus_total": 290,
                    "is_complete": 0
                },
                {
                    "referral_count": 20,
                    "referral_bonus": 490,
                    "referral_bonus_extra": 210,
                    "referral_bonus_total": 700,
                    "is_complete": 0
                }
            ]
        }
    }
}
```
<div id="execution-results-GETreferrals-landing-page" hidden>
    <blockquote>Received response<span id="execution-response-status-GETreferrals-landing-page"></span>:</blockquote>
    <pre class="json"><code id="execution-response-content-GETreferrals-landing-page"></code></pre>
</div>
<div id="execution-error-GETreferrals-landing-page" hidden>
    <blockquote>Request failed with error:</blockquote>
    <pre><code id="execution-error-message-GETreferrals-landing-page"></code></pre>
</div>
<form id="form-GETreferrals-landing-page" data-method="GET" data-path="referrals/landing-page" data-authed="1" data-hasfiles="0" data-headers='{"Authorization":"Bearer {YOUR_AUTH_KEY}","Content-Type":"application\/json","Accept":"application\/json"}' onsubmit="event.preventDefault(); executeTryOut('GETreferrals-landing-page', this);">
<h3>
    Request&nbsp;&nbsp;&nbsp;
        <button type="button" style="background-color: #8fbcd4; padding: 5px 10px; border-radius: 5px; border-width: thin;" id="btn-tryout-GETreferrals-landing-page" onclick="tryItOut('GETreferrals-landing-page');">Try it out ⚡</button>
    <button type="button" style="background-color: #c97a7e; padding: 5px 10px; border-radius: 5px; border-width: thin;" id="btn-canceltryout-GETreferrals-landing-page" onclick="cancelTryOut('GETreferrals-landing-page');" hidden>Cancel</button>&nbsp;&nbsp;
    <button type="submit" style="background-color: #6ac174; padding: 5px 10px; border-radius: 5px; border-width: thin;" id="btn-executetryout-GETreferrals-landing-page" hidden>Send Request 💥</button>
    </h3>
<p>
<small class="badge badge-green">GET</small>
 <b><code>referrals/landing-page</code></b>
</p>
<p>
<label id="auth-GETreferrals-landing-page" hidden>Authorization header: <b><code>Bearer </code></b><input type="text" name="Authorization" data-prefix="Bearer " data-endpoint="GETreferrals-landing-page" data-component="header"></label>
</p>
</form>


## History Page

<small class="badge badge-darkred">requires authentication</small>

Use this end point to get the referral history page data

> Example request:

```bash
curl -X GET \
    -G "https://apiqa.bettorfantasy.com/referrals/history" \
    -H "Authorization: Bearer {YOUR_AUTH_KEY}" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json"
```


> Example response (200):

```json

{
      "message": "Referral History Page",
      "data": {
          "referrals_completed": "Recruit a friend, Secure the bag.",
          "bonus_cash_earned": 2500,
          "referrals": [
                         {
                             "referred_user_name": "admin",
                             "referred_user_id": 1,
                             "user_id": 1,
                             "has_onboarding_completed": 1,
                             "has_funds_added": 1,
                             "funds_added_at": "2024-09-02 15:02:17",
                             "has_entered_cash_contest": 1,
                             "has_cash_bonus_given": 1,
                             "onboarding_completed_at": "2024-09-02 15:02:17",
                             "entered_cash_contest_at": "2024-09-02 15:02:17",
                             "cash_bonus_given_at": "2024-09-02 15:02:17"
                         }
      }
  }
```
<div id="execution-results-GETreferrals-history" hidden>
    <blockquote>Received response<span id="execution-response-status-GETreferrals-history"></span>:</blockquote>
    <pre class="json"><code id="execution-response-content-GETreferrals-history"></code></pre>
</div>
<div id="execution-error-GETreferrals-history" hidden>
    <blockquote>Request failed with error:</blockquote>
    <pre><code id="execution-error-message-GETreferrals-history"></code></pre>
</div>
<form id="form-GETreferrals-history" data-method="GET" data-path="referrals/history" data-authed="1" data-hasfiles="0" data-headers='{"Authorization":"Bearer {YOUR_AUTH_KEY}","Content-Type":"application\/json","Accept":"application\/json"}' onsubmit="event.preventDefault(); executeTryOut('GETreferrals-history', this);">
<h3>
    Request&nbsp;&nbsp;&nbsp;
        <button type="button" style="background-color: #8fbcd4; padding: 5px 10px; border-radius: 5px; border-width: thin;" id="btn-tryout-GETreferrals-history" onclick="tryItOut('GETreferrals-history');">Try it out ⚡</button>
    <button type="button" style="background-color: #c97a7e; padding: 5px 10px; border-radius: 5px; border-width: thin;" id="btn-canceltryout-GETreferrals-history" onclick="cancelTryOut('GETreferrals-history');" hidden>Cancel</button>&nbsp;&nbsp;
    <button type="submit" style="background-color: #6ac174; padding: 5px 10px; border-radius: 5px; border-width: thin;" id="btn-executetryout-GETreferrals-history" hidden>Send Request 💥</button>
    </h3>
<p>
<small class="badge badge-green">GET</small>
 <b><code>referrals/history</code></b>
</p>
<p>
<label id="auth-GETreferrals-history" hidden>Authorization header: <b><code>Bearer </code></b><input type="text" name="Authorization" data-prefix="Bearer " data-endpoint="GETreferrals-history" data-component="header"></label>
</p>
</form>



