Ejemplo n.º 1
0
        internal static LocationOptions DeserializeLocationOptions(JsonElement element)
        {
            Optional <string> labelId   = default;
            Optional <string> labelName = default;
            Optional <IList <LocationOptionsDetails> > options = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("labelId"))
                {
                    labelId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("labelName"))
                {
                    labelName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("options"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <LocationOptionsDetails> array = new List <LocationOptionsDetails>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(LocationOptionsDetails.DeserializeLocationOptionsDetails(item));
                    }
                    options = array;
                    continue;
                }
            }
            return(new LocationOptions(labelId.Value, labelName.Value, Optional.ToList(options)));
        }
        internal static PhoneNumberReservation DeserializePhoneNumberReservation(JsonElement element)
        {
            Optional <string>                  searchId     = default;
            Optional <string>                  displayName  = default;
            Optional <DateTimeOffset>          createdAt    = default;
            Optional <string>                  description  = default;
            Optional <IReadOnlyList <string> > phonePlanIds = default;
            Optional <string>                  areaCode     = default;
            Optional <int> quantity = default;
            Optional <IReadOnlyList <LocationOptionsDetails> > locationOptions = default;
            Optional <ReservationStatus>       status                = default;
            Optional <IReadOnlyList <string> > phoneNumbers          = default;
            Optional <DateTimeOffset>          reservationExpiryDate = default;
            Optional <int> errorCode = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("searchId"))
                {
                    searchId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("displayName"))
                {
                    displayName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("createdAt"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    createdAt = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("phonePlanIds"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    phonePlanIds = array;
                    continue;
                }
                if (property.NameEquals("areaCode"))
                {
                    areaCode = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("quantity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    quantity = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("locationOptions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <LocationOptionsDetails> array = new List <LocationOptionsDetails>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(LocationOptionsDetails.DeserializeLocationOptionsDetails(item));
                    }
                    locationOptions = array;
                    continue;
                }
                if (property.NameEquals("status"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    status = new ReservationStatus(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("phoneNumbers"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    phoneNumbers = array;
                    continue;
                }
                if (property.NameEquals("reservationExpiryDate"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    reservationExpiryDate = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("errorCode"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    errorCode = property.Value.GetInt32();
                    continue;
                }
            }
            return(new PhoneNumberReservation(searchId.Value, displayName.Value, Optional.ToNullable(createdAt), description.Value, Optional.ToList(phonePlanIds), areaCode.Value, Optional.ToNullable(quantity), Optional.ToList(locationOptions), Optional.ToNullable(status), Optional.ToList(phoneNumbers), Optional.ToNullable(reservationExpiryDate), Optional.ToNullable(errorCode)));
        }