/// <summary>
        /// Allocate local phone number and assign it to the application
        /// </summary>
        /// <param name="phoneNumber">IPhoneNumber instance</param>
        /// <param name="availableNumber">IAvailableNumber instance</param>
        /// <param name="applicationId">Application Id</param>
        /// <param name="query">Optioons to allocate number</param>
        /// <param name="name">Name of allocated phone number</param>
        /// <param name="cancellationToken">Cancellation token</param>
        /// <returns>Created phone number</returns>
        public static async Task <string> CreateLocalAsync(this IPhoneNumber phoneNumber, IAvailableNumber availableNumber, string applicationId, LocalNumberQueryForOrder query = null, string name = null, CancellationToken?cancellationToken = null)
        {
            query          = query ?? new LocalNumberQueryForOrder();
            query.Quantity = 1;
            var result = (await availableNumber.SearchAndOrderLocalAsync(query, cancellationToken)).First();
            await phoneNumber.UpdateAsync(result.Id, new UpdatePhoneNumberData
            {
                ApplicationId = applicationId,
                Name          = name
            }, cancellationToken);

            return(result.Number);
        }
        /// <summary>
        /// Allocate toll free number and assign it to the application
        /// </summary>
        /// <param name="phoneNumber">IPhoneNumber instance</param>
        /// <param name="availableNumber">IAvailableNumber instance</param>
        /// <param name="applicationId">Application Id</param>
        /// <param name="name">Name of allocated phone number</param>
        /// <param name="cancellationToken">Cancellation token</param>
        /// <returns>Created phone number</returns>
        public static async Task <string> CreateTollFreeAsync(this IPhoneNumber phoneNumber, IAvailableNumber availableNumber, string applicationId, string name = null, CancellationToken?cancellationToken = null)
        {
            var query = new TollFreeNumberQuery {
                Quantity = 1
            };
            var result = (await availableNumber.SearchAndOrderTollFreeAsync(query, cancellationToken)).First();
            await phoneNumber.UpdateAsync(result.Id, new UpdatePhoneNumberData
            {
                ApplicationId = applicationId,
                Name          = name
            }, cancellationToken);

            return(result.Number);
        }
        /// <summary>
        /// Get toll free phone number assigned to the applcation by name (or reserve it if need)
        /// </summary>
        /// <param name="phoneNumber">IPhoneNumber instance</param>
        /// <param name="availableNumber">IAvailableNumber instance</param>
        /// <param name="applicationId">Application Id</param>
        /// <param name="name">Name of allocated phone number</param>
        /// <param name="cancellationToken">Cancellation token</param>
        /// <returns>Phone number</returns>
        public static async Task <string> GetOrCreateTollFreeAsync(this IPhoneNumber phoneNumber, IAvailableNumber availableNumber, string applicationId, string name = null, CancellationToken?cancellationToken = null)
        {
            var existingNumber = phoneNumber.GetByName(applicationId, name);

            if (existingNumber != null)
            {
                return(existingNumber.Number);
            }
            return(await phoneNumber.CreateTollFreeAsync(availableNumber, applicationId, name, cancellationToken));
        }