Can someone please help me understand this part of recipe referral Code with Unity and Playfab.
This is a segment from the cloud script. Can someone better comment it so I may understand?
//Before proceeding, validate the provided referral code. Use a Try / Catch block if you want to do more before returning the error to the client. var GetUserReadOnlyDataRequest = { "PlayFabId": args.referralCode, "Keys": [ PLAYER_REFERRAL_KEY ] }; var GetUserReadOnlyDataResult = server.GetUserReadOnlyData(GetUserReadOnlyDataRequest); var referralValues = []; -----------------What is above segment doing? --------------- if(!GetUserReadOnlyDataResult.Data.hasOwnProperty(PLAYER_REFERRAL_KEY)) { // This was a valid referral code, but this is the first redeemed code. ------------------What does the above comment mean?? -------------- referralValues.push(currentPlayerId); ProcessReferrer(args.referralCode, referralValues); } else { // This was a valid referral code, now we need to extract the JSON array --------------Why is this a json array ? What Data are we retrieving here? ---------- referralValues = JSON.parse(GetUserReadOnlyDataResult.Data[PLAYER_REFERRAL_KEY].Value); if(Array.isArray(referralValues)) { // need to ensure we have not exceded the MAXIMUM_REFERRALS { // here we know that the referrer has not exceeded the max, so we will add the current player referralValues.push(currentPlayerId); ProcessReferrer(args.referralCode, referralValues); } else { // Referrer has exceeded the MAXIMUM_REFERRALS // this is not an error, but the referrer does not get thier reward. log.info("Player:" + args.referralCode + " has hit the maximum number of referrals (" + MAXIMUM_REFERRALS + ")." ); } } else { throw "An error occured when parsing the referrer's player data."; } } ----------The below code is obvious , but what baout the above code? ---------- // finally, reward the calling player return GrantReferralBonus(args.referralCode); } catch(e) { var retObj = {}; retObj["errorDetails"] = "Error: " + e; return retObj; } };