Skip to main content
Version: SDK-5.11.2

GetUserRank

public BackendReturnObject GetUserRank(string rankUuid, string userInDate);
public BackendReturnObject GetUserRank(string rankUuid, string userInDate, int gap);

Note

Old version rankings cannot use this method.

Parameters

ValueTypeDescriptionDefault
rankUuidstringuuid of the ranking to look up-
userIndatestringinDate of the user to look up-
gapintNumber of rank holders above/below to be looked up together(0 - 100)0

The rankUuid value can be checked using the following methods:

The userIndate value can be checked using the following methods:

  • Check the inDate of your friend
  • Check the inDate of a guild member
  • Check using the owner_inDate column of the public table
  • Check by sharing the inDate of a user

Description

Looks up the user's rank in the ranking using a uuid value and userIndate.

  • If there is a tie between users(with the same rank), users with the same ranks may be returned when the gap method is used for the lookup.

Example

Synchronous

// Look up the rank of the user only
Backend.URank.User.GetUserRank("rankUuid", "userIndate");

// Look up the ranking including three users above and below
// If the user is the 4th, the 1st - 7th users are looked up.
Backend.URank.User.GetUserRank("rankUuid", "userIndate", 3);

Asynchronous

// Look up the rank of the user only
Backend.URank.User.GetUserRank("rankUuid", "userIndate", callback => {
// Post-process
});

// Look up the ranking including three users above and below
// If the user is the 4th, the 1st - 7th users are looked up.
Backend.URank.User.GetUserRank("rankUuid", "userIndate", 5, callback => {
// Post-process
});

SendQueue

// Look up the rank of the user only
SendQueue.Enqueue(Backend.URank.User.GetUserRank, "rankUuid", "userIndate", callback => {
// Post-process
});

// Look up the ranking including three users above and below
// If there are 10 users in the ranking and the user is the 9th,
// the 6th - 10th users are looked up.
SendQueue.Enqueue(Backend.URank.User.GetUserRank, "rankUuid", "userIndate", 3, callback => {
// Post-process
});

Return cases

Success cases

When the user is in the ranking
statusCode : 200
message : Success returnValue : refer to GetReturnValuetoJSON

Error cases

When the uuid is null or string.Empty
statusCode : 400
errorCode : ValidationException
message : rankUuid is null or empty

When there is an attempt to look up with a userIndate of a non-existent user
statusCode : 404
errorCode : NotFoundException
message : gamer not found, gamer cannot be found

When there is an attempt to look up with a non-existent uuid
statusCode : 404
errorCode : NotFoundException
message : rank not found, rank cannot be found

When the user does not exist in the ranking
statusCode : 404
errorCode : NotFoundException
message : userRank not found, userRank cannot be found

GetReturnValuetoJSON

When the gap is 0

{
"rows": [
{
// Gamer inDate of the user
"gamerInDate": {
"S": "2021-03-11T06:37:30.934Z"
},
// User's nickname
"nickname": {
"S": "Nickname No. 0"
},
// Additional field
// Name and value of the column are displayed.
// 'extraScore' if the column name of the additional field is 'extraScore'
"extraScore": {
"N": "0"
},
// Score
// Column names are unified as 'score'.
// It will be called 'score' even if the column name of the ranking field is 'power.'
"score": {
"N": "101"
},
// offset
"index": {
"N": 98
},
// User's rank
"rank": {
"N": 99
}
}
],
// Total number of rank holders registered in the ranking
"totalCount": 100
}

When the gap is 1

{
"rows": [
// User whose rank is 1 place higher than your rank
{
"gamerInDate": {
"S": "2021-03-11T06:37:32.616Z"
},
"nickname": {
"S": "Nickname No. 22"
},
"extraScore": {
"N": "2346"
},
"score": {
"N": "102"
},
"index": {
"N": 97
},
"rank": {
"N": 98
}
},
// Yourself
{
"gamerInDate": {
"S": "2021-03-11T06:37:30.934Z"
},
"nickname": {
"S": "Nickname No. 0"
},
"extraScore": {
"N": "0"
},
"score": {
"N": 101
},
"index": {
"N": 98
},
"rank": {
"N": 99
}
},
// User whose rank is 1 place lower than your rank
{
"gamerInDate": {
"S": "2021-03-11T06:37:31.838Z"
},
"nickname": {
"S": "Nickname No. 44"
},
"extraScore": {
"N": "2323"
},
"score": {
"N": "100"
},
"index": {
"N": 99
},
"rank": {
"N": 100
}
}
],
"totalCount": 100
}

Sample code

public class RankItem
{
public string gamerInDate;
public string nickname;
public string score;
public string index;
public string rank;
public string extraData = string.Empty;
public string extraName = string.Empty;
public string totalCount;

public override string ToString()
{
string str = $"UserinDate:{gamerInDate}\nNikckname:{nickname}\nScore:{score}\nSort:{index}\nPlacement:{rank}\nTotal:{totalCount}\n";
if(extraName != string.Empty)
{
str += $"{extraName}:{extraData}\n";
}
return str;
}
}
public void GetUserRankTest()
{
string userUuid = "81272320-8c40-112b-b174-d9233f6bd0e8";
string userIndate = "2022-03-02T01:51:32.967Z";

List<RankItem> rankItemList = new List<RankItem>();

BackendReturnObject bro = Backend.URank.User.GetUserRank(userUuid, userIndate, 3);

if(bro.IsSuccess())
{
LitJson.JsonData rankListJson = bro.GetFlattenJSON();
string extraName = string.Empty;
for(int i = 0; i < rankListJson["rows"].Count; i++)
{
RankItem rankItem = new RankItem();

rankItem.gamerInDate = rankListJson["rows"][i]["gamerInDate"].ToString();
rankItem.nickname = rankListJson["rows"][i]["nickname"].ToString();
rankItem.score = rankListJson["rows"][i]["score"].ToString();
rankItem.index = rankListJson["rows"][i]["index"].ToString();
rankItem.rank = rankListJson["rows"][i]["rank"].ToString();
rankItem.totalCount = rankListJson["totalCount"].ToString();

if(rankListJson["rows"][i].ContainsKey(rankItem.extraName))
{
rankItem.extraData = rankListJson["rows"][i][rankItem.extraName].ToString();
}

rankItemList.Add(rankItem);
Debug.Log(rankItem.ToString());
}
}
}