Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions Assets/Talo Game Services/Talo/Runtime/APIs/PlayersAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

namespace TaloGameServices
{
public class MergeOptions
{
public string postMergeIdentityService = "";
}

public class PlayersAPI : BaseAPI
{
public event Action<Player> OnIdentified;
Expand Down Expand Up @@ -113,14 +118,27 @@ public async Task<Player> Update()
return Talo.CurrentPlayer;
}

public async Task<Player> Merge(string playerId1, string playerId2)
public async Task<Player> Merge(string playerId1, string playerId2, MergeOptions options = null)
{
options ??= new MergeOptions();

var uri = new Uri($"{baseUrl}/merge");
string content = JsonUtility.ToJson(new PlayersMergeRequest(playerId1, playerId2));
var json = await Call(uri, "POST", content);

var res = JsonUtility.FromJson<PlayersUpdateResponse>(json);
return res.player;
var player = res.player;

if (options.postMergeIdentityService != "")
{
var alias = player.GetAlias(options.postMergeIdentityService);
if (alias != null)
{
await Identify(alias.service, alias.identifier);
}
}

return player;
}

public async Task<Player> Find(string playerId)
Expand Down