From 88b851b79a340338e4a70ed4bae84db96c40674e Mon Sep 17 00:00:00 2001 From: femsci Date: Wed, 21 Feb 2024 15:34:45 +0100 Subject: [PATCH] initial domain model --- .gitignore | 6 ++++ Nyanbyte.PPCheck.sln | 27 ++++++++++++++++ README.md | 5 +++ src/Nyanbyte.PPCheck.Lib/ApiClient.cs | 32 +++++++++++++++++++ .../Models/OffenderInformation.cs | 30 +++++++++++++++++ src/Nyanbyte.PPCheck.Lib/Models/Request.cs | 18 +++++++++++ src/Nyanbyte.PPCheck.Lib/Models/Response.cs | 9 ++++++ src/Nyanbyte.PPCheck.Lib/Models/Sex.cs | 7 ++++ .../Nyanbyte.PPCheck.Lib.csproj | 9 ++++++ 9 files changed, 143 insertions(+) create mode 100644 .gitignore create mode 100644 Nyanbyte.PPCheck.sln create mode 100644 README.md create mode 100644 src/Nyanbyte.PPCheck.Lib/ApiClient.cs create mode 100644 src/Nyanbyte.PPCheck.Lib/Models/OffenderInformation.cs create mode 100644 src/Nyanbyte.PPCheck.Lib/Models/Request.cs create mode 100644 src/Nyanbyte.PPCheck.Lib/Models/Response.cs create mode 100644 src/Nyanbyte.PPCheck.Lib/Models/Sex.cs create mode 100644 src/Nyanbyte.PPCheck.Lib/Nyanbyte.PPCheck.Lib.csproj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b9bfbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +**/bin/ +**/obj/ +/packages/ +riderModule.iml +/_ReSharper.Caches/ +.idea diff --git a/Nyanbyte.PPCheck.sln b/Nyanbyte.PPCheck.sln new file mode 100644 index 0000000..fa17c82 --- /dev/null +++ b/Nyanbyte.PPCheck.sln @@ -0,0 +1,27 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C3B18ED6-C901-49BD-A417-B28A660CE50A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nyanbyte.PPCheck.Lib", "src\Nyanbyte.PPCheck.Lib\Nyanbyte.PPCheck.Lib.csproj", "{02AFAE01-FBD5-49EE-8D3F-329CDA5FEA79}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {02AFAE01-FBD5-49EE-8D3F-329CDA5FEA79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {02AFAE01-FBD5-49EE-8D3F-329CDA5FEA79}.Debug|Any CPU.Build.0 = Debug|Any CPU + {02AFAE01-FBD5-49EE-8D3F-329CDA5FEA79}.Release|Any CPU.ActiveCfg = Release|Any CPU + {02AFAE01-FBD5-49EE-8D3F-329CDA5FEA79}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {02AFAE01-FBD5-49EE-8D3F-329CDA5FEA79} = {C3B18ED6-C901-49BD-A417-B28A660CE50A} + EndGlobalSection +EndGlobal diff --git a/README.md b/README.md new file mode 100644 index 0000000..0bd9ac0 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# PPCheck + +Background checker integrated with the [National Sex Offenders Registry](https://rps.ms.gov.pl) :3 \ +This software performs a bulk check of employees, generating reports for any persons whose records might be within the registry. \ +Legal basis: [Dz. U. z 2023 r. poz. 1606](https://www.dziennikustaw.gov.pl/DU/rok/2023/pozycja/1606). diff --git a/src/Nyanbyte.PPCheck.Lib/ApiClient.cs b/src/Nyanbyte.PPCheck.Lib/ApiClient.cs new file mode 100644 index 0000000..1f797ed --- /dev/null +++ b/src/Nyanbyte.PPCheck.Lib/ApiClient.cs @@ -0,0 +1,32 @@ +namespace Nyanbyte.PPCheck.Lib; + +public class ApiClient : IDisposable +{ + internal const string BaseAddr = "https://rps.ms.gov.pl/pl-PL/api/"; + + private readonly HttpClient _http; + private readonly bool _isHttpExternal; + + public ApiClient(HttpClient http) + { + _http = http; + _isHttpExternal = true; + } + + public ApiClient() + { + _http = new HttpClient + { + BaseAddress = new Uri(BaseAddr) + }; + } + + public void Dispose() + { + GC.SuppressFinalize(this); + if (!_isHttpExternal) + { + _http.Dispose(); + } + } +} diff --git a/src/Nyanbyte.PPCheck.Lib/Models/OffenderInformation.cs b/src/Nyanbyte.PPCheck.Lib/Models/OffenderInformation.cs new file mode 100644 index 0000000..7c79fa7 --- /dev/null +++ b/src/Nyanbyte.PPCheck.Lib/Models/OffenderInformation.cs @@ -0,0 +1,30 @@ +using System.Text.Json.Serialization; + +namespace Nyanbyte.PPCheck.Lib.Models; + +public record OffenderInformation +{ + public Guid PersonIdentityId { get; set; } + public int AnnotationCount { get; set; } + + [JsonPropertyName("persones")] + public ICollection Personas { get; set; } = new List(); +} + +public record OffenderPersona +{ + public Guid Id { get; set; } + public Guid PersonIdentityId { get; set; } + public string FirstName { get; set; } = string.Empty; + public string? SecondName { get; set; } + public string LastName { get; set; } + public string CityOfBirth { get; set; } + public DateTime DateOfBirth { get; set; } + public string FamilyName { get; set; } + public string? FathersName { get; set; } + public string? MothersName { get; set; } + public Sex Sex { get; set; } + public string CountryOfBirth { get; set; } + public string Nationalities { get; set; } + public string DwellingPlace { get; set; } +} diff --git a/src/Nyanbyte.PPCheck.Lib/Models/Request.cs b/src/Nyanbyte.PPCheck.Lib/Models/Request.cs new file mode 100644 index 0000000..b46a27c --- /dev/null +++ b/src/Nyanbyte.PPCheck.Lib/Models/Request.cs @@ -0,0 +1,18 @@ +namespace Nyanbyte.PPCheck.Lib.Models; + +public record SearchRequest +{ + public bool Advanced { get; set; } = false; + + public string? FirstName { get; set; } + public string? LastName { get; set; } + public string? Nationality { get; set; } + public string? CityOfBirth { get; set; } + public string? CityOfResidence { get; set; } + + public int Page { get; set; } = 0; + public bool ShowYearCal => false; + public string SortColumn => "LastName"; + public string SortOrder => "asc"; + public int Take => 5; +} diff --git a/src/Nyanbyte.PPCheck.Lib/Models/Response.cs b/src/Nyanbyte.PPCheck.Lib/Models/Response.cs new file mode 100644 index 0000000..179f87b --- /dev/null +++ b/src/Nyanbyte.PPCheck.Lib/Models/Response.cs @@ -0,0 +1,9 @@ +namespace Nyanbyte.PPCheck.Lib.Models; + +public record Response +{ + public int Total { get; set; } + public bool HasError { get; set; } + + public ICollection Data { get; set; } = new List(); +} diff --git a/src/Nyanbyte.PPCheck.Lib/Models/Sex.cs b/src/Nyanbyte.PPCheck.Lib/Models/Sex.cs new file mode 100644 index 0000000..38ba744 --- /dev/null +++ b/src/Nyanbyte.PPCheck.Lib/Models/Sex.cs @@ -0,0 +1,7 @@ +namespace Nyanbyte.PPCheck.Lib.Models; + +public enum Sex : byte +{ + Male = (byte)'M', + Female = (byte)'F' +} diff --git a/src/Nyanbyte.PPCheck.Lib/Nyanbyte.PPCheck.Lib.csproj b/src/Nyanbyte.PPCheck.Lib/Nyanbyte.PPCheck.Lib.csproj new file mode 100644 index 0000000..3a63532 --- /dev/null +++ b/src/Nyanbyte.PPCheck.Lib/Nyanbyte.PPCheck.Lib.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + +