Class: LinkIO::ReferralsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/linkio/referrals_controller.rb

Overview

Tracks and lists referrals.

Instance Method Summary collapse

Instance Method Details

#createObject

POST /track-referral Body: { referralCode:, userId:, metadata: }



8
9
10
11
12
13
14
15
# File 'app/controllers/linkio/referrals_controller.rb', line 8

def create
  linkio_client.track_referral(
    params[:referralCode],
    params[:userId],
    params[:metadata]&.to_unsafe_h
  )
  render json: { success: true }
end

#indexObject

GET /referrals/:referrer_id



18
19
20
21
# File 'app/controllers/linkio/referrals_controller.rb', line 18

def index
  referrals = linkio_client.referrals(params[:referrer_id])
  render json: { referrals: referrals.map(&:to_h) }
end