< Summary

Information
Class: Livekit.Server.Sdk.Dotnet.ConnectorServiceClient
Assembly: LivekitApi
File(s): /home/runner/work/livekit-server-sdk-dotnet/livekit-server-sdk-dotnet/LivekitApi/ConnectorServiceClient.cs
Line coverage
100%
Covered lines: 46
Uncovered lines: 0
Coverable lines: 46
Total lines: 117
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
DialWhatsAppCall()100%11100%
DisconnectWhatsAppCall()100%11100%
ConnectWhatsAppCall()100%11100%
AcceptWhatsAppCall()100%11100%
ConnectTwilioCall()100%11100%

File(s)

/home/runner/work/livekit-server-sdk-dotnet/livekit-server-sdk-dotnet/LivekitApi/ConnectorServiceClient.cs

#LineLine coverage
 1using System.Net.Http;
 2using System.Threading.Tasks;
 3
 4namespace Livekit.Server.Sdk.Dotnet
 5{
 6    /// <summary>
 7    /// A client for interacting with the Connector service, which connects WhatsApp and Twilio
 8    /// calls to LiveKit rooms. Only available in LiveKit Cloud.
 9    /// </summary>
 10    public class ConnectorServiceClient : BaseService
 11    {
 12        /// <summary>
 13        /// Creates the client.
 14        /// </summary>
 15        /// <param name="host">URL of the LiveKit server, <c>http(s)://</c> or <c>ws(s)://</c>; a subpath such as <c>htt
 16        /// <param name="apiKey">API key; the <c>LIVEKIT_API_KEY</c> environment variable when omitted.</param>
 17        /// <param name="apiSecret">API secret; the <c>LIVEKIT_API_SECRET</c> environment variable when omitted.</param>
 18        /// <param name="client">Optional <see cref="HttpClient"/> to send the requests with. The SDK never modifies it,
 19        public ConnectorServiceClient(
 20            string host,
 21            string apiKey = null,
 22            string apiSecret = null,
 23            HttpClient client = null
 24        )
 1525            : base(host, apiKey, apiSecret, client) { }
 26
 27        /// <summary>
 28        /// Starts an outbound WhatsApp call.
 29        /// </summary>
 30        /// <param name="request">WhatsApp phone number ID, API key, the number to call and the room to connect the call
 31        /// <returns>The WhatsApp call ID and the room.</returns>
 32        public async Task<DialWhatsAppCallResponse> DialWhatsAppCall(
 33            DialWhatsAppCallRequest request
 34        )
 135        {
 136            return await SendAsync(
 137                    Twirp.Routes.Connector.DialWhatsAppCall,
 138                    request,
 139                    DialWhatsAppCallResponse.Parser,
 140                    AuthHeader(new VideoGrants { RoomCreate = true })
 141                )
 142                .ConfigureAwait(false);
 143        }
 44
 45        /// <summary>
 46        /// Disconnects an active WhatsApp call.
 47        /// </summary>
 48        /// <param name="request">WhatsApp call ID and the reason.</param>
 49        /// <returns>Empty response.</returns>
 50        public async Task<DisconnectWhatsAppCallResponse> DisconnectWhatsAppCall(
 51            DisconnectWhatsAppCallRequest request
 52        )
 153        {
 154            return await SendAsync(
 155                    Twirp.Routes.Connector.DisconnectWhatsAppCall,
 156                    request,
 157                    DisconnectWhatsAppCallResponse.Parser,
 158                    AuthHeader(new VideoGrants { RoomCreate = true })
 159                )
 160                .ConfigureAwait(false);
 161        }
 62
 63        /// <summary>
 64        /// Connects an established WhatsApp call, for business-initiated calls.
 65        /// </summary>
 66        /// <param name="request">WhatsApp call ID and the SDP of the call; optionally wait until it is answered.</param
 67        /// <returns>The connection details of the call.</returns>
 68        public async Task<ConnectWhatsAppCallResponse> ConnectWhatsAppCall(
 69            ConnectWhatsAppCallRequest request
 70        )
 171        {
 172            return await SendAsync(
 173                    Twirp.Routes.Connector.ConnectWhatsAppCall,
 174                    request,
 175                    ConnectWhatsAppCallResponse.Parser,
 176                    AuthHeader(new VideoGrants { RoomCreate = true })
 177                )
 178                .ConfigureAwait(false);
 179        }
 80
 81        /// <summary>
 82        /// Accepts an inbound WhatsApp call.
 83        /// </summary>
 84        /// <param name="request">WhatsApp phone number ID, API key and the ID of the incoming call to accept.</param>
 85        /// <returns>The accepted call.</returns>
 86        public async Task<AcceptWhatsAppCallResponse> AcceptWhatsAppCall(
 87            AcceptWhatsAppCallRequest request
 88        )
 189        {
 190            return await SendAsync(
 191                    Twirp.Routes.Connector.AcceptWhatsAppCall,
 192                    request,
 193                    AcceptWhatsAppCallResponse.Parser,
 194                    AuthHeader(new VideoGrants { RoomCreate = true })
 195                )
 196                .ConfigureAwait(false);
 197        }
 98
 99        /// <summary>
 100        /// Connects a Twilio call to a LiveKit room.
 101        /// </summary>
 102        /// <param name="request">Twilio call direction and the room to connect the call to.</param>
 103        /// <returns>The URL Twilio must connect the call to.</returns>
 104        public async Task<ConnectTwilioCallResponse> ConnectTwilioCall(
 105            ConnectTwilioCallRequest request
 106        )
 1107        {
 1108            return await SendAsync(
 1109                    Twirp.Routes.Connector.ConnectTwilioCall,
 1110                    request,
 1111                    ConnectTwilioCallResponse.Parser,
 1112                    AuthHeader(new VideoGrants { RoomCreate = true })
 1113                )
 1114                .ConfigureAwait(false);
 1115        }
 116    }
 117}