internal static EntityApiModel DeserializeEntityApiModel(XElement element) { string address = default; string city = default; long? companyId = default; string country = default; long? countryId = default; string customField1 = default; string customField2 = default; double? discountPercentage = default; string email = default; string fax = default; string firstname = default; long? id = default; string lastname = default; double? latitude = default; double? longitude = default; string name = default; string nif = default; string notes = default; string organization = default; string phone = default; string postalCode = default; string province = default; EntityApiModelType?type = default; string url = default; if (element.Element("address") is XElement addressElement) { address = (string)addressElement; } if (element.Element("city") is XElement cityElement) { city = (string)cityElement; } if (element.Element("companyId") is XElement companyIdElement) { companyId = (long?)companyIdElement; } if (element.Element("country") is XElement countryElement) { country = (string)countryElement; } if (element.Element("countryId") is XElement countryIdElement) { countryId = (long?)countryIdElement; } if (element.Element("customField1") is XElement customField1Element) { customField1 = (string)customField1Element; } if (element.Element("customField2") is XElement customField2Element) { customField2 = (string)customField2Element; } if (element.Element("discountPercentage") is XElement discountPercentageElement) { discountPercentage = (double?)discountPercentageElement; } if (element.Element("email") is XElement emailElement) { email = (string)emailElement; } if (element.Element("fax") is XElement faxElement) { fax = (string)faxElement; } if (element.Element("firstname") is XElement firstnameElement) { firstname = (string)firstnameElement; } if (element.Element("id") is XElement idElement) { id = (long?)idElement; } if (element.Element("lastname") is XElement lastnameElement) { lastname = (string)lastnameElement; } if (element.Element("latitude") is XElement latitudeElement) { latitude = (double?)latitudeElement; } if (element.Element("longitude") is XElement longitudeElement) { longitude = (double?)longitudeElement; } if (element.Element("name") is XElement nameElement) { name = (string)nameElement; } if (element.Element("nif") is XElement nifElement) { nif = (string)nifElement; } if (element.Element("notes") is XElement notesElement) { notes = (string)notesElement; } if (element.Element("organization") is XElement organizationElement) { organization = (string)organizationElement; } if (element.Element("phone") is XElement phoneElement) { phone = (string)phoneElement; } if (element.Element("postalCode") is XElement postalCodeElement) { postalCode = (string)postalCodeElement; } if (element.Element("province") is XElement provinceElement) { province = (string)provinceElement; } if (element.Element("type") is XElement typeElement) { type = new EntityApiModelType(typeElement.Value); } if (element.Element("url") is XElement urlElement) { url = (string)urlElement; } return(new EntityApiModel(address, city, companyId, country, countryId, customField1, customField2, discountPercentage, email, fax, firstname, id, lastname, latitude, longitude, name, nif, notes, organization, phone, postalCode, province, type, url)); }
internal static EntityApiModel DeserializeEntityApiModel(JsonElement element) { Optional <string> address = default; Optional <string> city = default; Optional <long> companyId = default; Optional <string> country = default; Optional <long> countryId = default; Optional <string> customField1 = default; Optional <string> customField2 = default; Optional <double> discountPercentage = default; Optional <string> email = default; Optional <string> fax = default; Optional <string> firstname = default; Optional <long> id = default; Optional <string> lastname = default; Optional <double> latitude = default; Optional <double> longitude = default; Optional <string> name = default; string nif = default; Optional <string> notes = default; string organization = default; Optional <string> phone = default; Optional <string> postalCode = default; Optional <string> province = default; Optional <EntityApiModelType> type = default; Optional <string> url = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("address")) { address = property.Value.GetString(); continue; } if (property.NameEquals("city")) { city = property.Value.GetString(); continue; } if (property.NameEquals("companyId")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } companyId = property.Value.GetInt64(); continue; } if (property.NameEquals("country")) { country = property.Value.GetString(); continue; } if (property.NameEquals("countryId")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } countryId = property.Value.GetInt64(); continue; } if (property.NameEquals("customField1")) { customField1 = property.Value.GetString(); continue; } if (property.NameEquals("customField2")) { customField2 = property.Value.GetString(); continue; } if (property.NameEquals("discountPercentage")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } discountPercentage = property.Value.GetDouble(); continue; } if (property.NameEquals("email")) { email = property.Value.GetString(); continue; } if (property.NameEquals("fax")) { fax = property.Value.GetString(); continue; } if (property.NameEquals("firstname")) { firstname = property.Value.GetString(); continue; } if (property.NameEquals("id")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } id = property.Value.GetInt64(); continue; } if (property.NameEquals("lastname")) { lastname = property.Value.GetString(); continue; } if (property.NameEquals("latitude")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } latitude = property.Value.GetDouble(); continue; } if (property.NameEquals("longitude")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } longitude = property.Value.GetDouble(); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("nif")) { nif = property.Value.GetString(); continue; } if (property.NameEquals("notes")) { notes = property.Value.GetString(); continue; } if (property.NameEquals("organization")) { organization = property.Value.GetString(); continue; } if (property.NameEquals("phone")) { phone = property.Value.GetString(); continue; } if (property.NameEquals("postalCode")) { postalCode = property.Value.GetString(); continue; } if (property.NameEquals("province")) { province = property.Value.GetString(); continue; } if (property.NameEquals("type")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } type = new EntityApiModelType(property.Value.GetString()); continue; } if (property.NameEquals("url")) { url = property.Value.GetString(); continue; } } return(new EntityApiModel(address.Value, city.Value, Optional.ToNullable(companyId), country.Value, Optional.ToNullable(countryId), customField1.Value, customField2.Value, Optional.ToNullable(discountPercentage), email.Value, fax.Value, firstname.Value, Optional.ToNullable(id), lastname.Value, Optional.ToNullable(latitude), Optional.ToNullable(longitude), name.Value, nif, notes.Value, organization, phone.Value, postalCode.Value, province.Value, Optional.ToNullable(type), url.Value)); }