46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|