< Summary

Information
Class: Livekit.Server.Sdk.Dotnet.PhoneNumberServiceClient
Assembly: LivekitApi
File(s): /home/runner/work/livekit-server-sdk-dotnet/livekit-server-sdk-dotnet/LivekitApi/PhoneNumberServiceClient.cs
Line coverage
100%
Covered lines: 55
Uncovered lines: 0
Coverable lines: 55
Total lines: 134
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%
SearchPhoneNumbers()100%11100%
PurchasePhoneNumber()100%11100%
ListPhoneNumbers()100%11100%
GetPhoneNumber()100%11100%
UpdatePhoneNumber()100%11100%
ReleasePhoneNumbers()100%11100%

File(s)

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

#LineLine coverage
 1using System.Net.Http;
 2using System.Threading.Tasks;
 3
 4namespace Livekit.Server.Sdk.Dotnet
 5{
 6    /// <summary>
 7    /// A client for the Phone Number service, which searches, purchases and manages the phone
 8    /// numbers of a LiveKit project. Only available in LiveKit Cloud. Every call is signed with
 9    /// the SIP <see cref="SIPGrants.Admin"/> grant.
 10    /// </summary>
 11    public class PhoneNumberServiceClient : BaseService
 12    {
 13        /// <summary>
 14        /// Creates the client.
 15        /// </summary>
 16        /// <param name="host">URL of the LiveKit server, <c>http(s)://</c> or <c>ws(s)://</c>; a subpath such as <c>htt
 17        /// <param name="apiKey">API key; the <c>LIVEKIT_API_KEY</c> environment variable when omitted.</param>
 18        /// <param name="apiSecret">API secret; the <c>LIVEKIT_API_SECRET</c> environment variable when omitted.</param>
 19        /// <param name="client">Optional <see cref="HttpClient"/> to send the requests with. The SDK never modifies it,
 20        public PhoneNumberServiceClient(
 21            string host,
 22            string apiKey = null,
 23            string apiSecret = null,
 24            HttpClient client = null
 25        )
 2126            : base(host, apiKey, apiSecret, client) { }
 27
 28        /// <summary>
 29        /// Searches the inventory for phone numbers available to purchase.
 30        /// </summary>
 31        /// <param name="request">Country code (required), and optionally an area code, the maximum number of results (5
 32        /// <returns>The available phone numbers and the token of the next page.</returns>
 33        public async Task<SearchPhoneNumbersResponse> SearchPhoneNumbers(
 34            SearchPhoneNumbersRequest request
 35        )
 136        {
 137            return await SendAsync(
 138                    Twirp.Routes.PhoneNumberService.SearchPhoneNumbers,
 139                    request,
 140                    SearchPhoneNumbersResponse.Parser,
 141                    AuthHeader(new VideoGrants { }, new SIPGrants { Admin = true })
 142                )
 143                .ConfigureAwait(false);
 144        }
 45
 46        /// <summary>
 47        /// Purchases phone numbers from the inventory for the project.
 48        /// </summary>
 49        /// <param name="request">Phone numbers to purchase, in E.164 format, and optionally the SIP dispatch rule to ap
 50        /// <returns>The purchased phone numbers, with their ID, E.164 format and status.</returns>
 51        public async Task<PurchasePhoneNumberResponse> PurchasePhoneNumber(
 52            PurchasePhoneNumberRequest request
 53        )
 254        {
 255            return await SendAsync(
 256                    Twirp.Routes.PhoneNumberService.PurchasePhoneNumber,
 257                    request,
 258                    PurchasePhoneNumberResponse.Parser,
 259                    AuthHeader(new VideoGrants { }, new SIPGrants { Admin = true })
 260                )
 261                .ConfigureAwait(false);
 262        }
 63
 64        /// <summary>
 65        /// Lists the phone numbers of the project.
 66        /// </summary>
 67        /// <param name="request">Optional filters (statuses, SIP dispatch rule), the maximum number of results (50 by d
 68        /// <returns>The phone numbers, the token of the next page, and the total and offline counts.</returns>
 69        public async Task<ListPhoneNumbersResponse> ListPhoneNumbers(
 70            ListPhoneNumbersRequest request
 71        )
 172        {
 173            return await SendAsync(
 174                    Twirp.Routes.PhoneNumberService.ListPhoneNumbers,
 175                    request,
 176                    ListPhoneNumbersResponse.Parser,
 177                    AuthHeader(new VideoGrants { }, new SIPGrants { Admin = true })
 178                )
 179                .ConfigureAwait(false);
 180        }
 81
 82        /// <summary>
 83        /// Gets a phone number of the project.
 84        /// </summary>
 85        /// <param name="request">The phone number to get, by its ID or in E.164 format.</param>
 86        /// <returns>The phone number.</returns>
 87        public async Task<GetPhoneNumberResponse> GetPhoneNumber(GetPhoneNumberRequest request)
 188        {
 189            return await SendAsync(
 190                    Twirp.Routes.PhoneNumberService.GetPhoneNumber,
 191                    request,
 192                    GetPhoneNumberResponse.Parser,
 193                    AuthHeader(new VideoGrants { }, new SIPGrants { Admin = true })
 194                )
 195                .ConfigureAwait(false);
 196        }
 97
 98        /// <summary>
 99        /// Updates a phone number of the project: its name or the SIP dispatch rule assigned to it.
 100        /// </summary>
 101        /// <param name="request">The phone number to update, by its ID or in E.164 format, and the new values.</param>
 102        /// <returns>The updated phone number.</returns>
 103        public async Task<UpdatePhoneNumberResponse> UpdatePhoneNumber(
 104            UpdatePhoneNumberRequest request
 105        )
 1106        {
 1107            return await SendAsync(
 1108                    Twirp.Routes.PhoneNumberService.UpdatePhoneNumber,
 1109                    request,
 1110                    UpdatePhoneNumberResponse.Parser,
 1111                    AuthHeader(new VideoGrants { }, new SIPGrants { Admin = true })
 1112                )
 1113                .ConfigureAwait(false);
 1114        }
 115
 116        /// <summary>
 117        /// Releases phone numbers of the project.
 118        /// </summary>
 119        /// <param name="request">The phone numbers to release, by their IDs or in E.164 format.</param>
 120        /// <returns>Empty response.</returns>
 121        public async Task<ReleasePhoneNumbersResponse> ReleasePhoneNumbers(
 122            ReleasePhoneNumbersRequest request
 123        )
 1124        {
 1125            return await SendAsync(
 1126                    Twirp.Routes.PhoneNumberService.ReleasePhoneNumbers,
 1127                    request,
 1128                    ReleasePhoneNumbersResponse.Parser,
 1129                    AuthHeader(new VideoGrants { }, new SIPGrants { Admin = true })
 1130                )
 1131                .ConfigureAwait(false);
 1132        }
 133    }
 134}