Skip to content
Merged
Show file tree
Hide file tree
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
32 changes: 29 additions & 3 deletions Assets/Talo Game Services/Talo/Runtime/APIs/ChannelsAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,30 @@ public string ToQueryString()
}
}

public class GetMembersOptions
{
public int page = 0;
public string playerId = "";
public int aliasId = -1;
public string identifier = "";
public string propKey = "";
public string propValue = "";
public string playerGroupId = "";

public string ToQueryString()
{
var query = new Dictionary<string, string> { ["page"] = page.ToString() };
if (!string.IsNullOrEmpty(playerId)) query["playerId"] = playerId;
if (aliasId != -1) query["aliasId"] = aliasId.ToString();
if (!string.IsNullOrEmpty(identifier)) query["identifier"] = identifier;
if (!string.IsNullOrEmpty(propKey)) query["propKey"] = propKey;
if (!string.IsNullOrEmpty(propValue)) query["propValue"] = propValue;
if (!string.IsNullOrEmpty(playerGroupId)) query["playerGroupId"] = playerGroupId;

return string.Join("&", query.Select((param) => $"{param.Key}={param.Value}"));
}
}

public class CreateChannelOptions
{
public string name;
Expand Down Expand Up @@ -273,15 +297,17 @@ public async Task Invite(int channelId, int playerAliasId)
await Call(uri, "POST", content);
}

public async Task<PlayerAlias[]> GetMembers(int channelId)
public async Task<ChannelsMembersResponse> GetMembers(int channelId, GetMembersOptions options = null)
{
Talo.IdentityCheck();

var uri = new Uri($"{baseUrl}/{channelId}/members");
options ??= new GetMembersOptions();

var uri = new Uri($"{baseUrl}/{channelId}/members?{options.ToQueryString()}");
var json = await Call(uri, "GET");

var res = JsonUtility.FromJson<ChannelsMembersResponse>(json);
return res.members;
return res;
}

public async Task<ChannelStorageProp> GetStorageProp(int channelId, string propKey, bool bustCache = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ namespace TaloGameServices
public class ChannelsMembersResponse
{
public PlayerAlias[] members;
public int count;
public int itemsPerPage;
public bool isLastPage;
}
}