internal static PhonePlan DeserializePhonePlan(JsonElement element) { string phonePlanId = default; string localizedName = default; LocationType locationType = default; Optional <IReadOnlyList <string> > areaCodes = default; Optional <IReadOnlyList <PhoneNumberCapability> > capabilities = default; Optional <int> maximumSearchSize = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("phonePlanId")) { phonePlanId = property.Value.GetString(); continue; } if (property.NameEquals("localizedName")) { localizedName = property.Value.GetString(); continue; } if (property.NameEquals("locationType")) { locationType = new LocationType(property.Value.GetString()); continue; } if (property.NameEquals("areaCodes")) { 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()); } areaCodes = array; continue; } if (property.NameEquals("capabilities")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <PhoneNumberCapability> array = new List <PhoneNumberCapability>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(new PhoneNumberCapability(item.GetString())); } capabilities = array; continue; } if (property.NameEquals("maximumSearchSize")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } maximumSearchSize = property.Value.GetInt32(); continue; } } return(new PhonePlan(phonePlanId, localizedName, locationType, Optional.ToList(areaCodes), Optional.ToList(capabilities), Optional.ToNullable(maximumSearchSize))); }
/// <summary> /// Initializes a new instance of the <see cref="PhonePlan"/> class. /// </summary> /// <param name="phonePlanId"> The phone plan id. </param> /// <param name="localizedName"> The name of the phone plan. </param> /// <param name="locationType"> The location type of the phone plan. </param> /// <returns>A new <see cref="PhonePlan"/> instance for mocking.</returns> public static PhonePlan PhonePlan(string phonePlanId, string localizedName, LocationType locationType) => new PhonePlan(phonePlanId, localizedName, locationType);