SHA256
StayExport - SpainParteViajerosProvider - Fixes in export format
- Added required XML Namespace (ns2) - Reorder some elements. - Fix collection serializations. - Fix gender code mapping. - Improve some error messages. - CodigoMunicipioCatastro - Add padding to codes to follow required format.
This commit is contained in:
@@ -32,6 +32,7 @@ public class StayExportProviderSpainParteViajeros(
|
||||
private const string PersonDireccionPais_ESP = "ESP";
|
||||
|
||||
private const string XmlNamespace_Peticion = "http://www.neg.hospedajes.mir.es/altaParteHospedaje";
|
||||
private const string XmlNamespace_Peticion_Prefix = "ns2";
|
||||
|
||||
private readonly StayExportSpainParteViajerosConfig config = configOptions.Value;
|
||||
|
||||
@@ -89,8 +90,12 @@ public class StayExportProviderSpainParteViajeros(
|
||||
}
|
||||
};
|
||||
|
||||
//Create XmlSerializerNamespaces to add prefix-namespace pairs.
|
||||
var docNamespaces = new XmlSerializerNamespaces();
|
||||
docNamespaces.Add(XmlNamespace_Peticion_Prefix, XmlNamespace_Peticion);
|
||||
|
||||
XmlSerializer serializer = new(typeof(Peticion));
|
||||
serializer.Serialize(dataStream, peticion);
|
||||
serializer.Serialize(stream: dataStream, o: peticion, namespaces: docNamespaces);
|
||||
|
||||
string details = JsonSerializer.Serialize(stayExportDetails);
|
||||
return (fileResult: StayExportFileResult.OK, exportDetails: details);
|
||||
@@ -146,7 +151,7 @@ public class StayExportProviderSpainParteViajeros(
|
||||
{
|
||||
return (
|
||||
comunicacion: null,
|
||||
errorMsg: "Can't get codigo municio"
|
||||
errorMsg: $"Can't get codigo municipio for {doc.AddressProvince}-{doc.AddressCity} in doc {doc.FullDocument}"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -197,7 +202,7 @@ public class StayExportProviderSpainParteViajeros(
|
||||
return doc.Gender switch
|
||||
{
|
||||
GuestConsts.GenderOptions_MALE => "H",
|
||||
GuestConsts.GenderOptions_FEMALE => "F",
|
||||
GuestConsts.GenderOptions_FEMALE => "M",
|
||||
null => null,
|
||||
_ => "O"
|
||||
};
|
||||
@@ -212,6 +217,7 @@ public class StayExportProviderSpainParteViajeros(
|
||||
{
|
||||
if (string.IsNullOrEmpty(doc.AddressCity) || string.IsNullOrEmpty(doc.AddressProvince))
|
||||
{
|
||||
logger.LogWarning("Found doc ({docNum}) without full address", doc.FullDocument);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -324,6 +330,7 @@ public class StayExportProviderSpainParteViajeros(
|
||||
[XmlRoot(ElementName = "peticion", Namespace = XmlNamespace_Peticion)]
|
||||
public class Peticion
|
||||
{
|
||||
[XmlElement(Namespace = "")]
|
||||
public required Solicitud solicitud;
|
||||
}
|
||||
|
||||
@@ -331,17 +338,20 @@ public class StayExportProviderSpainParteViajeros(
|
||||
public class Solicitud
|
||||
{
|
||||
public required string codigoEstablecimiento;
|
||||
|
||||
[XmlElement(ElementName = "comunicacion")]
|
||||
public required List<Comunicacion> comunicacion;
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "comunicacion")]
|
||||
public class Comunicacion
|
||||
{
|
||||
[XmlElement(ElementName = "contrato")]
|
||||
public required Contrato contrato;
|
||||
|
||||
[XmlElement(ElementName = "persona")]
|
||||
public required List<Persona> persona;
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "contrato")]
|
||||
public class Contrato
|
||||
{
|
||||
public required string referencia;
|
||||
@@ -363,7 +373,6 @@ public class StayExportProviderSpainParteViajeros(
|
||||
public required Pago pago;
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "persona")]
|
||||
public class Persona
|
||||
{
|
||||
public required string rol;
|
||||
@@ -379,12 +388,13 @@ public class StayExportProviderSpainParteViajeros(
|
||||
public required string nacionalidad;
|
||||
public required string sexo;
|
||||
|
||||
// BLOQUE DIRECCION
|
||||
public required Direccion direccion;
|
||||
|
||||
public string? telefono;
|
||||
public string? correo;
|
||||
public required string parentesco;
|
||||
|
||||
// BLOQUE DIRECCION
|
||||
public required Direccion direccion;
|
||||
}
|
||||
|
||||
public class Pago
|
||||
|
||||
Reference in New Issue
Block a user