|
| 1 | +Promoter Logic |
| 2 | +============== |
| 3 | + |
| 4 | + |
| 5 | +1. Promoter Creation |
| 6 | +-------------------- |
| 7 | + |
| 8 | +A promoter is created by associating a `User` with a referral token and referral link. Promoters are responsible for sending out referral links, tracking referrals, and earning commissions. |
| 9 | + |
| 10 | +You can retrieve or create a promoter for a user using the following API action: |
| 11 | + |
| 12 | +- **Retrieve Promoter**: This endpoint retrieves or creates a promoter for the authenticated user. |
| 13 | + |
| 14 | +.. code-block:: bash |
| 15 | +
|
| 16 | + GET http://localhost:8000/referrals/promoter |
| 17 | + Accept: application/json |
| 18 | + Authorization: Bearer your_token |
| 19 | +
|
| 20 | +
|
| 21 | +Example response: |
| 22 | + |
| 23 | +.. code-block:: json |
| 24 | +
|
| 25 | + { |
| 26 | + "id": 2, |
| 27 | + "user": 1, |
| 28 | + "referralToken": "6B86B273FF", |
| 29 | + "referralLink": "http://localhost:8000/?ref=6B86B273FF", |
| 30 | + "currentBalance": 0, |
| 31 | + "totalEarned": 0, |
| 32 | + "totalPaid": 0, |
| 33 | + "created": "2024-08-24T12:12:03.374694Z", |
| 34 | + "updated": "2024-09-08T09:11:15.032367Z", |
| 35 | + "linkClicked": 0, |
| 36 | + "minWithdrawalBalance": "20.00", |
| 37 | + "commissionRate": 15.0 |
| 38 | + } |
| 39 | +
|
| 40 | +2. Setting the Payout Method |
| 41 | +----------------------------- |
| 42 | + |
| 43 | +Promoters can set their preferred payout method using the following API action: |
| 44 | + |
| 45 | +- **Set Payout Method**: This endpoint allows promoters to set their payout method (e.g., Wise, Crypto) and payment address (email or wallet address). |
| 46 | + |
| 47 | +.. code-block:: bash |
| 48 | +
|
| 49 | + PATCH http://localhost:8000/referrals/set-payout-method/ |
| 50 | + Content-Type: application/json |
| 51 | + Authorization: Bearer your_token |
| 52 | +
|
| 53 | + { |
| 54 | + "method": "wise", |
| 55 | + "payment_address": "[email protected]" |
| 56 | + } |
| 57 | +
|
| 58 | +
|
| 59 | +Example response: |
| 60 | + |
| 61 | +.. code-block:: json |
| 62 | +
|
| 63 | + { |
| 64 | + "id": 2, |
| 65 | + "user": 1, |
| 66 | + "referralToken": "6B86B273FF", |
| 67 | + "referralLink": "http://localhost:8000/?ref=6B86B273FF", |
| 68 | + "activePayoutMethod": { |
| 69 | + "method": "wise", |
| 70 | + "paymentAddress": "[email protected]" |
| 71 | + }, |
| 72 | + "currentBalance": 0, |
| 73 | + "totalEarned": 0, |
| 74 | + "totalPaid": 0, |
| 75 | + "created": "2024-08-24T12:12:03.374694Z", |
| 76 | + "updated": "2024-09-08T09:11:15.032367Z", |
| 77 | + "linkClicked": 0, |
| 78 | + "minWithdrawalBalance": "20.00", |
| 79 | + "commissionRate": 15.0 |
| 80 | + } |
| 81 | +
|
| 82 | +The promoter’s payout method is used when processing their earnings. |
| 83 | + |
| 84 | +3. Tracking Referrals and Earnings |
| 85 | +----------------------------------- |
| 86 | + |
| 87 | +Once a promoter is created, they can start sharing their referral link. The system tracks clicks on the referral link and the earnings generated from those referrals. Promoters can retrieve their recent earnings and view a breakdown of their performance over the last 7 days. |
| 88 | + |
| 89 | +To view the promoter's recent earnings: |
| 90 | + |
| 91 | +.. code-block:: bash |
| 92 | +
|
| 93 | + GET http://localhost:8000/referrals/promoter-recent-earnings |
| 94 | + Accept: application/json |
| 95 | + Authorization: Bearer your_token |
| 96 | +
|
| 97 | +Example response: |
| 98 | + |
| 99 | +.. code-block:: json |
| 100 | +
|
| 101 | + [ |
| 102 | + { |
| 103 | + "day": "Mon", |
| 104 | + "value": 50 |
| 105 | + }, |
| 106 | + { |
| 107 | + "day": "Tue", |
| 108 | + "value": 0 |
| 109 | + }, |
| 110 | + { |
| 111 | + "day": "Wed", |
| 112 | + "value": 30 |
| 113 | + }, |
| 114 | + { |
| 115 | + "day": "Thu", |
| 116 | + "value": 70 |
| 117 | + }, |
| 118 | + { |
| 119 | + "day": "Fri", |
| 120 | + "value": 20 |
| 121 | + }, |
| 122 | + { |
| 123 | + "day": "Sat", |
| 124 | + "value": 0 |
| 125 | + }, |
| 126 | + { |
| 127 | + "day": "Sun", |
| 128 | + "value": 10 |
| 129 | + } |
| 130 | + ] |
| 131 | +
|
| 132 | +The response contains a list of the last 7 days, with each day showing the corresponding earnings value. Even if no earnings occurred on a particular day, it is still represented with a value of `0`. The earnings are grouped by the day of the week when they were created. |
| 133 | + |
| 134 | +4. Incrementing Link Clicks |
| 135 | +---------------------------- |
| 136 | + |
| 137 | +Every time a referral link is clicked, the system can increment the count of link clicks for the promoter. This can be done via the following API action: |
| 138 | + |
| 139 | +.. code-block:: bash |
| 140 | +
|
| 141 | + POST http://localhost:8000/referrals/increment-link-clicked/ |
| 142 | + Content-Type: application/json |
| 143 | + Authorization: Bearer your_token |
| 144 | +
|
| 145 | + { |
| 146 | + "referral_token": "6B86B273FF" |
| 147 | + } |
| 148 | +
|
| 149 | +
|
| 150 | +Example response: |
| 151 | + |
| 152 | +.. code-block:: json |
| 153 | +
|
| 154 | + { |
| 155 | + "message": "Link clicked count incremented successfully" |
| 156 | + } |
0 commit comments