コード例 #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;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        internal static AcquiredPhoneNumber DeserializeAcquiredPhoneNumber(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 AcquiredPhoneNumber(id, phoneNumber, countryCode, phoneNumberType, capabilities, assignmentType, purchaseDate, cost));
        }
コード例 #4
0
 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;
 }
        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));
        }
コード例 #6
0
        public PhoneNumberSearchRequest(PhoneNumberType phoneNumberType, PhoneNumberAssignmentType assignmentType, PhoneNumberCapabilities capabilities)
        {
            if (capabilities == null)
            {
                throw new ArgumentNullException(nameof(capabilities));
            }

            PhoneNumberType = phoneNumberType;
            AssignmentType  = assignmentType;
            Capabilities    = capabilities;
        }
コード例 #7
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);