Exemple #1
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));
        }
        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));
        }