Skip to content

Commit

Permalink
Modelos con constructor por defecto y utilizando get; init; (🔔 Brea…
Browse files Browse the repository at this point in the history
…king changes)

Es dificil serializar los modelos a XML si estos no tienen un constructor por defecto. Por lo tanto, hemos decidido utilizar `get; init;` en vez de crear las propiedades utilizando un constructor.
  • Loading branch information
dluciano committed Jun 30, 2024
1 parent cacbea7 commit 1457823
Show file tree
Hide file tree
Showing 19 changed files with 144 additions and 81 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ArtifactsPath>$(MSBuildThisFileDirectory)artifacts</ArtifactsPath>
</PropertyGroup>
<PropertyGroup>
<Version>1.2.2</Version>
<Version>2.0.0</Version>
<Authors>SSD Smart Software Development SRL</Authors>
<Company>SSD Smart Software Development SRL</Company>
<Copyright>© SSD Smart Software Development SRL</Copyright>
Expand Down
13 changes: 7 additions & 6 deletions ECF_DGII.Models/Anulacion/RespuestaAnulacionRango.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
namespace ECF_DGII.Models.Anulacion;

public record RespuestaAnulacionRango(
string? Rnc,
string? Codigo,
string? Nombre,
string[]? Mensajes
);
public record RespuestaAnulacionRango
{
public string? Rnc { get; init; }
public string? Codigo { get; init; }
public string? Nombre { get; init; }
public string[]? Mensajes { get; init; }
}
15 changes: 8 additions & 7 deletions ECF_DGII.Models/ConsultaDirectorio/Directorio.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
namespace ECF_DGII.Models.ConsultaDirectorio;

public record Directorio(
string? Nombre,
string? Rnc,
string? UrlRecepcion,
string? UrlAceptacion,
string? UrlOpcional
);
public record Directorio
{
public string? Nombre { get; init; }
public string? Rnc { get; init; }
public string? UrlRecepcion { get; init; }
public string? UrlAceptacion { get; init; }
public string? UrlOpcional { get; init; }
}
15 changes: 8 additions & 7 deletions ECF_DGII.Models/ConsultaDirectorio/DirectorioModel.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
namespace ECF_DGII.Models.ConsultaDirectorio;

public record DirectorioModel(
string? Nombre,
string? Rnc,
string? UrlRecepcion,
string? UrlAceptacion,
string? UrlOpcional
);
public record DirectorioModel
{
public string? Nombre { get; init; }
public string? Rnc { get; init; }
public string? UrlRecepcion { get; init; }
public string? UrlAceptacion { get; init; }
public string? UrlOpcional { get; init; }
}
27 changes: 14 additions & 13 deletions ECF_DGII.Models/ConsultaEstado/RespuestaConsultaEstado.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
namespace ECF_DGII.Models.ConsultaEstado;

public record RespuestaConsultaEstado(
int Codigo,
string? Estado,
string? RncEmisor,
string? NcfElectronico,
double? MontoTotal,
double? TotalITBIS,
string? FechaEmision,
string? FechaFirma,
string? RncComprador,
string? CodigoSeguridad,
string? IdExtranjero
);
public record RespuestaConsultaEstado
{
public int Codigo { get; init; }
public string? Estado { get; init; }
public string? RncEmisor { get; init; }
public string? NcfElectronico { get; init; }
public double? MontoTotal { get; init; }
public double? TotalITBIS { get; init; }
public string? FechaEmision { get; init; }
public string? FechaFirma { get; init; }
public string? RncComprador { get; init; }
public string? CodigoSeguridad { get; init; }
public string? IdExtranjero { get; init; }
}
6 changes: 5 additions & 1 deletion ECF_DGII.Models/ConsultaRFCE/Mensaje.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
namespace ECF_DGII.Models.ConsultaRFCE;

public record Mensaje(string? Valor, int Codigo);
public record Mensaje
{
public string? Valor { get; init; }
public int Codigo { get; init; }
}
17 changes: 9 additions & 8 deletions ECF_DGII.Models/ConsultaRFCE/RespuestaConsultaRFCE.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
namespace ECF_DGII.Models.ConsultaRFCE;

public record RespuestaConsultaRFCE(
string? Rnc,
string Encf,
bool SecuenciaUtilizada,
string? Codigo,
string? Estado,
Mensaje[]? Mensajes
);
public record RespuestaConsultaRFCE
{
public string? Rnc { get; init; }
public string Encf { get; init; }
public bool SecuenciaUtilizada { get; init; }
public string? Codigo { get; init; }
public string? Estado { get; init; }
public Mensaje[]? Mensajes { get; init; }
}
6 changes: 5 additions & 1 deletion ECF_DGII.Models/ConsultaResultado/Mensaje.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
namespace ECF_DGII.Models.ConsultaResultado;

public record Mensaje(string? Valor, int Codigo);
public record Mensaje
{
public string? Valor { get; init; }
public int Codigo { get; init; }
}
21 changes: 11 additions & 10 deletions ECF_DGII.Models/ConsultaResultado/RespuestaConsultaRFCE.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
namespace ECF_DGII.Models.ConsultaResultado;

public record RespuestaConsultaTrackId(
string? TrackId,
string? Codigo,
string? Estado,
string? Rnc,
string? Encf,
bool SecuenciaUtilizada,
string? FechaRecepcion,
Mensaje[]? Mensajes
);
public record RespuestaConsultaTrackId
{
public string? TrackId { get; init; }
public string? Codigo { get; init; }
public string? Estado { get; init; }
public string? Rnc { get; init; }
public string? Encf { get; init; }
public bool SecuenciaUtilizada { get; init; }
public string? FechaRecepcion { get; init; }
public Mensaje[]? Mensajes { get; init; }
}
11 changes: 6 additions & 5 deletions ECF_DGII.Models/ConsultaTrackId/TrackingDetalle.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
namespace ECF_DGII.Models.ConsultaTrackId;

public record TrackingDetalle(
string? TrackId,
string? Estado,
string? FechaRecepcion
);
public record TrackingDetalle
{
public string? TrackId { get; init; }
public string? Estado { get; init; }
public string? FechaRecepcion { get; init; }
}
5 changes: 4 additions & 1 deletion ECF_DGII.Models/EstatusServicios/RespuestaEstado.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
namespace ECF_DGII.Models.EstatusServicios;

public record RespuestaEstado(string? Estado);
public record RespuestaEstado
{
public string? Estado { get; init; }
}
8 changes: 7 additions & 1 deletion ECF_DGII.Models/EstatusServicios/RespuestaEstatusServicio.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
namespace ECF_DGII.Models.EstatusServicios;

public record RespuestaEstatusServicio(string? Servicio, string? Status, string? Ambiente);
public record RespuestaEstatusServicio
{
public string? Servicio { get; init; }
public string? Status { get; init; }
public string? Ambiente { get; init; }
}

Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
namespace ECF_DGII.Models.EstatusServicios;

public record RespuestaVentanaDeMantenimiento(VentanaDeMantenimiento[] VentanaMantenimientos);
public record RespuestaVentanaDeMantenimiento
{
public VentanaDeMantenimiento[] VentanaMantenimientos { get; init; }

Check warning on line 5 in ECF_DGII.Models/EstatusServicios/RespuestaVentanaDeMantenimiento.cs

View workflow job for this annotation

GitHub Actions / build_and_pack

Non-nullable property 'VentanaMantenimientos' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 5 in ECF_DGII.Models/EstatusServicios/RespuestaVentanaDeMantenimiento.cs

View workflow job for this annotation

GitHub Actions / build_and_pack

Non-nullable property 'VentanaMantenimientos' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
}
13 changes: 7 additions & 6 deletions ECF_DGII.Models/EstatusServicios/VentanaDeMantenimiento.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
namespace ECF_DGII.Models.EstatusServicios;

public record VentanaDeMantenimiento(
string? Ambiente,
string? HoraInicio,
string? HoraFin,
string[]? Dias
);
public record VentanaDeMantenimiento
{
public string? Ambiente { get; init; }
public string? HoraInicio { get; init; }
public string? HoraFin { get; init; }
public string[]? Dias { get; init; }
}
7 changes: 6 additions & 1 deletion ECF_DGII.Models/Recepcion/RespuestaRecepcion.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
namespace ECF_DGII.Models.Recepcion;

public record RespuestaRecepcion(string? TrackId, string? Error, string? Mensaje);
public record RespuestaRecepcion
{
public string? TrackId { get; init;}
public string? Error { get; init;}
public string? Mensaje { get; init;}
}
6 changes: 5 additions & 1 deletion ECF_DGII.Models/RecepcionFC/MensajeRespuesta.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
namespace ECF_DGII.Models.RecepcionFC;

public record MensajeRespuesta(string? Codigo, string? Valor);
public record MensajeRespuesta
{
public string? Codigo { get; init; }
public string? Valor { get; init; }
}
15 changes: 8 additions & 7 deletions ECF_DGII.Models/RecepcionFC/Respuesta.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
namespace ECF_DGII.Models.RecepcionFC;

public record Respuesta(
EstadoCF Codigo,
string? Estado,
MensajeRespuesta[]? Mensajes,
string? Enfc,
bool SecuenciaUtilizada
);
public record Respuesta
{
public EstadoCF Codigo { get; init; }
public string? Estado { get; init; }
public MensajeRespuesta[]? Mensajes { get; init; }
public string? Enfc { get; init; }
public bool SecuenciaUtilizada { get; init; }
}
18 changes: 16 additions & 2 deletions ECF_DGII.SDK.Tests/ConsultaDirectorioTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ public async Task WhenListadoTest()
response.IsSuccessStatusCode.Should().BeTrue();
response.Error.Should().BeNull();
response.Content.Should().NotBeNullOrEmpty();
response.Content.Should().BeEquivalentTo([new Directorio("", "", "", "", "")]);
response.Content.Should().BeEquivalentTo([new Directorio()
{
Nombre = "",
Rnc = "",
UrlRecepcion = "",
UrlAceptacion = "",
UrlOpcional = "",
}]);
}

[Fact]
Expand All @@ -42,6 +49,13 @@ public async Task WhenObtenerDirectorioPorRncTest()
response.IsSuccessStatusCode.Should().BeTrue();
response.Error.Should().BeNull();
response.Content.Should().NotBeNullOrEmpty();
response.Content.Should().BeEquivalentTo([new DirectorioModel("", "", "", "", "")]);
response.Content.Should().BeEquivalentTo([new DirectorioModel()
{
Nombre = "",
Rnc = "",
UrlRecepcion = "",
UrlAceptacion = "",
UrlOpcional = "",
}]);
}
}
15 changes: 13 additions & 2 deletions ECF_DGII.SDK.Tests/EstatusServiciosTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ public async Task WhenObtenerEstatusTest()
response.IsSuccessStatusCode.Should().BeTrue();
response.Error.Should().BeNull();
response.Content.Should().NotBeNullOrEmpty();
response.Content.Should().BeEquivalentTo([new RespuestaEstatusServicio("", "", "")]);
response.Content.Should().BeEquivalentTo([new RespuestaEstatusServicio()
{
Servicio = "",
Status = "",
Ambiente = ""
}]);
}

[Fact]
Expand All @@ -42,7 +47,13 @@ public async Task WhenObtenerVentanasDeMantenimientoEstatusTest()
response.IsSuccessStatusCode.Should().BeTrue();
response.Error.Should().BeNull();
response.Content.Should().NotBeNull();
response.Content.VentanaMantenimientos.Should().BeEquivalentTo([new VentanaDeMantenimiento("", "", "", [])]);
response.Content.VentanaMantenimientos.Should().BeEquivalentTo([new VentanaDeMantenimiento()
{
Ambiente = "",
HoraInicio = "",
HoraFin = "",
Dias = [],
}]);
}

[Fact]
Expand Down

0 comments on commit 1457823

Please sign in to comment.