Compare commits
2 commits
723eb19090
...
6fce808693
Author | SHA1 | Date | |
---|---|---|---|
6fce808693 | |||
ee97edfd39 |
3 changed files with 27 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
using System.Data;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Nyanbyte.PPCheck.Lib.Models;
|
||||
|
@ -58,6 +59,28 @@ public class ApiClient : IDisposable
|
|||
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()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
|
|
|
@ -20,7 +20,7 @@ public record OffenderPersona
|
|||
public string LastName { get; set; } = string.Empty;
|
||||
public string CityOfBirth { get; set; } = string.Empty;
|
||||
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? FathersName { get; set; }
|
||||
public string? MothersName { get; set; }
|
||||
|
@ -29,5 +29,5 @@ public record OffenderPersona
|
|||
public string DwellingPlace { get; set; } = string.Empty;
|
||||
|
||||
[JsonIgnore]
|
||||
public Sex OffenderSex => (Sex)Sex;
|
||||
public Sex OffenderSex => string.IsNullOrWhiteSpace(Sex) ? Models.Sex.Unknown : (Sex)Sex[0];
|
||||
}
|
||||
|
|
|
@ -3,5 +3,6 @@ namespace Nyanbyte.PPCheck.Lib.Models;
|
|||
public enum Sex : byte
|
||||
{
|
||||
Male = (byte)'M',
|
||||
Female = (byte)'F'
|
||||
Female = (byte)'F',
|
||||
Unknown = 0,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue