Skip to content

Commit 5bed656

Browse files
authored
Merge pull request #39 from LootLocker/feature/add-methods-for-looking-up-player-1st-platform-ids
Feature/add methods for looking up player 1st party platform ids
2 parents ad3384a + 22bf64a commit 5bed656

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

Runtime/Client/LootLockerEndPoints.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class LootLockerEndPoints
4444
public static EndPointClass getPlayerName = new EndPointClass("player/name", LootLockerHTTPMethod.GET);
4545
public static EndPointClass setPlayerName = new EndPointClass("player/name", LootLockerHTTPMethod.PATCH);
4646
public static EndPointClass lookupPlayerNames = new EndPointClass("player/lookup/name", LootLockerHTTPMethod.GET);
47+
public static EndPointClass lookupPlayer1stPartyPlatformIDs = new EndPointClass("player/lookup/ids", LootLockerHTTPMethod.GET);
4748
public static EndPointClass getPlayerFiles = new EndPointClass("player/files", LootLockerHTTPMethod.GET);
4849
public static EndPointClass getPlayerFilesByPlayerId = new EndPointClass("player/{0}/files", LootLockerHTTPMethod.GET);
4950
public static EndPointClass getSingleplayerFile = new EndPointClass("player/files/{0}", LootLockerHTTPMethod.GET);

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,34 @@ public static void GetPlayerName(Action<PlayerNameResponse> onComplete)
676676
LootLockerAPIManager.GetPlayerName(onComplete);
677677
}
678678

679+
public static void LookupPlayer1stPartyPlatformIds(ulong[] playerIds, Action<Player1stPartyPlatformIDsLookupResponse> onComplete)
680+
{
681+
if (!CheckInitialized())
682+
{
683+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<Player1stPartyPlatformIDsLookupResponse>());
684+
return;
685+
}
686+
687+
LootLockerAPIManager.LookupPlayer1stPartyPlatformIDs(new LookupPlayer1stPartyPlatformIDsRequest()
688+
{
689+
player_ids = playerIds
690+
}, onComplete);
691+
}
692+
693+
public static void LookupPlayer1stPartyPlatformIds(string[] playerPublicUIds, Action<Player1stPartyPlatformIDsLookupResponse> onComplete)
694+
{
695+
if (!CheckInitialized())
696+
{
697+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<Player1stPartyPlatformIDsLookupResponse>());
698+
return;
699+
}
700+
701+
LootLockerAPIManager.LookupPlayer1stPartyPlatformIDs(new LookupPlayer1stPartyPlatformIDsRequest()
702+
{
703+
player_public_uids = playerPublicUIds
704+
}, onComplete);
705+
}
706+
679707
public static void LookupPlayerNamesByPlayerIds(ulong[] playerIds, Action<PlayerNameLookupResponse> onComplete)
680708
{
681709
if (!CheckInitialized())

Runtime/Game/Requests/PlayerRequest.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,40 @@ public LookupPlayerNamesRequest()
4040
xbox_ids = new string[] { };
4141
}
4242
}
43+
44+
public class LookupPlayer1stPartyPlatformIDsRequest
45+
{
46+
public ulong[] player_ids { get; set; }
47+
public string[] player_public_uids { get; set; }
48+
49+
public LookupPlayer1stPartyPlatformIDsRequest()
50+
{
51+
player_ids = new ulong[] { };
52+
player_public_uids = new string[] { };
53+
}
54+
}
55+
56+
[System.Serializable]
57+
public class Player1stPartyPlatformIDsLookupResponse : LootLockerResponse
58+
{
59+
public PlayerWith1stPartyPlatformIDs[] players { get; set; }
60+
}
61+
62+
public class PlayerWith1stPartyPlatformIDs
63+
{
64+
public uint player_id { get; set; }
65+
public string player_public_uid { get; set; }
66+
public string name { get; set; }
67+
public string last_active_platform { get; set; }
68+
public PlatformIDs platform_ids { get; set; }
69+
}
70+
71+
public class PlatformIDs
72+
{
73+
public ulong? steam_id { get; set; }
74+
public string xbox_id { get; set; }
75+
public ulong? psn_id { get; set; }
76+
}
4377

4478
[System.Serializable]
4579
public class PlayerNameLookupResponse : LootLockerResponse
@@ -340,6 +374,25 @@ public static void LookupPlayerNames(LookupPlayerNamesRequest lookupPlayerNamesR
340374

341375
LootLockerServerRequest.CallAPI(getVariable, endPoint.httpMethod, null, onComplete: (serverResponse) => { LootLockerResponse.Serialize(onComplete, serverResponse); });
342376
}
377+
378+
public static void LookupPlayer1stPartyPlatformIDs(LookupPlayer1stPartyPlatformIDsRequest lookupPlayer1stPartyPlatformIDsRequest, Action<Player1stPartyPlatformIDsLookupResponse> onComplete)
379+
{
380+
var endPoint = LootLockerEndPoints.lookupPlayer1stPartyPlatformIDs;
381+
382+
var getVariable = endPoint.endPoint + "?";
383+
384+
foreach (var playerID in lookupPlayer1stPartyPlatformIDsRequest.player_ids)
385+
{
386+
getVariable += $"player_id={playerID}&";
387+
}
388+
389+
foreach (var playerPublicUID in lookupPlayer1stPartyPlatformIDsRequest.player_public_uids)
390+
{
391+
getVariable += $"player_public_uid={playerPublicUID}&";
392+
}
393+
394+
LootLockerServerRequest.CallAPI(getVariable, endPoint.httpMethod, null, onComplete: (serverResponse) => { LootLockerResponse.Serialize(onComplete, serverResponse); });
395+
}
343396

344397
public static void SetPlayerName(PlayerNameRequest data, Action<PlayerNameResponse> onComplete)
345398
{

0 commit comments

Comments
 (0)