From c49a6bbbc98d750f73fd8da3fead3507afa3cf3c Mon Sep 17 00:00:00 2001 From: tudor <7089284+tudddorrr@users.noreply.github.com> Date: Fri, 5 Sep 2025 01:35:00 +0100 Subject: [PATCH] add channel members pagination and filtering options --- .../Talo/Runtime/APIs/ChannelsAPI.cs | 32 +++++++++++++++++-- .../Responses/ChannelsMembersResponse.cs | 3 ++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Assets/Talo Game Services/Talo/Runtime/APIs/ChannelsAPI.cs b/Assets/Talo Game Services/Talo/Runtime/APIs/ChannelsAPI.cs index d6bc216..38a10ef 100644 --- a/Assets/Talo Game Services/Talo/Runtime/APIs/ChannelsAPI.cs +++ b/Assets/Talo Game Services/Talo/Runtime/APIs/ChannelsAPI.cs @@ -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 { ["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; @@ -273,15 +297,17 @@ public async Task Invite(int channelId, int playerAliasId) await Call(uri, "POST", content); } - public async Task GetMembers(int channelId) + public async Task 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(json); - return res.members; + return res; } public async Task GetStorageProp(int channelId, string propKey, bool bustCache = false) diff --git a/Assets/Talo Game Services/Talo/Runtime/Responses/ChannelsMembersResponse.cs b/Assets/Talo Game Services/Talo/Runtime/Responses/ChannelsMembersResponse.cs index ca9ed67..3d43768 100644 --- a/Assets/Talo Game Services/Talo/Runtime/Responses/ChannelsMembersResponse.cs +++ b/Assets/Talo Game Services/Talo/Runtime/Responses/ChannelsMembersResponse.cs @@ -4,5 +4,8 @@ namespace TaloGameServices public class ChannelsMembersResponse { public PlayerAlias[] members; + public int count; + public int itemsPerPage; + public bool isLastPage; } }