Compare commits

..

2 commits

Author SHA1 Message Date
6fce808693
sex 2024-02-22 18:10:06 +01:00
ee97edfd39
picture retrieval 2024-02-22 17:14:40 +01:00
3 changed files with 27 additions and 3 deletions

View file

@ -1,6 +1,7 @@
using System.Data; using System.Data;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Net.Http.Json; using System.Net.Http.Json;
using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using Nyanbyte.PPCheck.Lib.Models; using Nyanbyte.PPCheck.Lib.Models;
@ -58,6 +59,28 @@ public class ApiClient : IDisposable
return resp; return resp;
} }
public async Task<byte[]?> GetImage(Guid identityId)
{
var request = new HttpRequestMessage(HttpMethod.Get, $"Persone/ImageGet/{identityId}");
request.Headers.Add("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0");
request.Headers.Add("Referer", "https://rps.ms.gov.pl/pl-PL/Public");
request.Headers.Add("Accept", "application/json, text/plain, */*");
request.Headers.Add("Accept-Language", "en-US,en;q=0.5");
var httpResponse = await _http.SendAsync(request);
httpResponse.EnsureSuccessStatusCode();
string resp = (await httpResponse.Content.ReadAsStringAsync()).Trim('"');
if (resp == null)
{
return null;
}
byte[] img = Convert.FromBase64String(resp);
return img;
}
public void Dispose() public void Dispose()
{ {
GC.SuppressFinalize(this); GC.SuppressFinalize(this);

View file

@ -20,7 +20,7 @@ public record OffenderPersona
public string LastName { get; set; } = string.Empty; public string LastName { get; set; } = string.Empty;
public string CityOfBirth { get; set; } = string.Empty; public string CityOfBirth { get; set; } = string.Empty;
public DateTime DateOfBirth { get; set; } public DateTime DateOfBirth { get; set; }
public char Sex { get; set; } public string Sex { get; set; } = string.Empty;
public string FamilyName { get; set; } = string.Empty; public string FamilyName { get; set; } = string.Empty;
public string? FathersName { get; set; } public string? FathersName { get; set; }
public string? MothersName { get; set; } public string? MothersName { get; set; }
@ -29,5 +29,5 @@ public record OffenderPersona
public string DwellingPlace { get; set; } = string.Empty; public string DwellingPlace { get; set; } = string.Empty;
[JsonIgnore] [JsonIgnore]
public Sex OffenderSex => (Sex)Sex; public Sex OffenderSex => string.IsNullOrWhiteSpace(Sex) ? Models.Sex.Unknown : (Sex)Sex[0];
} }

View file

@ -3,5 +3,6 @@ namespace Nyanbyte.PPCheck.Lib.Models;
public enum Sex : byte public enum Sex : byte
{ {
Male = (byte)'M', Male = (byte)'M',
Female = (byte)'F' Female = (byte)'F',
Unknown = 0,
} }