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); - } -}