From 14500fc07ac52131a2483cb09a19cf2f78fe8795 Mon Sep 17 00:00:00 2001 From: GoldenBIOS Date: Sun, 3 May 2026 20:40:15 +0200 Subject: [PATCH] synchronize ICallService with stateful implementation and resolve build errors --- Services/CallService.cs | 45 ++++++++++++++++++++++++++++++++++ Services/CallServiceMethods.cs | 29 ---------------------- 2 files changed, 45 insertions(+), 29 deletions(-) create mode 100644 Services/CallService.cs delete mode 100644 Services/CallServiceMethods.cs diff --git a/Services/CallService.cs b/Services/CallService.cs new file mode 100644 index 0000000..67c96ff --- /dev/null +++ b/Services/CallService.cs @@ -0,0 +1,45 @@ +using System; +using System.Threading.Tasks; +using Chtn.CSharp.SDK.Core; +using Chtn.CSharp.SDK.Models.Call; + +namespace Chtn.CSharp.SDK.Services +{ + public interface ICallService + { + Task InviteToCall(); + Task GetRTCAccess(); + } + + public class CallService: ICallService + { + private readonly ApiClient _apiClient; + private readonly string _userId; + private readonly string _token; + + public CallService(ApiClient apiClient, string userId, string token) + { + _apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient)); + _userId = userId; + _token = token; + } + + public async Task InviteToCall() + { + var body = new + { + userid = _userId + }; + + await _apiClient.PostAsync("v2/chat/rtcInvite", body); + } + public async Task GetRTCAccess() + { + var body = new + { + userid = _userId + }; + return await _apiClient.PostAsync("v2/chat/getRTCAccess", body); + } + } +} diff --git a/Services/CallServiceMethods.cs b/Services/CallServiceMethods.cs deleted file mode 100644 index cb5c5ef..0000000 --- a/Services/CallServiceMethods.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Threading.Tasks; -using Chtn.CSharp.SDK.Core; -using Chtn.CSharp.SDK.Models.Call; - -namespace Chtn.CSharp.SDK.Services -{ - public interface ICallService - { - Task InviteToCall(InviteToCallReq req); - Task GetRTCAccess(GetRTCAccessReq req); - } - - public class CallServiceProvider: ICallService - { - private readonly ApiClient _apiClient; - - public CallServiceProvider(ApiClient apiClient) - { - _apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient)); - } - - public async Task InviteToCall(InviteToCallReq req) => - await _apiClient.PostAsync("v2/chat/rtcInvite", req); - - public async Task GetRTCAccess(GetRTCAccessReq req) => - await _apiClient.PostAsync("v2/chat/getRTCAccess", req); - } -}