Esempio n. 1
0
        internal PurchasedPhoneNumber(string id, string phoneNumber, string countryCode, PhoneNumberType phoneNumberType, PhoneNumberCapabilities capabilities, PhoneNumberAssignmentType assignmentType, DateTimeOffset purchaseDate, PhoneNumberCost cost)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }
            if (phoneNumber == null)
            {
                throw new ArgumentNullException(nameof(phoneNumber));
            }
            if (countryCode == null)
            {
                throw new ArgumentNullException(nameof(countryCode));
            }
            if (capabilities == null)
            {
                throw new ArgumentNullException(nameof(capabilities));
            }
            if (cost == null)
            {
                throw new ArgumentNullException(nameof(cost));
            }

            Id              = id;
            PhoneNumber     = phoneNumber;
            CountryCode     = countryCode;
            PhoneNumberType = phoneNumberType;
            Capabilities    = capabilities;
            AssignmentType  = assignmentType;
            PurchaseDate    = purchaseDate;
            Cost            = cost;
        }
        internal PhoneNumberSearchResult(string searchId, IEnumerable <string> phoneNumbers, PhoneNumberType phoneNumberType, PhoneNumberAssignmentType assignmentType, PhoneNumberCapabilities capabilities, PhoneNumberCost cost, DateTimeOffset searchExpiresOn)
        {
            if (searchId == null)
            {
                throw new ArgumentNullException(nameof(searchId));
            }
            if (phoneNumbers == null)
            {
                throw new ArgumentNullException(nameof(phoneNumbers));
            }
            if (capabilities == null)
            {
                throw new ArgumentNullException(nameof(capabilities));
            }
            if (cost == null)
            {
                throw new ArgumentNullException(nameof(cost));
            }

            SearchId        = searchId;
            PhoneNumbers    = phoneNumbers.ToList();
            PhoneNumberType = phoneNumberType;
            AssignmentType  = assignmentType;
            Capabilities    = capabilities;
            Cost            = cost;
            SearchExpiresOn = searchExpiresOn;
        }
Esempio n. 3
0
        internal static PurchasedPhoneNumber DeserializePurchasedPhoneNumber(JsonElement element)
        {
            string                    id              = default;
            string                    phoneNumber     = default;
            string                    countryCode     = default;
            PhoneNumberType           phoneNumberType = default;
            PhoneNumberCapabilities   capabilities    = default;
            PhoneNumberAssignmentType assignmentType  = default;
            DateTimeOffset            purchaseDate    = default;
            PhoneNumberCost           cost            = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("phoneNumber"))
                {
                    phoneNumber = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("countryCode"))
                {
                    countryCode = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("phoneNumberType"))
                {
                    phoneNumberType = new PhoneNumberType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("capabilities"))
                {
                    capabilities = PhoneNumberCapabilities.DeserializePhoneNumberCapabilities(property.Value);
                    continue;
                }
                if (property.NameEquals("assignmentType"))
                {
                    assignmentType = new PhoneNumberAssignmentType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("purchaseDate"))
                {
                    purchaseDate = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("cost"))
                {
                    cost = PhoneNumberCost.DeserializePhoneNumberCost(property.Value);
                    continue;
                }
            }
            return(new PurchasedPhoneNumber(id, phoneNumber, countryCode, phoneNumberType, capabilities, assignmentType, purchaseDate, cost));
        }
 internal PhoneNumberSearchResult(string searchId, IReadOnlyList <string> phoneNumbers, PhoneNumberType phoneNumberType, PhoneNumberAssignmentType assignmentType, PhoneNumberCapabilities capabilities, PhoneNumberCost cost, DateTimeOffset searchExpiresOn)
 {
     SearchId        = searchId;
     PhoneNumbers    = phoneNumbers;
     PhoneNumberType = phoneNumberType;
     AssignmentType  = assignmentType;
     Capabilities    = capabilities;
     Cost            = cost;
     SearchExpiresOn = searchExpiresOn;
 }
Esempio n. 5
0
        internal static PhoneNumberSearchResult DeserializePhoneNumberSearchResult(JsonElement element)
        {
            string searchId = default;
            IReadOnlyList <string>    phoneNumbers    = default;
            PhoneNumberType           phoneNumberType = default;
            PhoneNumberAssignmentType assignmentType  = default;
            PhoneNumberCapabilities   capabilities    = default;
            PhoneNumberCost           cost            = default;
            DateTimeOffset            searchExpiresBy = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("searchId"))
                {
                    searchId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("phoneNumbers"))
                {
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    phoneNumbers = array;
                    continue;
                }
                if (property.NameEquals("phoneNumberType"))
                {
                    phoneNumberType = new PhoneNumberType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("assignmentType"))
                {
                    assignmentType = new PhoneNumberAssignmentType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("capabilities"))
                {
                    capabilities = PhoneNumberCapabilities.DeserializePhoneNumberCapabilities(property.Value);
                    continue;
                }
                if (property.NameEquals("cost"))
                {
                    cost = PhoneNumberCost.DeserializePhoneNumberCost(property.Value);
                    continue;
                }
                if (property.NameEquals("searchExpiresBy"))
                {
                    searchExpiresBy = property.Value.GetDateTimeOffset("O");
                    continue;
                }
            }
            return(new PhoneNumberSearchResult(searchId, phoneNumbers, phoneNumberType, assignmentType, capabilities, cost, searchExpiresBy));
        }
Esempio n. 6
0
 public static PhoneNumberSearchResult PhoneNumberSearchResult(string searchId = default, IReadOnlyList <string> phoneNumbers = default, PhoneNumberType phoneNumberType = default, PhoneNumberAssignmentType assignmentType = default, PhoneNumberCapabilities capabilities = default, PhoneNumberCost cost = default, DateTimeOffset searchExpiresOn = default)
 {
     phoneNumbers ??= new List <string>();
     return(new PhoneNumberSearchResult(searchId, phoneNumbers, phoneNumberType, assignmentType, capabilities, cost, searchExpiresOn));
 }
Esempio n. 7
0
 /// <summary> Initializes a new instance of PhoneNumberSearchResult. </summary>
 /// <param name="searchId"> The search id. </param>
 /// <param name="phoneNumbers"> The phone numbers that are available. Can be fewer than the desired search quantity. </param>
 /// <param name="phoneNumberType"> The phone number&apos;s type, e.g. geographic, or tollFree. </param>
 /// <param name="assignmentType"> Phone number&apos;s assignment type. </param>
 /// <param name="capabilities"> Capabilities of a phone number. </param>
 /// <param name="cost"> The incurred cost for a single phone number. </param>
 /// <param name="searchExpiresOn"> The date that this search result expires and phone numbers are no longer on hold. A search result expires in less than 15min, e.g. 2020-11-19T16:31:49.048Z. </param>
 /// <exception cref="ArgumentNullException"> <paramref name="searchId"/>, <paramref name="phoneNumbers"/>, <paramref name="capabilities"/>, or <paramref name="cost"/> is null. </exception>
 public static PhoneNumberSearchResult PhoneNumberSearchResult(string searchId, IEnumerable <string> phoneNumbers, PhoneNumberType phoneNumberType, PhoneNumberAssignmentType assignmentType, PhoneNumberCapabilities capabilities, PhoneNumberCost cost, DateTimeOffset searchExpiresOn)
 => new PhoneNumberSearchResult(searchId, phoneNumbers, phoneNumberType, assignmentType, capabilities, cost, searchExpiresOn);
Esempio n. 8
0
        /// <summary> Initializes a new instance of <see cref="PurchasedPhoneNumber"/>. </summary>
        /// <param name="id"> The id of the phone number, e.g. 14255550123. </param>
        /// <param name="phoneNumber"> String of the E.164 format of the phone number, e.g. +14255550123. </param>
        /// <param name="countryCode"> The ISO 3166-2 code of the phone number&apos;s country, e.g. US. </param>
        /// <param name="phoneNumberType"> The phone number&apos;s type, e.g. Geographic, TollFree. </param>
        /// <param name="capabilities"> Capabilities of a phone number. </param>
        /// <param name="assignmentType"> The assignment type of the phone number. A phone number can be assigned to a person, or to an application. </param>
        /// <param name="purchaseDate"> The date and time that the phone number was purchased. </param>
        /// <param name="cost"> The incurred cost for a single phone number. </param>
#pragma warning disable CA1054 // URI-like parameters should not be strings
        public static PurchasedPhoneNumber PurchasedPhoneNumber(string id, string phoneNumber, string countryCode, PhoneNumberType phoneNumberType, PhoneNumberCapabilities capabilities, PhoneNumberAssignmentType assignmentType, DateTimeOffset purchaseDate, PhoneNumberCost cost)
#pragma warning restore CA1054 // URI-like parameters should not be strings
        => new PurchasedPhoneNumber(id, phoneNumber, countryCode, phoneNumberType, capabilities, assignmentType, purchaseDate, cost);