From 6e4c6daed6056abfb3b1ec259b611277619711d5 Mon Sep 17 00:00:00 2001 From: tudor <7089284+tudddorrr@users.noreply.github.com> Date: Mon, 21 Apr 2025 22:01:12 +0100 Subject: [PATCH] add CreatePrivate and Invite for channels api --- .../Talo/Runtime/APIs/ChannelsAPI.cs | 33 +++++++++++++++++-- .../Talo/Runtime/Entities/Channel.cs | 2 ++ .../Runtime/Requests/ChannelsCreateRequest.cs | 2 +- .../Runtime/Requests/ChannelsInviteRequest.cs | 8 +++++ .../Requests/ChannelsInviteRequest.cs.meta | 2 ++ 5 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 Assets/Talo Game Services/Talo/Runtime/Requests/ChannelsInviteRequest.cs create mode 100644 Assets/Talo Game Services/Talo/Runtime/Requests/ChannelsInviteRequest.cs.meta diff --git a/Assets/Talo Game Services/Talo/Runtime/APIs/ChannelsAPI.cs b/Assets/Talo Game Services/Talo/Runtime/APIs/ChannelsAPI.cs index 5dcd6b2..d988a4d 100644 --- a/Assets/Talo Game Services/Talo/Runtime/APIs/ChannelsAPI.cs +++ b/Assets/Talo Game Services/Talo/Runtime/APIs/ChannelsAPI.cs @@ -69,20 +69,40 @@ public async Task GetSubscribedChannels() return res.channels; } - public async Task Create(string name, bool autoCleanup = false, params (string, string)[] propTuples) + private async Task SendCreateChannelRequest( + string name, + bool autoCleanup = false, + bool isPrivate = false, + params (string, string)[] propTuples + ) { Talo.IdentityCheck(); var props = propTuples.Select((propTuple) => new Prop(propTuple)).ToArray(); var uri = new Uri(baseUrl); - var content = JsonUtility.ToJson(new ChannelsCreateRequest { name = name, autoCleanup = autoCleanup, props = props }); + var content = JsonUtility.ToJson(new ChannelsCreateRequest { + name = name, + autoCleanup = autoCleanup, + props = props, + @private = isPrivate + }); var json = await Call(uri, "POST", content); var res = JsonUtility.FromJson(json); return res.channel; } + public async Task Create(string name, bool autoCleanup = false, params (string, string)[] propTuples) + { + return await SendCreateChannelRequest(name, autoCleanup, false, propTuples); + } + + public async Task CreatePrivate(string name, bool autoCleanup = false, params (string, string)[] propTuples) + { + return await SendCreateChannelRequest(name, autoCleanup, true, propTuples); + } + public async Task Join(int channelId) { Talo.IdentityCheck(); @@ -154,5 +174,14 @@ public async Task Find(int channelId) var res = JsonUtility.FromJson(json); return res.channel; } + + public async Task Invite(int channelId, int playerAliasId) + { + Talo.IdentityCheck(); + + var uri = new Uri($"{baseUrl}/{channelId}/invite"); + var content = JsonUtility.ToJson(new ChannelsInviteRequest { inviteeAliasId = playerAliasId }); + await Call(uri, "POST", content); + } } } diff --git a/Assets/Talo Game Services/Talo/Runtime/Entities/Channel.cs b/Assets/Talo Game Services/Talo/Runtime/Entities/Channel.cs index c0c9a13..73d80a7 100644 --- a/Assets/Talo Game Services/Talo/Runtime/Entities/Channel.cs +++ b/Assets/Talo Game Services/Talo/Runtime/Entities/Channel.cs @@ -10,6 +10,8 @@ public class Channel: EntityWithProps public PlayerAlias ownerAlias; public int totalMessages; public int memberCount; + public bool autoCleanup; + public bool @private; public string createdAt; public string updatedAt; } diff --git a/Assets/Talo Game Services/Talo/Runtime/Requests/ChannelsCreateRequest.cs b/Assets/Talo Game Services/Talo/Runtime/Requests/ChannelsCreateRequest.cs index 5280059..8e54975 100644 --- a/Assets/Talo Game Services/Talo/Runtime/Requests/ChannelsCreateRequest.cs +++ b/Assets/Talo Game Services/Talo/Runtime/Requests/ChannelsCreateRequest.cs @@ -1,4 +1,3 @@ - namespace TaloGameServices { [System.Serializable] @@ -7,5 +6,6 @@ public class ChannelsCreateRequest public string name; public bool autoCleanup; public Prop[] props; + public bool @private; } } diff --git a/Assets/Talo Game Services/Talo/Runtime/Requests/ChannelsInviteRequest.cs b/Assets/Talo Game Services/Talo/Runtime/Requests/ChannelsInviteRequest.cs new file mode 100644 index 0000000..8fbb21a --- /dev/null +++ b/Assets/Talo Game Services/Talo/Runtime/Requests/ChannelsInviteRequest.cs @@ -0,0 +1,8 @@ +namespace TaloGameServices +{ + [System.Serializable] + public class ChannelsInviteRequest + { + public int inviteeAliasId; + } +} diff --git a/Assets/Talo Game Services/Talo/Runtime/Requests/ChannelsInviteRequest.cs.meta b/Assets/Talo Game Services/Talo/Runtime/Requests/ChannelsInviteRequest.cs.meta new file mode 100644 index 0000000..8bee892 --- /dev/null +++ b/Assets/Talo Game Services/Talo/Runtime/Requests/ChannelsInviteRequest.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 9fb70f64019a4460bbec2f6a7e71813a \ No newline at end of file