internal static ShortCode DeserializeShortCode(JsonElement element) { Optional <string> number = default; Optional <NumberType> numberType = default; Optional <string> countryCode = default; Optional <IReadOnlyList <string> > programBriefIds = default; Optional <DateTimeOffset> purchaseDate = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("number")) { number = property.Value.GetString(); continue; } if (property.NameEquals("numberType")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } numberType = new NumberType(property.Value.GetString()); continue; } if (property.NameEquals("countryCode")) { countryCode = property.Value.GetString(); continue; } if (property.NameEquals("programBriefIds")) { 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()); } programBriefIds = array; continue; } if (property.NameEquals("purchaseDate")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } purchaseDate = property.Value.GetDateTimeOffset("O"); continue; } } return(new ShortCode(number.Value, Optional.ToNullable(numberType), countryCode.Value, Optional.ToList(programBriefIds), Optional.ToNullable(purchaseDate))); }
internal static ProgramDetails DeserializeProgramDetails(JsonElement element) { Optional <bool> isVanity = default; Optional <IList <string> > preferredVanityNumbers = default; Optional <NumberType> numberType = default; Optional <bool> isPoliticalCampaign = default; Optional <string> name = default; Optional <string> description = default; Optional <string> url = default; Optional <IList <ProgramSignUpType> > signUpTypes = default; Optional <string> signUpUrl = default; Optional <string> termsOfServiceUrl = default; Optional <string> privacyPolicyUrl = default; Optional <DateTimeOffset> expectedDateOfService = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("isVanity")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } isVanity = property.Value.GetBoolean(); continue; } if (property.NameEquals("preferredVanityNumbers")) { 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()); } preferredVanityNumbers = array; continue; } if (property.NameEquals("numberType")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } numberType = new NumberType(property.Value.GetString()); continue; } if (property.NameEquals("isPoliticalCampaign")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } isPoliticalCampaign = property.Value.GetBoolean(); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("description")) { description = property.Value.GetString(); continue; } if (property.NameEquals("url")) { url = property.Value.GetString(); continue; } if (property.NameEquals("signUpTypes")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <ProgramSignUpType> array = new List <ProgramSignUpType>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(new ProgramSignUpType(item.GetString())); } signUpTypes = array; continue; } if (property.NameEquals("signUpUrl")) { signUpUrl = property.Value.GetString(); continue; } if (property.NameEquals("termsOfServiceUrl")) { termsOfServiceUrl = property.Value.GetString(); continue; } if (property.NameEquals("privacyPolicyUrl")) { privacyPolicyUrl = property.Value.GetString(); continue; } if (property.NameEquals("expectedDateOfService")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } expectedDateOfService = property.Value.GetDateTimeOffset("O"); continue; } } return(new ProgramDetails(Optional.ToNullable(isVanity), Optional.ToList(preferredVanityNumbers), Optional.ToNullable(numberType), Optional.ToNullable(isPoliticalCampaign), name.Value, description.Value, url.Value, Optional.ToList(signUpTypes), signUpUrl.Value, termsOfServiceUrl.Value, privacyPolicyUrl.Value, Optional.ToNullable(expectedDateOfService))); }