push my ork

This commit is contained in:
2024-08-15 09:20:31 +02:00
parent b08c7619a4
commit 24708eb798

View File

@@ -14,14 +14,16 @@ public class OwnCharApiClient
internal string? AuthSecret { get; set; } = null; internal string? AuthSecret { get; set; } = null;
public bool IsLoggedIn => AuthSecret != null; public bool IsLoggedIn => AuthSecret != null;
public string ApiUrl { get; }
public LoginApiClient Auth { get; } public LoginApiClient Auth { get; }
public UsersApiClient Users { get; } public UsersApiClient Users { get; }
public CharactersApiClient Characters { get; } public CharactersApiClient Characters { get; }
public GroupsApiClient Groups { get; } public GroupsApiClient Groups { get; }
public OwnCharApiClient() public OwnCharApiClient(string apiUrl)
{ {
this.ApiUrl = apiUrl;
Auth = GetClient<LoginApiClient>(); Auth = GetClient<LoginApiClient>();
Users = GetClient<UsersApiClient>(); Users = GetClient<UsersApiClient>();
Characters = GetClient<CharactersApiClient>(); Characters = GetClient<CharactersApiClient>();
@@ -55,8 +57,9 @@ public class OwnCharApiClient
{ {
request.AuthSecret = AuthSecret; request.AuthSecret = AuthSecret;
var content = new StringContent(JsonHelpers.SerializeRequest(request)!, MediaTypeHeaderValue.Parse("application/json")); var fullRequestUrl = ApiUrl + requestUrl;
var res = await httpClient.PostAsync(requestUrl, content); var content = new StringContent(JsonHelpers.SerializeRequest(request)!, null, "application/json");
var res = await httpClient.PostAsync(fullRequestUrl, content);
if (res.IsSuccessStatusCode) if (res.IsSuccessStatusCode)
return JsonHelpers.DeserializeResponse<TResponse>(await res.Content.ReadAsStringAsync()); return JsonHelpers.DeserializeResponse<TResponse>(await res.Content.ReadAsStringAsync());