Referral Referral APIs are responsible for tracking and recording the referral action.
Referral
POST
/integrations/referral
A Gameball player can refer a new user to use your system through a referral code. The API records the referral action in Gameball.
Request Body
Name Type Description Referring player’s referral code
Player unique identifier of the referred player used to uniquely identify the player on Gameball.
An object containing all of the properties of the referred player. Player object is described in Object Reference section .
200 Success. 400 JSON Body Invalid or missing required parameters. The response will include error description payload described in Errors section. 401 Invalid APIKey. 402 Request failed. the response will include error description payload described in Errors section. 403 APIKey missing.
Copy {
"code" : 4 ,
"message" : "The PlayerCode field is required."
}
Copy {
"code" : 151 ,
"message" : "Player Referred Already Exists!"
}
Examples
Example One
The example shown is a request sent to Gameball when a player with playerCode
“ CODE11” successfully refers a new player with playerUniqueId
“ player456” .
cURL Node.js Ruby .NET PHP Python
Copy curl - X POST - H 'apiKey: 807b041b7d35425988e354e1f6bce186' - d '{
"playerCode" : "CODE11" ,
"playerUniqueId" : "player456"
} ' -v -i ' https : //api.gameball.co/api/v2.0/integrations/referral'
Copy var apiKey = '807b041b7d35425988e354e1f6bce186'
var gameball = require ( 'gameball' )
var Gameball = new gameball (apikey)
Gameball .createReferral ({
"playerCode" : "CODE11" ,
"playerUniqueId" : "player456"
} ,
function (err , res) {
if (err) console .log (err)
else console .log (res)
})
Copy require 'gameball'
Gameball . api_key = "807b041b7d35425988e354e1f6bce186"
Gameball :: Referral . create_referral({
playerCode: "CODE11" ,
playerUniqueId: "player456"
})
Copy using Gameball ;
using Gameball . Models ;
var apiKey = "807b041b7d35425988e354e1f6bce186" ;
var Gameball = new Gameball (apiKey);
ReferralRequest request = new ReferralRequest ()
{
PlayerUniqueId = "player456" ,
PlayerCode = "CODE11"
};
var create_referral_response = Gameball . CreateReferral (request);
Copy require_once ( 'vendor/autoload.php' );
$apiKey = "807b041b7d35425988e354e1f6bce186" ;
$gameball = new \ Gameball \ GameballClient (apiKey);
$playerCode = 'CODE11' ;
$playerRequest = \ Gameball \ Models \ PlayerRequest :: factory ( 'player456' ) ;
$createReferralResponse = $gameball -> referral -> createReferral ( $playerCode , $playerRequest ) ;
Copy import gameball
apiKey = "807b041b7d35425988e354e1f6bce186"
gameball . api_key = apiKey
request = gameball . referralObject (player_code = "CODE11" , player_unique_id = "player456" )
create_referral_response = gameball . create_referral (request)
Example Two
This example is a request sent to Gameball when player with playerCode
“ CODE11” successfully refers a new player with playerUniqueId
“ player456”. Player attributes are also sent within the same request.
Note : All attributes inside the playerAttributes
object are optional, if the values of any attributes shown below are unavailable, remove the attribute from the playerAttributes
object.
cURL Node.js Ruby .NET PHP Python
Copy curl - X POST - H 'apiKey: 807b041b7d35425988e354e1f6bce186' - d '{
"playerCode" : "CODE11" ,
"playerUniqueId" : "player456" ,
"playerAttributes" :{
"displayName" : " Tyrion Lannister" ,
"firstName" : "Tyrion" ,
"lastName" : "Lannister" ,
"email" : "tyrion@example.com" ,
"gender" : "M" ,
"dateOfBirth" : "1978-01-11T00:00:00.000Z" ,
"joinDate" : "2019-09-19T21:06:29.158Z" ,
"custom" : {
"location" : "Miami" ,
"graduationDate" : "2018-07-04T21:06:29.158Z" ,
"isMarried" : false
}
}
} ' -v -i ' https : //api.gameball.co/api/v2.0/integrations/referral'
Copy var apiKey = '807b041b7d35425988e354e1f6bce186'
var gameball = require ( 'gameball' )
var Gameball = new gameball (apikey)
Gameball .createReferral ({
"playerCode" : "CODE11" ,
"playerAttributes" : {
"displayName" : "Tyrion Lannister" ,
"firstName" : "Tyrion" ,
"lastName" : "Lannister" ,
"email" : "tyrion@example.com" ,
"gender" : "M" ,
"dateOfBirth" : "1978-01-11T00:00:00.000Z" ,
"joinDate" : "2019-09-19T21:06:29.158Z" ,
"custom" : {
"location" : "Miami" ,
"graduationDate" : "2018-07-04T21:06:29.158Z" ,
"isMarried" : false
}
}
} ,
function (err , res) {
if (err) console .log (err)
else console .log (res)
})
Copy require 'gameball'
Gameball . api_key = "807b041b7d35425988e354e1f6bce186"
Gameball :: Referral . create_referral({
playerCode: "CODE11" ,
playerUniqueId: "player456" ,
playerAttributes: {
displayName: " Tyrion Lannister" ,
firstName: "Tyrion" ,
lastName: "Lannister" ,
email: "tyrion@example.com" ,
gender: "M" ,
dateOfBirth: "1978-01-11T00:00:00.000Z" ,
joinDate: "2019-09-19T21:06:29.158Z" ,
custom: {
location: "Miami" ,
graduationDate: "2018-07-04T21:06:29.158Z" ,
isMarried: false
}
}
})
Copy using Gameball ;
using Gameball . Models ;
var apiKey = "807b041b7d35425988e354e1f6bce186" ;
var Gameball = new Gameball (apiKey);
ReferralRequest request = new ReferralRequest ()
{
PlayerUniqueId = "player456" ,
PlayerCode = "CODE11" ,
PlayerAttributes = new PlayerAttributes ()
{
DisplayName = "Tyrion Lannister" ,
FirstName = "Tyrion" ,
LastName = "Lannister" ,
Email = "tyrion@example.com" ,
Gender = "M" ,
DateOfBirth = new DateTime ( 1978 , 1 , 11 ) ,
JoinDate = new DateTime ( 2019 , 9 , 19 , 21 , 6 , 29 , 158 )
}
};
//Adding Custom Attributes
request . PlayerAttributes . AddCustomAttribute ( "location" , "Miami" );
request . PlayerAttributes . AddCustomAttribute ( "graduationDate" , new DateTime ( 2018 , 7 , 4 , 21 , 6 , 29 , 158 ));
request . PlayerAttributes . AddCustomAttribute ( "isMarried" , false );
};
var create_referral_response = Gameball . CreateReferral (request);
Copy require_once ( 'vendor/autoload.php' );
$apiKey = "807b041b7d35425988e354e1f6bce186" ;
$gameball = new \ Gameball \ GameballClient (apiKey);
$playerCode = 'CODE11' ;
//All are optional
//displayName, firstName, lastName, email, gender, mobileNumber, dateOfBirth
$playerAttributes = \ Gameball \ Models \ PlayerAttributes :: factory ( 'Tyrion Lannister' ,
'Tyrion' ,
'Lannister' ,
'tyrion@example.com' ,
'M' , , // empty for mobileNumber
'1978-01-11T00:00:00.000Z' ,
) ;
//custom attributes <Key => Value>
$playerAttributes -> addCustomAttribute ( 'location' , 'Miami' ) ;
$playerAttributes -> addCustomAttribute ( 'graduationDate' , '2018-07-04T21:06:29.158Z' ) ;
$playerAttributes -> addCustomAttribute ( 'isMarried' , false ) ;
$playerRequest = \ Gameball \ Models \ PlayerRequest :: factory ( 'player456' , $playerAttributes ) ;
$createReferralResponse = $gameball -> referral -> createReferral ( $playerCode , $playerRequest ) ;
Copy import gameball
apiKey = "807b041b7d35425988e354e1f6bce186"
gameball . api_key = apiKey
request = gameball . referralObject (player_code = "CODE11" , player_unique_id = "player456" )
request . add_player_attribute ( "displayName" , " Tyrion Lannister" )
request . add_player_attribute ( "firstName" , "Tyrion" )
request . add_player_attribute ( "lastName" , "Lannister" )
request . add_player_attribute ( "email" , "tyrion@example.com" )
request . add_player_attribute ( "gender" , "M" )
request . add_player_attribute ( "dateOfBirth" , "1978-01-11T00:00:00.000Z" )
request . add_player_attribute ( "joinDate" , "2019-09-19T21:06:29.158Z" )
request . add_custom_player_attribute ( "location" , "Miami" )
request . add_custom_player_attribute ( "graduationDate" , "2018-07-04T21:06:29.158Z" )
request . add_custom_player_attribute ( "isMarried" , False )
create_referral_response = gameball . create_referral (request)