synchronize ICallService with stateful implementation and resolve build errors
This commit is contained in:
45
Services/CallService.cs
Normal file
45
Services/CallService.cs
Normal file
@@ -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<GetRTCAccessResp> 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<object, object>("v2/chat/rtcInvite", body);
|
||||
}
|
||||
public async Task<GetRTCAccessResp> GetRTCAccess()
|
||||
{
|
||||
var body = new
|
||||
{
|
||||
userid = _userId
|
||||
};
|
||||
return await _apiClient.PostAsync<object, GetRTCAccessResp>("v2/chat/getRTCAccess", body);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<GetRTCAccessResp> 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<InviteToCallReq, object>("v2/chat/rtcInvite", req);
|
||||
|
||||
public async Task<GetRTCAccessResp> GetRTCAccess(GetRTCAccessReq req) =>
|
||||
await _apiClient.PostAsync<GetRTCAccessReq, GetRTCAccessResp>("v2/chat/getRTCAccess", req);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user